# K8S Config Connector

> This skill provides a structured workflow for matching the mock {service}{resource} behaviour with the real GCP. Use when this capability is needed.

- Skill: `tomevault-io/k8s-config-connector` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/k8s-config-connector`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/k8s-config-connector/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/k8s-config-connector

---

# Skill: Match Mock behaviour with real GCP api

This skill provides a structured workflow for matching the mock {service}{resource} behaviour with the real GCP.

When the golden tests for K8s Config Connector mock output diverge from real GCP output, we need to inspect the discrepancies and fix either the mock implementation or the normalizers. This ensures that `hack/compare-mock` runs cleanly and accurately represents GCP API contracts.

## Critical Rules

*   **Real GCP Baseline Required**: You must always generate the initial baseline `_http.log` by running `hack/record-gcp` against a real GCP project and commit it first.
*   **Do NOT Generate Golden Logs from Mock**: You are strictly forbidden from generating or updating `_http.log` files against the mock in this step. You MUST first establish a baseline against `real` GCP with `E2E_GCP_TARGET=real E2E_KUBE_TARGET=envtest` with `WRITE_GOLDEN_OUTPUT=1`.

## Workflow

### Step 1: Record GCP logs

1.  Run `hack/record-gcp "fixtures/^<testname>$"` to capture real GCP behavior.
    *   **Troubleshooting Service Not Enabled**: If `hack/record-gcp` fails because a GCP service is not enabled (e.g., error mentions that the API is disabled or has not been used in the project before), enable the service using `gcloud` and try again:
        ```bash
        gcloud services enable <service-name>.googleapis.com
        ```
        *(For example: `gcloud services enable compute.googleapis.com` or `gcloud services enable run.googleapis.com`)*
2.  Please commit the real gcp logs generated by running the command.

Important:
* It is important to commit the files modified by running realgcp tests in its own commit.
* This is for the human reviewer to compare the diff in the test artifacts when running real and mockgcp.


### Step 2: Match mockgcp behaviour with real GCP
1.  Run `hack/compare-mock "fixtures/^<testname>$"` to check mock behavior.
2.  Iteratively fix discrepancies in the mock implementation or `normalize.go`.

Tips for fixing the discrepancies:

1. Look closely at the `compare-mock` HTTP log differences (typically mock on left `=>` real on right).
2. For missing default values (e.g., `<missing> => REGIONAL`), add a `populateDefaultsFor<Resource>` function to the mock service's file (e.g. `mockgcp/mockcompute/networksv1.go`). Make sure it is called on `Insert` and `Get`.
3. For generated IDs or volatile values (e.g. IPs, resource URLs) where real GCP generates dynamically but mockgcp outputs something static, you need to update the normalizer `mockgcp/mock<service>/normalize.go`.
4. Run `hack/compare-mock "fixtures/^<testname>$"` to see the diff and overwrite `_http.log`.
5. Run `git diff` on the test fixtures to ensure that the golden `_http.log` accurately replaces volatile data with placeholder variables (e.g., `${ipAddress}`).
6. Certain operation metadata values (e.g. `done: <missing> => false`) can be safely ignored as mock operations are generally simpler.

---
> Source: [GoogleCloudPlatform/k8s-config-connector](https://github.com/GoogleCloudPlatform/k8s-config-connector) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-27 -->

