-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: sunguroku <[email protected]> Co-authored-by: Porter Support <[email protected]>
- Loading branch information
1 parent
72d6a76
commit 3b3323f
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
} | ||
|