create-fuzzer

Implement round-trip KRM fuzzers for Config Connector direct controllers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Config Connector direct controllers need verified, lossless bidirectional mapping between Kubernetes Resource Model (KRM) types and GCP proto or OpenAPI types, and manually writing round-trip fuzzers for each resource is error-prone and inconsistent.

Core Features & Use Cases

  • Guided Fuzzer Creation: Step-by-step instructions for creating <kind>_fuzzer.go files with correct naming conventions, init() registration via fuzztesting.RegisterKRMFuzzer, and field categorization using SpecField, StatusField, and Unimplemented_* helpers.
  • No-Proto Resource Support: Covers OpenAPI/Discovery API-based resources using RegisterKRMFuzzer_NoProto and the generate-mapper tool for automatic mapper generation.
  • Centralized Verification: Explains how to register packages in register.go and run focused fuzz tests via FOCUS=<Kind> go test ./pkg/fuzztesting/fuzztests/ -run TestFocusedMappers.
  • Use Case: When adding a new direct controller resource like KMSKeyHandle, follow the skill to implement missing ToProto status mappers, create the fuzzer file, categorize proto fields, and validate lossless round-trips in the central fuzz suite.

Quick Start

Ask the agent to create a round-trip KRM fuzzer for a specific Config Connector direct resource, such as ComputeFirewall, following the create-fuzzer skill.

Frequently Asked Questions about create-fuzzer

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

FAQPage Schema
How do I create a KRM fuzzer for a Config Connector direct resource?

Create a `<kind>_fuzzer.go` file in the resource's direct controller package, register it in `init()` with `fuzztesting.RegisterKRMFuzzer`, and pass the Spec and Status FromProto/ToProto mappers to `fuzztesting.NewKRMTypedFuzzer`. Then categorize proto fields using `f.SpecField`, `f.StatusField`, and `f.Unimplemented_*` helpers.

How do I fuzz a Config Connector resource without a proto schema?

Use the NoProto framework: generate mappers with the `generate-mapper` tool against the OpenAPI Go SDK types, hand-write custom mappers in `mappers.go` where needed, and register the fuzzer with `fuzztesting.RegisterKRMFuzzer_NoProto` using `NewKRMTypedFuzzer_NoProto`.

How do I run fuzz tests for a single Config Connector resource?

Set the FOCUS environment variable and run the focused test: `FOCUS=<ResourceKind> go test -count=1 -v ./pkg/fuzztesting/fuzztests/ -run TestFocusedMappers`. Never create a per-resource `*_test.go` file; all fuzzers run centrally via the shared suite.

Why does my fuzzer fail with nil versus empty struct mismatches?

This happens when KRM uses non-pointer struct fields, so a nil proto field round-trips to an empty struct. Use `f.FilterSpec` to normalize the fuzzed proto before comparison, or adjust the ToProto mapper to only emit the field when subfields are set.

Why is my fuzzer not running in the central fuzz test suite?

The direct controller package must be anonymously imported in `pkg/controller/direct/register/register.go` in alphabetical order, otherwise its `init()` function never executes and the fuzzer is never registered.