Skip to content

Commit 1a998b1

Browse files
Move references for kube, image, registry to registry-scanner (#998)
Signed-off-by: Ishita Sequeira <[email protected]>
1 parent 9a20452 commit 1a998b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+248
-5892
lines changed

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type ImageUpdaterConfig struct {
3535
CheckInterval time.Duration
3636
ArgoClient argocd.ArgoCD
3737
LogLevel string
38-
KubeClient *kube.KubernetesClient
38+
KubeClient *kube.ImageUpdaterKubernetesClient
3939
MaxConcurrency int
4040
HealthPort int
4141
MetricsPort int

cmd/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
1515
"github.com/argoproj-labs/argocd-image-updater/pkg/health"
1616
"github.com/argoproj-labs/argocd-image-updater/pkg/metrics"
17-
"github.com/argoproj-labs/argocd-image-updater/pkg/registry"
1817
"github.com/argoproj-labs/argocd-image-updater/pkg/version"
1918
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/env"
2019
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
20+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/registry"
2121

2222
"github.com/argoproj/argo-cd/v2/reposerver/askpass"
2323

@@ -115,7 +115,7 @@ func newRunCommand() *cobra.Command {
115115
log.Fatalf("could not create K8s client: %v", err)
116116
}
117117
if cfg.ClientOpts.ServerAddr == "" {
118-
cfg.ClientOpts.ServerAddr = fmt.Sprintf("argocd-server.%s", cfg.KubeClient.Namespace)
118+
cfg.ClientOpts.ServerAddr = fmt.Sprintf("argocd-server.%s", cfg.KubeClient.KubeClient.Namespace)
119119
}
120120
}
121121
if cfg.ClientOpts.ServerAddr == "" {

cmd/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/argoproj-labs/argocd-image-updater/pkg/argocd"
1010
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
11-
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
11+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
1212
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/tag"
1313

1414
"github.com/spf13/cobra"

cmd/test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"fmt"
66
"runtime"
77

8-
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
98
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
10-
"github.com/argoproj-labs/argocd-image-updater/pkg/registry"
9+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
1110
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
1211
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/options"
12+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/registry"
1313

1414
"github.com/spf13/cobra"
1515
"github.com/spf13/pflag"
@@ -64,7 +64,7 @@ argocd-image-updater test nginx --allow-tags '^1.19.\d+(\-.*)*$' --update-strate
6464
log.Fatalf("could not set log level to %s: %v", logLevel, err)
6565
}
6666

67-
var kubeClient *kube.KubernetesClient
67+
var kubeClient *kube.ImageUpdaterKubernetesClient
6868
var err error
6969
if !disableKubernetes {
7070
ctx := context.Background()
@@ -118,7 +118,7 @@ argocd-image-updater test nginx --allow-tags '^1.19.\d+(\-.*)*$' --update-strate
118118
logCtx.Fatalf("could not get registry endpoint: %v", err)
119119
}
120120

121-
if err := ep.SetEndpointCredentials(kubeClient); err != nil {
121+
if err := ep.SetEndpointCredentials(kubeClient.KubeClient); err != nil {
122122
logCtx.Fatalf("could not set registry credentials: %v", err)
123123
}
124124

@@ -138,7 +138,7 @@ argocd-image-updater test nginx --allow-tags '^1.19.\d+(\-.*)*$' --update-strate
138138
if err != nil {
139139
logCtx.Fatalf("could not parse credential definition '%s': %v", credentials, err)
140140
}
141-
creds, err = credSrc.FetchCredentials(ep.RegistryAPI, kubeClient)
141+
creds, err = credSrc.FetchCredentials(ep.RegistryAPI, kubeClient.KubeClient)
142142
if err != nil {
143143
logCtx.Fatalf("could not fetch credentials: %v", err)
144144
}

cmd/util.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
10+
registryKube "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/kube"
1011
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
1112
)
1213

@@ -26,9 +27,9 @@ func getPrintableHealthPort(port int) string {
2627
}
2728
}
2829

