Skip to content

Commit

Permalink
fix: apply CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 committed Nov 22, 2022
1 parent 4c64068 commit 8f6b03b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
FROM alpine:3.16.3
RUN ["apk", "add", "--no-cache", "--repository=http://dl-cdn.alpinelinux.org/alpine/edge/community", "skopeo>=1.2.0"]

COPY k8s-image-swapper /
ARG TARGETARCH
COPY k8s-image-swapper-$TARGETARCH /k8s-image-swapper

ENTRYPOINT ["/k8s-image-swapper"]

Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ A mutating webhook for Kubernetes, pointing the images to a new location.`,
//metricsRec := metrics.NewPrometheus(promReg)
log.Trace().Interface("config", cfg).Msg("config")

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)
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)
if err != nil {
log.Err(err).Msg("error connecting to registry client")
os.Exit(1)
}

rClient.SetRepositoryCustomTags(cfg.RepositoryCustomTags)

imageSwapPolicy, err := types.ParseImageSwapPolicy(cfg.ImageSwapPolicy)
if err != nil {
log.Err(err)
Expand Down
7 changes: 5 additions & 2 deletions pkg/registry/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (e *ECRClient) CreateRepository(name string) error {
return nil
}

func (e *ECRClient) SetRepositoryCustomTags(tags []config.CustomTag) {
e.customTags = tags
}

func (e *ECRClient) buildEcrTags() []*ecr.Tag {
ecrTags := []*ecr.Tag{
{
Expand Down Expand Up @@ -196,7 +200,7 @@ func (e *ECRClient) scheduleTokenRenewal() error {
return nil
}

func NewECRClient(region string, ecrDomain string, targetAccount string, role string, accessPolicy string, lifecyclePolicy string, ecrCustomTags []config.CustomTag) (*ECRClient, error) {
func NewECRClient(region string, ecrDomain string, targetAccount string, role string, accessPolicy string, lifecyclePolicy string) (*ECRClient, error) {
var sess *session.Session
var config *aws.Config
if role != "" {
Expand Down Expand Up @@ -245,7 +249,6 @@ func NewECRClient(region string, ecrDomain string, targetAccount string, role st
targetAccount: targetAccount,
accessPolicy: accessPolicy,
lifecyclePolicy: lifecyclePolicy,
customTags: ecrCustomTags,
}

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

0 comments on commit 8f6b03b

Please sign in to comment.