Compare commits

..

1 Commits

Author SHA1 Message Date
salatamartin
64b2218915 Merge pull request #4 from ysoftdevs/maintenance/deps
Maintenance/deps
2022-06-09 17:28:17 +02:00
5 changed files with 24 additions and 57 deletions

View File

@@ -67,10 +67,6 @@ test:
# build section
############################################################
vendor:
@echo "Vendoring..."
@go mod vendor
build:
@echo "Building the $(IMAGE_NAME) binary..."
@CGO_ENABLED=0 go build -o build/_output/bin/$(IMAGE_NAME) ./cmd/
@@ -80,39 +76,10 @@ build-linux:
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/_output/linux/bin/$(IMAGE_NAME) ./cmd/
############################################################
# Containerd image section
# image section
############################################################
containerd-image: containerd-login containerd-image containerd-image
containerd-login:
@echo "$(DOCKER_TOKEN)" | nerdctl login -u "$(DOCKER_USER)" --password-stdin "$(REPOSITORY_BASE)"
containerd-logout:
@docker logout
containerd-build:
@echo "Building the docker image: $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)..."
@nerdctl build -t $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) -f build/Dockerfile .
@echo "Building the docker image: $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG)..."
@nerdctl build -t $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG) -f build/Dockerfile.cert-generator .
containerd-push: containerd-build-image
@echo "Pushing the docker image for $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) and $(IMAGE_REPO)/$(IMAGE_NAME):latest..."
@nerdctl tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_REPO)/$(IMAGE_NAME):latest
@nerdctl push $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
@nerdctl push $(IMAGE_REPO)/$(IMAGE_NAME):latest
@echo "Pushing the docker image for $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG) and $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):latest..."
@nerdctl tag $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):latest
@nerdctl push $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG)
@nerdctl push $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):latest
############################################################
# Docker image section
############################################################
docker-image: docker-login docker-build docker-push
image: docker-login build-image push-image
docker-login:
@echo "$(DOCKER_TOKEN)" | docker login -u "$(DOCKER_USER)" --password-stdin "$(REPOSITORY_BASE)"
@@ -120,13 +87,13 @@ docker-login:
docker-logout:
@docker logout
docker-build:
build-image:
@echo "Building the docker image: $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)..."
@docker build -t $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) -f build/Dockerfile .
@echo "Building the docker image: $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG)..."
@docker build -t $(IMAGE_REPO)/$(GENERATOR_IMAGE_NAME):$(IMAGE_TAG) -f build/Dockerfile.cert-generator .
docker-push: docker-build
push-image: build-image
@echo "Pushing the docker image for $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) and $(IMAGE_REPO)/$(IMAGE_NAME):latest..."
@docker tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_REPO)/$(IMAGE_NAME):latest
@docker push $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
@@ -143,4 +110,4 @@ docker-push: docker-build
clean:
@rm -rf build/_output
.PHONY: all fmt lint check test build docker-image containerd-image clean
.PHONY: all fmt lint check test build image clean

View File

@@ -1 +1 @@
0.0.15
0.0.14

View File

@@ -2,7 +2,7 @@ FROM golang:1.17.10 AS builder
WORKDIR /go/src/github.com/ysoftdevs/imagepullsecret-injector
COPY . .
RUN make vendor build
RUN make build
FROM alpine:3.15.4 as base
COPY --from=builder /go/src/github.com/ysoftdevs/imagepullsecret-injector/build/_output/bin/imagepullsecret-injector /usr/local/bin/imagepullsecret-injector

View File

@@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.26
version: 0.0.25
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 0.0.25
appVersion: 0.0.14

View File

@@ -236,24 +236,11 @@ func (whsvr *WebhookServer) mutateServiceAccount(ar *v1beta1.AdmissionReview) *v
}
}
// Make sure the secrets are present
if err := whsvr.ensureSecrets(ar); err != nil {
whsvr.logger.Errorf("Could not ensure existence of the imagePullSecret")
if !whsvr.config.ignoreSecretCreationError {
whsvr.logger.Errorf("Failing the mutation process")
return &v1beta1.AdmissionResponse{
Result: &metav1.Status{
Message: err.Error(),
},
}
}
whsvr.logger.Infof("ignoreSecretCreationError is true, ignoring")
}
// Check whether we already have the imagePullSecretName present
if sa.ImagePullSecrets != nil {
whsvr.logger.Infof("ServiceAccount is already in the correct state, skipping")
for _, lor := range sa.ImagePullSecrets {
if whsvr.config.targetImagePullSecretName == lor.Name {
whsvr.logger.Infof("ServiceAccount is already in the correct state, skipping the patch")
return &v1beta1.AdmissionResponse{
Allowed: true,
}
@@ -275,6 +262,19 @@ func (whsvr *WebhookServer) mutateServiceAccount(ar *v1beta1.AdmissionReview) *v
}
}
if err := whsvr.ensureSecrets(ar); err != nil {
whsvr.logger.Errorf("Could not ensure existence of the imagePullSecret")
if !whsvr.config.ignoreSecretCreationError {
whsvr.logger.Errorf("Failing the mutation process")
return &v1beta1.AdmissionResponse{
Result: &metav1.Status{
Message: err.Error(),
},
}
}
whsvr.logger.Infof("ignoreSecretCreationError is true, ignoring")
}
return &v1beta1.AdmissionResponse{
Allowed: true,
Patch: patchBytes,