Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce ResolveServicesEnvironment and resolve service environment AFTER profiles have been applied #338

Merged
merged 1 commit into from
Jan 19, 2023

Conversation

ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Jan 5, 2023

This introduces WithProfiles so the loader can directly apply selected profiles, and moves env_file loading logic to a later phase, so we won't try to load for services which have been disabled
Also introduce load option SkipResolveEnvFiles to fully bypass this and process env_files in a later phase

closes docker/compose#8713

@ndeloof ndeloof force-pushed the ResolveServicesEnvironment branch from 2d20532 to dc76fd1 Compare January 13, 2023 07:19
@ndeloof ndeloof force-pushed the ResolveServicesEnvironment branch from dc76fd1 to 2f8259f Compare January 13, 2023 07:52
Copy link
Member

@milas milas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of type errors from GHA and one potential file leak from me but otherwise LGTM

types/project.go Outdated
}

// Do not defer to avoid it inside a loop
file.Close() //nolint:errcheck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leak if we end up returning an error above - perhaps os.ReadFile instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, or if we just want to pass file name we should use envFile variable directly

types/types.go Outdated
@@ -357,12 +357,12 @@ type ThrottleDevice struct {
// ShellCommand is a string or list of string args.
//
// When marshaled to YAML, nil command fields will be omitted if `omitempty`
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or ``)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fun quotes are back 😂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of my favorite running gags of the moment 😂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or ``)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)

Copy link
Collaborator

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just few little things to fix before merging

types/project.go Outdated
}

// Do not defer to avoid it inside a loop
file.Close() //nolint:errcheck
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, or if we just want to pass file name we should use envFile variable directly

types/types.go Outdated
@@ -357,12 +357,12 @@ type ThrottleDevice struct {
// ShellCommand is a string or list of string args.
//
// When marshaled to YAML, nil command fields will be omitted if `omitempty`
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or ``)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of my favorite running gags of the moment 😂

types/types.go Outdated
@@ -357,12 +357,12 @@ type ThrottleDevice struct {
// ShellCommand is a string or list of string args.
//
// When marshaled to YAML, nil command fields will be omitted if `omitempty`
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or ``)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or ``)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)

types/types.go Outdated
// will serialize to an empty array (`[]`).
//
// When marshaled to JSON, the `omitempty` struct must NOT be specified.
// If the command field is nil, it will be serialized as `null`.
// Explicitly empty commands (i.e. `[]` or `''`) will serialize to an empty
// Explicitly empty commands (i.e. `[]` or ``) will serialize to an empty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Explicitly empty commands (i.e. `[]` or ``) will serialize to an empty
// Explicitly empty commands (i.e. `[]` or `''`) will serialize to an empty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes me crazy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My LSP has turned to doing the same thing and now I have to fix it before I make my PRs 😭

@ndeloof ndeloof force-pushed the ResolveServicesEnvironment branch 3 times, most recently from ebf718b to b559569 Compare January 18, 2023 10:23
…AFTER profiles have been applied

Signed-off-by: Nicolas De Loof <[email protected]>
@ndeloof ndeloof force-pushed the ResolveServicesEnvironment branch from b559569 to a30b5f7 Compare January 18, 2023 10:46
@ndeloof ndeloof requested a review from glours January 18, 2023 10:54
Copy link
Collaborator

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndeloof ndeloof requested a review from milas January 19, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.env file referenced underneath env_file in a compose file is being parsed when file is not used.
4 participants