mirror of
https://github.com/ysoftdevs/imagepullsecret-injector.git
synced 2026-01-11 14:30:42 +01:00
Create proper secrets before checking whether the SA needs to be patched (in case the secret itself changed)
This commit is contained in:
@@ -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.25
|
||||
version: 0.0.26
|
||||
|
||||
# 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.14
|
||||
appVersion: 0.0.25
|
||||
|
||||
@@ -236,11 +236,24 @@ func (whsvr *WebhookServer) mutateServiceAccount(ar *v1beta1.AdmissionReview) *v
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether we already have the imagePullSecretName present
|
||||
// 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")
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
@@ -262,19 +275,6 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user