-
Notifications
You must be signed in to change notification settings - Fork 62
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
[v0.6] Populate backing namespace field for projects #532
[v0.6] Populate backing namespace field for projects #532
Conversation
@@ -4,6 +4,9 @@ | |||
|
|||
ClusterName must be equal to the namespace, and must refer to an existing `management.cattle.io/v3.Cluster` object. In addition, users cannot update the field after creation. | |||
|
|||
### BackingNamespace validation | |||
The BackingNamespace field cannot be changed once set. Projects without the BackingNamespace field can have it added. |
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.
The BackingNamespace field cannot be changed once set. Projects without the BackingNamespace field can have it added. | |
The `BackingNamespace` field cannot be changed once set. Projects without the `BackingNamespace` field can have it added. |
@@ -31,4 +34,13 @@ If `field.cattle.io/no-creator-rbac` annotation is set, `field.cattle.io/creator | |||
|
|||
### On create | |||
|
|||
Populates the BackingNamespace field by concatenating `Project.ClusterName` and `Project.Name`. |
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.
Populates the BackingNamespace field by concatenating `Project.ClusterName` and `Project.Name`. | |
Populates the `BackingNamespace` field by concatenating `Project.ClusterName` and `Project.Name`. |
Populates the BackingNamespace field by concatenating `Project.ClusterName` and `Project.Name`. | ||
|
||
If the project is using a generated name (ie `GenerateName` is not empty), the generation happens within the mutating webhook. | ||
The reason for this is that the BackingNamespace is made up of the `Project.Name`, and name generation happens after mutating webhooks and before validating webhooks. |
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.
The reason for this is that the BackingNamespace is made up of the `Project.Name`, and name generation happens after mutating webhooks and before validating webhooks. | |
The reason for this is that the `BackingNamespace` is made up of the `Project.Name`, and name generation happens after mutating and before validating webhooks. |
|
||
### On update | ||
|
||
If the BackingNamespace field is empty, populate the BackingNamespace field with the project name. |
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.
If the BackingNamespace field is empty, populate the BackingNamespace field with the project name. | |
If the `BackingNamespace` field is empty, it's populated with the project name. |
backingNamespace = name.SafeConcatName(newProject.Spec.ClusterName, strings.ToLower(newProject.Name)) | ||
_, err = m.namespaceClient.Get(backingNamespace, v1.GetOptions{}) | ||
if err == nil { | ||
return nil, fmt.Errorf("failed to create project: namespace %v already exists", backingNamespace) |
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.
return nil, fmt.Errorf("failed to create project: namespace %v already exists", backingNamespace) | |
return nil, fmt.Errorf("failed to create project: namespace %s already exists", backingNamespace) |
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.
Q: Should we throw an error or just make it a no-op? 🤔
// updateProjectNamespace fills in BackingNamespace with the project name if it wasn't already set | ||
// this was the naming convention of project namespaces prior to using the BackingNamespace field. Filling | ||
// it here is just to maintain backwards compatibility |
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.
// updateProjectNamespace fills in BackingNamespace with the project name if it wasn't already set | |
// this was the naming convention of project namespaces prior to using the BackingNamespace field. Filling | |
// it here is just to maintain backwards compatibility | |
// updateProjectNamespace fills in BackingNamespace with the project name if it wasn't already set. | |
// This was the naming convention for project namespaces prior to using the BackingNamespace field. | |
// Filling it here is just to maintain backwards compatibility. |
Issue:
Builds on rancher/rancher#47723