Skip to content
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

[0.6] Make sure to update the name in the mutator #535

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/resources/management.cattle.io/v3/project/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ func (m *Mutator) createProjectNamespace(project *v3.Project) (*v3.Project, erro
// for the backing namespace, we need to generate it ourselves
if project.Name == "" {
// If err is nil, (meaning "project exists", see below) we need to repeat the generation process to find a project name and backing namespace that isn't taken
var newName string
for err == nil {
newName := names.SimpleNameGenerator.GenerateName(project.GenerateName)
newName = names.SimpleNameGenerator.GenerateName(project.GenerateName)
JonCrowther marked this conversation as resolved.
Show resolved Hide resolved
_, err = m.projectClient.Get(newProject.Spec.ClusterName, newName, v1.GetOptions{})
if err == nil {
// A project with this name already exists. Generate a new name.
Expand All @@ -144,6 +145,7 @@ func (m *Mutator) createProjectNamespace(project *v3.Project) (*v3.Project, erro
return nil, err
}
}
newProject.Name = newName
} else {
backingNamespace = name.SafeConcatName(newProject.Spec.ClusterName, strings.ToLower(newProject.Name))
_, err = m.namespaceClient.Get(backingNamespace, v1.GetOptions{})
Expand Down