Skip to content

Commit

Permalink
allow actions on the applications
Browse files Browse the repository at this point in the history
Signed-off-by: ashutosh16 <11219262+ashutosh16@users.noreply.github.com>
  • Loading branch information
ashutosh16 committed Apr 2, 2024
1 parent affd1cb commit fe7e5fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,12 @@ func (s *Server) getUnstructuredLiveResourceOrApp(ctx context.Context, rbacReque
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("error getting application cluster config: %w", err)
}
app.TypeMeta = metav1.TypeMeta{
Kind: applicationType.ApplicationKind,
APIVersion: "argoproj.io/v1alpha1",
}
obj, err = kube.ToUnstructured(app)

} else {
res, config, app, err = s.getAppLiveResource(ctx, rbacRequest, q)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions server/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,13 @@ func TestNoAppEnumeration(t *testing.T) {
assert.NoError(t, err)
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Name: pointer.String("test")})
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Group: pointer.String("argoproj.io"), Kind: pointer.String("Application"), Name: pointer.String("test")})
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: pointer.String("doest-not-exist")})
assert.Equal(t, permissionDeniedErr.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: pointer.String("doest-not-exist"), Project: pointer.String("test")})
assert.Equal(t, "rpc error: code = NotFound desc = applications.argoproj.io \"doest-not-exist\" not found", err.Error(), "when the request specifies a project, we can return the standard k8s error message")
_, err = appServer.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: pointer.String("test"), ResourceName: pointer.String("test"), Group: pointer.String("argoproj.io"), Kind: pointer.String("Application"), Namespace: pointer.String("test"), Action: pointer.String("restart")})
assert.Equal(t, "error executing Lua resource action: expect table output from Lua script, not nil", err.Error(), "when action invoked on the application, returns the lua error; which indicate the missing or config issue")

})

t.Run("GetApplicationSyncWindows", func(t *testing.T) {
Expand Down

0 comments on commit fe7e5fb

Please sign in to comment.