csp

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package csp provides direct CSP (Cloud Service Provider) API call utilities. This bypasses CB-Spider for cases where direct SDK calls are more efficient or where CB-Spider does not provide the needed functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSecretPath

func BuildSecretPath(ctx context.Context, provider string) string

BuildSecretPath builds the OpenBao secret path for a given CSP provider based on the credential holder from context. For "admin" holder: "secret/data/csp/{provider}" For other holders: "secret/data/users/{holder}/csp/{provider}"

func GetString

func GetString(data map[string]interface{}, key string) string

GetString safely extracts a string value from a map.

func LogCSP

func LogCSP(provider, msg string)

LogCSP logs a CSP-related message with consistent prefix.

func ReadOpenBaoSecret

func ReadOpenBaoSecret(ctx context.Context, path string) (map[string]interface{}, error)

ReadOpenBaoSecret reads a secret from OpenBao at the given path and returns the data map. It validates that VaultToken is set and the secret exists. A context is used for request-scoped cancellation and timeout.

func RegisterBatchTagHandler

func RegisterBatchTagHandler(platform string, handler BatchTagHandler)

RegisterBatchTagHandler registers a batch tag upsert handler for a CSP. Called by CSP-specific packages during init().

func TryBatchUpsertTags

func TryBatchUpsertTags(ctx context.Context, providerName, region, zone, cspResourceId, resourceType string, tags map[string]string) (bool, error)

TryBatchUpsertTags attempts to upsert multiple tags on a CSP resource in a single API call. resourceType is the CB-Tumblebug label type (e.g., "node", "vNet", "sshKey"). region is the CSP region, zone is the availability zone (used by GCP; can be empty for others). Returns (true, nil) if successfully handled by a direct CSP batch API. Returns (false, nil) if no batch handler exists for this CSP (caller should fall back to Spider). Returns (false, err) if a batch handler exists but failed (caller should fall back to Spider).

Types

type BatchTagHandler

type BatchTagHandler func(ctx context.Context, region, zone, cspResourceId, resourceType string, tags map[string]string) error

BatchTagHandler defines the function signature for CSP-specific batch tag upsert. Returns error if the operation fails. The handler should set all given tags on the CSP resource identified by cspResourceId in a single API call. resourceType is the CB-Tumblebug label type (e.g., "node", "vNet", "sshKey"). region is the CSP region (e.g., "us-east-1"), zone is the availability zone (e.g., "us-east-1a").

Directories

Path Synopsis
Package azure provides direct Azure API call utilities for cases where CB-Spider is too slow or does not provide adequate functionality.
Package azure provides direct Azure API call utilities for cases where CB-Spider is too slow or does not provide adequate functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL