mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 08:57:17 +00:00
refactor: replace ptr.To with new(expr) (#26534)
Signed-off-by: sivchari <shibuuuu5@gmail.com>
This commit is contained in:
parent
6ab9426cf5
commit
6795b80cfc
38 changed files with 485 additions and 523 deletions
|
|
@ -38,7 +38,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/retry"
|
||||
"k8s.io/utils/ptr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
|
@ -1588,7 +1587,7 @@ func (r *ApplicationSetReconciler) syncDesiredApplications(logCtx *log.Entry, ap
|
|||
// ensure that Applications generated with RollingSync do not have an automated sync policy, since the AppSet controller will handle triggering the sync operation instead
|
||||
if desiredApplications[i].Spec.SyncPolicy != nil && desiredApplications[i].Spec.SyncPolicy.IsAutomatedSyncEnabled() {
|
||||
pruneEnabled = desiredApplications[i].Spec.SyncPolicy.Automated.Prune
|
||||
desiredApplications[i].Spec.SyncPolicy.Automated.Enabled = ptr.To(false)
|
||||
desiredApplications[i].Spec.SyncPolicy.Automated.Enabled = new(false)
|
||||
}
|
||||
|
||||
appSetStatusPending := false
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/applicationset/services/mocks"
|
||||
|
|
@ -2423,7 +2422,7 @@ func TestGitGenerator_GenerateParams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expected: []map[string]any{{"path": "app1", "path.basename": "app1", "path.basenameNormalized": "app1", "path[0]": "app1", "values.foo": "bar"}},
|
||||
expectedProject: ptr.To("project"),
|
||||
expectedProject: new("project"),
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
|
|
@ -2457,7 +2456,7 @@ func TestGitGenerator_GenerateParams(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expected: []map[string]any{{"path": "app1", "path.basename": "app1", "path.basenameNormalized": "app1", "path[0]": "app1", "values.foo": "bar"}},
|
||||
expectedProject: ptr.To(""),
|
||||
expectedProject: new(""),
|
||||
expectedError: nil,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/microsoft/azure-devops-go-api/azuredevops/v7"
|
||||
azureGit "github.com/microsoft/azure-devops-go-api/azuredevops/v7/git"
|
||||
|
|
@ -19,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
func s(input string) *string {
|
||||
return ptr.To(input)
|
||||
return new(input)
|
||||
}
|
||||
|
||||
func TestAzureDevopsRepoHasPath(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
cmdutil "github.com/argoproj/argo-cd/v3/cmd/util"
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
|
|
@ -137,7 +136,7 @@ func loadClusters(ctx context.Context, kubeClient kubernetes.Interface, appClien
|
|||
cluster := batch[i]
|
||||
if replicas > 0 {
|
||||
clusterShard = clusterShards[cluster.Server]
|
||||
cluster.Shard = ptr.To(int64(clusterShard))
|
||||
cluster.Shard = new(int64(clusterShard))
|
||||
log.Infof("Cluster with uid: %s will be processed by shard %d", cluster.ID, clusterShard)
|
||||
}
|
||||
if shard != -1 && clusterShard != shard {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func Test_loadClusters(t *testing.T) {
|
||||
|
|
@ -74,7 +73,7 @@ func Test_loadClusters(t *testing.T) {
|
|||
},
|
||||
ServerVersion: ".",
|
||||
},
|
||||
Shard: ptr.To(int64(0)),
|
||||
Shard: new(int64(0)),
|
||||
},
|
||||
Namespaces: []string{"test"},
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
k8swatch "k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/argocd/commands/headless"
|
||||
|
|
@ -602,17 +601,17 @@ func NewApplicationLogsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
stream, err := appIf.PodLogs(ctx, &application.ApplicationPodLogsQuery{
|
||||
Name: &appName,
|
||||
Group: &group,
|
||||
Namespace: ptr.To(namespace),
|
||||
Namespace: new(namespace),
|
||||
Kind: &kind,
|
||||
ResourceName: &resourceName,
|
||||
Follow: ptr.To(follow),
|
||||
TailLines: ptr.To(tail),
|
||||
SinceSeconds: ptr.To(sinceSeconds),
|
||||
Follow: new(follow),
|
||||
TailLines: new(tail),
|
||||
SinceSeconds: new(sinceSeconds),
|
||||
UntilTime: &untilTime,
|
||||
Filter: &filter,
|
||||
MatchCase: ptr.To(matchCase),
|
||||
Container: ptr.To(container),
|
||||
Previous: ptr.To(previous),
|
||||
MatchCase: new(matchCase),
|
||||
Container: new(container),
|
||||
Previous: new(previous),
|
||||
AppNamespace: &appNs,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -1872,7 +1871,7 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
conn, appIf := headless.NewClientOrDie(clientOpts, c).NewApplicationClientOrDie()
|
||||
defer utilio.Close(conn)
|
||||
apps, err := appIf.List(ctx, &application.ApplicationQuery{
|
||||
Selector: ptr.To(selector),
|
||||
Selector: new(selector),
|
||||
AppNamespace: &appNamespace,
|
||||
})
|
||||
|
||||
|
|
@ -2073,7 +2072,7 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
closer, appIf := acdClient.NewApplicationClientOrDie()
|
||||
defer utilio.Close(closer)
|
||||
if selector != "" {
|
||||
list, err := appIf.List(ctx, &application.ApplicationQuery{Selector: ptr.To(selector)})
|
||||
list, err := appIf.List(ctx, &application.ApplicationQuery{Selector: new(selector)})
|
||||
errors.CheckError(err)
|
||||
for _, i := range list.Items {
|
||||
appNames = append(appNames, i.QualifiedName())
|
||||
|
|
@ -2257,7 +2256,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
appNames := args
|
||||
if selector != "" || len(projects) > 0 {
|
||||
list, err := appIf.List(ctx, &application.ApplicationQuery{
|
||||
Selector: ptr.To(selector),
|
||||
Selector: new(selector),
|
||||
AppNamespace: &appNamespace,
|
||||
Projects: projects,
|
||||
})
|
||||
|
|
@ -2431,7 +2430,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
Backoff: &argoappv1.Backoff{
|
||||
Duration: retryBackoffDuration.String(),
|
||||
MaxDuration: retryBackoffMaxDuration.String(),
|
||||
Factor: ptr.To(retryBackoffFactor),
|
||||
Factor: new(retryBackoffFactor),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2525,7 +2524,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
func getAppNamesBySelector(ctx context.Context, appIf application.ApplicationServiceClient, selector string) ([]string, error) {
|
||||
appNames := []string{}
|
||||
if selector != "" {
|
||||
list, err := appIf.List(ctx, &application.ApplicationQuery{Selector: ptr.To(selector)})
|
||||
list, err := appIf.List(ctx, &application.ApplicationQuery{Selector: new(selector)})
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
|
@ -2703,7 +2702,7 @@ func checkResourceStatus(watch watchOpts, healthStatus string, syncStatus string
|
|||
func resourceParentChild(ctx context.Context, acdClient argocdclient.Client, appName string, appNs string) (map[string]argoappv1.ResourceNode, map[string][]string, map[string]struct{}, map[string]*resourceState) {
|
||||
_, appIf := acdClient.NewApplicationClientOrDie()
|
||||
mapUIDToNode, mapParentToChild, parentNode := parentChildDetails(ctx, appIf, appName, appNs)
|
||||
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: ptr.To(appName), AppNamespace: ptr.To(appNs)})
|
||||
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: new(appName), AppNamespace: new(appNs)})
|
||||
errors.CheckError(err)
|
||||
mapNodeNameToResourceState := make(map[string]*resourceState)
|
||||
for _, res := range getResourceStates(app, nil) {
|
||||
|
|
@ -3135,8 +3134,8 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
|||
_, err = appIf.Rollback(ctx, &application.ApplicationRollbackRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Id: ptr.To(depInfo.ID),
|
||||
Prune: ptr.To(prune),
|
||||
Id: new(depInfo.ID),
|
||||
Prune: new(prune),
|
||||
})
|
||||
errors.CheckError(err)
|
||||
|
||||
|
|
@ -3288,7 +3287,7 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
q := application.ApplicationManifestQuery{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Revision: ptr.To(revision),
|
||||
Revision: new(revision),
|
||||
Revisions: revisions,
|
||||
SourcePositions: sourcePositions,
|
||||
}
|
||||
|
|
@ -3304,7 +3303,7 @@ func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cob
|
|||
q := application.ApplicationManifestQuery{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Revision: ptr.To(revision),
|
||||
Revision: new(revision),
|
||||
}
|
||||
res, err := appIf.GetManifests(ctx, &q)
|
||||
errors.CheckError(err)
|
||||
|
|
@ -3665,7 +3664,7 @@ func NewApplicationConfirmDeletionCommand(clientOpts *argocdclient.ClientOptions
|
|||
|
||||
_, err = appIf.Update(ctx, &application.ApplicationUpdateRequest{
|
||||
Application: app,
|
||||
Validate: ptr.To(false),
|
||||
Validate: new(false),
|
||||
Project: &app.Spec.Project,
|
||||
})
|
||||
errors.CheckError(err)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
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"
|
||||
|
|
@ -95,11 +94,11 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
|
|||
availActionsForResource, err := appIf.ListResourceActions(ctx, &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Namespace: ptr.To(obj.GetNamespace()),
|
||||
ResourceName: ptr.To(obj.GetName()),
|
||||
Group: ptr.To(gvk.Group),
|
||||
Kind: ptr.To(gvk.Kind),
|
||||
Version: ptr.To(gvk.Version),
|
||||
Namespace: new(obj.GetNamespace()),
|
||||
ResourceName: new(obj.GetName()),
|
||||
Group: new(gvk.Group),
|
||||
Kind: new(gvk.Kind),
|
||||
Version: new(gvk.Version),
|
||||
})
|
||||
errors.CheckError(err)
|
||||
for _, action := range availActionsForResource.Actions {
|
||||
|
|
@ -195,12 +194,12 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
|
|||
_, 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),
|
||||
Namespace: new(obj.GetNamespace()),
|
||||
ResourceName: new(objResourceName),
|
||||
Group: new(gvk.Group),
|
||||
Kind: new(gvk.Kind),
|
||||
Version: new(gvk.GroupVersion().Version),
|
||||
Action: new(actionName),
|
||||
// TODO: add support for parameters
|
||||
})
|
||||
if err == nil {
|
||||
|
|
@ -214,12 +213,12 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
|
|||
_, err = appIf.RunResourceAction(ctx, &applicationpkg.ResourceActionRunRequest{
|
||||
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),
|
||||
Namespace: new(obj.GetNamespace()),
|
||||
ResourceName: new(objResourceName),
|
||||
Group: new(gvk.Group),
|
||||
Kind: new(gvk.Kind),
|
||||
Version: new(gvk.GroupVersion().Version),
|
||||
Action: new(actionName),
|
||||
})
|
||||
errors.CheckError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/argocd/commands/headless"
|
||||
argocdclient "github.com/argoproj/argo-cd/v3/pkg/apiclient"
|
||||
|
|
@ -337,14 +336,14 @@ func NewApplicationPatchResourceCommand(clientOpts *argocdclient.ClientOptions)
|
|||
_, err = appIf.PatchResource(ctx, &applicationpkg.ApplicationResourcePatchRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Namespace: ptr.To(obj.GetNamespace()),
|
||||
ResourceName: ptr.To(obj.GetName()),
|
||||
Version: ptr.To(gvk.Version),
|
||||
Group: ptr.To(gvk.Group),
|
||||
Kind: ptr.To(gvk.Kind),
|
||||
Patch: ptr.To(patch),
|
||||
PatchType: ptr.To(patchType),
|
||||
Project: ptr.To(project),
|
||||
Namespace: new(obj.GetNamespace()),
|
||||
ResourceName: new(obj.GetName()),
|
||||
Version: new(gvk.Version),
|
||||
Group: new(gvk.Group),
|
||||
Kind: new(gvk.Kind),
|
||||
Patch: new(patch),
|
||||
PatchType: new(patchType),
|
||||
Project: new(project),
|
||||
})
|
||||
errors.CheckError(err)
|
||||
log.Infof("Resource '%s' patched", obj.GetName())
|
||||
|
|
@ -410,14 +409,14 @@ func NewApplicationDeleteResourceCommand(clientOpts *argocdclient.ClientOptions)
|
|||
_, err = appIf.DeleteResource(ctx, &applicationpkg.ApplicationResourceDeleteRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: &appNs,
|
||||
Namespace: ptr.To(obj.GetNamespace()),
|
||||
ResourceName: ptr.To(obj.GetName()),
|
||||
Version: ptr.To(gvk.Version),
|
||||
Group: ptr.To(gvk.Group),
|
||||
Kind: ptr.To(gvk.Kind),
|
||||
Namespace: new(obj.GetNamespace()),
|
||||
ResourceName: new(obj.GetName()),
|
||||
Version: new(gvk.Version),
|
||||
Group: new(gvk.Group),
|
||||
Kind: new(gvk.Kind),
|
||||
Force: &force,
|
||||
Orphan: &orphan,
|
||||
Project: ptr.To(project),
|
||||
Project: new(project),
|
||||
})
|
||||
errors.CheckError(err)
|
||||
log.Infof("Resource '%s' deleted", obj.GetName())
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
cache2 "k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/argocd/commands/initialize"
|
||||
|
|
@ -209,7 +208,7 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti
|
|||
log.SetLevel(log.ErrorLevel)
|
||||
os.Setenv(v1alpha1.EnvVarFakeInClusterConfig, "true")
|
||||
if address == nil {
|
||||
address = ptr.To("localhost")
|
||||
address = new("localhost")
|
||||
}
|
||||
if port == nil || *port == 0 {
|
||||
addr := *address + ":0"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application"
|
||||
argoappv1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -262,7 +261,7 @@ func SetAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, ap
|
|||
Backoff: &argoappv1.Backoff{
|
||||
Duration: appOpts.retryBackoffDuration.String(),
|
||||
MaxDuration: appOpts.retryBackoffMaxDuration.String(),
|
||||
Factor: ptr.To(appOpts.retryBackoffFactor),
|
||||
Factor: new(appOpts.retryBackoffFactor),
|
||||
},
|
||||
Refresh: appOpts.retryRefresh,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -146,7 +145,7 @@ func GetOrphanedResourcesSettings(flagSet *pflag.FlagSet, opts ProjectOpts) *v1a
|
|||
if opts.orphanedResourcesEnabled || warnChanged {
|
||||
settings := v1alpha1.OrphanedResourcesMonitorSettings{}
|
||||
if warnChanged {
|
||||
settings.Warn = ptr.To(opts.orphanedResourcesWarn)
|
||||
settings.Warn = new(opts.orphanedResourcesWarn)
|
||||
}
|
||||
return &settings
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import (
|
|||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
commitclient "github.com/argoproj/argo-cd/v3/commitserver/apiclient"
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
|
|
@ -2216,7 +2215,7 @@ func (ctrl *ApplicationController) autoSync(app *appv1.Application, syncStatus *
|
|||
}
|
||||
}
|
||||
|
||||
source := ptr.To(app.Spec.GetSource())
|
||||
source := new(app.Spec.GetSource())
|
||||
desiredRevisions := []string{syncStatus.Revision}
|
||||
if app.Spec.HasMultipleSources() {
|
||||
source = nil
|
||||
|
|
@ -2368,7 +2367,7 @@ func (ctrl *ApplicationController) selfHealRemainingBackoff(app *appv1.Applicati
|
|||
|
||||
var timeSinceOperation *time.Duration
|
||||
if app.Status.OperationState.FinishedAt != nil {
|
||||
timeSinceOperation = ptr.To(time.Since(app.Status.OperationState.FinishedAt.Time))
|
||||
timeSinceOperation = new(time.Since(app.Status.OperationState.FinishedAt.Time))
|
||||
}
|
||||
|
||||
var retryAfter time.Duration
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
statecache "github.com/argoproj/argo-cd/v3/controller/cache"
|
||||
|
|
@ -2540,7 +2539,7 @@ func TestProcessRequestedAppOperation_RunningPreviouslyFailedBackoff(t *testing.
|
|||
Limit: 1,
|
||||
Backoff: &v1alpha1.Backoff{
|
||||
Duration: "1h",
|
||||
Factor: ptr.To(int64(100)),
|
||||
Factor: new(int64(100)),
|
||||
MaxDuration: "1h",
|
||||
},
|
||||
},
|
||||
|
|
@ -2742,7 +2741,7 @@ func TestProcessRequestedAppOperation_SyncTimeout(t *testing.T) {
|
|||
StartedAt: metav1.NewTime(time.Now().Add(-tc.startedSince)),
|
||||
}
|
||||
if tc.retryAttempt > 0 {
|
||||
app.Status.OperationState.FinishedAt = ptr.To(metav1.NewTime(time.Now().Add(-tc.startedSince)))
|
||||
app.Status.OperationState.FinishedAt = new(metav1.NewTime(time.Now().Add(-tc.startedSince)))
|
||||
app.Status.OperationState.RetryCount = int64(tc.retryAttempt)
|
||||
}
|
||||
|
||||
|
|
@ -3224,17 +3223,17 @@ func TestSelfHealRemainingBackoff(t *testing.T) {
|
|||
shouldSelfHeal bool
|
||||
}{{
|
||||
attempts: 0,
|
||||
finishedAt: ptr.To(metav1.Now()),
|
||||
finishedAt: new(metav1.Now()),
|
||||
expectedDuration: 0,
|
||||
shouldSelfHeal: true,
|
||||
}, {
|
||||
attempts: 1,
|
||||
finishedAt: ptr.To(metav1.Now()),
|
||||
finishedAt: new(metav1.Now()),
|
||||
expectedDuration: 2 * time.Second,
|
||||
shouldSelfHeal: false,
|
||||
}, {
|
||||
attempts: 2,
|
||||
finishedAt: ptr.To(metav1.Now()),
|
||||
finishedAt: new(metav1.Now()),
|
||||
expectedDuration: 6 * time.Second,
|
||||
shouldSelfHeal: false,
|
||||
}, {
|
||||
|
|
@ -3259,7 +3258,7 @@ func TestSelfHealRemainingBackoff(t *testing.T) {
|
|||
shouldSelfHeal: false,
|
||||
}, {
|
||||
attempts: 6,
|
||||
finishedAt: ptr.To(metav1.Now()),
|
||||
finishedAt: new(metav1.Now()),
|
||||
expectedDuration: 120 * time.Second,
|
||||
shouldSelfHeal: false,
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/gitops-engine/pkg/utils/kube"
|
||||
|
||||
|
|
@ -362,7 +361,7 @@ func setTestAppPhase(app *v1alpha1.Application, phase v1alpha1.HydrateOperationP
|
|||
status = v1alpha1.SourceHydratorStatus{
|
||||
CurrentOperation: &v1alpha1.HydrateOperation{
|
||||
StartedAt: metav1.Now(),
|
||||
FinishedAt: ptr.To(metav1.Now()),
|
||||
FinishedAt: new(metav1.Now()),
|
||||
Phase: phase,
|
||||
Message: "some error",
|
||||
SourceHydrator: *app.Spec.SourceHydrator,
|
||||
|
|
@ -373,7 +372,7 @@ func setTestAppPhase(app *v1alpha1.Application, phase v1alpha1.HydrateOperationP
|
|||
status = v1alpha1.SourceHydratorStatus{
|
||||
CurrentOperation: &v1alpha1.HydrateOperation{
|
||||
StartedAt: metav1.Now(),
|
||||
FinishedAt: ptr.To(metav1.Now()),
|
||||
FinishedAt: new(metav1.Now()),
|
||||
Phase: phase,
|
||||
DrySHA: "12345",
|
||||
HydratedSHA: "67890",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
"github.com/argoproj/argo-cd/v3/controller/testdata"
|
||||
|
|
@ -1661,7 +1660,7 @@ func TestUseDiffCache(t *testing.T) {
|
|||
Namespace: namespace,
|
||||
},
|
||||
Spec: v1alpha1.ApplicationSpec{
|
||||
Source: ptr.To(source()),
|
||||
Source: new(source()),
|
||||
Destination: v1alpha1.ApplicationDestination{
|
||||
Server: "https://kubernetes.default.svc",
|
||||
Namespace: "httpbin",
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -114,7 +114,7 @@ require (
|
|||
k8s.io/klog/v2 v2.130.1
|
||||
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b
|
||||
k8s.io/kubectl v0.34.0
|
||||
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
|
||||
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
|
||||
layeh.com/gopher-json v0.0.0-20190114024228-97fed8db8427
|
||||
oras.land/oras-go/v2 v2.6.0
|
||||
sigs.k8s.io/controller-runtime v0.21.0
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/gitops-engine/pkg/health"
|
||||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func testAppSetCond(t ApplicationSetConditionType, msg string, lastTransitionTime *metav1.Time, status ApplicationSetConditionStatus, reason string) ApplicationSetCondition {
|
||||
|
|
@ -314,9 +313,9 @@ func TestSCMProviderGeneratorGitlab_WillIncludeSharedProjects(t *testing.T) {
|
|||
settings := SCMProviderGeneratorGitlab{}
|
||||
assert.True(t, settings.WillIncludeSharedProjects())
|
||||
|
||||
settings.IncludeSharedProjects = ptr.To(false)
|
||||
settings.IncludeSharedProjects = new(false)
|
||||
assert.False(t, settings.WillIncludeSharedProjects())
|
||||
|
||||
settings.IncludeSharedProjects = ptr.To(true)
|
||||
settings.IncludeSharedProjects = new(true)
|
||||
assert.True(t, settings.WillIncludeSharedProjects())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
argocdcommon "github.com/argoproj/argo-cd/v3/common"
|
||||
|
||||
|
|
@ -3648,7 +3647,7 @@ func TestRetryStrategy_NextRetryAtCustomBackoff(t *testing.T) {
|
|||
retry := RetryStrategy{
|
||||
Backoff: &Backoff{
|
||||
Duration: "2s",
|
||||
Factor: ptr.To(int64(3)),
|
||||
Factor: new(int64(3)),
|
||||
MaxDuration: "1m",
|
||||
},
|
||||
}
|
||||
|
|
@ -3757,10 +3756,10 @@ func TestOrphanedResourcesMonitorSettings_IsWarn(t *testing.T) {
|
|||
settings := OrphanedResourcesMonitorSettings{}
|
||||
assert.False(t, settings.IsWarn())
|
||||
|
||||
settings.Warn = ptr.To(false)
|
||||
settings.Warn = new(false)
|
||||
assert.False(t, settings.IsWarn())
|
||||
|
||||
settings.Warn = ptr.To(true)
|
||||
settings.Warn = new(true)
|
||||
assert.True(t, settings.IsWarn())
|
||||
}
|
||||
|
||||
|
|
@ -4162,7 +4161,7 @@ func TestApplicationSourcePluginParameters_Environ_string(t *testing.T) {
|
|||
params := ApplicationSourcePluginParameters{
|
||||
{
|
||||
Name: "version",
|
||||
String_: ptr.To("1.2.3"),
|
||||
String_: new("1.2.3"),
|
||||
},
|
||||
}
|
||||
environ, err := params.Environ()
|
||||
|
|
@ -4219,7 +4218,7 @@ func TestApplicationSourcePluginParameters_Environ_all(t *testing.T) {
|
|||
params := ApplicationSourcePluginParameters{
|
||||
{
|
||||
Name: "some-name",
|
||||
String_: ptr.To("1.2.3"),
|
||||
String_: new("1.2.3"),
|
||||
OptionalArray: &OptionalArray{
|
||||
Array: []string{"redis", "minio"},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
argocommon "github.com/argoproj/argo-cd/v3/common"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
|
|
@ -1395,9 +1394,9 @@ func (s *Server) getCachedAppState(ctx context.Context, a *v1alpha1.Application,
|
|||
return errors.New(argo.FormatAppConditions(conditions))
|
||||
}
|
||||
_, err = s.Get(ctx, &application.ApplicationQuery{
|
||||
Name: ptr.To(a.GetName()),
|
||||
AppNamespace: ptr.To(a.GetNamespace()),
|
||||
Refresh: ptr.To(string(v1alpha1.RefreshTypeNormal)),
|
||||
Name: new(a.GetName()),
|
||||
AppNamespace: new(a.GetNamespace()),
|
||||
Refresh: new(string(v1alpha1.RefreshTypeNormal)),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting application by query: %w", err)
|
||||
|
|
@ -1794,10 +1793,10 @@ func (s *Server) PodLogs(q *application.ApplicationPodLogsQuery, ws application.
|
|||
|
||||
var sinceSeconds, tailLines *int64
|
||||
if q.GetSinceSeconds() > 0 {
|
||||
sinceSeconds = ptr.To(q.GetSinceSeconds())
|
||||
sinceSeconds = new(q.GetSinceSeconds())
|
||||
}
|
||||
if q.GetTailLines() > 0 {
|
||||
tailLines = ptr.To(q.GetTailLines())
|
||||
tailLines = new(q.GetTailLines())
|
||||
}
|
||||
var untilTime *metav1.Time
|
||||
if q.GetUntilTime() != "" {
|
||||
|
|
@ -1913,10 +1912,10 @@ func (s *Server) PodLogs(q *application.ApplicationPodLogsQuery, ws application.
|
|||
ts := metav1.NewTime(entry.timeStamp)
|
||||
if untilTime != nil && entry.timeStamp.After(untilTime.Time) {
|
||||
done <- ws.Send(&application.LogEntry{
|
||||
Last: ptr.To(true),
|
||||
Last: new(true),
|
||||
PodName: &entry.podName,
|
||||
Content: &entry.line,
|
||||
TimeStampStr: ptr.To(entry.timeStamp.Format(time.RFC3339Nano)),
|
||||
TimeStampStr: new(entry.timeStamp.Format(time.RFC3339Nano)),
|
||||
TimeStamp: &ts,
|
||||
})
|
||||
return
|
||||
|
|
@ -1925,9 +1924,9 @@ func (s *Server) PodLogs(q *application.ApplicationPodLogsQuery, ws application.
|
|||
if err := ws.Send(&application.LogEntry{
|
||||
PodName: &entry.podName,
|
||||
Content: &entry.line,
|
||||
TimeStampStr: ptr.To(entry.timeStamp.Format(time.RFC3339Nano)),
|
||||
TimeStampStr: new(entry.timeStamp.Format(time.RFC3339Nano)),
|
||||
TimeStamp: &ts,
|
||||
Last: ptr.To(false),
|
||||
Last: new(false),
|
||||
}); err != nil {
|
||||
done <- err
|
||||
break
|
||||
|
|
@ -1936,10 +1935,10 @@ func (s *Server) PodLogs(q *application.ApplicationPodLogsQuery, ws application.
|
|||
now := time.Now()
|
||||
nowTS := metav1.NewTime(now)
|
||||
done <- ws.Send(&application.LogEntry{
|
||||
Last: ptr.To(true),
|
||||
PodName: ptr.To(""),
|
||||
Content: ptr.To(""),
|
||||
TimeStampStr: ptr.To(now.Format(time.RFC3339Nano)),
|
||||
Last: new(true),
|
||||
PodName: new(""),
|
||||
Content: new(""),
|
||||
TimeStampStr: new(now.Format(time.RFC3339Nano)),
|
||||
TimeStamp: &nowTS,
|
||||
})
|
||||
}()
|
||||
|
|
@ -2078,7 +2077,7 @@ func (s *Server) Sync(ctx context.Context, syncReq *application.ApplicationSyncR
|
|||
|
||||
var source *v1alpha1.ApplicationSource
|
||||
if !a.Spec.HasMultipleSources() {
|
||||
source = ptr.To(a.Spec.GetSource())
|
||||
source = new(a.Spec.GetSource())
|
||||
}
|
||||
|
||||
op := v1alpha1.Operation{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import (
|
|||
"k8s.io/client-go/rest"
|
||||
kubetesting "k8s.io/client-go/testing"
|
||||
k8scache "k8s.io/client-go/tools/cache"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
|
|
@ -618,9 +617,9 @@ func (t *TestServerStream) Recv() (*application.ApplicationManifestQueryWithFile
|
|||
t.headerSent = true
|
||||
return &application.ApplicationManifestQueryWithFilesWrapper{Part: &application.ApplicationManifestQueryWithFilesWrapper_Query{
|
||||
Query: &application.ApplicationManifestQueryWithFiles{
|
||||
Name: ptr.To(t.appName),
|
||||
Project: ptr.To(t.project),
|
||||
Checksum: ptr.To(""),
|
||||
Name: new(t.appName),
|
||||
Project: new(t.project),
|
||||
Checksum: new(""),
|
||||
},
|
||||
}}, nil
|
||||
}
|
||||
|
|
@ -805,55 +804,55 @@ func TestNoAppEnumeration(t *testing.T) {
|
|||
adminCtx := context.WithValue(noRoleCtx, "claims", &jwt.MapClaims{"groups": []string{"admin"}})
|
||||
|
||||
t.Run("Get", func(t *testing.T) {
|
||||
_, err := appServer.Get(adminCtx, &application.ApplicationQuery{Name: ptr.To("test")})
|
||||
_, err := appServer.Get(adminCtx, &application.ApplicationQuery{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Get(noRoleCtx, &application.ApplicationQuery{Name: ptr.To("test")})
|
||||
_, err = appServer.Get(noRoleCtx, &application.ApplicationQuery{Name: new("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.Get(adminCtx, &application.ApplicationQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.Get(adminCtx, &application.ApplicationQuery{Name: new("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.Get(adminCtx, &application.ApplicationQuery{Name: ptr.To("doest-not-exist"), Project: []string{"test"}})
|
||||
_, err = appServer.Get(adminCtx, &application.ApplicationQuery{Name: new("doest-not-exist"), Project: []string{"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")
|
||||
})
|
||||
|
||||
t.Run("GetManifests", func(t *testing.T) {
|
||||
_, err := appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("test")})
|
||||
_, err := appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.GetManifests(noRoleCtx, &application.ApplicationManifestQuery{Name: ptr.To("test")})
|
||||
_, err = appServer.GetManifests(noRoleCtx, &application.ApplicationManifestQuery{Name: new("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.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: new("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.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.GetManifests(adminCtx, &application.ApplicationManifestQuery{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("ListResourceEvents", func(t *testing.T) {
|
||||
_, err := appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("test")})
|
||||
_, err := appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ListResourceEvents(noRoleCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("test")})
|
||||
_, err = appServer.ListResourceEvents(noRoleCtx, &application.ApplicationResourceEventsQuery{Name: new("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.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: new("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.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.ListResourceEvents(adminCtx, &application.ApplicationResourceEventsQuery{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("UpdateSpec", func(t *testing.T) {
|
||||
_, err := appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
_, err := appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: new("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
||||
Source: &v1alpha1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.UpdateSpec(noRoleCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
_, err = appServer.UpdateSpec(noRoleCtx, &application.ApplicationUpdateSpecRequest{Name: new("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
||||
Source: &v1alpha1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
||||
}})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("doest-not-exist"), Spec: &v1alpha1.ApplicationSpec{
|
||||
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: new("doest-not-exist"), Spec: &v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
||||
Source: &v1alpha1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
||||
}})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
_, err = appServer.UpdateSpec(adminCtx, &application.ApplicationUpdateSpecRequest{Name: new("doest-not-exist"), Project: new("test"), Spec: &v1alpha1.ApplicationSpec{
|
||||
Destination: v1alpha1.ApplicationDestination{Namespace: "default", Server: "https://cluster-api.example.com"},
|
||||
Source: &v1alpha1.ApplicationSource{RepoURL: "https://some-fake-source", Path: "."},
|
||||
}})
|
||||
|
|
@ -861,105 +860,105 @@ func TestNoAppEnumeration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Patch", func(t *testing.T) {
|
||||
_, err := appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
_, err := appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Patch(noRoleCtx, &application.ApplicationPatchRequest{Name: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
_, err = appServer.Patch(noRoleCtx, &application.ApplicationPatchRequest{Name: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: new("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.Patch(adminCtx, &application.ApplicationPatchRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.Patch(adminCtx, &application.ApplicationPatchRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("GetResource", func(t *testing.T) {
|
||||
_, err := appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err := appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.GetResource(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.GetResource(noRoleCtx, &application.ApplicationResourceRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: new("doest-not-exist"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.GetResource(adminCtx, &application.ApplicationResourceRequest{Name: new("doest-not-exist"), Project: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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")
|
||||
})
|
||||
|
||||
t.Run("PatchResource", func(t *testing.T) {
|
||||
_, err := appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
_, err := appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
// This will always throw an error, because the kubectl mock for PatchResource is hard-coded to return nil.
|
||||
// The best we can do is to confirm we get past the permission check.
|
||||
assert.NotEqual(t, common.PermissionDeniedAPIError.Error(), err.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.PatchResource(noRoleCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
_, err = appServer.PatchResource(noRoleCtx, &application.ApplicationResourcePatchRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: new("doest-not-exist"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Patch: ptr.To(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
_, err = appServer.PatchResource(adminCtx, &application.ApplicationResourcePatchRequest{Name: new("doest-not-exist"), Project: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Patch: new(`[{"op": "replace", "path": "/spec/replicas", "value": 3}]`)})
|
||||
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")
|
||||
})
|
||||
|
||||
t.Run("DeleteResource", func(t *testing.T) {
|
||||
_, err := appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err := appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.DeleteResource(noRoleCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.DeleteResource(noRoleCtx, &application.ApplicationResourceDeleteRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("doest-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: new("doest-not-exist"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.DeleteResource(adminCtx, &application.ApplicationResourceDeleteRequest{Name: new("doest-not-exist"), Project: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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")
|
||||
})
|
||||
|
||||
t.Run("ResourceTree", func(t *testing.T) {
|
||||
_, err := appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
||||
_, err := appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ResourceTree(noRoleCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
||||
_, err = appServer.ResourceTree(noRoleCtx, &application.ResourcesQuery{ApplicationName: new("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.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: new("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.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.ResourceTree(adminCtx, &application.ResourcesQuery{ApplicationName: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("RevisionMetadata", func(t *testing.T) {
|
||||
_, err := appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("test")})
|
||||
_, err := appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-multi"), SourceIndex: ptr.To(int32(0)), VersionId: ptr.To(int32(1))})
|
||||
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: new("test-multi"), SourceIndex: new(int32(0)), VersionId: new(int32(1))})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RevisionMetadata(noRoleCtx, &application.RevisionMetadataQuery{Name: ptr.To("test")})
|
||||
_, err = appServer.RevisionMetadata(noRoleCtx, &application.RevisionMetadataQuery{Name: new("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.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: new("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.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.RevisionMetadata(adminCtx, &application.RevisionMetadataQuery{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("RevisionChartDetails", func(t *testing.T) {
|
||||
_, err := appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-helm")})
|
||||
_, err := appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: new("test-helm")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RevisionChartDetails(noRoleCtx, &application.RevisionMetadataQuery{Name: ptr.To("test-helm")})
|
||||
_, err = appServer.RevisionChartDetails(noRoleCtx, &application.RevisionMetadataQuery{Name: new("test-helm")})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
_, err = appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: new("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.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.RevisionChartDetails(adminCtx, &application.RevisionMetadataQuery{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("ManagedResources", func(t *testing.T) {
|
||||
_, err := appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
||||
_, err := appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ManagedResources(noRoleCtx, &application.ResourcesQuery{ApplicationName: ptr.To("test")})
|
||||
_, err = appServer.ManagedResources(noRoleCtx, &application.ResourcesQuery{ApplicationName: new("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.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: new("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.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.ManagedResources(adminCtx, &application.ResourcesQuery{ApplicationName: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("Sync", func(t *testing.T) {
|
||||
_, err := appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("test")})
|
||||
_, err := appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Sync(noRoleCtx, &application.ApplicationSyncRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.Sync(noRoleCtx, &application.ApplicationSyncRequest{Name: new("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.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: new("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.Sync(adminCtx, &application.ApplicationSyncRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.Sync(adminCtx, &application.ApplicationSyncRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
|
|
@ -967,78 +966,78 @@ func TestNoAppEnumeration(t *testing.T) {
|
|||
// The sync operation is already started from the previous test. We just need to set the field that the
|
||||
// controller would set if this were an actual Argo CD environment.
|
||||
setSyncRunningOperationState(t, appServer)
|
||||
_, err := appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("test")})
|
||||
_, err := appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.TerminateOperation(noRoleCtx, &application.OperationTerminateRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.TerminateOperation(noRoleCtx, &application.OperationTerminateRequest{Name: new("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.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: new("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.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.TerminateOperation(adminCtx, &application.OperationTerminateRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("Rollback", func(t *testing.T) {
|
||||
unsetSyncRunningOperationState(t, appServer)
|
||||
_, err := appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("test")})
|
||||
_, err := appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("test-multi"), Id: ptr.To(int64(1))})
|
||||
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: new("test-multi"), Id: new(int64(1))})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Rollback(noRoleCtx, &application.ApplicationRollbackRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.Rollback(noRoleCtx, &application.ApplicationRollbackRequest{Name: new("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.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: new("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.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.Rollback(adminCtx, &application.ApplicationRollbackRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("ListResourceActions", func(t *testing.T) {
|
||||
_, err := appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err := appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Name: new("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.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
||||
_, err = appServer.ListResourceActions(noRoleCtx, &application.ApplicationResourceRequest{Group: new("argoproj.io"), Kind: new("Application"), Name: new("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.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: new("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.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.ListResourceActions(adminCtx, &application.ApplicationResourceRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
//nolint:staticcheck // SA1019: RunResourceAction is deprecated, but we still need to support it for backward compatibility.
|
||||
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.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Action: new("restart")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Name: new("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.RunResourceAction(noRoleCtx, &application.ResourceActionRunRequest{Group: new("argoproj.io"), Kind: new("Application"), Name: new("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.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: new("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.RunResourceAction(adminCtx, &application.ResourceActionRunRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("RunResourceActionV2", func(t *testing.T) {
|
||||
_, 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")})
|
||||
_, err := appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Action: new("restart")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Name: new("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.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Group: ptr.To("argoproj.io"), Kind: ptr.To("Application"), Name: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(noRoleCtx, &application.ResourceActionRunRequestV2{Group: new("argoproj.io"), Kind: new("Application"), Name: new("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.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: new("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.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.RunResourceActionV2(adminCtx, &application.ResourceActionRunRequestV2{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
t.Run("GetApplicationSyncWindows", func(t *testing.T) {
|
||||
_, err := appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("test")})
|
||||
_, err := appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.GetApplicationSyncWindows(noRoleCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("test")})
|
||||
_, err = appServer.GetApplicationSyncWindows(noRoleCtx, &application.ApplicationSyncWindowsQuery{Name: new("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.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: new("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.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.GetApplicationSyncWindows(adminCtx, &application.ApplicationSyncWindowsQuery{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
|
||||
|
|
@ -1054,58 +1053,58 @@ func TestNoAppEnumeration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("WatchResourceTree", func(t *testing.T) {
|
||||
err := appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
err := appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: new("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
require.NoError(t, err)
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("test")}, &TestResourceTreeServer{ctx: noRoleCtx})
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: new("test")}, &TestResourceTreeServer{ctx: noRoleCtx})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("does-not-exist")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: new("does-not-exist")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: ptr.To("does-not-exist"), Project: ptr.To("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
err = appServer.WatchResourceTree(&application.ResourcesQuery{ApplicationName: new("does-not-exist"), Project: new("test")}, &TestResourceTreeServer{ctx: adminCtx})
|
||||
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
||||
})
|
||||
|
||||
t.Run("PodLogs", func(t *testing.T) {
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
require.NoError(t, err)
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: noRoleCtx})
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: noRoleCtx})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("does-not-exist")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("does-not-exist")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
require.EqualError(t, err, common.PermissionDeniedAPIError.Error(), "error message must be _only_ the permission error, to avoid leaking information about app existence")
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("does-not-exist"), Project: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err = appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("does-not-exist"), Project: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
||||
})
|
||||
|
||||
t.Run("ListLinks", func(t *testing.T) {
|
||||
_, err := appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("test")})
|
||||
_, err := appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ListLinks(noRoleCtx, &application.ListAppLinksRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.ListLinks(noRoleCtx, &application.ListAppLinksRequest{Name: new("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.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("does-not-exist")})
|
||||
_, err = appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: new("does-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.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: ptr.To("does-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.ListLinks(adminCtx, &application.ListAppLinksRequest{Name: new("does-not-exist"), Project: new("test")})
|
||||
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
||||
})
|
||||
|
||||
t.Run("ListResourceLinks", func(t *testing.T) {
|
||||
_, err := appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err := appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.ListResourceLinks(noRoleCtx, &application.ApplicationResourceRequest{Name: ptr.To("test"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.ListResourceLinks(noRoleCtx, &application.ApplicationResourceRequest{Name: new("test"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("does-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test")})
|
||||
_, err = appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: new("does-not-exist"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("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.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: ptr.To("does-not-exist"), ResourceName: ptr.To("test"), Group: ptr.To("apps"), Kind: ptr.To("Deployment"), Namespace: ptr.To("test"), Project: ptr.To("test")})
|
||||
_, err = appServer.ListResourceLinks(adminCtx, &application.ApplicationResourceRequest{Name: new("does-not-exist"), ResourceName: new("test"), Group: new("apps"), Kind: new("Deployment"), Namespace: new("test"), Project: new("test")})
|
||||
assert.EqualError(t, err, "rpc error: code = NotFound desc = applications.argoproj.io \"does-not-exist\" not found", "when the request specifies a project, we can return the standard k8s error message")
|
||||
})
|
||||
|
||||
// Do this last so other stuff doesn't fail.
|
||||
t.Run("Delete", func(t *testing.T) {
|
||||
_, err := appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("test")})
|
||||
_, err := appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: new("test")})
|
||||
require.NoError(t, err)
|
||||
_, err = appServer.Delete(noRoleCtx, &application.ApplicationDeleteRequest{Name: ptr.To("test")})
|
||||
_, err = appServer.Delete(noRoleCtx, &application.ApplicationDeleteRequest{Name: new("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.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("doest-not-exist")})
|
||||
_, err = appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: new("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.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: ptr.To("doest-not-exist"), Project: ptr.To("test")})
|
||||
_, err = appServer.Delete(adminCtx, &application.ApplicationDeleteRequest{Name: new("doest-not-exist"), Project: new("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")
|
||||
})
|
||||
}
|
||||
|
|
@ -1582,7 +1581,7 @@ func TestCreateAppUpsert(t *testing.T) {
|
|||
newApp.Spec.Source.Name = "updated"
|
||||
createReq := application.ApplicationCreateRequest{
|
||||
Application: newApp,
|
||||
Upsert: ptr.To(true),
|
||||
Upsert: new(true),
|
||||
}
|
||||
app, err := appServer.Create(t.Context(), &createReq)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1599,7 +1598,7 @@ func TestCreateAppUpsert(t *testing.T) {
|
|||
newApp.Spec.Project = "my-proj"
|
||||
createReq := application.ApplicationCreateRequest{
|
||||
Application: newApp,
|
||||
Upsert: ptr.To(true),
|
||||
Upsert: new(true),
|
||||
}
|
||||
app, err := appServer.Create(t.Context(), &createReq)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1619,7 +1618,7 @@ func TestCreateAppUpsert(t *testing.T) {
|
|||
newApp.Labels = map[string]string{"update": "new"}
|
||||
createReq := application.ApplicationCreateRequest{
|
||||
Application: newApp,
|
||||
Upsert: ptr.To(true),
|
||||
Upsert: new(true),
|
||||
}
|
||||
app, err := appServer.Create(t.Context(), &createReq)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1729,7 +1728,7 @@ func TestUpdateApp(t *testing.T) {
|
|||
updateApp.Spec.Project = "my-proj"
|
||||
app, err := appServer.Update(t.Context(), &application.ApplicationUpdateRequest{
|
||||
Application: updateApp,
|
||||
Project: ptr.To("default"),
|
||||
Project: new("default"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, app)
|
||||
|
|
@ -2074,7 +2073,7 @@ func TestSyncRBACOverrideRequired_DiffRevDenied(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
_, err = appServer.Sync(ctx, syncReq)
|
||||
assert.Equal(t, codes.PermissionDenied.String(), status.Code(err).String(),
|
||||
|
|
@ -2120,7 +2119,7 @@ func TestSyncRBACOverrideRequired_SameRevisionAllowed(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("HEAD"),
|
||||
Revision: new("HEAD"),
|
||||
}
|
||||
syncedApp, err := appServer.Sync(ctx, syncReq)
|
||||
require.NoError(t, err,
|
||||
|
|
@ -2213,7 +2212,7 @@ func TestSyncRBACOverrideGranted_DiffRevisionAllowed(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
syncedApp, err := appServer.Sync(ctx, syncReq)
|
||||
require.NoError(t, err,
|
||||
|
|
@ -2357,7 +2356,7 @@ func TestSyncRBACSettingsError(t *testing.T) {
|
|||
// and sync to different revision
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
|
||||
_, err2 := appServer.Sync(ctx, syncReq)
|
||||
|
|
@ -2385,7 +2384,7 @@ func TestSyncRBACOverrideFalse_DiffRevNoOverrideAllowed(t *testing.T) {
|
|||
// and sync to different revision
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
|
||||
syncedApp, err := appServer.Sync(ctx, syncReq)
|
||||
|
|
@ -2429,7 +2428,7 @@ func TestSyncRBACOverrideNotRequired_SameRevisionAllowed(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("HEAD"),
|
||||
Revision: new("HEAD"),
|
||||
}
|
||||
|
||||
syncedApp, err := appServer.Sync(ctx, syncReq)
|
||||
|
|
@ -2511,7 +2510,7 @@ func TestSyncRBACOverrideNotRequired_DiffRevisionAllowed(t *testing.T) {
|
|||
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
|
||||
syncedApp, err := appServer.Sync(ctx, syncReq)
|
||||
|
|
@ -2560,7 +2559,7 @@ func TestSyncRBACOverrideNotRequired_DiffRevisionWithAutosyncPrevented(t *testin
|
|||
require.NoError(t, err)
|
||||
syncReq := &application.ApplicationSyncRequest{
|
||||
Name: &app.Name,
|
||||
Revision: ptr.To("revisionbranch"),
|
||||
Revision: new("revisionbranch"),
|
||||
}
|
||||
|
||||
_, err = appServer.Sync(ctx, syncReq)
|
||||
|
|
@ -2716,7 +2715,7 @@ func TestGetManifests_WithNoCache(t *testing.T) {
|
|||
|
||||
_, err := appServer.GetManifests(t.Context(), &application.ApplicationManifestQuery{
|
||||
Name: &testApp.Name,
|
||||
NoCache: ptr.To(true),
|
||||
NoCache: new(true),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
|
@ -2734,7 +2733,7 @@ func TestRollbackApp(t *testing.T) {
|
|||
|
||||
updatedApp, err := appServer.Rollback(t.Context(), &application.ApplicationRollbackRequest{
|
||||
Name: &testApp.Name,
|
||||
Id: ptr.To(int64(1)),
|
||||
Id: new(int64(1)),
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
|
|
@ -2765,7 +2764,7 @@ func TestRollbackApp_WithRefresh(t *testing.T) {
|
|||
|
||||
updatedApp, err := appServer.Rollback(t.Context(), &application.ApplicationRollbackRequest{
|
||||
Name: &testApp.Name,
|
||||
Id: ptr.To(int64(1)),
|
||||
Id: new(int64(1)),
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
|
|
@ -2847,19 +2846,19 @@ func TestAppJsonPatch(t *testing.T) {
|
|||
appServer := newTestAppServer(t, testApp)
|
||||
appServer.enf.SetDefaultRole("")
|
||||
|
||||
app, err := appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: ptr.To("garbage")})
|
||||
app, err := appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: new("garbage")})
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, app)
|
||||
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: ptr.To("[]")})
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: new("[]")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, app)
|
||||
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: ptr.To(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: new(`[{"op": "replace", "path": "/spec/source/path", "value": "foo"}]`)})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "foo", app.Spec.Source.Path)
|
||||
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: ptr.To(`[{"op": "remove", "path": "/metadata/annotations/test.annotation"}]`)})
|
||||
app, err = appServer.Patch(ctx, &application.ApplicationPatchRequest{Name: &testApp.Name, Patch: new(`[{"op": "remove", "path": "/metadata/annotations/test.annotation"}]`)})
|
||||
require.NoError(t, err)
|
||||
assert.NotContains(t, app.Annotations, "test.annotation")
|
||||
}
|
||||
|
|
@ -2873,7 +2872,7 @@ func TestAppMergePatch(t *testing.T) {
|
|||
appServer.enf.SetDefaultRole("")
|
||||
|
||||
app, err := appServer.Patch(ctx, &application.ApplicationPatchRequest{
|
||||
Name: &testApp.Name, Patch: ptr.To(`{"spec": { "source": { "path": "foo" } }}`), PatchType: ptr.To("merge"),
|
||||
Name: &testApp.Name, Patch: new(`{"spec": { "source": { "path": "foo" } }}`), PatchType: new("merge"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "foo", app.Spec.Source.Path)
|
||||
|
|
@ -3079,7 +3078,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|||
appServer, adminCtx := createAppServerWithMaxLodLogs(t, podNumber)
|
||||
|
||||
t.Run("PodLogs", func(t *testing.T) {
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
statusCode, _ := status.FromError(err)
|
||||
assert.Equal(t, codes.OK, statusCode.Code())
|
||||
})
|
||||
|
|
@ -3089,7 +3088,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|||
appServer, adminCtx = createAppServerWithMaxLodLogs(t, podNumber)
|
||||
|
||||
t.Run("PodLogs", func(t *testing.T) {
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
require.Error(t, err)
|
||||
statusCode, _ := status.FromError(err)
|
||||
assert.Equal(t, codes.InvalidArgument, statusCode.Code())
|
||||
|
|
@ -3102,7 +3101,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|||
appServer, adminCtx = createAppServerWithMaxLodLogs(t, podNumber, customMaxPodLogsToRender)
|
||||
|
||||
t.Run("PodLogs", func(t *testing.T) {
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
statusCode, _ := status.FromError(err)
|
||||
assert.Equal(t, codes.OK, statusCode.Code())
|
||||
})
|
||||
|
|
@ -3113,7 +3112,7 @@ func TestMaxPodLogsRender(t *testing.T) {
|
|||
appServer, adminCtx = createAppServerWithMaxLodLogs(t, podNumber, customMaxPodLogsToRender)
|
||||
|
||||
t.Run("PodLogs", func(t *testing.T) {
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: ptr.To("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
err := appServer.PodLogs(&application.ApplicationPodLogsQuery{Name: new("test")}, &TestPodLogsServer{ctx: adminCtx})
|
||||
require.Error(t, err)
|
||||
statusCode, _ := status.FromError(err)
|
||||
assert.Equal(t, codes.InvalidArgument, statusCode.Code())
|
||||
|
|
@ -3207,7 +3206,7 @@ func TestGetAppRefresh_NormalRefresh(t *testing.T) {
|
|||
|
||||
_, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: &testApp.Name,
|
||||
Refresh: ptr.To(string(v1alpha1.RefreshTypeNormal)),
|
||||
Refresh: new(string(v1alpha1.RefreshTypeNormal)),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -3242,7 +3241,7 @@ func TestGetAppRefresh_HardRefresh(t *testing.T) {
|
|||
|
||||
_, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: &testApp.Name,
|
||||
Refresh: ptr.To(string(v1alpha1.RefreshTypeHard)),
|
||||
Refresh: new(string(v1alpha1.RefreshTypeHard)),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, getAppDetailsQuery)
|
||||
|
|
@ -3314,7 +3313,7 @@ func TestGetApp_HealthStatusPropagation(t *testing.T) {
|
|||
|
||||
fetchedApp, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: &testApp.Name,
|
||||
Refresh: ptr.To(string(v1alpha1.RefreshTypeNormal)),
|
||||
Refresh: new(string(v1alpha1.RefreshTypeNormal)),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -3337,7 +3336,7 @@ func TestGetApp_HealthStatusPropagation(t *testing.T) {
|
|||
|
||||
fetchedApp, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: &testApp.Name,
|
||||
Refresh: ptr.To(string(v1alpha1.RefreshTypeHard)),
|
||||
Refresh: new(string(v1alpha1.RefreshTypeHard)),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -3712,7 +3711,7 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
testApp2 := newTestApp()
|
||||
testApp2.Namespace = "argocd-1"
|
||||
appServer := newTestAppServer(t, testApp1, testApp2)
|
||||
apps, err := appServer.List(t.Context(), &application.ApplicationQuery{AppNamespace: ptr.To("argocd-1")})
|
||||
apps, err := appServer.List(t.Context(), &application.ApplicationQuery{AppNamespace: new("argocd-1")})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, apps.Items)
|
||||
})
|
||||
|
|
@ -3733,7 +3732,7 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
testApp := newTestApp()
|
||||
appServer := newTestAppServer(t, testApp)
|
||||
app, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: ptr.To("test-app"),
|
||||
Name: new("test-app"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test-app", app.GetName())
|
||||
|
|
@ -3744,8 +3743,8 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
testApp.Namespace = "argocd-1"
|
||||
appServer := newTestAppServer(t, testApp)
|
||||
app, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To("argocd-1"),
|
||||
Name: new("test-app"),
|
||||
AppNamespace: new("argocd-1"),
|
||||
})
|
||||
require.ErrorContains(t, err, "permission denied")
|
||||
require.Nil(t, app)
|
||||
|
|
@ -3766,8 +3765,8 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
appServer := newTestAppServer(t, testApp, otherNsProj)
|
||||
appServer.enabledNamespaces = []string{"argocd-1"}
|
||||
app, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To("argocd-1"),
|
||||
Name: new("test-app"),
|
||||
AppNamespace: new("argocd-1"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, app)
|
||||
|
|
@ -3790,8 +3789,8 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
appServer := newTestAppServer(t, testApp, otherNsProj)
|
||||
appServer.enabledNamespaces = []string{"argocd-1"}
|
||||
app, err := appServer.Get(t.Context(), &application.ApplicationQuery{
|
||||
Name: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To("argocd-1"),
|
||||
Name: new("test-app"),
|
||||
AppNamespace: new("argocd-1"),
|
||||
})
|
||||
require.Error(t, err)
|
||||
require.Nil(t, app)
|
||||
|
|
@ -3921,8 +3920,8 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
appServer := newTestAppServer(t, testApp, otherNsProj)
|
||||
appServer.enabledNamespaces = []string{"argocd-1"}
|
||||
links, err := appServer.ListLinks(t.Context(), &application.ListAppLinksRequest{
|
||||
Name: ptr.To("test-app"),
|
||||
Namespace: ptr.To("argocd-1"),
|
||||
Name: new("test-app"),
|
||||
Namespace: new("argocd-1"),
|
||||
})
|
||||
require.Error(t, err)
|
||||
require.Nil(t, links)
|
||||
|
|
@ -3944,8 +3943,8 @@ func TestAppNamespaceRestrictions(t *testing.T) {
|
|||
appServer := newTestAppServer(t, testApp, otherNsProj)
|
||||
appServer.enabledNamespaces = []string{"argocd-1"}
|
||||
links, err := appServer.ListLinks(t.Context(), &application.ListAppLinksRequest{
|
||||
Name: ptr.To("test-app"),
|
||||
Namespace: ptr.To("argocd-1"),
|
||||
Name: new("test-app"),
|
||||
Namespace: new("argocd-1"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, links.Items)
|
||||
|
|
@ -4129,19 +4128,19 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
{
|
||||
name: "single-source app without history, no source index, missing version ID",
|
||||
multiSource: false,
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("the app has no history"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("the app has no history"),
|
||||
},
|
||||
{
|
||||
name: "single source app without history, present source index, no version ID",
|
||||
multiSource: false,
|
||||
sourceIndex: ptr.To(int32(0)),
|
||||
sourceIndex: new(int32(0)),
|
||||
},
|
||||
{
|
||||
name: "single source app without history, invalid source index, no version ID",
|
||||
multiSource: false,
|
||||
sourceIndex: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("source index 999 not found"),
|
||||
sourceIndex: new(int32(999)),
|
||||
expectErrorContains: new("source index 999 not found"),
|
||||
},
|
||||
{
|
||||
name: "single source app with matching history, no source index, no version ID",
|
||||
|
|
@ -4152,14 +4151,14 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
name: "single source app with matching history, no source index, missing version ID",
|
||||
multiSource: false,
|
||||
history: &struct{ matchesSourceType bool }{true},
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("history not found for version ID 999"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("history not found for version ID 999"),
|
||||
},
|
||||
{
|
||||
name: "single source app with matching history, no source index, present version ID",
|
||||
multiSource: false,
|
||||
history: &struct{ matchesSourceType bool }{true},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "single source app with multi-source history, no source index, no version ID",
|
||||
|
|
@ -4170,37 +4169,37 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
name: "single source app with multi-source history, no source index, missing version ID",
|
||||
multiSource: false,
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("history not found for version ID 999"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("history not found for version ID 999"),
|
||||
},
|
||||
{
|
||||
name: "single source app with multi-source history, no source index, present version ID",
|
||||
multiSource: false,
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "single-source app with multi-source history, source index 1, no version ID",
|
||||
multiSource: false,
|
||||
sourceIndex: ptr.To(int32(1)),
|
||||
sourceIndex: new(int32(1)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
// Since the user requested source index 1, but no version ID, we'll get an error when looking at the live
|
||||
// source, because the live source is single-source.
|
||||
expectErrorContains: ptr.To("there is only 1 source"),
|
||||
expectErrorContains: new("there is only 1 source"),
|
||||
},
|
||||
{
|
||||
name: "single-source app with multi-source history, invalid source index, no version ID",
|
||||
multiSource: false,
|
||||
sourceIndex: ptr.To(int32(999)),
|
||||
sourceIndex: new(int32(999)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
expectErrorContains: ptr.To("source index 999 not found"),
|
||||
expectErrorContains: new("source index 999 not found"),
|
||||
},
|
||||
{
|
||||
name: "single-source app with multi-source history, valid source index, present version ID",
|
||||
multiSource: false,
|
||||
sourceIndex: ptr.To(int32(1)),
|
||||
sourceIndex: new(int32(1)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "multi-source app without history, no source index, no version ID",
|
||||
|
|
@ -4209,19 +4208,19 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
{
|
||||
name: "multi-source app without history, no source index, missing version ID",
|
||||
multiSource: true,
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("the app has no history"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("the app has no history"),
|
||||
},
|
||||
{
|
||||
name: "multi-source app without history, present source index, no version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(1)),
|
||||
sourceIndex: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "multi-source app without history, invalid source index, no version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("source index 999 not found"),
|
||||
sourceIndex: new(int32(999)),
|
||||
expectErrorContains: new("source index 999 not found"),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with matching history, no source index, no version ID",
|
||||
|
|
@ -4232,14 +4231,14 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
name: "multi-source app with matching history, no source index, missing version ID",
|
||||
multiSource: true,
|
||||
history: &struct{ matchesSourceType bool }{true},
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("history not found for version ID 999"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("history not found for version ID 999"),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with matching history, no source index, present version ID",
|
||||
multiSource: true,
|
||||
history: &struct{ matchesSourceType bool }{true},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, no source index, no version ID",
|
||||
|
|
@ -4250,42 +4249,42 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
name: "multi-source app with single-source history, no source index, missing version ID",
|
||||
multiSource: true,
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(999)),
|
||||
expectErrorContains: ptr.To("history not found for version ID 999"),
|
||||
versionId: new(int32(999)),
|
||||
expectErrorContains: new("history not found for version ID 999"),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, no source index, present version ID",
|
||||
multiSource: true,
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, source index 1, no version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(1)),
|
||||
sourceIndex: new(int32(1)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, invalid source index, no version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(999)),
|
||||
sourceIndex: new(int32(999)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
expectErrorContains: ptr.To("source index 999 not found"),
|
||||
expectErrorContains: new("source index 999 not found"),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, valid source index, present version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(0)),
|
||||
sourceIndex: new(int32(0)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(1)),
|
||||
versionId: new(int32(1)),
|
||||
},
|
||||
{
|
||||
name: "multi-source app with single-source history, source index 1, present version ID",
|
||||
multiSource: true,
|
||||
sourceIndex: ptr.To(int32(1)),
|
||||
sourceIndex: new(int32(1)),
|
||||
history: &struct{ matchesSourceType bool }{false},
|
||||
versionId: ptr.To(int32(1)),
|
||||
expectErrorContains: ptr.To("source index 1 not found"),
|
||||
versionId: new(int32(1)),
|
||||
expectErrorContains: new("source index 1 not found"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -4317,8 +4316,8 @@ func Test_RevisionMetadata(t *testing.T) {
|
|||
s := newTestAppServer(t, app)
|
||||
|
||||
request := &application.RevisionMetadataQuery{
|
||||
Name: ptr.To(app.Name),
|
||||
Revision: ptr.To("HEAD"),
|
||||
Name: new(app.Name),
|
||||
Revision: new("HEAD"),
|
||||
SourceIndex: tcc.sourceIndex,
|
||||
VersionId: tcc.versionId,
|
||||
}
|
||||
|
|
@ -4472,9 +4471,9 @@ func TestServerSideDiff(t *testing.T) {
|
|||
t.Run("InputValidation", func(t *testing.T) {
|
||||
// Test missing application name
|
||||
query := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: ptr.To(""), // Empty name instead of nil
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("test-project"),
|
||||
AppName: new(""), // Empty name instead of nil
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("test-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{},
|
||||
TargetManifests: []string{},
|
||||
}
|
||||
|
|
@ -4486,8 +4485,8 @@ func TestServerSideDiff(t *testing.T) {
|
|||
// Test nil application name
|
||||
queryNil := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: nil,
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("test-project"),
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("test-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{},
|
||||
TargetManifests: []string{},
|
||||
}
|
||||
|
|
@ -4500,9 +4499,9 @@ func TestServerSideDiff(t *testing.T) {
|
|||
t.Run("InvalidManifest", func(t *testing.T) {
|
||||
// Test error handling for malformed JSON in target manifests
|
||||
query := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("test-project"),
|
||||
AppName: new("test-app"),
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("test-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{},
|
||||
TargetManifests: []string{`invalid json`},
|
||||
}
|
||||
|
|
@ -4527,9 +4526,9 @@ func TestServerSideDiff(t *testing.T) {
|
|||
}
|
||||
|
||||
query := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("test-project"),
|
||||
AppName: new("test-app"),
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("test-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{liveResource},
|
||||
TargetManifests: []string{`{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"name":"test"}}`},
|
||||
}
|
||||
|
|
@ -4544,9 +4543,9 @@ func TestServerSideDiff(t *testing.T) {
|
|||
t.Run("EmptyRequest", func(t *testing.T) {
|
||||
// Test with empty resources - should succeed without errors but no diffs
|
||||
query := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: ptr.To("test-app"),
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("test-project"),
|
||||
AppName: new("test-app"),
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("test-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{},
|
||||
TargetManifests: []string{},
|
||||
}
|
||||
|
|
@ -4563,9 +4562,9 @@ func TestServerSideDiff(t *testing.T) {
|
|||
t.Run("MissingAppPermission", func(t *testing.T) {
|
||||
// Test RBAC enforcement
|
||||
query := &application.ApplicationServerSideDiffQuery{
|
||||
AppName: ptr.To("nonexistent-app"),
|
||||
AppNamespace: ptr.To(testNamespace),
|
||||
Project: ptr.To("nonexistent-project"),
|
||||
AppName: new("nonexistent-app"),
|
||||
AppNamespace: new(testNamespace),
|
||||
Project: new("nonexistent-project"),
|
||||
LiveResources: []*v1alpha1.ResourceDiff{},
|
||||
TargetManifests: []string{},
|
||||
}
|
||||
|
|
@ -4642,7 +4641,7 @@ func TestTerminateOperationWithConflicts(t *testing.T) {
|
|||
|
||||
// Attempt to terminate the operation
|
||||
_, err := appServer.TerminateOperation(ctx, &application.OperationTerminateRequest{
|
||||
Name: ptr.To(testApp.Name),
|
||||
Name: new(testApp.Name),
|
||||
})
|
||||
|
||||
// Should succeed after retrying with the fresh app
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/cluster"
|
||||
|
|
@ -374,7 +373,7 @@ func TestUpdateCluster_FieldsPathSet(t *testing.T) {
|
|||
_, err := server.Update(t.Context(), &cluster.ClusterUpdateRequest{
|
||||
Cluster: &appv1.Cluster{
|
||||
Server: "https://127.0.0.1",
|
||||
Shard: ptr.To(int64(1)),
|
||||
Shard: new(int64(1)),
|
||||
},
|
||||
UpdatedFields: []string{"shard"},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/argoproj/argo-cd/gitops-engine/pkg/utils/kube"
|
||||
"github.com/expr-lang/expr"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -126,8 +125,8 @@ func EvaluateDeepLinksResponse(obj map[string]any, name string, links []settings
|
|||
}
|
||||
|
||||
finalLinks = append(finalLinks, &application.LinkInfo{
|
||||
Title: ptr.To(link.Title),
|
||||
Url: ptr.To(finalURL.String()),
|
||||
Title: new(link.Title),
|
||||
Url: new(finalURL.String()),
|
||||
Description: link.Description,
|
||||
IconClass: link.IconClass,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -82,11 +81,11 @@ func TestDeepLinks(t *testing.T) {
|
|||
inputLinks: []settings.DeepLink{{
|
||||
Title: "link",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .resource.data.key }}&{{ index .project.spec.sourceRepos 0}}&{{ .cluster.name }}",
|
||||
Condition: ptr.To(`application.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
Condition: new(`application.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
}},
|
||||
outputLinks: []*application.LinkInfo{{
|
||||
Title: ptr.To("link"),
|
||||
Url: ptr.To("http://example.com/test&value1&test-repo.git&test-cluster"),
|
||||
Title: new("link"),
|
||||
Url: new("http://example.com/test&value1&test-repo.git&test-cluster"),
|
||||
}},
|
||||
error: []string{},
|
||||
},
|
||||
|
|
@ -99,11 +98,11 @@ func TestDeepLinks(t *testing.T) {
|
|||
inputLinks: []settings.DeepLink{{
|
||||
Title: "link",
|
||||
URL: "http://example.com/{{ .app.metadata.name }}&{{ .resource.data.key }}&{{ index .project.spec.sourceRepos 0}}&{{ .cluster.name }}",
|
||||
Condition: ptr.To(`app.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
Condition: new(`app.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
}},
|
||||
outputLinks: []*application.LinkInfo{{
|
||||
Title: ptr.To("link"),
|
||||
Url: ptr.To("http://example.com/test&value1&test-repo.git&test-cluster"),
|
||||
Title: new("link"),
|
||||
Url: new("http://example.com/test&value1&test-repo.git&test-cluster"),
|
||||
}},
|
||||
error: []string{},
|
||||
},
|
||||
|
|
@ -116,22 +115,22 @@ func TestDeepLinks(t *testing.T) {
|
|||
{
|
||||
Title: "link",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .application.spec.destination.namespace }}",
|
||||
Condition: ptr.To(`application.metadata.name matches "test"`),
|
||||
Condition: new(`application.metadata.name matches "test"`),
|
||||
},
|
||||
{
|
||||
Title: "link1",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .application.spec.destination.namespace }}",
|
||||
Condition: ptr.To(`application.metadata.name matches "test1"`),
|
||||
Condition: new(`application.metadata.name matches "test1"`),
|
||||
},
|
||||
{
|
||||
Title: "link2",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .application.spec.destination.namespace }}",
|
||||
Condition: ptr.To(`application.metadata.test matches "test"`),
|
||||
Condition: new(`application.metadata.test matches "test"`),
|
||||
},
|
||||
},
|
||||
outputLinks: []*application.LinkInfo{{
|
||||
Title: ptr.To("link"),
|
||||
Url: ptr.To("http://example.com/test&testns"),
|
||||
Title: new("link"),
|
||||
Url: new("http://example.com/test&testns"),
|
||||
}},
|
||||
error: []string{},
|
||||
},
|
||||
|
|
@ -144,17 +143,17 @@ func TestDeepLinks(t *testing.T) {
|
|||
{
|
||||
Title: "link",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .application.spec.destination.namespace }}",
|
||||
Condition: ptr.To(`application.metadata.name matches "test"`),
|
||||
Condition: new(`application.metadata.name matches "test"`),
|
||||
},
|
||||
{
|
||||
Title: "link1",
|
||||
URL: "http://example.com/{{ .application.metadata.name }}&{{ .application.spec.destination.namespace }}",
|
||||
Condition: ptr.To(`1 + 1`),
|
||||
Condition: new(`1 + 1`),
|
||||
},
|
||||
},
|
||||
outputLinks: []*application.LinkInfo{{
|
||||
Title: ptr.To("link"),
|
||||
Url: ptr.To("http://example.com/test&testns"),
|
||||
Title: new("link"),
|
||||
Url: new("http://example.com/test&testns"),
|
||||
}},
|
||||
error: []string{"link condition '1 + 1' evaluated to non-boolean value for resource test"},
|
||||
},
|
||||
|
|
@ -167,11 +166,11 @@ func TestDeepLinks(t *testing.T) {
|
|||
inputLinks: []settings.DeepLink{{
|
||||
Title: "link",
|
||||
URL: "http://example.com/{{ .cluster.name | replace \"-\" \"_\" }}&{{ first .project.spec.sourceRepos }}",
|
||||
Condition: ptr.To(`application.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
Condition: new(`application.metadata.name == "test" && project.metadata.name == "test-project"`),
|
||||
}},
|
||||
outputLinks: []*application.LinkInfo{{
|
||||
Title: ptr.To("link"),
|
||||
Url: ptr.To("http://example.com/test_cluster&test-repo.git"),
|
||||
Title: new("link"),
|
||||
Url: new("http://example.com/test_cluster&test-repo.git"),
|
||||
}},
|
||||
error: []string{},
|
||||
},
|
||||
|
|
@ -184,12 +183,12 @@ func TestDeepLinks(t *testing.T) {
|
|||
{
|
||||
Title: "link",
|
||||
URL: "http://not-evaluated.com/{{ index \"invalid\" .application.metadata.labels }}",
|
||||
Condition: ptr.To(`false`),
|
||||
Condition: new(`false`),
|
||||
},
|
||||
{
|
||||
Title: "link",
|
||||
URL: "http://evaluated.com/{{ index \"invalid\" .application.metadata.labels }}",
|
||||
Condition: ptr.To(`true`),
|
||||
Condition: new(`true`),
|
||||
},
|
||||
},
|
||||
outputLinks: []*application.LinkInfo{},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"github.com/argoproj/notifications-engine/pkg/api"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/notification"
|
||||
)
|
||||
|
|
@ -31,7 +30,7 @@ func (s *Server) ListTriggers(_ context.Context, _ *notification.TriggersListReq
|
|||
}
|
||||
triggers := []*notification.Trigger{}
|
||||
for trigger := range api.GetConfig().Triggers {
|
||||
triggers = append(triggers, ¬ification.Trigger{Name: ptr.To(trigger)})
|
||||
triggers = append(triggers, ¬ification.Trigger{Name: new(trigger)})
|
||||
}
|
||||
return ¬ification.TriggerList{Items: triggers}, nil
|
||||
}
|
||||
|
|
@ -47,7 +46,7 @@ func (s *Server) ListServices(_ context.Context, _ *notification.ServicesListReq
|
|||
}
|
||||
services := []*notification.Service{}
|
||||
for svc := range api.GetConfig().Services {
|
||||
services = append(services, ¬ification.Service{Name: ptr.To(svc)})
|
||||
services = append(services, ¬ification.Service{Name: new(svc)})
|
||||
}
|
||||
return ¬ification.ServiceList{Items: services}, nil
|
||||
}
|
||||
|
|
@ -63,7 +62,7 @@ func (s *Server) ListTemplates(_ context.Context, _ *notification.TemplatesListR
|
|||
}
|
||||
templates := []*notification.Template{}
|
||||
for tmpl := range api.GetConfig().Templates {
|
||||
templates = append(templates, ¬ification.Template{Name: ptr.To(tmpl)})
|
||||
templates = append(templates, ¬ification.Template{Name: new(tmpl)})
|
||||
}
|
||||
return ¬ification.TemplateList{Items: templates}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/notification"
|
||||
"github.com/argoproj/argo-cd/v3/reposerver/apiclient/mocks"
|
||||
|
|
@ -76,7 +75,7 @@ func TestNotificationServer(t *testing.T) {
|
|||
services, err := server.ListServices(ctx, ¬ification.ServicesListRequest{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, services.Items, 1)
|
||||
assert.Equal(t, services.Items[0].Name, ptr.To("test"))
|
||||
assert.Equal(t, services.Items[0].Name, new("test"))
|
||||
assert.NotEmpty(t, services.Items[0])
|
||||
})
|
||||
t.Run("TestListTriggers", func(t *testing.T) {
|
||||
|
|
@ -84,7 +83,7 @@ func TestNotificationServer(t *testing.T) {
|
|||
triggers, err := server.ListTriggers(ctx, ¬ification.TriggersListRequest{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, triggers.Items, 1)
|
||||
assert.Equal(t, triggers.Items[0].Name, ptr.To("on-created"))
|
||||
assert.Equal(t, triggers.Items[0].Name, new("on-created"))
|
||||
assert.NotEmpty(t, triggers.Items[0])
|
||||
})
|
||||
t.Run("TestListTemplates", func(t *testing.T) {
|
||||
|
|
@ -92,7 +91,7 @@ func TestNotificationServer(t *testing.T) {
|
|||
templates, err := server.ListTemplates(ctx, ¬ification.TemplatesListRequest{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, templates.Items, 1)
|
||||
assert.Equal(t, templates.Items[0].Name, ptr.To("app-created"))
|
||||
assert.Equal(t, templates.Items[0].Name, new("app-created"))
|
||||
assert.NotEmpty(t, templates.Items[0])
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
|
|
@ -109,7 +108,7 @@ func TestAutoSyncRetryAndRefreshEnabled(t *testing.T) {
|
|||
Refresh: true,
|
||||
Backoff: &Backoff{
|
||||
Duration: time.Second.String(),
|
||||
Factor: ptr.To(int64(1)),
|
||||
Factor: new(int64(1)),
|
||||
MaxDuration: time.Second.String(),
|
||||
},
|
||||
},
|
||||
|
|
@ -149,7 +148,7 @@ func TestAutoSyncRetryAndRefreshEnabledChangedSource(t *testing.T) {
|
|||
Refresh: true,
|
||||
Backoff: &Backoff{
|
||||
Duration: time.Second.String(),
|
||||
Factor: ptr.To(int64(1)),
|
||||
Factor: new(int64(1)),
|
||||
MaxDuration: time.Second.String(),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
|
|
@ -551,12 +550,12 @@ func TestNamespacedManipulateApplicationResources(t *testing.T) {
|
|||
|
||||
_, err = client.DeleteResource(t.Context(), &applicationpkg.ApplicationResourceDeleteRequest{
|
||||
Name: &app.Name,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
Group: ptr.To(deployment.GroupVersionKind().Group),
|
||||
Kind: ptr.To(deployment.GroupVersionKind().Kind),
|
||||
Version: ptr.To(deployment.GroupVersionKind().Version),
|
||||
Namespace: ptr.To(deployment.GetNamespace()),
|
||||
ResourceName: ptr.To(deployment.GetName()),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
Group: new(deployment.GroupVersionKind().Group),
|
||||
Kind: new(deployment.GroupVersionKind().Kind),
|
||||
Version: new(deployment.GroupVersionKind().Version),
|
||||
Namespace: new(deployment.GetNamespace()),
|
||||
ResourceName: new(deployment.GetName()),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}).
|
||||
|
|
@ -581,18 +580,18 @@ func TestNamespacedAppWithSecrets(t *testing.T) {
|
|||
And(func(app *Application) {
|
||||
res := errors.NewHandler(t).FailOnErr(client.GetResource(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Namespace: &app.Spec.Destination.Namespace,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
Kind: ptr.To(kube.SecretKind),
|
||||
Group: ptr.To(""),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
Kind: new(kube.SecretKind),
|
||||
Group: new(""),
|
||||
Name: &app.Name,
|
||||
Version: ptr.To("v1"),
|
||||
ResourceName: ptr.To("test-secret"),
|
||||
Version: new("v1"),
|
||||
ResourceName: new("test-secret"),
|
||||
})).(*applicationpkg.ApplicationResourceResponse)
|
||||
assetSecretDataHidden(t, res.GetManifest())
|
||||
|
||||
manifests, err := client.GetManifests(t.Context(), &applicationpkg.ApplicationManifestQuery{
|
||||
Name: &app.Name,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -636,7 +635,7 @@ func TestNamespacedAppWithSecrets(t *testing.T) {
|
|||
app.Spec.IgnoreDifferences = []ResourceIgnoreDifferences{{
|
||||
Kind: kube.SecretKind, JSONPointers: []string{"/data"},
|
||||
}}
|
||||
errors.NewHandler(t).FailOnErr(client.UpdateSpec(t.Context(), &applicationpkg.ApplicationUpdateSpecRequest{Name: &app.Name, AppNamespace: ptr.To(fixture.AppNamespace()), Spec: &app.Spec}))
|
||||
errors.NewHandler(t).FailOnErr(client.UpdateSpec(t.Context(), &applicationpkg.ApplicationUpdateSpecRequest{Name: &app.Name, AppNamespace: new(fixture.AppNamespace()), Spec: &app.Spec}))
|
||||
}).
|
||||
When().
|
||||
Refresh(RefreshTypeNormal).
|
||||
|
|
@ -868,25 +867,25 @@ func TestNamespacedResourceAction(t *testing.T) {
|
|||
|
||||
actions, err := client.ListResourceActions(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &app.Name,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Action: ptr.To("sample"),
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Action: new("sample"),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -1043,15 +1042,15 @@ func assertNSResourceActions(t *testing.T, appName string, deploymentNamespace s
|
|||
require.NoError(t, err)
|
||||
|
||||
logs, err := cdClient.PodLogs(t.Context(), &applicationpkg.ApplicationPodLogsQuery{
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Container: ptr.To(""),
|
||||
SinceSeconds: ptr.To(int64(0)),
|
||||
TailLines: ptr.To(int64(0)),
|
||||
Follow: ptr.To(false),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Container: new(""),
|
||||
SinceSeconds: new(int64(0)),
|
||||
TailLines: new(int64(0)),
|
||||
Follow: new(false),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = logs.Recv()
|
||||
|
|
@ -1061,44 +1060,44 @@ func assertNSResourceActions(t *testing.T, appName string, deploymentNamespace s
|
|||
|
||||
_, err = cdClient.ListResourceEvents(t.Context(), &applicationpkg.ApplicationResourceEventsQuery{
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
ResourceNamespace: ptr.To(deploymentNamespace),
|
||||
ResourceUID: ptr.To(string(deploymentResource.UID)),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
ResourceNamespace: new(deploymentNamespace),
|
||||
ResourceUID: new(string(deploymentResource.UID)),
|
||||
})
|
||||
assertError(err, fmt.Sprintf("%s not found as part of application %s", "guestbook-ui", appName))
|
||||
|
||||
_, err = cdClient.GetResource(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Action: ptr.To("restart"),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Action: new("restart"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.DeleteResource(t.Context(), &applicationpkg.ApplicationResourceDeleteRequest{
|
||||
Name: &appName,
|
||||
AppNamespace: ptr.To(fixture.AppNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
AppNamespace: new(fixture.AppNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
}
|
||||
|
|
@ -1410,7 +1409,7 @@ func TestNamespacedOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true)},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true)},
|
||||
SourceNamespaces: []string{fixture.AppNamespace()},
|
||||
}).
|
||||
SetTrackingMethod("annotation").
|
||||
|
|
@ -1442,7 +1441,7 @@ func TestNamespacedOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Group: "Test", Kind: "ConfigMap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Group: "Test", Kind: "ConfigMap"}}},
|
||||
SourceNamespaces: []string{fixture.AppNamespace()},
|
||||
}).
|
||||
When().
|
||||
|
|
@ -1458,7 +1457,7 @@ func TestNamespacedOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap"}}},
|
||||
SourceNamespaces: []string{fixture.AppNamespace()},
|
||||
}).
|
||||
When().
|
||||
|
|
@ -1475,7 +1474,7 @@ func TestNamespacedOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap", Name: "orphaned-configmap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap", Name: "orphaned-configmap"}}},
|
||||
SourceNamespaces: []string{fixture.AppNamespace()},
|
||||
}).
|
||||
When().
|
||||
|
|
@ -1698,7 +1697,7 @@ func TestNamespacedListResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true)},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true)},
|
||||
SourceNamespaces: []string{fixture.AppNamespace()},
|
||||
}).
|
||||
Path(guestbookPath).
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
|
|
@ -779,11 +778,11 @@ func TestManipulateApplicationResources(t *testing.T) {
|
|||
|
||||
_, err = client.DeleteResource(t.Context(), &applicationpkg.ApplicationResourceDeleteRequest{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To(deployment.GroupVersionKind().Group),
|
||||
Kind: ptr.To(deployment.GroupVersionKind().Kind),
|
||||
Version: ptr.To(deployment.GroupVersionKind().Version),
|
||||
Namespace: ptr.To(deployment.GetNamespace()),
|
||||
ResourceName: ptr.To(deployment.GetName()),
|
||||
Group: new(deployment.GroupVersionKind().Group),
|
||||
Kind: new(deployment.GroupVersionKind().Kind),
|
||||
Version: new(deployment.GroupVersionKind().Version),
|
||||
Namespace: new(deployment.GetNamespace()),
|
||||
ResourceName: new(deployment.GetName()),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}).
|
||||
|
|
@ -830,11 +829,11 @@ func TestAppWithSecrets(t *testing.T) {
|
|||
And(func(app *Application) {
|
||||
res := errors.NewHandler(t).FailOnErr(client.GetResource(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Namespace: &app.Spec.Destination.Namespace,
|
||||
Kind: ptr.To(kube.SecretKind),
|
||||
Group: ptr.To(""),
|
||||
Kind: new(kube.SecretKind),
|
||||
Group: new(""),
|
||||
Name: &app.Name,
|
||||
Version: ptr.To("v1"),
|
||||
ResourceName: ptr.To("test-secret"),
|
||||
Version: new("v1"),
|
||||
ResourceName: new("test-secret"),
|
||||
})).(*applicationpkg.ApplicationResourceResponse)
|
||||
assetSecretDataHidden(t, res.GetManifest())
|
||||
|
||||
|
|
@ -1119,23 +1118,23 @@ func TestOldStyleResourceAction(t *testing.T) {
|
|||
|
||||
actions, err := client.ListResourceActions(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Action: ptr.To("sample"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Action: new("sample"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -1226,23 +1225,23 @@ func TestNewStyleResourceActionPermitted(t *testing.T) {
|
|||
|
||||
actions, err := client.ListResourceActions(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("hello"),
|
||||
Group: new("batch"),
|
||||
Kind: new("CronJob"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("hello"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("hello"),
|
||||
Action: ptr.To("sample"),
|
||||
Group: new("batch"),
|
||||
Kind: new("CronJob"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("hello"),
|
||||
Action: new("sample"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -1339,23 +1338,23 @@ func TestNewStyleResourceActionMixedOk(t *testing.T) {
|
|||
|
||||
actions, err := client.ListResourceActions(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("hello"),
|
||||
Group: new("batch"),
|
||||
Kind: new("CronJob"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("hello"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*ResourceAction{{Name: "sample", Disabled: false}}, actions.Actions)
|
||||
|
||||
_, err = client.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &app.Name,
|
||||
Group: ptr.To("batch"),
|
||||
Kind: ptr.To("CronJob"),
|
||||
Version: ptr.To("v1"),
|
||||
Namespace: ptr.To(ctx.DeploymentNamespace()),
|
||||
ResourceName: ptr.To("hello"),
|
||||
Action: ptr.To("sample"),
|
||||
Group: new("batch"),
|
||||
Kind: new("CronJob"),
|
||||
Version: new("v1"),
|
||||
Namespace: new(ctx.DeploymentNamespace()),
|
||||
ResourceName: new("hello"),
|
||||
Action: new("sample"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -1518,14 +1517,14 @@ func assertResourceActions(t *testing.T, appName string, successful bool, deploy
|
|||
require.NoError(t, err)
|
||||
|
||||
logs, err := cdClient.PodLogs(t.Context(), &applicationpkg.ApplicationPodLogsQuery{
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Name: &appName,
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Container: ptr.To(""),
|
||||
SinceSeconds: ptr.To(int64(0)),
|
||||
TailLines: ptr.To(int64(0)),
|
||||
Follow: ptr.To(false),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Container: new(""),
|
||||
SinceSeconds: new(int64(0)),
|
||||
TailLines: new(int64(0)),
|
||||
Follow: new(false),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = logs.Recv()
|
||||
|
|
@ -1535,40 +1534,40 @@ func assertResourceActions(t *testing.T, appName string, successful bool, deploy
|
|||
|
||||
_, err = cdClient.ListResourceEvents(t.Context(), &applicationpkg.ApplicationResourceEventsQuery{
|
||||
Name: &appName,
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
ResourceNamespace: ptr.To(deploymentNamespace),
|
||||
ResourceUID: ptr.To(string(deploymentResource.UID)),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
ResourceNamespace: new(deploymentNamespace),
|
||||
ResourceUID: new(string(deploymentResource.UID)),
|
||||
})
|
||||
assertError(err, fmt.Sprintf("%s not found as part of application %s", "guestbook-ui", appName))
|
||||
|
||||
_, err = cdClient.GetResource(t.Context(), &applicationpkg.ApplicationResourceRequest{
|
||||
Name: &appName,
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.RunResourceActionV2(t.Context(), &applicationpkg.ResourceActionRunRequestV2{
|
||||
Name: &appName,
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
Action: ptr.To("restart"),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
Action: new("restart"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
|
||||
_, err = cdClient.DeleteResource(t.Context(), &applicationpkg.ApplicationResourceDeleteRequest{
|
||||
Name: &appName,
|
||||
ResourceName: ptr.To("guestbook-ui"),
|
||||
Namespace: ptr.To(deploymentNamespace),
|
||||
Version: ptr.To("v1"),
|
||||
Group: ptr.To("apps"),
|
||||
Kind: ptr.To("Deployment"),
|
||||
ResourceName: new("guestbook-ui"),
|
||||
Namespace: new(deploymentNamespace),
|
||||
Version: new("v1"),
|
||||
Group: new("apps"),
|
||||
Kind: new("Deployment"),
|
||||
})
|
||||
assertError(err, expectedError)
|
||||
}
|
||||
|
|
@ -1941,7 +1940,7 @@ func TestOrphanedResource(t *testing.T) {
|
|||
ctx.ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true)},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true)},
|
||||
}).
|
||||
Path(guestbookPath).
|
||||
When().
|
||||
|
|
@ -1970,7 +1969,7 @@ func TestOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Group: "Test", Kind: "ConfigMap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Group: "Test", Kind: "ConfigMap"}}},
|
||||
}).
|
||||
When().
|
||||
Refresh(RefreshTypeNormal).
|
||||
|
|
@ -1985,7 +1984,7 @@ func TestOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap"}}},
|
||||
}).
|
||||
When().
|
||||
Refresh(RefreshTypeNormal).
|
||||
|
|
@ -2001,7 +2000,7 @@ func TestOrphanedResource(t *testing.T) {
|
|||
ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap", Name: "orphaned-configmap"}}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true), Ignore: []OrphanedResourceKey{{Kind: "ConfigMap", Name: "orphaned-configmap"}}},
|
||||
}).
|
||||
When().
|
||||
Refresh(RefreshTypeNormal).
|
||||
|
|
@ -2153,7 +2152,7 @@ func TestSyncWithRetryAndRefreshEnabled(t *testing.T) {
|
|||
Refresh: true,
|
||||
Backoff: &Backoff{
|
||||
Duration: time.Second.String(),
|
||||
Factor: ptr.To(int64(1)),
|
||||
Factor: new(int64(1)),
|
||||
MaxDuration: time.Second.String(),
|
||||
},
|
||||
},
|
||||
|
|
@ -2277,7 +2276,7 @@ func TestListResource(t *testing.T) {
|
|||
ctx.ProjectSpec(AppProjectSpec{
|
||||
SourceRepos: []string{"*"},
|
||||
Destinations: []ApplicationDestination{{Namespace: "*", Server: "*"}},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: ptr.To(true)},
|
||||
OrphanedResources: &OrphanedResourcesMonitorSettings{Warn: new(true)},
|
||||
}).
|
||||
Path(guestbookPath).
|
||||
When().
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -122,9 +121,9 @@ func (c *Consequences) resource(kind, name, namespace string) v1alpha1.ResourceS
|
|||
require.NoError(c.context.T(), err)
|
||||
defer utilio.Close(closer)
|
||||
app, err := client.Get(context.Background(), &applicationpkg.ApplicationQuery{
|
||||
Name: ptr.To(c.context.AppName()),
|
||||
Name: new(c.context.AppName()),
|
||||
Projects: []string{c.context.project},
|
||||
AppNamespace: ptr.To(c.context.appNamespace),
|
||||
AppNamespace: new(c.context.appNamespace),
|
||||
})
|
||||
require.NoError(c.context.T(), err)
|
||||
for _, r := range app.Status.Resources {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/settings"
|
||||
|
|
@ -83,7 +82,7 @@ func TestManagedByURLWithAnnotation(t *testing.T) {
|
|||
defer conn.Close()
|
||||
|
||||
links, err := appClient.ListLinks(t.Context(), &application.ListAppLinksRequest{
|
||||
Name: ptr.To(app.Name),
|
||||
Name: new(app.Name),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -156,7 +155,7 @@ func TestManagedByURLFallbackToCurrentInstance(t *testing.T) {
|
|||
defer conn.Close()
|
||||
|
||||
links, err := appClient.ListLinks(t.Context(), &application.ListAppLinksRequest{
|
||||
Name: ptr.To(app.Name),
|
||||
Name: new(app.Name),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/notification"
|
||||
notifFixture "github.com/argoproj/argo-cd/v3/test/e2e/fixture/notification"
|
||||
|
|
@ -17,7 +16,7 @@ func TestNotificationsListServices(t *testing.T) {
|
|||
SetParamInNotificationConfigMap("service.webhook.test", "url: https://test.example.com").
|
||||
Then().Services(func(services *notification.ServiceList, err error) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*notification.Service{{Name: ptr.To("test")}}, services.Items)
|
||||
assert.Equal(t, []*notification.Service{{Name: new("test")}}, services.Items)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +26,7 @@ func TestNotificationsListTemplates(t *testing.T) {
|
|||
SetParamInNotificationConfigMap("template.app-created", "email:\n subject: Application {{.app.metadata.name}} has been created.\nmessage: Application {{.app.metadata.name}} has been created.\nteams:\n title: Application {{.app.metadata.name}} has been created.\n").
|
||||
Then().Templates(func(templates *notification.TemplateList, err error) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*notification.Template{{Name: ptr.To("app-created")}}, templates.Items)
|
||||
assert.Equal(t, []*notification.Template{{Name: new("app-created")}}, templates.Items)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ func TestNotificationsListTriggers(t *testing.T) {
|
|||
SetParamInNotificationConfigMap("trigger.on-created", "- description: Application is created.\n oncePer: app.metadata.name\n send:\n - app-created\n when: \"true\"\n").
|
||||
Then().Triggers(func(triggers *notification.TriggerList, err error) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*notification.Trigger{{Name: ptr.To("on-created")}}, triggers.Items)
|
||||
assert.Equal(t, []*notification.Trigger{{Name: new("on-created")}}, triggers.Items)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
||||
|
|
@ -415,7 +414,7 @@ func TestRemoveOrphanedIgnore(t *testing.T) {
|
|||
ObjectMeta: metav1.ObjectMeta{Name: projectName},
|
||||
Spec: v1alpha1.AppProjectSpec{
|
||||
OrphanedResources: &v1alpha1.OrphanedResourcesMonitorSettings{
|
||||
Warn: ptr.To(true),
|
||||
Warn: new(true),
|
||||
Ignore: []v1alpha1.OrphanedResourceKey{{Group: "group", Kind: "kind", Name: "name"}},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
fileutil "github.com/argoproj/argo-cd/v3/test/fixture/path"
|
||||
|
|
@ -146,25 +145,25 @@ func Test_GetAppRefreshPaths(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "single source without annotation",
|
||||
app: getApp(nil, ptr.To("source/path")),
|
||||
app: getApp(nil, new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{},
|
||||
},
|
||||
{
|
||||
name: "single source with annotation",
|
||||
app: getApp(ptr.To(".;dev/deploy;other/path"), ptr.To("source/path")),
|
||||
app: getApp(new(".;dev/deploy;other/path"), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{"source/path", "source/path/dev/deploy", "source/path/other/path"},
|
||||
},
|
||||
{
|
||||
name: "single source with empty annotation",
|
||||
app: getApp(ptr.To(".;;"), ptr.To("source/path")),
|
||||
app: getApp(new(".;;"), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{"source/path"},
|
||||
},
|
||||
{
|
||||
name: "single source with absolute path annotation",
|
||||
app: getApp(ptr.To("/fullpath/deploy;other/path"), ptr.To("source/path")),
|
||||
app: getApp(new("/fullpath/deploy;other/path"), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{"fullpath/deploy", "source/path/other/path"},
|
||||
},
|
||||
|
|
@ -182,19 +181,19 @@ func Test_GetAppRefreshPaths(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "source hydrator sync source with annotation",
|
||||
app: getSourceHydratorApp(ptr.To("deploy"), "dry/path", "sync/path"),
|
||||
app: getSourceHydratorApp(new("deploy"), "dry/path", "sync/path"),
|
||||
source: v1alpha1.ApplicationSource{Path: "sync/path"},
|
||||
expectedPaths: []string{"sync/path"},
|
||||
},
|
||||
{
|
||||
name: "source hydrator dry source with annotation",
|
||||
app: getSourceHydratorApp(ptr.To("deploy"), "dry/path", "sync/path"),
|
||||
app: getSourceHydratorApp(new("deploy"), "dry/path", "sync/path"),
|
||||
source: v1alpha1.ApplicationSource{Path: "dry/path"},
|
||||
expectedPaths: []string{"dry/path/deploy"},
|
||||
},
|
||||
{
|
||||
name: "annotation paths with spaces after semicolon",
|
||||
app: getApp(ptr.To(".; dev/deploy; other/path"), ptr.To("source/path")),
|
||||
app: getApp(new(".; dev/deploy; other/path"), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{
|
||||
"source/path",
|
||||
|
|
@ -204,7 +203,7 @@ func Test_GetAppRefreshPaths(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "annotation paths with spaces before semicolon",
|
||||
app: getApp(ptr.To(". ;dev/deploy ;other/path"), ptr.To("source/path")),
|
||||
app: getApp(new(". ;dev/deploy ;other/path"), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{
|
||||
"source/path",
|
||||
|
|
@ -214,7 +213,7 @@ func Test_GetAppRefreshPaths(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "annotation paths with spaces around absolute path",
|
||||
app: getApp(ptr.To(" /fullpath/deploy ; other/path "), ptr.To("source/path")),
|
||||
app: getApp(new(" /fullpath/deploy ; other/path "), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{
|
||||
"fullpath/deploy",
|
||||
|
|
@ -223,7 +222,7 @@ func Test_GetAppRefreshPaths(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "annotation paths only spaces and separators",
|
||||
app: getApp(ptr.To(" ; ; . ; "), ptr.To("source/path")),
|
||||
app: getApp(new(" ; ; . ; "), new("source/path")),
|
||||
source: v1alpha1.ApplicationSource{Path: "source/path"},
|
||||
expectedPaths: []string{
|
||||
"source/path",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import (
|
|||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
appv1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -424,7 +423,7 @@ func SecretToCluster(s *corev1.Secret) (*appv1.Cluster, error) {
|
|||
if val, err := strconv.Atoi(string(shardStr)); err != nil {
|
||||
log.Warnf("Error while parsing shard in cluster secret '%s': %v", s.Name, err)
|
||||
} else {
|
||||
shard = ptr.To(int64(val))
|
||||
shard = new(int64(val))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,15 +4,13 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
)
|
||||
|
||||
// ListHelmRepositories lists configured helm repositories
|
||||
func (db *db) ListHelmRepositories(ctx context.Context) ([]*v1alpha1.Repository, error) {
|
||||
var result []*v1alpha1.Repository
|
||||
repos, err := db.listRepositories(ctx, ptr.To("helm"), false)
|
||||
repos, err := db.listRepositories(ctx, new("helm"), false)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list Helm repositories: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"hash/fnv"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
|
@ -193,7 +192,7 @@ func (db *db) listRepositories(ctx context.Context, repoType *string, writeCreds
|
|||
|
||||
func (db *db) ListOCIRepositories(ctx context.Context) ([]*v1alpha1.Repository, error) {
|
||||
var result []*v1alpha1.Repository
|
||||
repos, err := db.listRepositories(ctx, ptr.To("oci"), false)
|
||||
repos, err := db.listRepositories(ctx, new("oci"), false)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list OCI repositories: %w", err)
|
||||
}
|
||||
|
|
|
|||
11
util/env/env_test.go
vendored
11
util/env/env_test.go
vendored
|
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func TestParseNumFromEnv(t *testing.T) {
|
||||
|
|
@ -262,12 +261,12 @@ func TestStringFromEnv(t *testing.T) {
|
|||
def string
|
||||
opts []StringFromEnvOpts
|
||||
}{
|
||||
{"Some string", ptr.To("true"), "true", def, nil},
|
||||
{"Empty string with default", ptr.To(""), def, def, nil},
|
||||
{"Empty string without default", ptr.To(""), "", "", nil},
|
||||
{"Some string", new("true"), "true", def, nil},
|
||||
{"Empty string with default", new(""), def, def, nil},
|
||||
{"Empty string without default", new(""), "", "", nil},
|
||||
{"No env variable with default allow empty", nil, "default", "default", []StringFromEnvOpts{{AllowEmpty: true}}},
|
||||
{"Some variable with default allow empty", ptr.To("true"), "true", "default", []StringFromEnvOpts{{AllowEmpty: true}}},
|
||||
{"Empty variable with default allow empty", ptr.To(""), "", "default", []StringFromEnvOpts{{AllowEmpty: true}}},
|
||||
{"Some variable with default allow empty", new("true"), "true", "default", []StringFromEnvOpts{{AllowEmpty: true}}},
|
||||
{"Empty variable with default allow empty", new(""), "", "default", []StringFromEnvOpts{{AllowEmpty: true}}},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
informersv1 "k8s.io/client-go/informers/core/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/common"
|
||||
appv1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
|
|
@ -196,7 +195,7 @@ func secretToCluster(s *corev1.Secret) (*appv1.Cluster, error) {
|
|||
if val, err := strconv.Atoi(string(shardStr)); err != nil {
|
||||
log.Warnf("Error while parsing shard in cluster secret '%s': %v", s.Name, err)
|
||||
} else {
|
||||
shard = ptr.To(int64(val))
|
||||
shard = new(int64(val))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue