From 0ad127cd8421e89be368df4573c6153a6436b6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Apayd=C4=B1n?= Date: Mon, 27 Jun 2022 21:39:45 +0300 Subject: [PATCH 1/3] feat: add new login cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Batuhan Apaydın --- cmd/syft/cli/commands.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/syft/cli/commands.go b/cmd/syft/cli/commands.go index 9f349739889..d2378bef8a2 100644 --- a/cmd/syft/cli/commands.go +++ b/cmd/syft/cli/commands.go @@ -15,6 +15,7 @@ import ( "github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/version" "github.com/anchore/syft/syft/event" + cranecmd "github.com/google/go-containerregistry/cmd/crane/cmd" "github.com/gookit/color" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -89,6 +90,7 @@ func New() (*cobra.Command, error) { rootCmd.AddCommand(poweruserCmd) rootCmd.AddCommand(Completion()) rootCmd.AddCommand(Version(v, app)) + rootCmd.AddCommand(cranecmd.NewCmdAuthLogin("syft")) return rootCmd, err } From e176fe3aca517b0453623fad5578ad3015b72563 Mon Sep 17 00:00:00 2001 From: Christopher Phillips Date: Fri, 1 Jul 2022 14:33:14 -0400 Subject: [PATCH 2/3] small updates for nolints Signed-off-by: Christopher Phillips --- cmd/syft/cli/commands.go | 23 ++++++++++++++++------- internal/config/registry.go | 1 - 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/syft/cli/commands.go b/cmd/syft/cli/commands.go index d2378bef8a2..e4663de8157 100644 --- a/cmd/syft/cli/commands.go +++ b/cmd/syft/cli/commands.go @@ -31,6 +31,7 @@ const indent = " " // at this level. Values from the config should only be used after `app.LoadAllValues` has been called. // Cobra does not have knowledge of the user provided flags until the `RunE` block of each command. // `RunE` is the earliest that the complete application configuration can be loaded. +// nolint:funlen func New() (*cobra.Command, error) { app := &config.Application{} @@ -83,14 +84,22 @@ func New() (*cobra.Command, error) { return nil, err } + // commands to add to root + cmds := []*cobra.Command{ + packagesCmd, + attestCmd, + convertCmd, + poweruserCmd, + poweruserCmd, + Completion(), + Version(v, app), + cranecmd.NewCmdAuthLogin("syft"), + } + // Add sub-commands. - rootCmd.AddCommand(packagesCmd) - rootCmd.AddCommand(attestCmd) - rootCmd.AddCommand(convertCmd) - rootCmd.AddCommand(poweruserCmd) - rootCmd.AddCommand(Completion()) - rootCmd.AddCommand(Version(v, app)) - rootCmd.AddCommand(cranecmd.NewCmdAuthLogin("syft")) + for _, cmd := range cmds { + rootCmd.AddCommand(cmd) + } return rootCmd, err } diff --git a/internal/config/registry.go b/internal/config/registry.go index 0506d25fe94..0602cc0c7c6 100644 --- a/internal/config/registry.go +++ b/internal/config/registry.go @@ -30,7 +30,6 @@ func (cfg registry) loadDefaultValues(v *viper.Viper) { v.SetDefault("registry.auth", []RegistryCredentials{}) } -// nolint: unparam func (cfg *registry) parseConfigValues() error { // there may be additional credentials provided by env var that should be appended to the set of credentials authority, username, password, token := From 1a53388698d4b714b83222cf0f1b7419468a7012 Mon Sep 17 00:00:00 2001 From: Christopher Phillips Date: Tue, 5 Jul 2022 11:28:46 -0400 Subject: [PATCH 3/3] lint update Signed-off-by: Christopher Phillips --- internal/config/registry.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/config/registry.go b/internal/config/registry.go index 0602cc0c7c6..7d9a76d8179 100644 --- a/internal/config/registry.go +++ b/internal/config/registry.go @@ -30,6 +30,7 @@ func (cfg registry) loadDefaultValues(v *viper.Viper) { v.SetDefault("registry.auth", []RegistryCredentials{}) } +// nolint:unparam func (cfg *registry) parseConfigValues() error { // there may be additional credentials provided by env var that should be appended to the set of credentials authority, username, password, token :=