Skip to content

Commit f55a5e6

Browse files
loresusopoiana
authored andcommitted
fix: allow login to express registry as ref but actually extract the registry
Signed-off-by: Lorenzo Susini <[email protected]>
1 parent fc648dc commit f55a5e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

cmd/registry/auth/basic/basic.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"github.com/falcosecurity/falcoctl/internal/config"
3232
"github.com/falcosecurity/falcoctl/internal/login/basic"
33+
"github.com/falcosecurity/falcoctl/internal/utils"
3334
"github.com/falcosecurity/falcoctl/pkg/oci/authn"
3435
"github.com/falcosecurity/falcoctl/pkg/options"
3536
"github.com/falcosecurity/falcoctl/pkg/output"
@@ -95,8 +96,15 @@ Example - Login with username and password in an interactive prompt:
9596

9697
// RunBasic executes the business logic for the basic command.
9798
func (o *loginOptions) RunBasic(ctx context.Context, args []string) error {
98-
reg := args[0]
99+
var reg string
99100
logger := o.Printer.Logger
101+
102+
// Allow to have the registry expressed as a ref, but actually extract it.
103+
reg, err := utils.GetRegistryFromRef(args[0])
104+
if err != nil {
105+
reg = args[0]
106+
}
107+
100108
if err := getCredentials(o.Printer, o); err != nil {
101109
return err
102110
}

internal/config/config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/mitchellh/mapstructure"
3131
"github.com/spf13/viper"
3232

33+
"github.com/falcosecurity/falcoctl/internal/utils"
3334
drivertype "github.com/falcosecurity/falcoctl/pkg/driver/type"
3435
"github.com/falcosecurity/falcoctl/pkg/oci"
3536
)
@@ -395,8 +396,14 @@ func basicAuthListHookFunc() mapstructure.DecodeHookFuncType {
395396
return data, fmt.Errorf("not valid token %q", token)
396397
}
397398

399+
// Allow to have the registry expressed as a ref, but actually extract it.
400+
registry, err := utils.GetRegistryFromRef(values[0])
401+
if err != nil {
402+
registry = values[0]
403+
}
404+
398405
auths[i] = BasicAuth{
399-
Registry: values[0],
406+
Registry: registry,
400407
User: values[1],
401408
Password: values[2],
402409
}

0 commit comments

Comments
 (0)