29-
func getKubeConfig(ctx context.Context, namespace string, kubeConfig string) (*kube.KubernetesClient, error) {
30+
func getKubeConfig(ctx context.Context, namespace string, kubeConfig string) (*kube.ImageUpdaterKubernetesClient, error) {
3031
var fullKubeConfigPath string
31-
var kubeClient *kube.KubernetesClient
32+
var kubeClient *kube.ImageUpdaterKubernetesClient
3233
var err error
3334

3435
if kubeConfig != "" {
@@ -44,10 +45,13 @@ func getKubeConfig(ctx context.Context, namespace string, kubeConfig string) (*k
4445
log.Debugf("Creating in-cluster Kubernetes client")
4546
}
4647

47-
kubeClient, err = kube.NewKubernetesClientFromConfig(ctx, namespace, fullKubeConfigPath)
48+
kubernetesClient, err := registryKube.NewKubernetesClientFromConfig(ctx, namespace, fullKubeConfigPath)
4849
if err != nil {
4950
return nil, err
5051
}
52+
kubeClient = &kube.ImageUpdaterKubernetesClient{
53+
KubeClient: kubernetesClient,
54+
}
5155

5256
return kubeClient, nil
5357
}

cmd/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestGetKubeConfig(t *testing.T) {
4747
} else {
4848
require.NoError(t, err)
4949
assert.NotNil(t, client)
50-
assert.Equal(t, tt.expectedNS, client.Namespace)
50+
assert.Equal(t, tt.expectedNS, client.KubeClient.Namespace)
5151
}
5252
})
5353
}

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ go 1.22.0
55
toolchain go1.23.0
66

