-
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.
use new update call and remove cli actions in cli apply (#3924)
Co-authored-by: David Townley <[email protected]> Co-authored-by: d-g-town <[email protected]>
- Loading branch information
1 parent
87f6d03
commit 8a9ae39
Showing
16 changed files
with
765 additions
and
144 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package porter_app | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/porter-dev/porter/api/server/authz" | ||
"github.com/porter-dev/porter/api/server/handlers" | ||
"github.com/porter-dev/porter/api/server/shared" | ||
"github.com/porter-dev/porter/api/server/shared/config" | ||
"github.com/porter-dev/porter/api/types" | ||
"github.com/porter-dev/porter/internal/models" | ||
"github.com/porter-dev/porter/internal/telemetry" | ||
) | ||
|
||
// UseNewApplyLogicHandler returns whether the CLI should use the new apply logic or not | ||
type UseNewApplyLogicHandler struct { | ||
handlers.PorterHandlerReadWriter | ||
authz.KubernetesAgentGetter | ||
} | ||
|
||
// NewUseNewApplyLogicHandler returns a new UseNewApplyLogicHandler | ||
func NewUseNewApplyLogicHandler( | ||
config *config.Config, | ||
decoderValidator shared.RequestDecoderValidator, | ||
writer shared.ResultWriter, | ||
) *UseNewApplyLogicHandler { | ||
return &UseNewApplyLogicHandler{ | ||
PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, decoderValidator, writer), | ||
KubernetesAgentGetter: authz.NewOutOfClusterAgentGetter(config), | ||
} | ||
} | ||
|
||
// UseNewApplyLogicRequest is the request body for the /apps/use-new-apply-logic endpoint | ||
type UseNewApplyLogicRequest struct{} | ||
|
||
// UseNewApplyLogicResponse is the response body for the /apps/use-new-apply-logic endpoint | ||
type UseNewApplyLogicResponse struct { | ||
UseNewApplyLogic bool `json:"use_new_apply_logic"` | ||
} | ||
|
||
// ServeHTTP handles the request on the /apps/use-new-apply-logic endpoint, allowing the server to tell the CLI whether to use the new apply logic or not | ||
func (c *UseNewApplyLogicHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
ctx, span := telemetry.NewSpan(r.Context(), "serve-use-new-apply-logic") | ||
defer span.End() | ||
|
||
project, _ := ctx.Value(types.ProjectScope).(*models.Project) | ||
cluster, _ := ctx.Value(types.ClusterScope).(*models.Cluster) | ||
|
||
telemetry.WithAttributes(span, | ||
telemetry.AttributeKV{Key: "project_id", Value: project.ID}, | ||
telemetry.AttributeKV{Key: "cluster_id", Value: cluster.ID}, | ||
) | ||
|
||
betaFeaturesEnabled := project.GetFeatureFlag(models.BetaFeaturesEnabled, c.Config().LaunchDarklyClient) | ||
|
||
telemetry.WithAttributes(span, | ||
telemetry.AttributeKV{Key: "beta_features_enabled", Value: betaFeaturesEnabled}, | ||
) | ||
|
||
c.WriteResult(w, r, &UseNewApplyLogicResponse{ | ||
UseNewApplyLogic: betaFeaturesEnabled, | ||
}) | ||
} |
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
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
Oops, something went wrong.