Skip to content

Commit 8f6b03b

Browse files
committed
fix: apply CR suggestions
1 parent 4c64068 commit 8f6b03b

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
FROM alpine:3.16.3
99
RUN ["apk", "add", "--no-cache", "--repository=http://dl-cdn.alpinelinux.org/alpine/edge/community", "skopeo>=1.2.0"]
1010

11-
COPY k8s-image-swapper /
11+
ARG TARGETARCH
12+
COPY k8s-image-swapper-$TARGETARCH /k8s-image-swapper
1213

1314
ENTRYPOINT ["/k8s-image-swapper"]
1415

cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ A mutating webhook for Kubernetes, pointing the images to a new location.`,
6363
//metricsRec := metrics.NewPrometheus(promReg)
6464
log.Trace().Interface("config", cfg).Msg("config")
6565

66-
rClient, err := registry.NewECRClient(cfg.Target.AWS.Region, cfg.Target.AWS.EcrDomain(), cfg.Target.AWS.AccountID, cfg.Target.AWS.Role, cfg.Target.AWS.AccessPolicy, cfg.Target.AWS.LifecyclePolicy, cfg.RepositoryCustomTags)
66+
rClient, err := registry.NewECRClient(cfg.Target.AWS.Region, cfg.Target.AWS.EcrDomain(), cfg.Target.AWS.AccountID, cfg.Target.AWS.Role, cfg.Target.AWS.AccessPolicy, cfg.Target.AWS.LifecyclePolicy)
6767
if err != nil {
6868
log.Err(err).Msg("error connecting to registry client")
6969
os.Exit(1)
7070
}
7171

72+
rClient.SetRepositoryCustomTags(cfg.RepositoryCustomTags)
73+
7274
imageSwapPolicy, err := types.ParseImageSwapPolicy(cfg.ImageSwapPolicy)
7375
if err != nil {
7476
log.Err(err)

pkg/registry/ecr.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ func (e *ECRClient) CreateRepository(name string) error {
9999
return nil
100100
}
101101

102+
func (e *ECRClient) SetRepositoryCustomTags(tags []config.CustomTag) {
103+
e.customTags = tags
104+
}
105+
102106
func (e *ECRClient) buildEcrTags() []*ecr.Tag {
103107
ecrTags := []*ecr.Tag{
104108
{
@@ -196,7 +200,7 @@ func (e *ECRClient) scheduleTokenRenewal() error {
196200
return nil
197201
}
198202

199-
func NewECRClient(region string, ecrDomain string, targetAccount string, role string, accessPolicy string, lifecyclePolicy string, ecrCustomTags []config.CustomTag) (*ECRClient, error) {
203+
func NewECRClient(region string, ecrDomain string, targetAccount string, role string, accessPolicy string, lifecyclePolicy string) (*ECRClient, error) {
200204
var sess *session.Session
201205
var config *aws.Config
202206
if role != "" {
@@ -245,7 +249,6 @@ func NewECRClient(region string, ecrDomain string, targetAccount string, role st
245249
targetAccount: targetAccount,
246250
accessPolicy: accessPolicy,
247251
lifecyclePolicy: lifecyclePolicy,
248-
customTags: ecrCustomTags,
249252
}
250253

251254
if err := client.scheduleTokenRenewal(); err != nil {

0 commit comments

Comments
 (0)