Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JonCrowther committed Oct 30, 2024
1 parent 993da4d commit 72e6f00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ This admission webhook prevents the disabling or deletion of a NodeDriver if the
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.
The `BackingNamespace` field cannot be changed once set. Projects without the `BackingNamespace` field can have it added.

#### Protects system project

Expand Down Expand Up @@ -280,16 +280,16 @@ 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`.
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.
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.

Adds the authz.management.cattle.io/creator-role-bindings annotation.

#### On update

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.

## ProjectRoleTemplateBinding

Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/management.cattle.io/v3/project/Project.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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.
The `BackingNamespace` field cannot be changed once set. Projects without the `BackingNamespace` field can have it added.

### Protects system project

Expand Down Expand Up @@ -34,13 +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`.
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.
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.

Adds the authz.management.cattle.io/creator-role-bindings annotation.

### On update

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.
8 changes: 4 additions & 4 deletions pkg/resources/management.cattle.io/v3/project/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (m *Mutator) createProjectNamespace(project *v3.Project) (*v3.Project, erro
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)
return nil, fmt.Errorf("failed to create project: namespace %s already exists", backingNamespace)
} else if !apierrors.IsNotFound(err) {
return nil, err
}
Expand All @@ -158,9 +158,9 @@ func (m *Mutator) createProjectNamespace(project *v3.Project) (*v3.Project, erro
return newProject, nil
}

// 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.
func (m *Mutator) updateProjectNamespace(project *v3.Project) *v3.Project {
if project.Status.BackingNamespace != "" {
return project
Expand Down

0 comments on commit 72e6f00

Please sign in to comment.