add-export-support

Implements export support for Config Connector direct controllers via AdapterForURL.

1.1k|377|Updated Apr 8, 2019
One-click install
npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill add-export-support
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-export-support
Source: https://github.com/GoogleCloudPlatform/k8s-config-connector/tree/main/.gemini/skills/add-export-support
Command: npx skills add https://github.com/GoogleCloudPlatform/k8s-config-connector --skill add-export-support

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Direct controllers in Config Connector cannot serve the config-connector export command until they implement AdapterForURL and a correct Export method, and mistakes in unstructured object construction or project binding silently break exported manifests.

Core Features & Use Cases

  • AdapterForURL Implementation: Parse CAI URLs into resource identities using gcpurls.Template/FromExternal and return a populated adapter.
  • Export Method Guidance: Correctly order u.Object assignment before SetName/SetGroupVersionKind, handle reference-bound spec.projectRef versus the project-id annotation, and set identity fields like resourceID and location manually.
  • E2E Test Integration: Register the GVK in tests/e2e/export.go, remove ratcheting exclusions, and generate golden _exported.yaml files aligned with the legacy exporter to avoid _exported_object.diff files.
  • Use Case: When adding export support for a resource like ArtifactRegistryRepository, follow the workflow to implement the adapter, wire up the test harness, and produce verified golden export output.

Quick Start

Ask the agent to add export support for a specific Config Connector direct controller resource and verify it with the unified E2E test runner.

Frequently Asked Questions about add-export-support

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add export support to a Config Connector direct controller?

Implement AdapterForURL on the model to parse the CAI URL into the resource identity via FromExternal, then implement the adapter's Export method to map the GCP state back to KRM. Finally register the GVK in tests/e2e/export.go and run the unified test runner with WRITE_GOLDEN_OUTPUT=1.

Why is my exported object missing name, apiVersion, and kind?

This happens when u.Object is assigned after calling u.SetName or u.SetGroupVersionKind, because assigning u.Object replaces the underlying map and wipes those fields. Always assign u.Object = uObj first, then set name and GVK.

Should I use export.SetProjectID or spec.projectRef when exporting?

If the resource has a spec.projectRef field (reference-bound), set obj.Spec.ProjectRef.External to the project ID and do not call export.SetProjectID. Only use export.SetProjectID to set the project-id annotation when the resource lacks spec.projectRef.

How do I avoid _exported_object.diff files in E2E export tests?

Align the direct Export output with the legacy exporter by using export.SetLabels, exposing identity fields like ResourceID on the spec, and matching legacy formatting such as default value omission. Inspect any generated diff and adjust the FromProto mapping accordingly.

Why does export fail with a nil pointer dereference on spec fields?

If the KRM spec embeds a pointer to a nested struct like *Parent and the FromProto mapper leaves it nil, assigning fields such as ProjectRef or Zone panics. Initialize the nested struct first or flatten those fields directly onto the spec.