Skip to content

Commit 01aa322

Browse files
authored
Merge pull request #2620 from devspace-sh/alexandra/devspace-init-lowercase-registry-username
Added Validation Regex and Message to the user provided registry username
2 parents fe6df28 + 066263b commit 01aa322

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/devspace/configure/image.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ func (m *manager) AddImage(imageName, image, projectNamespace, dockerfile string
172172
registryHostname = generator.GithubContainerRegistry
173173
} else {
174174
registryHostname, err = m.log.Question(&survey.QuestionOptions{
175-
Question: "Please provide the registry hostname without the image path (e.g. gcr.io, ghcr.io, ecr.io)",
176-
DefaultValue: "gcr.io",
175+
Question: "Please provide the registry hostname without the image path (e.g. gcr.io, ghcr.io, ecr.io)",
176+
DefaultValue: "gcr.io",
177+
ValidationRegexPattern: "^[^A-Z\\s]+\\.[^A-Z\\s]+$",
178+
ValidationMessage: "Error parsing registry username: must only include lowercase letters.",
177179
})
178180
if err != nil {
179181
return err
@@ -264,12 +266,13 @@ func (m *manager) addPullSecretConfig(dockerClient docker.Client, image string)
264266

265267
registryUsername, err = m.log.Question(&survey.QuestionOptions{
266268
Question: usernameQuestion,
267-
ValidationRegexPattern: "^.*$",
269+
ValidationRegexPattern: "^[^A-Z\\s]+\\.[^A-Z\\s]+$",
270+
ValidationMessage: "Error parsing registry username: must only include lowercase letters.",
268271
})
272+
269273
if err != nil {
270274
return "", err
271275
}
272-
273276
if registryUsername != "" {
274277
registryPassword, err = m.log.Question(&survey.QuestionOptions{
275278
Question: passwordQuestion,

0 commit comments

Comments
 (0)