diff --git a/api/client/porter_app.go b/api/client/porter_app.go index 565ab0656a..efc4e8a00c 100644 --- a/api/client/porter_app.go +++ b/api/client/porter_app.go @@ -500,10 +500,13 @@ func (c *Client) GetAppEnvVariables( ctx context.Context, projectID uint, clusterID uint, appName string, + deploymentTargetName string, ) (*porter_app.AppEnvVariablesResponse, error) { resp := &porter_app.AppEnvVariablesResponse{} - req := &porter_app.AppEnvVariablesRequest{} + req := &porter_app.AppEnvVariablesRequest{ + DeploymentTargetName: deploymentTargetName, + } err := c.getRequest( fmt.Sprintf( diff --git a/api/server/handlers/porter_app/app_env_variables.go b/api/server/handlers/porter_app/app_env_variables.go index 493e7db547..d203323e68 100644 --- a/api/server/handlers/porter_app/app_env_variables.go +++ b/api/server/handlers/porter_app/app_env_variables.go @@ -39,7 +39,8 @@ type EnvVariables struct { // AppEnvVariablesRequest is the request object for the /apps/{porter_app_name}/env-variables endpoint type AppEnvVariablesRequest struct { - DeploymentTargetID string `schema:"deployment_target_id"` + DeploymentTargetID string `schema:"deployment_target_id"` + DeploymentTargetName string `schema:"deployment_target_name"` } // AppEnvVariablesResponse is the response object for the /apps/{porter_app_name}/env-variables endpoint @@ -73,12 +74,17 @@ func (c *AppEnvVariablesHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques // optional deployment target id - if not provided, use the cluster's default deploymentTargetID := request.DeploymentTargetID - telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "deployment-target-id", Value: deploymentTargetID}) + deploymentTargetName := request.DeploymentTargetName + telemetry.WithAttributes(span, + telemetry.AttributeKV{Key: "deployment-target-id", Value: deploymentTargetID}, + telemetry.AttributeKV{Key: "deployment-target-name", Value: deploymentTargetName}, + ) var deploymentTargetIdentifer *porterv1.DeploymentTargetIdentifier - if deploymentTargetID != "" { + if deploymentTargetID != "" || deploymentTargetName != "" { deploymentTargetIdentifer = &porterv1.DeploymentTargetIdentifier{ - Id: deploymentTargetID, + Id: deploymentTargetID, + Name: deploymentTargetName, } } diff --git a/cli/cmd/commands/env.go b/cli/cmd/commands/env.go index 190872a7a4..a4fd2bd6c5 100644 --- a/cli/cmd/commands/env.go +++ b/cli/cmd/commands/env.go @@ -48,6 +48,7 @@ Optionally, specify a file to write the environment variables to. Otherwise the pullCommand.Flags().StringVarP(&appName, "app", "a", "", "app name") pullCommand.Flags().StringVarP(&envGroupName, "group", "g", "", "environment group name") pullCommand.Flags().StringVarP(&envFilePath, "file", "f", "", "file to write environment variables to") + pullCommand.Flags().StringVarP(&deploymentTargetName, "target", "x", "", "the name of the deployment target for the app") envCmd.AddCommand(pullCommand) @@ -67,7 +68,7 @@ func pullEnv(ctx context.Context, user *types.GetAuthenticatedUserResponse, clie if appName != "" { color.New(color.FgGreen).Printf("Pulling environment variables for app %s...\n", appName) // nolint:errcheck,gosec - envVarsResp, err := client.GetAppEnvVariables(ctx, cliConf.Project, cliConf.Cluster, appName) + envVarsResp, err := client.GetAppEnvVariables(ctx, cliConf.Project, cliConf.Cluster, appName, deploymentTargetName) if err != nil { return fmt.Errorf("could not get app env variables: %w", err) }