Skip to content

Commit 3b3323f

Browse files
sungurokusungurokuportersupport
authored
kubectl for v1 users (#4552)
Co-authored-by: sunguroku <[email protected]> Co-authored-by: Porter Support <[email protected]>
1 parent 72d6a76 commit 3b3323f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cli/cmd/commands/kubectl.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ func registerCommand_Kubectl(cliConf config.CLIConfig) *cobra.Command {
3838
func runKubectl(ctx context.Context, _ *types.GetAuthenticatedUserResponse, client api.Client, cliConf config.CLIConfig, featureFlags config.FeatureFlags, cmd *cobra.Command, args []string) error {
3939
// this will never error because it just ran
4040
user, _ := client.AuthCheck(ctx)
41-
if !strings.HasSuffix(user.Email, "@porter.run") {
41+
42+
project, err := client.GetProject(ctx, cliConf.Project)
43+
if err != nil {
44+
return fmt.Errorf("could not retrieve project from Porter API. Please contact [email protected]: %w", err)
45+
}
46+
47+
if project == nil {
48+
return fmt.Errorf("project [%d] not found", cliConf.Project)
49+
}
50+
51+
if !strings.HasSuffix(user.Email, "@porter.run") && project.ValidateApplyV2 {
4252
return fmt.Errorf("Forbidden")
4353
}
4454

45-
_, err := exec.LookPath("kubectl")
55+
_, err = exec.LookPath("kubectl")
4656
if err != nil {
4757
return fmt.Errorf("error finding kubectl: %w", err)
4858
}

0 commit comments

Comments
 (0)