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

fix: allow login to express registry as ref but actually extract the … #610

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/registry/auth/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/falcosecurity/falcoctl/internal/config"
"github.com/falcosecurity/falcoctl/internal/login/basic"
"github.com/falcosecurity/falcoctl/internal/utils"
"github.com/falcosecurity/falcoctl/pkg/oci/authn"
"github.com/falcosecurity/falcoctl/pkg/options"
"github.com/falcosecurity/falcoctl/pkg/output"
Expand Down Expand Up @@ -95,8 +96,15 @@ Example - Login with username and password in an interactive prompt:

// RunBasic executes the business logic for the basic command.
func (o *loginOptions) RunBasic(ctx context.Context, args []string) error {
reg := args[0]
var reg string
logger := o.Printer.Logger

// Allow to have the registry expressed as a ref, but actually extract it.
reg, err := utils.GetRegistryFromRef(args[0])
if err != nil {
reg = args[0]
}

if err := getCredentials(o.Printer, o); err != nil {
return err
}
Expand Down
9 changes: 8 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"

"github.com/falcosecurity/falcoctl/internal/utils"
drivertype "github.com/falcosecurity/falcoctl/pkg/driver/type"
"github.com/falcosecurity/falcoctl/pkg/oci"
)
Expand Down Expand Up @@ -395,8 +396,14 @@ func basicAuthListHookFunc() mapstructure.DecodeHookFuncType {
return data, fmt.Errorf("not valid token %q", token)
}

// Allow to have the registry expressed as a ref, but actually extract it.
registry, err := utils.GetRegistryFromRef(values[0])
if err != nil {
registry = values[0]
}

auths[i] = BasicAuth{
Registry: values[0],
Registry: registry,
User: values[1],
Password: values[2],
}
Expand Down
Loading