Skip to content

Commit

Permalink
Add check for namespace access (#1946)
Browse files Browse the repository at this point in the history
Signed-off-by: Javier López Barba <javier@okteto.com>
  • Loading branch information
jLopezbarb committed Nov 16, 2021
1 parent 20236f8 commit 60ee441
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/context/create.go
Expand Up @@ -121,6 +121,17 @@ func UseContext(ctx context.Context, ctxOptions *ContextOptions) error {
return err
}
}
if ctxOptions.isOkteto && ctxOptions.Save {
hasAccess, err := utils.HasAccessToNamespace(ctx, ctxOptions.Namespace)
if err != nil {
return err
}
if !hasAccess {
return errors.UserError{E: fmt.Errorf("namespace '%s' not found on context '%s'", ctxOptions.Namespace, ctxOptions.Context),
Hint: "Please verify that the namespace exists and that you have access to it.",
}
}
}
if ctxOptions.Save {
if err := okteto.WriteOktetoContextConfig(); err != nil {
return err
Expand Down

0 comments on commit 60ee441

Please sign in to comment.