-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add handling of incorrect docker hub URLs #295
Conversation
Signed-off-by: alexey.komyakov <[email protected]>
Signed-off-by: alexey.komyakov <[email protected]>
Signed-off-by: alexey.komyakov <[email protected]>
pkg/providers/k8s/k8s.go
Outdated
if secret.Type != corev1.SecretTypeDockerConfigJson { | ||
continue | ||
} | ||
|
||
data, exists := secret.Data[corev1.DockerConfigJsonKey] | ||
if !exists { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two types of docker secrets. We have to cover both:
// SecretTypeDockercfg contains a dockercfg file that follows the same format rules as ~/.dockercfg
//
// Required fields:
// - Secret.Data[".dockercfg"] - a serialized ~/.dockercfg file
SecretTypeDockercfg SecretType = "kubernetes.io/dockercfg"
// DockerConfigKey is the key of the required data for SecretTypeDockercfg secrets
DockerConfigKey = ".dockercfg"
// SecretTypeDockerConfigJson contains a dockercfg file that follows the same format rules as ~/.docker/config.json
//
// Required fields:
// - Secret.Data[".dockerconfigjson"] - a serialized ~/.docker/config.json file
SecretTypeDockerConfigJson SecretType = "kubernetes.io/dockerconfigjson"
// DockerConfigJsonKey is the key of the required data for SecretTypeDockerConfigJson secrets
DockerConfigJsonKey = ".dockerconfigjson"
pkg/providers/k8s/k8s.go
Outdated
return secrets, nil | ||
} | ||
|
||
func parseDockerConfig(data []byte) (map[string]interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave a comment with the example of data.
pkg/providers/k8s/k8s.go
Outdated
} | ||
|
||
func updateDockerRegistryAuths(dockerConfig map[string]interface{}) error { | ||
auths, ok := dockerConfig["auths"].(map[string]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In "kubernetes.io/dockercfg" there is no auth, we have to parse these two types differently.
pkg/providers/k8s/k8s.go
Outdated
} | ||
|
||
func parseDockerConfig(data []byte) (map[string]interface{}, error) { | ||
var dockerConfig map[string]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: it is better to use map[string]json.RawMessage
Signed-off-by: alexey.komyakov <[email protected]>
Signed-off-by: alexey.komyakov <[email protected]>
Because of incorrect registry url of docker hub in imagePullSecret we receiving alerts that images are unavailable and 401 UNAUTHORIZED in app logs.
Example of incorrect creds:
Correct way: