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

feat: Add label_file support to service #713

Merged
merged 11 commits into from
Dec 2, 2024

Conversation

idsulik
Copy link
Contributor

@idsulik idsulik commented Nov 22, 2024

@idsulik
Copy link
Contributor Author

idsulik commented Nov 23, 2024

@ndeloof hi! What do you think about the PR, should I continue implementing the feature like I do(it uses the same way as we load env_file) or should I do it in a different way?

@ndeloof
Copy link
Collaborator

ndeloof commented Nov 25, 2024

Sounds good to me. I'd prefer we can rely on docker/cli parser for this file so we don't have 2 implementations, but this would mean we resolve labels in docker/compose, and on the other hand format is pretty minimalist, so let's go this way

idsulik and others added 4 commits November 27, 2024 11:08
Signed-off-by: Suleiman Dibirov <[email protected]>
Signed-off-by: Suleiman Dibirov <[email protected]>
Signed-off-by: Suleiman Dibirov <[email protected]>
@idsulik idsulik marked this pull request as ready for review November 27, 2024 09:35
@idsulik idsulik requested a review from ndeloof as a code owner November 27, 2024 09:35
Copy link
Collaborator

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

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

LGTM

in this PR, you're anticipating the need to set a label_file as required. Do you have a use-case in mind ? We introduced this for env_file as a workaround for corner-case usages, but I'd prefer we don't make things unnecessary complicated if we don't have to, at least for a first iteration.

Signed-off-by: Suleiman Dibirov <[email protected]>
@idsulik
Copy link
Contributor Author

idsulik commented Nov 27, 2024

Do you have a use-case in mind

I did it to follow the current logic for the env_file. removed it + added tests

Signed-off-by: Suleiman Dibirov <[email protected]>
@idsulik idsulik requested a review from ndeloof November 27, 2024 11:37
"label_file": {
"oneOf": [
{"type": "string"},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds to me this is a premature feature to add support for required here. label_file should be declared at most a string|array of string for user convenience

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ndeloof agree, fixed

Signed-off-by: Suleiman Dibirov <[email protected]>
@idsulik idsulik requested a review from ndeloof November 27, 2024 15:06
switch value := y.(type) {
case string:
return value, nil
case map[string]any:
Copy link
Collaborator

Choose a reason for hiding this comment

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

not relevant anymore AFAICT

}
}

func transformLabelFileValue(data any) any {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not relevant anymore

@@ -217,10 +217,24 @@ func services(workingDir, homeDir string) types.Services {
Ipc: "host",
Uts: "host",
Labels: map[string]string{
"FOO": "foo_from_label_file",
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI this huge test we inherited from legacy compose parser in docker/cli.
As it is painful to maintain, we prefer to have individual test checking specific attribute is well supported (which you also provided 🥳)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I revert these changes or keep them?

@idsulik
Copy link
Contributor Author

idsulik commented Nov 27, 2024

@ndeloof pushed changes, now label_file has type []string

@idsulik idsulik requested a review from ndeloof November 27, 2024 16:20
Comment on lines 869 to 871
"format": {
"type": "string"
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this removal intentional ?

Copy link
Contributor Author

@idsulik idsulik Nov 27, 2024

Choose a reason for hiding this comment

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

yes, you wrote to make it string or []string, so I did it).

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure, but here you removed format attribute from env_file defintion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, accidentally deleted it, put it back

"encoding/json"
)

type LabelFile struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

unused ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, thank you, removed

Signed-off-by: Suleiman Dibirov <[email protected]>
Signed-off-by: Suleiman Dibirov <[email protected]>
@idsulik idsulik requested a review from ndeloof November 28, 2024 08:57
@ndeloof ndeloof requested a review from glours November 28, 2024 13:03
@ndeloof ndeloof merged commit bfe7111 into compose-spec:main Dec 2, 2024
8 checks passed
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.

2 participants