Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions defang.code-workspace
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
{
"folders": [
{
"path": "."
},
{
"path": "src"
}
],
"settings": {
"go.testEnvVars": {
"AWS_PROFILE": "defang-sandbox"
},
"go.buildTags": "integration",
"go.testFlags": ["-short"],
"go.testTimeout": "300s",
"makefile.configureOnOpen": false
}
}
"folders": [
{
"path": "."
},
{
"path": "src"
}
],
"settings": {
"yaml.customTags": [
"!reset mapping",
"!reset sequence",
"!reset scalar",
"!reset null",
"!override mapping",
"!override sequence"
],
"go.testEnvVars": {
"AWS_PROFILE": "defang-sandbox"
},
"go.buildTags": "integration",
"go.testFlags": ["-short"],
"go.testTimeout": "300s",
"makefile.configureOnOpen": false
}
}
2 changes: 1 addition & 1 deletion src/cmd/cli/command/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ This ensures the priority order: command-line flags > environment variables > RC
func (r *GlobalConfig) syncFlagsWithEnv(flags *pflag.FlagSet) error {
var err error

// called once once more in case stack name was changed by an RC file
// called once more in case stack name was changed by an RC file
r.Stack = r.getStackName(flags)

if !flags.Changed("verbose") {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cli/command/globals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Test_configurationPrecedence(t *testing.T) {
// no matter the order they are applied, or combination, the final configuration should be correct.
// The precedence should be: flags > env vars > .defangrc files

// make a default config for for comparison and copying
// make a default config for comparison and copying
defaultConfig := GlobalConfig{
ColorMode: ColorAuto,
Debug: false,
Expand Down
7 changes: 3 additions & 4 deletions src/pkg/cli/compose/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestValidationAndConvert(t *testing.T) {
if err != nil {
return nil, err
}

return configs.Names, nil
}

Expand All @@ -49,12 +48,12 @@ func TestValidationAndConvert(t *testing.T) {

if err := FixupServices(t.Context(), mockClient, project, UploadModeIgnore); err != nil {
t.Logf("Service conversion failed: %v", err)
logs.WriteString(err.Error() + "\n")
logs.WriteString("Error: " + err.Error() + "\n") // no coverage!
}

if err := ValidateProjectConfig(t.Context(), project, listConfigNamesFunc); err != nil {
t.Logf("Project config validation failed: %v", err)
logs.WriteString(err.Error() + "\n")
logs.WriteString("Error: " + err.Error() + "\n")
}

mode := modes.ModeAffordable
Expand All @@ -63,7 +62,7 @@ func TestValidationAndConvert(t *testing.T) {
}
if err := ValidateProject(project, mode); err != nil {
t.Logf("Project validation failed: %v", err)
logs.WriteString(err.Error() + "\n")
logs.WriteString("Error: " + err.Error() + "\n") // no coverage!
}

// The order of the services is not guaranteed, so we sort the logs before comparing
Expand Down
15 changes: 15 additions & 0 deletions src/testdata/extends/compose.base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
array-env:
image: bogus
environment:
- WITH_VALUE=foo
- EMPTY_VALUE=
- NO_VALUE
- BASE_ONLY=foo
map-env:
image: bogus
environment:
WITH_VALUE: foo
EMPTY_VALUE: ""
NO_VALUE:
BASE_ONLY: foo
76 changes: 76 additions & 0 deletions src/testdata/extends/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
services:
array-set:
extends:
file: ./compose.base.yaml
service: array-env
environment:
- WITH_VALUE=bar
- EMPTY_VALUE=bar
- NO_VALUE=bar
- NEW_VALUE=bar

map-set:
extends:
file: ./compose.base.yaml
service: map-env
environment:
WITH_VALUE: bar
EMPTY_VALUE: bar
NO_VALUE: bar
NEW_VALUE: bar

array-unset:
extends:
file: ./compose.base.yaml
service: array-env
environment:
- WITH_VALUE
- EMPTY_VALUE
- NO_VALUE
- NEW_VALUE

map-unset:
extends:
file: ./compose.base.yaml
service: map-env
environment:
WITH_VALUE:
EMPTY_VALUE:
NO_VALUE:
NEW_VALUE:

array-reset:
extends:
file: ./compose.base.yaml
service: array-env
environment: !reset []

map-reset:
extends:
file: ./compose.base.yaml
service: map-env
environment:
WITH_VALUE: !reset
EMPTY_VALUE: !reset
NO_VALUE: !reset
NEW_VALUE: !reset

array-override:
extends:
file: ./compose.base.yaml
service: array-env
environment: !override
- WITH_VALUE=bar
- EMPTY_VALUE=bar
- NO_VALUE=bar
- NEW_VALUE=bar

map-override:
extends:
file: ./compose.base.yaml
service: map-env
environment: !override
WITH_VALUE: bar
EMPTY_VALUE: bar
NO_VALUE: bar
NEW_VALUE: bar
109 changes: 109 additions & 0 deletions src/testdata/extends/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"array-override": {
"command": null,
"entrypoint": null,
"environment": {
"EMPTY_VALUE": "bar",
"NEW_VALUE": "bar",
"NO_VALUE": "bar",
"WITH_VALUE": "bar"
},
"image": "bogus",
"networks": {
"default": null
}
},
"array-reset": {
"command": null,
"entrypoint": null,
"image": "bogus",
"networks": {
"default": null
}
},
"array-set": {
"command": null,
"entrypoint": null,
"environment": {
"BASE_ONLY": "foo",
"EMPTY_VALUE": "bar",
"NEW_VALUE": "bar",
"NO_VALUE": "bar",
"WITH_VALUE": "bar"
},
"image": "bogus",
"networks": {
"default": null
}
},
"array-unset": {
"command": null,
"entrypoint": null,
"environment": {
"BASE_ONLY": "foo",
"EMPTY_VALUE": null,
"NEW_VALUE": null,
"NO_VALUE": null,
"WITH_VALUE": null
},
"image": "bogus",
"networks": {
"default": null
}
},
"map-override": {
"command": null,
"entrypoint": null,
"environment": {
"EMPTY_VALUE": "bar",
"NEW_VALUE": "bar",
"NO_VALUE": "bar",
"WITH_VALUE": "bar"
},
"image": "bogus",
"networks": {
"default": null
}
},
"map-reset": {
"command": null,
"entrypoint": null,
"environment": {
"BASE_ONLY": "foo"
},
"image": "bogus",
"networks": {
"default": null
}
},
"map-set": {
"command": null,
"entrypoint": null,
"environment": {
"BASE_ONLY": "foo",
"EMPTY_VALUE": "bar",
"NEW_VALUE": "bar",
"NO_VALUE": "bar",
"WITH_VALUE": "bar"
},
"image": "bogus",
"networks": {
"default": null
}
},
"map-unset": {
"command": null,
"entrypoint": null,
"environment": {
"BASE_ONLY": "foo",
"EMPTY_VALUE": null,
"NEW_VALUE": null,
"NO_VALUE": null,
"WITH_VALUE": null
},
"image": "bogus",
"networks": {
"default": null
}
}
}
73 changes: 73 additions & 0 deletions src/testdata/extends/compose.yaml.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: extends
services:
array-override:
environment:
EMPTY_VALUE: bar
NEW_VALUE: bar
NO_VALUE: bar
WITH_VALUE: bar
image: bogus
networks:
default: null
array-reset:
image: bogus
networks:
default: null
array-set:
environment:
BASE_ONLY: foo
EMPTY_VALUE: bar
NEW_VALUE: bar
NO_VALUE: bar
WITH_VALUE: bar
image: bogus
networks:
default: null
array-unset:
environment:
BASE_ONLY: foo
EMPTY_VALUE: null
NEW_VALUE: null
NO_VALUE: null
WITH_VALUE: null
image: bogus
networks:
default: null
map-override:
environment:
EMPTY_VALUE: bar
NEW_VALUE: bar
NO_VALUE: bar
WITH_VALUE: bar
image: bogus
networks:
default: null
map-reset:
environment:
BASE_ONLY: foo
image: bogus
networks:
default: null
map-set:
environment:
BASE_ONLY: foo
EMPTY_VALUE: bar
NEW_VALUE: bar
NO_VALUE: bar
WITH_VALUE: bar
image: bogus
networks:
default: null
map-unset:
environment:
BASE_ONLY: foo
EMPTY_VALUE: null
NEW_VALUE: null
NO_VALUE: null
WITH_VALUE: null
image: bogus
networks:
default: null
networks:
default:
name: extends_default
9 changes: 9 additions & 0 deletions src/testdata/extends/compose.yaml.warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
! service "array-override": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "array-reset": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "array-set": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "array-unset": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "map-override": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "map-reset": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "map-set": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "map-unset": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
Error: missing configs ["EMPTY_VALUE" "NEW_VALUE" "NO_VALUE" "WITH_VALUE"] (https://docs.defang.io/docs/concepts/configuration)
2 changes: 1 addition & 1 deletion src/testdata/interpolate/compose.yaml.warnings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! Environment variable "NODE_ENV" is ignored; add it to `.env` if needed
! Environment variable "NODE_ENV" is ignored; add it to `.env` or it may be resolved from config during deployment
! service "interpolate": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
missing configs ["NODE_ENV" "POSTGRES_PASSWORD" "def"] (https://docs.defang.io/docs/concepts/configuration)
Error: missing configs ["NODE_ENV" "POSTGRES_PASSWORD" "def"] (https://docs.defang.io/docs/concepts/configuration)
Loading