googlecloud-api

Enforces CallOptionInjector patterns for Google Cloud API calls in KHI Go code.

2.1k|97|Updated Jan 22, 2025
One-click install
npx skills add https://github.com/GoogleCloudPlatform/khi --skill googlecloud-api-googlecloudplatform
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: googlecloud-api
Source: https://github.com/GoogleCloudPlatform/khi/tree/main/.agents/skills/googlecloud_api
Command: npx skills add https://github.com/GoogleCloudPlatform/khi --skill googlecloud-api-googlecloudplatform

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Google Cloud API calls in KHI fail with authentication, quota, or routing errors when required call options (gRPC metadata, routing headers, credentials) are not propagated to the request context. This Skill provides the mandatory patterns for injecting those options correctly. ## Core Features & Use Cases - Task Integration Pattern: Shows how to retrieve CallOptionInjector through the KHI task DAG dependency system using APIClientCallOptionsInjectorTaskID. - Reusable Component Pattern: Defines how fetchers and helper structs accept, store, and apply CallOptionInjector before RPC calls and errgroup goroutines. - Raw HTTP Support: Covers ApplyToRawHTTPHeader for REST requests where gRPC context options do not apply, plus unit testing with mock CallOptionInjectorOption. - Use Case: When writing a new KHI inspection task that queries Cloud Logging, follow this guide to inject call options into the context before creating the logging client, preventing quota and routing failures. ## Quick Start Show me how to call the Cloud Logging API from a new KHI inspection task with proper call option injection.

Frequently Asked Questions about googlecloud-api

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

FAQPage Schema
How do I call Google Cloud APIs from a KHI inspection task?▼

Add APIClientCallOptionsInjectorTaskID to the task dependencies, retrieve the injector with coretask.GetTaskResult, then call InjectToCallContext on the context for the target container before creating clients and making API calls.

How do I propagate call options in reusable Go fetcher components?▼

Accept CallOptionInjector as a constructor argument, store it as a struct field, and call InjectToCallContext right before RPC calls or before passing the context to errgroup goroutines so child contexts inherit the options.

Does CallOptionInjector work with raw HTTP requests?▼

gRPC context call options do not affect REST requests. Use ApplyToRawHTTPHeader to inject the options directly into the http.Request headers before executing the request with an HTTP client.

Why do Google Cloud API calls fail without context injection?▼

Skipping InjectToCallContext means required gRPC metadata, routing headers, quota parameters, and credentials never reach the RPC. This causes authentication, quota, or routing failures against the target project, folder, or organization.

How do I unit test components that use CallOptionInjector?▼

Create a mock CallOptionInjectorOption that writes a known value into the context, then verify the component applies it. Also test with a nil injector to confirm the component handles its absence defensively.