Skip to content

Commit

Permalink
Add check for namespace access
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 4, 2021
1 parent 155601a commit d8f5c8e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/context/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,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 d8f5c8e

Please sign in to comment.