Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ratulbasak/argo-cd into 15505-sca…
Browse files Browse the repository at this point in the history
…le-resources-in-ui
  • Loading branch information
ratulbasak committed Jan 7, 2025
2 parents 6389786 + fe8bab0 commit 4d71c6c
Show file tree
Hide file tree
Showing 224 changed files with 1,778 additions and 2,440 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/bump-major-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@ jobs:
run: |
hack/bump-major-version.sh
- name: Setup Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Create symlink in GOPATH
run: |
mkdir -p ~/go/src/github.com/argoproj
cp -a ../argo-cd ~/go/src/github.com/argoproj
- name: Add ~/go/bin to PATH
run: |
echo "/home/runner/go/bin" >> $GITHUB_PATH
- name: Add /usr/local/bin to PATH
run: |
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Download & vendor dependencies
run: |
# We need to vendor go modules for codegen yet
go mod download
go mod vendor -v
working-directory: /home/runner/go/src/github.com/argoproj/argo-cd
- name: Install toolchain for codegen
run: |
make install-codegen-tools-local
make install-go-tools-local
working-directory: /home/runner/go/src/github.com/argoproj/argo-cd
# We install kustomize in the dist directory
- name: Add dist to PATH
run: |
echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH
- name: Run codegen
run: |
set -x
export GOPATH=$(go env GOPATH)
make codegen-local
working-directory: /home/runner/go/src/github.com/argoproj/argo-cd

- name: Create pull request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
Expand Down
21 changes: 16 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ linters-settings:
disabled: true
# context.Context() should be the first parameter of a function when provided as argument.
- name: context-as-argument
disabled: true
disabled: false
arguments:
# Allow functions with test or bench signatures.
- allowTypesBefore: "*testing.T,testing.TB"
# Basic types should not be used as a key in `context.WithValue`
- name: context-keys-type
disabled: true
Expand Down Expand Up @@ -120,9 +123,11 @@ linters-settings:
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
- name: increment-decrement
disabled: false
# highlights redundant else-blocks that can be eliminated from the code
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
- name: indent-error-flow
disabled: true
disabled: false
arguments:
- "preserveScope"
# This rule suggests a shorter way of writing ranges that do not use the second value.
- name: range
disabled: false
Expand All @@ -132,23 +137,29 @@ linters-settings:
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
- name: redefines-builtin-id
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias
- name: redundant-import-alias
disabled: false
# redundant else-blocks that can be eliminated from the code.
- name: superfluous-else
disabled: false
# prevent confusing name for variables when using `time` package
arguments:
- "preserveScope"
# prevent confusing name for variables when using `time` package
- name: time-naming
disabled: true
# warns when an exported function or method returns a value of an un-exported type.
- name: unexported-return
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
disabled: false
# spots and proposes to remove unreachable code. also helps to spot errors
- name: unreachable-code
disabled: false
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
- name: unused-parameter
disabled: true
disabled: false
# Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any.
- name: use-any
disabled: false
Expand Down
42 changes: 21 additions & 21 deletions applicationset/controllers/applicationset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjs...).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

