1
0

labels.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package api
  14. import (
  15. "fmt"
  16. "github.com/hashicorp/go-version"
  17. "github.com/docker/compose/v2/internal"
  18. )
  19. const (
  20. // ProjectLabel allow to track resource related to a compose project
  21. ProjectLabel = "com.docker.compose.project"
  22. // ServiceLabel allow to track resource related to a compose service
  23. ServiceLabel = "com.docker.compose.service"
  24. // ConfigHashLabel stores configuration hash for a compose service
  25. ConfigHashLabel = "com.docker.compose.config-hash"
  26. // ContainerNumberLabel stores the container index of a replicated service
  27. ContainerNumberLabel = "com.docker.compose.container-number"
  28. // VolumeLabel allow to track resource related to a compose volume
  29. VolumeLabel = "com.docker.compose.volume"
  30. // NetworkLabel allow to track resource related to a compose network
  31. NetworkLabel = "com.docker.compose.network"
  32. // WorkingDirLabel stores absolute path to compose project working directory
  33. WorkingDirLabel = "com.docker.compose.project.working_dir"
  34. // ConfigFilesLabel stores absolute path to compose project configuration files
  35. ConfigFilesLabel = "com.docker.compose.project.config_files"
  36. // EnvironmentFileLabel stores absolute path to compose project env file set by `--env-file`
  37. EnvironmentFileLabel = "com.docker.compose.project.environment_file"
  38. // OneoffLabel stores value 'True' for one-off containers created by `compose run`
  39. OneoffLabel = "com.docker.compose.oneoff"
  40. // SlugLabel stores unique slug used for one-off container identity
  41. SlugLabel = "com.docker.compose.slug"
  42. // ImageDigestLabel stores digest of the container image used to run service
  43. ImageDigestLabel = "com.docker.compose.image"
  44. // DependenciesLabel stores service dependencies
  45. DependenciesLabel = "com.docker.compose.depends_on"
  46. // VersionLabel stores the compose tool version used to run application
  47. VersionLabel = "com.docker.compose.version"
  48. )
  49. // ComposeVersion is the compose tool version as declared by label VersionLabel
  50. var ComposeVersion string
  51. func init() {
  52. v, err := version.NewVersion(internal.Version)
  53. if err == nil {
  54. segments := v.Segments()
  55. if len(segments) > 2 {
  56. ComposeVersion = fmt.Sprintf("%d.%d.%d", segments[0], segments[1], segments[2])
  57. }
  58. }
  59. }