Skip to content

feat(api): add CustomTemplate type and TemplatePhase enum (#565)#701

Merged
ArangoGutierrez merged 3 commits intoNVIDIA:mainfrom
ArangoGutierrez:feat/565-custom-template-types
Mar 4, 2026
Merged

feat(api): add CustomTemplate type and TemplatePhase enum (#565)#701
ArangoGutierrez merged 3 commits intoNVIDIA:mainfrom
ArangoGutierrez:feat/565-custom-template-types

Conversation

@ArangoGutierrez
Copy link
Collaborator

Summary

  • Add CustomTemplate struct with inline/file/URL script sources, execution phases, checksum verification, timeout, continueOnError, and environment variables
  • Add TemplatePhase enum with five provisioning phases: pre-install, post-runtime, post-toolkit, post-kubernetes, post-install
  • Add CustomTemplates []CustomTemplate field to EnvironmentSpec
  • Update zz_generated.deepcopy.go with DeepCopy methods for CustomTemplate

Test plan

  • JSON round-trip test for CustomTemplate serialization
  • All source types test (inline, file, URL)
  • TemplatePhase constants test (5 phases with correct string values)
  • EnvironmentSpec CustomTemplates field test
  • Full build passes (go build ./...)

Closes part of #565

Add CustomTemplate struct with inline/file/URL sources, execution phases,
checksum verification, and environment variables. Add TemplatePhase enum
with five provisioning phases. Add CustomTemplates field to EnvironmentSpec.
Update deepcopy methods. Includes JSON round-trip and constant tests.

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
- R1: Reorder CustomTemplate deepcopy to alphabetical position
  (between ContainerRuntime and Environment) matching controller-gen
  convention
- N1: Add TestCustomTemplate_JSONRoundTrip_AllFields covering Env map,
  Timeout, and ContinueOnError serialization
- N2: Use realistic SHA256 digest in URL test case checksum

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
@ArangoGutierrez ArangoGutierrez marked this pull request as ready for review March 4, 2026 18:16
Copilot AI review requested due to automatic review settings March 4, 2026 18:16
@ArangoGutierrez ArangoGutierrez enabled auto-merge (squash) March 4, 2026 18:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds API surface area to let Holodeck users define custom, user-provided provisioning scripts in the Environment spec, including when they run (phase) and how they’re sourced (inline/file/URL), plus generated deepcopy updates and unit tests to validate serialization.

Changes:

  • Introduces CustomTemplate and TemplatePhase to api/holodeck/v1alpha1 and wires customTemplates into EnvironmentSpec.
  • Updates controller-gen zz_generated.deepcopy.go to deep-copy CustomTemplate (including Env) and EnvironmentSpec.CustomTemplates.
  • Adds unit tests validating JSON round-trips, source fields, phase string constants, and EnvironmentSpec serialization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
api/holodeck/v1alpha1/types.go Defines CustomTemplate, TemplatePhase, and adds customTemplates to EnvironmentSpec.
api/holodeck/v1alpha1/zz_generated.deepcopy.go Adds autogenerated DeepCopy methods for CustomTemplate and deep-copies CustomTemplates in EnvironmentSpec.
api/holodeck/v1alpha1/types_test.go Adds JSON serialization/unit coverage for the new API types and field.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +226 to +229
// Phase determines when the template is executed.
// +kubebuilder:default=post-install
// +optional
Phase TemplatePhase `json:"phase,omitempty"`
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+kubebuilder:default=post-install only affects CRD defaulting; Holodeck's local YAML parsing via sigs.k8s.io/yaml won't apply it, so omitted phase will deserialize as the empty string. Consider adding explicit defaulting in the config load path (or documenting/handling empty Phase as post-install in consumers) to make the default reliable for CLI usage.

Copilot uses AI. Check for mistakes.
// +optional
Checksum string `json:"checksum,omitempty"`

// Timeout in seconds for script execution (default: 600).
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says Timeout defaults to 600 seconds, but there is no +kubebuilder:default=600 marker and plain JSON/YAML unmarshalling will leave it as 0. Either add an explicit default marker (and/or validation like minimum 1) or clarify that 0 means "use default" and ensure consumers implement that behavior.

Suggested change
// Timeout in seconds for script execution (default: 600).
// Timeout in seconds for script execution (default: 600).
// +kubebuilder:default=600

Copilot uses AI. Check for mistakes.
// +optional
File string `json:"file,omitempty"`

// URL is a remote HTTPS location to fetch the script from.
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL is documented as an "HTTPS location", but the schema doesn't currently constrain the scheme (e.g., it will accept http:// or other schemes). If HTTPS-only is a security requirement, add a kubebuilder validation (pattern / XValidation) or adjust the field comment to match what will actually be accepted and validated at runtime.

Suggested change
// URL is a remote HTTPS location to fetch the script from.
// URL is a remote HTTPS location to fetch the script from.
// +kubebuilder:validation:Pattern=`^https://`

Copilot uses AI. Check for mistakes.
Merge upstream/main into feat/565-custom-template-types. Resolved
conflicts in types.go and zz_generated.deepcopy.go by keeping all
upstream changes (cluster support, driver sources, etc.) and adding
CustomTemplate types and deepcopy methods in correct alphabetical
positions.

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 22684060478

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 48.424%

Totals Coverage Status
Change from base Build 22679755064: 0.0%
Covered Lines: 2657
Relevant Lines: 5487

💛 - Coveralls

@ArangoGutierrez ArangoGutierrez merged commit b3ff45e into NVIDIA:main Mar 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants