mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
fix(server): make parameterized resource actions backwards-compatible (#23695)
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
This commit is contained in:
parent
d39c0083ea
commit
f420cce7a5
12 changed files with 1224 additions and 235 deletions
81
assets/swagger.json
generated
81
assets/swagger.json
generated
|
|
@ -1473,10 +1473,11 @@
|
|||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Deprecated: use RunResourceActionV2 instead. This version does not support resource action parameters but is\nmaintained for backward compatibility. It will be removed in a future release.",
|
||||
"tags": [
|
||||
"ApplicationService"
|
||||
],
|
||||
"summary": "RunResourceAction run resource action",
|
||||
"summary": "RunResourceAction runs a resource action",
|
||||
"operationId": "ApplicationService_RunResourceAction",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
@ -1490,7 +1491,81 @@
|
|||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/applicationResourceActionRunRequest"
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "namespace",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "resourceName",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "version",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "group",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "kind",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "appNamespace",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "project",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/applicationApplicationResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/applications/{name}/resource/actions/v2": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"ApplicationService"
|
||||
],
|
||||
"summary": "RunResourceActionV2 runs a resource action with parameters",
|
||||
"operationId": "ApplicationService_RunResourceActionV2",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/applicationResourceActionRunRequestV2"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -5127,7 +5202,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"applicationResourceActionRunRequest": {
|
||||
"applicationResourceActionRunRequestV2": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"action": {
|
||||
|
|
|
|||
|
|
@ -8,23 +8,23 @@ import (
|
|||
"strconv"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/util/templates"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/util"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/grpc/codes"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/argocd/commands/headless"
|
||||
"github.com/argoproj/argo-cd/v3/cmd/util"
|
||||
argocdclient "github.com/argoproj/argo-cd/v3/pkg/apiclient"
|
||||
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/util/argo"
|
||||
"github.com/argoproj/argo-cd/v3/util/errors"
|
||||
"github.com/argoproj/argo-cd/v3/util/grpc"
|
||||
utilio "github.com/argoproj/argo-cd/v3/util/io"
|
||||
"github.com/argoproj/argo-cd/v3/util/templates"
|
||||
)
|
||||
|
||||
type DisplayedAction struct {
|
||||
|
|
@ -192,7 +192,26 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
|
|||
obj := filteredObjects[i]
|
||||
gvk := obj.GroupVersionKind()
|
||||
objResourceName := obj.GetName()
|
||||
_, err := appIf.RunResourceAction(ctx, &applicationpkg.ResourceActionRunRequest{
|
||||
_, err := appIf.RunResourceActionV2(ctx, &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Namespace: ptr.To(obj.GetNamespace()),
|
||||
ResourceName: ptr.To(objResourceName),
|
||||
Group: ptr.To(gvk.Group),
|
||||
Kind: ptr.To(gvk.Kind),
|
||||
Version: ptr.To(gvk.GroupVersion().Version),
|
||||
Action: ptr.To(actionName),
|
||||
// TODO: add support for parameters
|
||||
})
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
if grpc.UnwrapGRPCStatus(err).Code() != codes.Unimplemented {
|
||||
errors.CheckError(err)
|
||||
}
|
||||
fmt.Println("RunResourceActionV2 is not supported by the server, falling back to RunResourceAction.")
|
||||
//nolint:staticcheck // RunResourceAction is deprecated, but we still need to support it for backward compatibility.
|
||||
_, err = appIf.RunResourceAction(ctx, &applicationpkg.ResourceActionRunRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Namespace: ptr.To(obj.GetNamespace()),
|
||||
|
|
|
|||
|
|
@ -2228,10 +2228,15 @@ func (c *fakeAppServiceClient) ListResourceActions(_ context.Context, _ *applica
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// nolint:staticcheck // ResourceActionRunRequest is deprecated, but we still need to implement it to satisfy the server interface.
|
||||
func (c *fakeAppServiceClient) RunResourceAction(_ context.Context, _ *applicationpkg.ResourceActionRunRequest, _ ...grpc.CallOption) (*applicationpkg.ApplicationResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAppServiceClient) RunResourceActionV2(_ context.Context, _ *applicationpkg.ResourceActionRunRequestV2, _ ...grpc.CallOption) (*applicationpkg.ApplicationResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeAppServiceClient) DeleteResource(_ context.Context, _ *applicationpkg.ApplicationResourceDeleteRequest, _ ...grpc.CallOption) (*applicationpkg.ApplicationResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,28 @@ The `--staticassets` directory in the API server (`/app/shared` by default) is n
|
|||
symlinks. This is to help protect against symlink attacks. If you have any symlinks in your `--staticassets` directory
|
||||
to a location outside the directory, they will return a 500 error starting with 3.1.
|
||||
|
||||
## v1 Actions API Deprecated
|
||||
|
||||
The `/api/v1/applications/{name}/resource/actions` endpoint is deprecated in favor of `/api/v1/applications/{name}/resource/actions/v2`.
|
||||
|
||||
This endpoint allows API users to run a custom resource action on a specific resource in an application.
|
||||
|
||||
The old endpoint accepted various parameters as query parameters. The POST body was the action name.
|
||||
|
||||
The new endpoint accepts all parameters as part of the POST body as a JSON object. The new endpoint also supports a new
|
||||
`resourceActionParameters` field to parameterize action runs.
|
||||
|
||||
The old endpoint will be removed in a future release, so users should migrate to the new endpoint as soon as possible.
|
||||
API clients will just need to change the endpoint URL and switch query string parameters to a JSON body.
|
||||
|
||||
If the old endpoint is used, the API will log a warning message:
|
||||
|
||||
> RunResourceAction was called. RunResourceAction is deprecated and will be removed in a future release. Use RunResourceActionV2 instead.
|
||||
|
||||
The CLI will fall back to the old endpoint if the new one is not available. If it falls back, it will log a warning message:
|
||||
|
||||
> RunResourceActionV2 is not supported by the server, falling back to RunResourceAction.
|
||||
|
||||
## OpenID Connect authorization code flow with PKCE is now handled by the server instead of the UI
|
||||
|
||||
Previously, when PKCE was enabled, the authorization code flow (the process which happens when you log in to Argo CD using OpenID Connect) was handled by the UI, whereas this flow was handled by the server if PKCE was not enabled. The server now always handles this flow, PKCE being enabled or not.
|
||||
|
|
|
|||
1099
pkg/apiclient/application/application.pb.go
generated
1099
pkg/apiclient/application/application.pb.go
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1715,6 +1715,10 @@ func local_request_ApplicationService_ListResourceActions_0(ctx context.Context,
|
|||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_ApplicationService_RunResourceAction_0 = &utilities.DoubleArray{Encoding: map[string]int{"action": 0, "name": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
|
||||
)
|
||||
|
||||
func request_ApplicationService_RunResourceAction_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ResourceActionRunRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
|
@ -1723,7 +1727,7 @@ func request_ApplicationService_RunResourceAction_0(ctx context.Context, marshal
|
|||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Action); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
|
|
@ -1745,6 +1749,13 @@ func request_ApplicationService_RunResourceAction_0(ctx context.Context, marshal
|
|||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApplicationService_RunResourceAction_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.RunResourceAction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
|
|
@ -1754,6 +1765,48 @@ func local_request_ApplicationService_RunResourceAction_0(ctx context.Context, m
|
|||
var protoReq ResourceActionRunRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Action); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
|
||||
protoReq.Name, err = runtime.StringP(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApplicationService_RunResourceAction_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.RunResourceAction(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_ApplicationService_RunResourceActionV2_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ResourceActionRunRequestV2
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
|
|
@ -1780,7 +1833,42 @@ func local_request_ApplicationService_RunResourceAction_0(ctx context.Context, m
|
|||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
|
||||
msg, err := server.RunResourceAction(ctx, &protoReq)
|
||||
msg, err := client.RunResourceActionV2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ApplicationService_RunResourceActionV2_0(ctx context.Context, marshaler runtime.Marshaler, server ApplicationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ResourceActionRunRequestV2
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
|
||||
protoReq.Name, err = runtime.StringP(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
|
||||
msg, err := server.RunResourceActionV2(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
|
@ -2637,6 +2725,29 @@ func RegisterApplicationServiceHandlerServer(ctx context.Context, mux *runtime.S
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ApplicationService_RunResourceActionV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ApplicationService_RunResourceActionV2_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ApplicationService_RunResourceActionV2_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("DELETE", pattern_ApplicationService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -3261,6 +3372,26 @@ func RegisterApplicationServiceHandlerClient(ctx context.Context, mux *runtime.S
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ApplicationService_RunResourceActionV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ApplicationService_RunResourceActionV2_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ApplicationService_RunResourceActionV2_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("DELETE", pattern_ApplicationService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -3415,6 +3546,8 @@ var (
|
|||
|
||||
pattern_ApplicationService_RunResourceAction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"api", "v1", "applications", "name", "resource", "actions"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_ApplicationService_RunResourceActionV2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5, 2, 6}, []string{"api", "v1", "applications", "name", "resource", "actions", "v2"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_ApplicationService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "applications", "name", "resource"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_ApplicationService_PodLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "applications", "name", "pods", "podName", "logs"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
|
@ -3477,6 +3610,8 @@ var (
|
|||
|
||||
forward_ApplicationService_RunResourceAction_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ApplicationService_RunResourceActionV2_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ApplicationService_DeleteResource_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ApplicationService_PodLogs_0 = runtime.ForwardResponseStream
|
||||
|
|
|
|||
|
|
@ -2497,7 +2497,32 @@ func (s *Server) getAvailableActions(resourceOverrides map[string]v1alpha1.Resou
|
|||
return availableActions, nil
|
||||
}
|
||||
|
||||
// RunResourceAction runs a resource action on a live resource
|
||||
//
|
||||
// Deprecated: use RunResourceActionV2 instead. This version does not support resource action parameters but is
|
||||
// maintained for backward compatibility. It will be removed in a future release.
|
||||
func (s *Server) RunResourceAction(ctx context.Context, q *application.ResourceActionRunRequest) (*application.ApplicationResponse, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"action": q.Action,
|
||||
"application": q.Name,
|
||||
"app-namespace": q.AppNamespace,
|
||||
"project": q.Project,
|
||||
"user": session.Username(ctx),
|
||||
}).Warn("RunResourceAction was called. RunResourceAction is deprecated and will be removed in a future release. Use RunResourceActionV2 instead.")
|
||||
qV2 := &application.ResourceActionRunRequestV2{
|
||||
Name: q.Name,
|
||||
AppNamespace: q.AppNamespace,
|
||||
Namespace: q.Namespace,
|
||||
ResourceName: q.ResourceName,
|
||||
Kind: q.Kind,
|
||||
Version: q.Version,
|
||||
Group: q.Group,
|
||||
Project: q.Project,
|
||||
}
|
||||
return s.RunResourceActionV2(ctx, qV2)
|
||||
}
|
||||
|
||||
func (s *Server) RunResourceActionV2(ctx context.Context, q *application.ResourceActionRunRequestV2) (*application.ApplicationResponse, error) {
|
||||
resourceRequest := &application.ApplicationResourceRequest{
|
||||
Name: q.Name,
|
||||
AppNamespace: q.AppNamespace,
|
||||
|
|
|
|||
|
|
@ -208,7 +208,22 @@ message ResourceActionParameters {
|
|||
required string value = 2;
|
||||
}
|
||||
|
||||
// ResourceActionRunRequest is a request to run a resource action.
|
||||
// This message is deprecated and replaced by ResourceActionRunRequestV2.
|
||||
message ResourceActionRunRequest {
|
||||
option deprecated = true;
|
||||
required string name = 1;
|
||||
optional string namespace = 2;
|
||||
required string resourceName = 3;
|
||||
required string version = 4;
|
||||
optional string group = 5;
|
||||
required string kind = 6;
|
||||
required string action = 7;
|
||||
optional string appNamespace = 8;
|
||||
optional string project = 9;
|
||||
}
|
||||
|
||||
message ResourceActionRunRequestV2 {
|
||||
required string name = 1;
|
||||
optional string namespace = 2;
|
||||
required string resourceName = 3;
|
||||
|
|
@ -470,10 +485,22 @@ service ApplicationService {
|
|||
option (google.api.http).get = "/api/v1/applications/{name}/resource/actions";
|
||||
}
|
||||
|
||||
// RunResourceAction run resource action
|
||||
// RunResourceAction runs a resource action
|
||||
//
|
||||
// Deprecated: use RunResourceActionV2 instead. This version does not support resource action parameters but is
|
||||
// maintained for backward compatibility. It will be removed in a future release.
|
||||
rpc RunResourceAction(ResourceActionRunRequest) returns (ApplicationResponse) {
|
||||
option deprecated = true;
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/applications/{name}/resource/actions"
|
||||
body: "action"
|
||||
};
|
||||
}
|
||||
|
||||
// RunResourceActionV2 runs a resource action with parameters
|
||||
rpc RunResourceActionV2(ResourceActionRunRequestV2) returns (ApplicationResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/applications/{name}/resource/actions/v2"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -989,15 +989,15 @@ func TestNoAppEnumeration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("RunResourceAction", func(t *testing.T) {
|
||||
_, err := appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Action: ptr.To("restart")})
|
||||
_, err := appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Action: ptr.To("restart")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("test")})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("doest-not-exist")})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
||||
})
|
||||
|
||||
|
|
@ -2536,7 +2536,7 @@ func TestRunNewStyleResourceAction(t *testing.T) {
|
|||
err := appStateCache.SetAppResourcesTree(testApp.Name, &v1alpha1.ApplicationTree{Nodes: nodes})
|
||||
require.NoError(t, err)
|
||||
|
||||
appResponse, runErr := appServer.RunResourceAction(t.Context(), &application.ResourceActionRunRequest{
|
||||
appResponse, runErr := appServer.RunResourceActionV2(t.Context(), &application.ResourceActionRunRequestV2{
|
||||
Name: &testApp.Name,
|
||||
Namespace: &namespace,
|
||||
Action: &action,
|
||||
|
|
@ -2562,7 +2562,7 @@ func TestRunNewStyleResourceAction(t *testing.T) {
|
|||
err := appStateCache.SetAppResourcesTree(testApp.Name, &v1alpha1.ApplicationTree{Nodes: nodes})
|
||||
require.NoError(t, err)
|
||||
|
||||
appResponse, runErr := appServer.RunResourceAction(t.Context(), &application.ResourceActionRunRequest{
|
||||
appResponse, runErr := appServer.RunResourceActionV2(t.Context(), &application.ResourceActionRunRequestV2{
|
||||
Name: &testApp.Name,
|
||||
Namespace: &namespace,
|
||||
Action: &action,
|
||||
|
|
@ -2633,7 +2633,7 @@ func TestRunOldStyleResourceAction(t *testing.T) {
|
|||
err := appStateCache.SetAppResourcesTree(testApp.Name, &v1alpha1.ApplicationTree{Nodes: nodes})
|
||||
require.NoError(t, err)
|
||||
|
||||
appResponse, runErr := appServer.RunResourceAction(t.Context(), &application.ResourceActionRunRequest{
|
||||
appResponse, runErr := appServer.RunResourceActionV2(t.Context(), &application.ResourceActionRunRequestV2{
|
||||
Name: &testApp.Name,
|
||||
Namespace: &namespace,
|
||||
Action: &action,
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ func TestNamespacedResourceAction(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
|
|
@ -1076,7 +1076,7 @@ func assertNSResourceActions(t *testing.T, appName string, successful bool) {
|
|||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = cdClient.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ func TestOldStyleResourceAction(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
|
|
@ -1192,7 +1192,7 @@ func TestNewStyleResourceActionPermitted(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
|
|
@ -1304,7 +1304,7 @@ func TestNewStyleResourceActionMixedOk(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
|
|
@ -1507,7 +1507,7 @@ func assertResourceActions(t *testing.T, appName string, successful bool) {
|
|||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.RunResourceAction(t.Context(), &applicationpkg.ResourceActionRunRequest{
|
||||
_, err = cdClient.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &appName,
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(fixture.DeploymentNamespace()),
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ export class ApplicationsService {
|
|||
resourceActionParameters: models.ResourceActionParam[]
|
||||
): Promise<models.ResourceAction[]> {
|
||||
return requests
|
||||
.post(`/applications/${name}/resource/actions`)
|
||||
.post(`/applications/${name}/resource/actions/v2`)
|
||||
.send(
|
||||
JSON.stringify({
|
||||
appNamespace,
|
||||
|
|
|
|||
Loading…
Reference in a new issue