77
require (
8-
github.com/Masterminds/semver/v3 v3.3.1
9-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20241218013735-14e60b8a83a4
8+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250106213822-5ae9a451b57d
109
github.com/argoproj/argo-cd/v2 v2.13.1
1110
github.com/argoproj/gitops-engine v0.7.1-0.20240905010810-bd7681ae3f8b
1211
github.com/argoproj/pkg v0.13.7-0.20230627120311-a4dd357b057e
@@ -15,8 +14,6 @@ require (
1514
github.com/distribution/distribution/v3 v3.0.0-20230722181636-7b502560cad4
1615
github.com/go-git/go-git/v5 v5.13.0
1716
github.com/google/uuid v1.6.0
18-
github.com/opencontainers/go-digest v1.0.0
19-
github.com/opencontainers/image-spec v1.1.0
2017
github.com/patrickmn/go-cache v2.1.0+incompatible
2118
github.com/prometheus/client_golang v1.20.5
2219
github.com/sirupsen/logrus v1.9.3
@@ -42,6 +39,7 @@ require (
4239
dario.cat/mergo v1.0.1 // indirect
4340
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
4441
github.com/MakeNowJust/heredoc v1.0.0 // indirect
42+
github.com/Masterminds/semver/v3 v3.3.1 // indirect
4543
github.com/Microsoft/go-winio v0.6.1 // indirect
4644
github.com/ProtonMail/go-crypto v1.1.3 // indirect
4745
github.com/benbjohnson/clock v1.3.0 // indirect
@@ -115,6 +113,8 @@ require (
115113
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
116114
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
117115
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
116+
github.com/opencontainers/go-digest v1.0.0 // indirect
117+
github.com/opencontainers/image-spec v1.1.0 // indirect
118118
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
119119
github.com/pjbgf/sha1cd v0.3.0 // indirect
120120
github.com/pkg/errors v0.9.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQ
2727
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
2828
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
2929
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
30-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20241218013735-14e60b8a83a4 h1:B6z7t09pdODcT4dJ2Rndata6+OFZOWjYlOXynyexFNc=
31-
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20241218013735-14e60b8a83a4/go.mod h1:GJD+hNHt9KbYFo1+OddD3vvqys7ct5ZIOx5yHFCBAXg=
30+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250106213822-5ae9a451b57d h1:Ut4/EiaiTDeuchus+bgq3pYu5nIgqMwpBI3+2Znw/VA=
31+
github.com/argoproj-labs/argocd-image-updater/registry-scanner v0.0.0-20250106213822-5ae9a451b57d/go.mod h1:GJD+hNHt9KbYFo1+OddD3vvqys7ct5ZIOx5yHFCBAXg=
3232
github.com/argoproj/argo-cd/v2 v2.13.1 h1:qoa8LD5suPCAYtoDNHp+BuqODf46hl5gCuXNj2oiAy0=
3333
github.com/argoproj/argo-cd/v2 v2.13.1/go.mod h1:RC23V2744nhZstZVpLCWTQLT2gR0+IXGC3GTBCI6M+I=
3434
github.com/argoproj/gitops-engine v0.7.1-0.20240905010810-bd7681ae3f8b h1:wOPWJ5MBScQO767WpU55oUJDXObfvPL0EfAYWxogbSw=

pkg/argocd/argocd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"time"
1010

1111
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
12-
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
1312
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
1413
"github.com/argoproj-labs/argocd-image-updater/pkg/metrics"
1514
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/env"
15+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
1616
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
1717

1818
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
@@ -24,7 +24,7 @@ import (
2424

2525
// Kubernetes based client
2626
type k8sClient struct {
27-
kubeClient *kube.KubernetesClient
27+
kubeClient *kube.ImageUpdaterKubernetesClient
2828
}
2929

3030
// GetApplication retrieves an application by name across all namespaces.
@@ -99,7 +99,7 @@ func (client *k8sClient) UpdateSpec(ctx context.Context, spec *application.Appli
9999
}
100100

101101
// NewK8SClient creates a new kubernetes client to interact with kubernetes api-server.
102-
func NewK8SClient(kubeClient *kube.KubernetesClient) (ArgoCD, error) {
102+
func NewK8SClient(kubeClient *kube.ImageUpdaterKubernetesClient) (ArgoCD, error) {
103103
return &k8sClient{kubeClient: kubeClient}, nil
104104
}
105105

pkg/argocd/argocd_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"testing"
88

99
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
10-
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
1110
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
11+
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
12+
registryKube "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/kube"
1213

1314
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
1415
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
@@ -1015,8 +1016,10 @@ func TestKubernetesClient(t *testing.T) {
10151016
ObjectMeta: v1.ObjectMeta{Name: "test-app2", Namespace: "testns2"},
10161017
}
10171018

1018-
client, err := NewK8SClient(&kube.KubernetesClient{
1019-
Namespace: "testns1",
1019+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
1020+
KubeClient: &registryKube.KubernetesClient{
1021+
Namespace: "testns1",
1022+
},
10201023
ApplicationsClientset: fake.NewSimpleClientset(app1, app2),
10211024
})
10221025

@@ -1057,7 +1060,7 @@ func TestKubernetesClient(t *testing.T) {
10571060
})
10581061

10591062
// Create the Kubernetes client
1060-
client, err := NewK8SClient(&kube.KubernetesClient{
1063+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
10611064
ApplicationsClientset: clientset,
10621065
})
10631066
require.NoError(t, err)
@@ -1087,7 +1090,7 @@ func TestKubernetesClient(t *testing.T) {
10871090
)
10881091

10891092
// Create the Kubernetes client
1090-
client, err := NewK8SClient(&kube.KubernetesClient{
1093+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
10911094
ApplicationsClientset: clientset,
10921095
})
10931096
require.NoError(t, err)
@@ -1117,7 +1120,7 @@ func TestKubernetesClientUpdateSpec(t *testing.T) {
11171120
}
11181121
})
11191122

1120-
client, err := NewK8SClient(&kube.KubernetesClient{
1123+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
11211124
ApplicationsClientset: clientset,
11221125
})
11231126
require.NoError(t, err)
@@ -1138,7 +1141,7 @@ func TestKubernetesClientUpdateSpec(t *testing.T) {
11381141
// Create a fake empty clientset
11391142
clientset := fake.NewSimpleClientset()
11401143

1141-
client, err := NewK8SClient(&kube.KubernetesClient{
1144+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
11421145
ApplicationsClientset: clientset,
11431146
})
11441147
require.NoError(t, err)
@@ -1162,7 +1165,7 @@ func TestKubernetesClientUpdateSpec(t *testing.T) {
11621165
Spec: v1alpha1.ApplicationSpec{},
11631166
})
11641167

1165-
client, err := NewK8SClient(&kube.KubernetesClient{
1168+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
11661169
ApplicationsClientset: clientset,
11671170
})
11681171
require.NoError(t, err)
@@ -1191,7 +1194,7 @@ func TestKubernetesClientUpdateSpec(t *testing.T) {
11911194
Spec: v1alpha1.ApplicationSpec{},
11921195
})
11931196

1194-
client, err := NewK8SClient(&kube.KubernetesClient{
1197+
client, err := NewK8SClient(&kube.ImageUpdaterKubernetesClient{
11951198
ApplicationsClientset: clientset,
11961199
})
11971200
require.NoError(t, err)

0 commit comments

Comments
 (0)