Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the NfsProvisioner controller against Helm value injection and moves Gcore API token handling away from plaintext CR fields toward Secret references, updating the controller, webhooks/CRDs, examples, and tests accordingly.
Changes:
- Pass Helm values as structured YAML (
ChartSpec.ValuesYaml) and sanitize the file share name before using it as a Kubernetes label value. - Add
spec.apiTokenSecretRef(SecretKeySelector) with webhook defaulting/validation, and resolve the API token from a Secret at reconcile time (keepingspec.apiTokenas a deprecated fallback). - Update CRD manifests, samples, README, and add envtest coverage for the injection regression + Secret-based token flow.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents Secret-based API token configuration and deprecates plaintext spec.apiToken. |
| pkg/gcoreclient/client.go | Updates client interface to accept an explicit API token argument. |
| internal/controller/nfsprovisioner_controller.go | Resolves API token from Secret, switches Helm values to YAML, and sanitizes label values. |
| internal/controller/nfsprovisioner_controller_test.go | Adds envtest regression verifying Helm injection resistance and label sanitization; uses Secret token. |
| go.mod | Promotes sigs.k8s.io/yaml to a direct dependency. |
| example/deploy/nfsprovisioner.yaml | Updates example to create a Secret and reference it via apiTokenSecretRef. |
| example/deploy/gcore-sfs-controller-install.yaml | Regenerates/install manifest CRD schema to include apiTokenSecretRef and deprecate apiToken. |
| config/samples/crd_v1_nfsprovisioner.yaml | Updates sample manifest to use Secret + apiTokenSecretRef. |
| config/crd/bases/crd.gcore-sfs-controller.io_nfsprovisioners.yaml | Updates CRD base schema to include apiTokenSecretRef and deprecate apiToken. |
| api/v1/zz_generated.deepcopy.go | Regenerates deepcopy methods for the new pointer field in spec. |
| api/v1/nfsprovisioner_webhook.go | Adds defaulting for Secret key + validates mutual exclusivity and presence of token config; fixes project error reporting. |
| api/v1/nfsprovisioner_webhook_test.go | Extends webhook tests to cover defaulting and new validation rules. |
| api/v1/nfsprovisioner_types.go | Adds DefaultAPITokenSecretKey and new spec field APITokenSecretRef; marks APIToken optional/deprecated. |
Files not reviewed (1)
- api/v1/zz_generated.deepcopy.go: Generated file
Suppressed comments (1)
internal/controller/nfsprovisioner_controller.go:223
- Same formatting issue here: %q is used with client.ObjectKey, which is not a string/rune/[]byte and will produce a %!q(...) formatting artifact. Prefer %s/%v for the Secret identifier.
token, found := secret.Data[key]
if !found || len(token) == 0 {
return "", fmt.Errorf("secret %q does not contain a non-empty key %q", secretName, key)
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+213
to
+215
| if err := r.Client.Get(ctx, secretName, &secret); err != nil { | ||
| return "", fmt.Errorf("get API token secret %q: %w", secretName, err) | ||
| } |
Comment on lines
+88
to
+98
| switch { | ||
| case r.Spec.APIToken == "" && r.Spec.APITokenSecretRef == nil: | ||
| allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("apiTokenSecretRef"), | ||
| "one of apiToken or apiTokenSecretRef must be set")) | ||
| case r.Spec.APIToken != "" && r.Spec.APITokenSecretRef != nil: | ||
| allErrs = append(allErrs, field.Forbidden(field.NewPath("spec").Child("apiToken"), | ||
| "apiToken and apiTokenSecretRef are mutually exclusive")) | ||
| case r.Spec.APITokenSecretRef != nil && r.Spec.APITokenSecretRef.Name == "": | ||
| allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("apiTokenSecretRef").Child("name"), | ||
| "secret name must be set")) | ||
| } |
daragok
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit 1 — 7a176a4 (ICM-50566, Helm value injection)
Commit 2 — c8cdf62 (ICM-50567, plaintext API token)
client (the FileShareLister interface now takes the token explicitly instead of reading it off the spec).
region value.
needed — the controller already has Secret read access.