From e2ae0ba5f8e755148112900883c06293c8caa8c2 Mon Sep 17 00:00:00 2001 From: Harsh Thakur Date: Fri, 15 Sep 2023 18:55:59 +0530 Subject: [PATCH] have flag struct include bkOpts struct Signed-off-by: Harsh Thakur --- pkg/patch/cmd.go | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/pkg/patch/cmd.go b/pkg/patch/cmd.go index 7b0fcc4d..1e6a59bd 100644 --- a/pkg/patch/cmd.go +++ b/pkg/patch/cmd.go @@ -21,18 +21,15 @@ import ( ) type patchArgs struct { - appImage string - reportFile string - patchedTag string - workingFolder string - buildkitAddr string - buildkitCACertPath string - buildkitClientCertPath string - buildkitClientKeyPath string - timeout time.Duration - ignoreError bool - format string - output string + appImage string + reportFile string + patchedTag string + workingFolder string + timeout time.Duration + ignoreError bool + format string + output string + bkOpts buildkit.Opts } func NewPatchCmd() *cobra.Command { @@ -43,10 +40,10 @@ func NewPatchCmd() *cobra.Command { Example: "copa patch -i images/python:3.7-alpine -r trivy.json -t 3.7-alpine-patched", RunE: func(cmd *cobra.Command, args []string) error { bkopts := buildkit.Opts{ - Addr: ua.buildkitAddr, - CACertPath: ua.buildkitCACertPath, - CertPath: ua.buildkitClientCertPath, - KeyPath: ua.buildkitClientKeyPath, + Addr: ua.bkOpts.Addr, + CACertPath: ua.bkOpts.CACertPath, + CertPath: ua.bkOpts.CertPath, + KeyPath: ua.bkOpts.KeyPath, } return Patch(context.Background(), ua.timeout, @@ -65,10 +62,10 @@ func NewPatchCmd() *cobra.Command { flags.StringVarP(&ua.reportFile, "report", "r", "", "Vulnerability report file path") flags.StringVarP(&ua.patchedTag, "tag", "t", "", "Tag for the patched image") flags.StringVarP(&ua.workingFolder, "working-folder", "w", "", "Working folder, defaults to system temp folder") - flags.StringVarP(&ua.buildkitAddr, "addr", "a", "", "Address of buildkitd service, defaults to local docker daemon with fallback to "+buildkit.DefaultAddr) - flags.StringVarP(&ua.buildkitCACertPath, "cacert", "", "", "Absolute path to buildkitd CA certificate") - flags.StringVarP(&ua.buildkitClientCertPath, "cert", "", "", "Absolute path to buildkit client certificate") - flags.StringVarP(&ua.buildkitClientKeyPath, "key", "", "", "Absolute path to buildkit client key") + flags.StringVarP(&ua.bkOpts.Addr, "addr", "a", "", "Address of buildkitd service, defaults to local docker daemon with fallback to "+buildkit.DefaultAddr) + flags.StringVarP(&ua.bkOpts.CACertPath, "cacert", "", "", "Absolute path to buildkitd CA certificate") + flags.StringVarP(&ua.bkOpts.CertPath, "cert", "", "", "Absolute path to buildkit client certificate") + flags.StringVarP(&ua.bkOpts.KeyPath, "key", "", "", "Absolute path to buildkit client key") flags.DurationVar(&ua.timeout, "timeout", 5*time.Minute, "Timeout for the operation, defaults to '5m'") flags.BoolVar(&ua.ignoreError, "ignore-errors", false, "Ignore errors and continue patching") flags.StringVarP(&ua.format, "format", "f", "openvex", "Output format, defaults to 'openvex'")