Skip to content

Commit 45d8cd6

Browse files
Implement direct KRM types, identity, and generate.sh for NotebookRuntime
This commit implements the direct KRM types, custom template references, and identity configuration for NotebookRuntime (as VertexAINotebookRuntime), fully conforming to the Greenfield resource guidelines. It includes: - Updating generate.sh to include VertexAINotebookRuntime. - Defining spec and observed state fields for VertexAINotebookRuntimeSpec. - Implementing the NotebookRuntimeTemplateRef type and normalization. - Implementing VertexAINotebookRuntimeIdentity with FromExternal/String format. - Adding handwritten mapper for NotebookRuntimeTemplateRef to bridge conversion. - Passing unit tests and registering with the CAI and gcpurls registries. Fix: 11122
1 parent 68dba5d commit 45d8cd6

11 files changed

Lines changed: 2152 additions & 1 deletion
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# VertexAINotebookRuntime Greenfield Types Implementation Journal
2+
3+
## Observations & Design Choices
4+
5+
1. **Mapping to GCP Resource**:
6+
- `NotebookRuntime` is a resource of `aiplatform.googleapis.com` (Vertex AI API). Following the established naming pattern under `apis/aiplatform/v1alpha1`, we mapped this to the KCC Kind `VertexAINotebookRuntime:NotebookRuntime`.
7+
8+
2. **Handwritten Mapper Support for References**:
9+
- Because `NotebookRuntime` requires a template reference during assignment, we defined `NotebookRuntimeTemplateRef` in its own file `vertexainotebookruntime_reference.go`.
10+
- The code generator maps `notebook_runtime_template_ref` in proto to our custom Go type but expects handwritten mappers `NotebookRuntimeTemplateRef_FromProto` and `NotebookRuntimeTemplateRef_ToProto` to avoid generation errors.
11+
- We created `notebookruntime_mapper.go` under `pkg/controller/direct/aiplatform/` to bridge this conversion.
12+
13+
3. **Verification**:
14+
- Built the packages and ran unit tests to ensure `VertexAINotebookRuntimeIdentity` parses and formats the GCP resource URL (`projects/{project}/locations/{location}/notebookRuntimes/{notebookRuntime}`) successfully.
15+
- Verified that the `gcpurls` registration tests successfully validate our newly added identity template.

apis/aiplatform/v1alpha1/generate.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ go run . generate-types \
3030
--resource VertexAISpecialistPool:SpecialistPool \
3131
--resource AIPlatformModel:Model \
3232
--resource VertexAIFeatureOnlineStore:FeatureOnlineStore \
33-
--resource VertexAITuningJob:TuningJob
33+
--resource VertexAITuningJob:TuningJob \
34+
--resource VertexAINotebookRuntime:NotebookRuntime
3435

3536
# Post-process types.generated.go to inject kubebuilder validation annotations for recursive self-referential fields
3637
python3 -c "

apis/aiplatform/v1alpha1/types.generated.go

Lines changed: 223 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)