Skip to content

Commit

Permalink
kubectl for v1 users (#4552)
Browse files Browse the repository at this point in the history
Co-authored-by: sunguroku <[email protected]>
Co-authored-by: Porter Support <[email protected]>
  • Loading branch information
3 people authored Apr 16, 2024
1 parent 72d6a76 commit 3b3323f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cli/cmd/commands/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@ func registerCommand_Kubectl(cliConf config.CLIConfig) *cobra.Command {
func runKubectl(ctx context.Context, _ *types.GetAuthenticatedUserResponse, client api.Client, cliConf config.CLIConfig, featureFlags config.FeatureFlags, cmd *cobra.Command, args []string) error {
// this will never error because it just ran
user, _ := client.AuthCheck(ctx)
if !strings.HasSuffix(user.Email, "@porter.run") {

project, err := client.GetProject(ctx, cliConf.Project)
if err != nil {
return fmt.Errorf("could not retrieve project from Porter API. Please contact [email protected]: %w", err)
}

if project == nil {
return fmt.Errorf("project [%d] not found", cliConf.Project)
}

if !strings.HasSuffix(user.Email, "@porter.run") && project.ValidateApplyV2 {
return fmt.Errorf("Forbidden")
}

_, err := exec.LookPath("kubectl")
_, err = exec.LookPath("kubectl")
if err != nil {
return fmt.Errorf("error finding kubectl: %w", err)
}
Expand Down

0 comments on commit 3b3323f

Please sign in to comment.