Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up repeated package import #13543

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions applicationset/services/repo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
repoapiclient "github.com/argoproj/argo-cd/v2/reposerver/apiclient"
"github.com/argoproj/argo-cd/v2/util/db"
"github.com/argoproj/argo-cd/v2/util/git"
"github.com/argoproj/argo-cd/v2/util/io"
Expand All @@ -22,7 +21,7 @@ type argoCDService struct {
repositoriesDB RepositoryDB
storecreds git.CredsStore
submoduleEnabled bool
repoServerClientSet repoapiclient.Clientset
repoServerClientSet apiclient.Clientset
}

type Repos interface {
Expand All @@ -34,7 +33,7 @@ type Repos interface {
GetDirectories(ctx context.Context, repoURL string, revision string) ([]string, error)
}

func NewArgoCDService(db db.ArgoDB, submoduleEnabled bool, repoClientset repoapiclient.Clientset) (Repos, error) {
func NewArgoCDService(db db.ArgoDB, submoduleEnabled bool, repoClientset apiclient.Clientset) (Repos, error) {
return &argoCDService{
repositoriesDB: db.(RepositoryDB),
submoduleEnabled: submoduleEnabled,
Expand Down
99 changes: 49 additions & 50 deletions applicationset/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"

argoappsetv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
argoappsv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
)

Expand Down Expand Up @@ -528,7 +527,7 @@ func TestRenderTemplateParamsFinalizers(t *testing.T) {

for _, c := range []struct {
testName string
syncPolicy *argoappsetv1.ApplicationSetSyncPolicy
syncPolicy *argoappsv1.ApplicationSetSyncPolicy
existingFinalizers []string
expectedFinalizers []string
}{
Expand Down Expand Up @@ -567,21 +566,21 @@ func TestRenderTemplateParamsFinalizers(t *testing.T) {
{
testName: "non-nil sync policy should use standard finalizer",
existingFinalizers: nil,
syncPolicy: &argoappsetv1.ApplicationSetSyncPolicy{},
syncPolicy: &argoappsv1.ApplicationSetSyncPolicy{},
expectedFinalizers: []string{"resources-finalizer.argocd.argoproj.io"},
},
{
testName: "preserveResourcesOnDeletion should not have a finalizer",
existingFinalizers: nil,
syncPolicy: &argoappsetv1.ApplicationSetSyncPolicy{
syncPolicy: &argoappsv1.ApplicationSetSyncPolicy{
PreserveResourcesOnDeletion: true,
},
expectedFinalizers: nil,
},
{
testName: "user-specified finalizer should overwrite preserveResourcesOnDeletion",
existingFinalizers: []string{"resources-finalizer.argocd.argoproj.io/background"},
syncPolicy: &argoappsetv1.ApplicationSetSyncPolicy{
syncPolicy: &argoappsv1.ApplicationSetSyncPolicy{
PreserveResourcesOnDeletion: true,
},
expectedFinalizers: []string{"resources-finalizer.argocd.argoproj.io/background"},
Expand Down Expand Up @@ -615,27 +614,27 @@ func TestRenderTemplateParamsFinalizers(t *testing.T) {
func TestCheckInvalidGenerators(t *testing.T) {

scheme := runtime.NewScheme()
err := argoappsetv1.AddToScheme(scheme)
err := argoappsv1.AddToScheme(scheme)
assert.Nil(t, err)
err = argoappsv1.AddToScheme(scheme)
assert.Nil(t, err)

for _, c := range []struct {
testName string
appSet argoappsetv1.ApplicationSet
appSet argoappsv1.ApplicationSet
expectedMsg string
}{
{
testName: "invalid generator, without annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-app-set",
Namespace: "namespace",
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: &argoappsetv1.ListGenerator{},
List: &argoappsv1.ListGenerator{},
Clusters: nil,
Git: nil,
},
Expand All @@ -647,7 +646,7 @@ func TestCheckInvalidGenerators(t *testing.T) {
{
List: nil,
Clusters: nil,
Git: &argoappsetv1.GitGenerator{},
Git: &argoappsv1.GitGenerator{},
},
},
},
Expand All @@ -656,7 +655,7 @@ func TestCheckInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generator, with annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-app-set",
Namespace: "namespace",
Expand All @@ -673,10 +672,10 @@ func TestCheckInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: &argoappsetv1.ListGenerator{},
List: &argoappsv1.ListGenerator{},
Clusters: nil,
Git: nil,
},
Expand All @@ -688,7 +687,7 @@ func TestCheckInvalidGenerators(t *testing.T) {
{
List: nil,
Clusters: nil,
Git: &argoappsetv1.GitGenerator{},
Git: &argoappsv1.GitGenerator{},
},
{
List: nil,
Expand Down Expand Up @@ -719,20 +718,20 @@ func TestCheckInvalidGenerators(t *testing.T) {
func TestInvalidGenerators(t *testing.T) {

scheme := runtime.NewScheme()
err := argoappsetv1.AddToScheme(scheme)
err := argoappsv1.AddToScheme(scheme)
assert.Nil(t, err)
err = argoappsv1.AddToScheme(scheme)
assert.Nil(t, err)

for _, c := range []struct {
testName string
appSet argoappsetv1.ApplicationSet
appSet argoappsv1.ApplicationSet
expectedInvalid bool
expectedNames map[string]bool
}{
{
testName: "valid generators, with annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -748,22 +747,22 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: &argoappsetv1.ListGenerator{},
List: &argoappsv1.ListGenerator{},
Clusters: nil,
Git: nil,
},
{
List: nil,
Clusters: &argoappsetv1.ClusterGenerator{},
Clusters: &argoappsv1.ClusterGenerator{},
Git: nil,
},
{
List: nil,
Clusters: nil,
Git: &argoappsetv1.GitGenerator{},
Git: &argoappsv1.GitGenerator{},
},
},
},
Expand All @@ -773,13 +772,13 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generators, no annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: nil,
Expand All @@ -798,16 +797,16 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "valid and invalid generators, no annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: &argoappsetv1.ClusterGenerator{},
Clusters: &argoappsv1.ClusterGenerator{},
Git: nil,
},
{
Expand All @@ -818,7 +817,7 @@ func TestInvalidGenerators(t *testing.T) {
{
List: nil,
Clusters: nil,
Git: &argoappsetv1.GitGenerator{},
Git: &argoappsv1.GitGenerator{},
},
},
},
Expand All @@ -828,7 +827,7 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "valid and invalid generators, with annotation",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -845,11 +844,11 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: &argoappsetv1.ClusterGenerator{},
Clusters: &argoappsv1.ClusterGenerator{},
Git: nil,
},
{
Expand All @@ -860,7 +859,7 @@ func TestInvalidGenerators(t *testing.T) {
{
List: nil,
Clusters: nil,
Git: &argoappsetv1.GitGenerator{},
Git: &argoappsv1.GitGenerator{},
},
{
List: nil,
Expand All @@ -878,7 +877,7 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generator, annotation with missing spec",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -887,8 +886,8 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: nil,
Expand All @@ -902,7 +901,7 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generator, annotation with missing generators array",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -913,8 +912,8 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: nil,
Expand All @@ -928,7 +927,7 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generator, annotation with empty generators array",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -941,8 +940,8 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: nil,
Expand All @@ -956,7 +955,7 @@ func TestInvalidGenerators(t *testing.T) {
},
{
testName: "invalid generator, annotation with empty generator",
appSet: argoappsetv1.ApplicationSet{
appSet: argoappsv1.ApplicationSet{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
Expand All @@ -970,8 +969,8 @@ func TestInvalidGenerators(t *testing.T) {
}`,
},
},
Spec: argoappsetv1.ApplicationSetSpec{
Generators: []argoappsetv1.ApplicationSetGenerator{
Spec: argoappsv1.ApplicationSetSpec{
Generators: []argoappsv1.ApplicationSetGenerator{
{
List: nil,
Clusters: nil,
Expand Down
Loading