r := ApplicationSetReconciler{
Client: client,
Expand Down Expand Up @@ -1163,7 +1163,7 @@ func TestRemoveFinalizerOnInvalidDestination_FinalizerTypes(t *testing.T) {

objects := append([]runtime.Object{}, secret)
kubeclientset := kubefake.NewSimpleClientset(objects...)
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -1322,7 +1322,7 @@ func TestRemoveFinalizerOnInvalidDestination_DestinationTypes(t *testing.T) {

objects := append([]runtime.Object{}, secret)
kubeclientset := kubefake.NewSimpleClientset(objects...)
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -1409,7 +1409,7 @@ func TestRemoveOwnerReferencesOnDeleteAppSet(t *testing.T) {
initObjs := []crtclient.Object{&app, &appSet}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjs...).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

r := ApplicationSetReconciler{
Client: client,
Expand Down Expand Up @@ -1608,7 +1608,7 @@ func TestCreateApplications(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjs...).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

r := ApplicationSetReconciler{
Client: client,
Expand Down Expand Up @@ -1750,7 +1750,7 @@ func TestDeleteInCluster(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjs...).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

r := ApplicationSetReconciler{
Client: client,
Expand Down Expand Up @@ -1796,7 +1796,7 @@ func TestGetMinRequeueAfter(t *testing.T) {
require.NoError(t, err)

client := fake.NewClientBuilder().WithScheme(scheme).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

generator := v1alpha1.ApplicationSetGenerator{
List: &v1alpha1.ListGenerator{},
Expand Down Expand Up @@ -1867,7 +1867,7 @@ func TestRequeueGeneratorFails(t *testing.T) {
generatorMock.On("GenerateParams", &generator, mock.AnythingOfType("*v1alpha1.ApplicationSet"), mock.Anything).
Return([]map[string]any{}, errors.New("Simulated error generating params that could be related to an external service/API call"))

metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

r := ApplicationSetReconciler{
Client: client,
Expand Down Expand Up @@ -1919,7 +1919,7 @@ func TestValidateGeneratedApplications(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(myProject).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

// Test a subset of the validations that 'validateGeneratedApplications' performs
for _, cc := range []struct {
Expand Down Expand Up @@ -2123,7 +2123,7 @@ func TestReconcilerValidationProjectErrorBehaviour(t *testing.T) {
kubeclientset := kubefake.NewSimpleClientset()

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &project).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2322,7 +2322,7 @@ func TestSetApplicationSetStatusCondition(t *testing.T) {

for _, testCase := range testCases {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&testCase.appset).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).WithStatusSubresource(&testCase.appset).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2411,7 +2411,7 @@ func applicationsUpdateSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
kubeclientset := kubefake.NewSimpleClientset(objects...)

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2587,7 +2587,7 @@ func applicationsDeleteSyncPolicyTest(t *testing.T, applicationsSyncPolicy v1alp
kubeclientset := kubefake.NewSimpleClientset(objects...)

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2776,7 +2776,7 @@ func TestPolicies(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&appSet, &defaultProject).WithStatusSubresource(&appSet).WithIndex(&v1alpha1.Application{}, ".metadata.controller", appControllerIndexer).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2935,7 +2935,7 @@ func TestSetApplicationSetApplicationStatus(t *testing.T) {
} {
t.Run(cc.name, func(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -2966,7 +2966,7 @@ func TestBuildAppDependencyList(t *testing.T) {
require.NoError(t, err)

client := fake.NewClientBuilder().WithScheme(scheme).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

for _, cc := range []struct {
name string
Expand Down Expand Up @@ -3722,7 +3722,7 @@ func TestBuildAppSyncMap(t *testing.T) {
require.NoError(t, err)

client := fake.NewClientBuilder().WithScheme(scheme).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

for _, cc := range []struct {
name string
Expand Down Expand Up @@ -5312,7 +5312,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -6062,7 +6062,7 @@ func TestUpdateApplicationSetApplicationStatusProgress(t *testing.T) {
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&cc.appSet).WithStatusSubresource(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -6274,7 +6274,7 @@ func TestUpdateResourceStatus(t *testing.T) {
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)

client := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(&cc.appSet).WithObjects(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down Expand Up @@ -6365,7 +6365,7 @@ func TestResourceStatusAreOrdered(t *testing.T) {
kubeclientset := kubefake.NewSimpleClientset([]runtime.Object{}...)

client := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(&cc.appSet).WithObjects(&cc.appSet).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()

argodb := db.NewDB("argocd", settings.NewSettingsManager(context.TODO(), kubeclientset, "argocd"), kubeclientset)

Expand Down
4 changes: 2 additions & 2 deletions applicationset/controllers/requeue_after_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestRequeueAfter(t *testing.T) {
scmConfig := generators.NewSCMConfig("", []string{""}, true, nil, true)
terminalGenerators := map[string]generators.Generator{
"List": generators.NewListGenerator(),
"Clusters": generators.NewClusterGenerator(k8sClient, ctx, appClientset, "argocd"),
"Clusters": generators.NewClusterGenerator(ctx, k8sClient, appClientset, "argocd"),
"Git": generators.NewGitGenerator(mockServer, "namespace"),
"SCMProvider": generators.NewSCMProviderGenerator(fake.NewClientBuilder().WithObjects(&corev1.Secret{}).Build(), scmConfig),
"ClusterDecisionResource": generators.NewDuckTypeGenerator(ctx, fakeDynClient, appClientset, "argocd"),
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestRequeueAfter(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).Build()
metrics := appsetmetrics.NewFakeAppsetMetrics(client)
metrics := appsetmetrics.NewFakeAppsetMetrics()
r := ApplicationSetReconciler{
Client: client,
Scheme: scheme,
Expand Down
2 changes: 1 addition & 1 deletion applicationset/generators/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ClusterGenerator struct {

var render = &utils.Render{}

func NewClusterGenerator(c client.Client, ctx context.Context, clientset kubernetes.Interface, namespace string) Generator {
func NewClusterGenerator(ctx context.Context, c client.Client, clientset kubernetes.Interface, namespace string) Generator {
settingsManager := settings.NewSettingsManager(ctx, clientset, namespace)

g := &ClusterGenerator{
Expand Down
4 changes: 2 additions & 2 deletions applicationset/generators/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func TestGenerateParams(t *testing.T) {
testCase.clientError,
}

clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
clusterGenerator := NewClusterGenerator(context.Background(), cl, appClientset, "namespace")

applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -853,7 +853,7 @@ func TestGenerateParamsGoTemplate(t *testing.T) {
testCase.clientError,
}

clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
clusterGenerator := NewClusterGenerator(context.Background(), cl, appClientset, "namespace")

applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion applicationset/generators/generator_spec_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func getMockClusterGenerator() Generator {
appClientset := kubefake.NewSimpleClientset(runtimeClusters...)

fakeClient := fake.NewClientBuilder().WithObjects(clusters...).Build()
return NewClusterGenerator(fakeClient, context.Background(), appClientset, "namespace")
return NewClusterGenerator(context.Background(), fakeClient, appClientset, "namespace")
}

func getMockGitGenerator() Generator {
Expand Down
2 changes: 1 addition & 1 deletion applicationset/generators/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewListGenerator() Generator {
return g
}

func (g *ListGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration {
func (g *ListGenerator) GetRequeueAfter(_ *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration {
return NoRequeueAfter
}

Expand Down
3 changes: 1 addition & 2 deletions applicationset/generators/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ func (m *MatrixGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.Ap

if found {
return res
} else {
return NoRequeueAfter
}
return NoRequeueAfter
}

func getMatrixGenerator(r argoprojiov1alpha1.ApplicationSetNestedGenerator) (*argoprojiov1alpha1.MatrixGenerator, error) {
Expand Down
4 changes: 2 additions & 2 deletions applicationset/generators/matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func TestInterpolatedMatrixGenerate(t *testing.T) {
fakeClient,
testCase.clientError,
}
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
clusterGenerator := NewClusterGenerator(context.Background(), cl, appClientset, "namespace")

for _, g := range testCaseCopy.baseGenerators {
gitGeneratorSpec := v1alpha1.ApplicationSetGenerator{
Expand Down Expand Up @@ -827,7 +827,7 @@ func TestInterpolatedMatrixGenerateGoTemplate(t *testing.T) {
fakeClient,
testCase.clientError,
}
clusterGenerator := NewClusterGenerator(cl, context.Background(), appClientset, "namespace")
clusterGenerator := NewClusterGenerator(context.Background(), cl, appClientset, "namespace")

for _, g := range testCaseCopy.baseGenerators {
gitGeneratorSpec := v1alpha1.ApplicationSetGenerator{
Expand Down
3 changes: 1 addition & 2 deletions applicationset/generators/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ func (m *MergeGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.App

if found {
return res
} else {
return NoRequeueAfter
}
return NoRequeueAfter
}

func getMergeGenerator(r argoprojiov1alpha1.ApplicationSetNestedGenerator) (*argoprojiov1alpha1.MergeGenerator, error) {
Expand Down
Loading

0 comments on commit 4d71c6c

Please sign in to comment.