Skip to content

Commit 0255976

Browse files
fixup project before validate
1 parent b3a3043 commit 0255976

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/pkg/cli/compose/fixup.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func fixupPostgresService(svccfg *composeTypes.ServiceConfig, provider client.Pr
246246
if port.Mode == Mode_INGRESS || port.Mode == "" {
247247
svccfg.Ports[i].Mode = Mode_HOST
248248
svccfg.Ports[i].Published = "" // ignore published port in host mode
249+
svccfg.Ports[i].AppProtocol = "" // ignore app protocol in host mode
249250
}
250251
}
251252
}
@@ -315,6 +316,7 @@ func fixupRedisService(svccfg *composeTypes.ServiceConfig, provider client.Provi
315316
if port.Mode == Mode_INGRESS || port.Mode == "" {
316317
svccfg.Ports[i].Mode = Mode_HOST
317318
svccfg.Ports[i].Published = "" // ignore published port in host mode
319+
svccfg.Ports[i].AppProtocol = "" // ignore app protocol in host mode
318320
}
319321
}
320322
}

src/pkg/cli/compose/validation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func TestValidationAndConvert(t *testing.T) {
4646
t.Fatal(err)
4747
}
4848

49+
if err := FixupServices(context.Background(), mockClient, project, UploadModeIgnore); err != nil {
50+
t.Logf("Service conversion failed: %v", err)
51+
logs.WriteString(err.Error() + "\n")
52+
}
53+
4954
if err := ValidateProjectConfig(context.Background(), project, listConfigNamesFunc); err != nil {
5055
t.Logf("Project config validation failed: %v", err)
5156
logs.WriteString(err.Error() + "\n")
@@ -56,11 +61,6 @@ func TestValidationAndConvert(t *testing.T) {
5661
logs.WriteString(err.Error() + "\n")
5762
}
5863

59-
if err := FixupServices(context.Background(), mockClient, project, UploadModeIgnore); err != nil {
60-
t.Logf("Service conversion failed: %v", err)
61-
logs.WriteString(err.Error() + "\n")
62-
}
63-
6464
// The order of the services is not guaranteed, so we sort the logs before comparing
6565
logLines := strings.SplitAfter(logs.String(), "\n")
6666
slices.Sort(logLines)

src/pkg/cli/composeUp.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
4747
}
4848
}
4949

50-
if err := compose.ValidateProject(project); err != nil {
51-
return nil, project, &ComposeError{err}
52-
}
53-
5450
// Create a new project with only the necessary resources.
5551
// Do not modify the original project, because the caller needs it for debugging.
5652
fixedProject := project.WithoutUnnecessaryResources()
@@ -59,6 +55,10 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
5955
return nil, project, err
6056
}
6157

58+
if err := compose.ValidateProject(project); err != nil {
59+
return nil, project, &ComposeError{err}
60+
}
61+
6262
bytes, err := fixedProject.MarshalYAML()
6363
if err != nil {
6464
return nil, project, err
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
! service "ai_model": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
12
! service "app": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
3+
! service "my_model": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
24
! service "withendpoint": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors

src/testdata/ports/compose.yaml.warnings

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
! service "short": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
1414
! service "short-published": ingress port without healthcheck defaults to GET / HTTP/1.1
1515
! service "short-published": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
16-
! service "short-udp": ingress port without healthcheck defaults to GET / HTTP/1.1
1716
! service "short-udp": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
18-
! service "short-udp-published": ingress port without healthcheck defaults to GET / HTTP/1.1
1917
! service "short-udp-published": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors

src/testdata/postgres/compose.yaml.warnings

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
! service "no-ext": stateful service will lose data on restart; use a managed service instead
33
! service "no-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
44
! service "no-ports-override": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
5-
! service "short-ports": ingress port without healthcheck defaults to GET / HTTP/1.1
65
! service "short-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
76
! service "with-ext": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
87
! service "wrong-image": managed Postgres service should use a postgres image

src/testdata/redis/compose.yaml.warnings

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
! service "no-ext": stateful service will lose data on restart; use a managed service instead
33
! service "no-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
44
! service "no-ports-override": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
5-
! service "short-ports": ingress port without healthcheck defaults to GET / HTTP/1.1
65
! service "short-ports": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
76
! service "with-ext": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
87
! service "wrong-image": managed Redis service should use a redis image

0 commit comments

Comments
 (0)