-
Notifications
You must be signed in to change notification settings - Fork 277
Fix parsing Docker scan flags and Args #3276
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
base: master
Are you sure you want to change the base?
Changes from all commits
0acb53e
e7311ad
246b80e
e9e8880
14868d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/BurntSushi/toml" | ||
| "github.com/jfrog/gofrog/datastructures" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container/strategies" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python" | ||
| "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup" | ||
|
|
@@ -427,7 +428,7 @@ func GetCommands() []cli.Command { | |
| }, | ||
| { | ||
| Name: "docker", | ||
| Flags: cliutils.GetCommandFlags(cliutils.Docker), | ||
| Flags: getDockerFlags(), | ||
| Usage: docker.GetDescription(), | ||
| HelpName: corecommon.CreateUsage("docker", docker.GetDescription(), docker.Usage), | ||
| UsageText: docker.GetArguments(), | ||
|
|
@@ -496,6 +497,28 @@ func skipFlagParsingForDockerCmd() bool { | |
| return true | ||
| } | ||
|
|
||
| func getDockerFlags() []cli.Flag { | ||
| flagNames := datastructures.MakeSet[string]() | ||
| // Collecting existing Docker flags | ||
| flagList := cliutils.GetCommandFlags(cliutils.Docker) | ||
| for _, f := range flagList { | ||
| flagNames.Add(f.GetName()) | ||
| } | ||
| // Adding `Docker Scan` flags | ||
| converted, _, err := components.ConvertFlags(securityDocs.DockerScan, securityDocs.GetCommandFlags(securityDocs.DockerScan)) | ||
| if err != nil { | ||
| log.Error("Could not convert Docker Scan flags:", err) | ||
| return flagList | ||
| } | ||
| for _, f := range converted { | ||
| // Avoiding flag duplication which causes panic in urfave/cli | ||
| if !flagNames.Exists(f.GetName()) { | ||
| flagList = append(flagList, f) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use flagNames in the whole method and then convert it to slice ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we do it, when converting to slice you will need to go over the 2 sources of flags to locate where it is. |
||
| } | ||
| } | ||
| return flagList | ||
| } | ||
|
|
||
| // decorateWithFlagCapture injects a Before hook into every command returned from this package, | ||
| // so we can capture user-provided flags consistently in one place for all build commands. | ||
| func decorateWithFlagCapture(cmds []cli.Command) []cli.Command { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added