Skip to content

Commit d86eb01

Browse files
committed
Only display one overridden warning, repharse warning message
1 parent 7d7a727 commit d86eb01

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/pkg/cli/compose/convert.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos
137137

138138
// Check if the environment variable is an existing config; if so, mark it as such
139139
if _, ok := slices.BinarySearch(config.Names, key); ok {
140-
term.Warnf("service %q: environment variable %q overridden by config", svccfg.Name, key)
141140
if serviceNameRegex != nil && serviceNameRegex.MatchString(*value) {
142-
term.Warnf("service %q: environment variable %q with value %q contains a service name needs to be normalized, but it will be repalced by an existing config. service names in a config will not be normalized.", svccfg.Name, key, *value)
141+
term.Warnf("service %q: The environment variable %q, with the value %q, contains a service name that needs to be normalized. however, it will be replaced by an existing configuration. service names within a configuration will not be normalized.", svccfg.Name, key, *value)
142+
} else {
143+
term.Warnf("service %q: environment variable %q overridden by config", svccfg.Name, key)
143144
}
144145
envFromConfig = append(envFromConfig, key)
145146
continue
@@ -154,7 +155,7 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos
154155
if val != *value {
155156
term.Warnf("service %q: service names were replaced in environment variable %q: %q", svccfg.Name, key, val)
156157
} else if nonReplaceServiceNameRegex != nil && nonReplaceServiceNameRegex.MatchString(*value) {
157-
term.Warnf("service %q: service names were NOT replaced in environment variable %q: %q, only service with port mode host will be replaced", svccfg.Name, key, val)
158+
term.Warnf("service %q: service names in the environment variable %q (%q) were not replaced. only services with port mode set to host will be replaced.", svccfg.Name, key, val)
158159
}
159160
}
160161
envs[key] = val

src/tests/fixupenv/compose.yaml.warnings

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
! service "bad-service": ingress port without healthcheck defaults to GET / HTTP/1.1
44
! service "bad-service": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
55
! service "bad-service": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
6-
! service "env-in-config": environment variable "CONFIG1" overridden by config
7-
! service "env-in-config": environment variable "CONFIG1" with value "http://Mistral:8000" contains a service name needs to be normalized, but it will be repalced by an existing config. service names in a config will not be normalized.
6+
! service "env-in-config": The environment variable "CONFIG1", with the value "http://Mistral:8000", contains a service name that needs to be normalized. however, it will be replaced by an existing configuration. service names within a configuration will not be normalized.
87
! service "env-in-config": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
98
! service "env-in-config": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
109
! service "ui": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
1110
! service "ui": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
1211
! service "ui": service names were replaced in environment variable "API_URL": "http://mock-mistral:8000"
1312
! service "use-bad-service": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
1413
! service "use-bad-service": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
15-
! service "use-bad-service": service names were NOT replaced in environment variable "DB_URL": "bad-service:5432", only service with port mode host will be replaced
14+
! service "use-bad-service": service names in the environment variable "DB_URL" ("bad-service:5432") were not replaced. only services with port mode set to host will be replaced.
1615
! service name "Mistral" was normalized to "mistral"

0 commit comments

Comments
 (0)