labels.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. "github.com/hashicorp/go-version"
  16. "github.com/docker/compose/v2/internal"
  17. )
  18. const (
  19. // ProjectLabel allow to track resource related to a compose project
  20. ProjectLabel = "com.docker.compose.project"
  21. // ServiceLabel allow to track resource related to a compose service
  22. ServiceLabel = "com.docker.compose.service"
  23. // ConfigHashLabel stores configuration hash for a compose service
  24. ConfigHashLabel = "com.docker.compose.config-hash"
  25. // ContainerNumberLabel stores the container index of a replicated service
  26. ContainerNumberLabel = "com.docker.compose.container-number"
  27. // VolumeLabel allow to track resource related to a compose volume
  28. VolumeLabel = "com.docker.compose.volume"
  29. // NetworkLabel allow to track resource related to a compose network
  30. NetworkLabel = "com.docker.compose.network"
  31. // WorkingDirLabel stores absolute path to compose project working directory
  32. WorkingDirLabel = "com.docker.compose.project.working_dir"
  33. // ConfigFilesLabel stores absolute path to compose project configuration files
  34. ConfigFilesLabel = "com.docker.compose.project.config_files"
  35. // EnvironmentFileLabel stores absolute path to compose project env file set by `--env-file`
  36. EnvironmentFileLabel = "com.docker.compose.project.environment_file"
  37. // OneoffLabel stores value 'True' for one-off containers created by `compose run`
  38. OneoffLabel = "com.docker.compose.oneoff"
  39. // SlugLabel stores unique slug used for one-off container identity
  40. SlugLabel = "com.docker.compose.slug"
  41. // ImageDigestLabel stores digest of the container image used to run service
  42. ImageDigestLabel = "com.docker.compose.image"
  43. // DependenciesLabel stores service dependencies
  44. DependenciesLabel = "com.docker.compose.depends_on"
  45. // VersionLabel stores the compose tool version used to build/run application
  46. VersionLabel = "com.docker.compose.version"
  47. // ImageBuilderLabel stores the builder (classic or BuildKit) used to produce the image.
  48. ImageBuilderLabel = "com.docker.compose.image.builder"
  49. // ContainerReplaceLabel is set when container is created to replace another container (recreated)
  50. ContainerReplaceLabel = "com.docker.compose.replace"
  51. )
  52. // ComposeVersion is the compose tool version as declared by label VersionLabel
  53. var ComposeVersion string
  54. func init() {
  55. v, err := version.NewVersion(internal.Version)
  56. if err == nil {
  57. ComposeVersion = v.Core().String()
  58. }
  59. }