vertex

package
v6.10.9-aug.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package vertex provides token storage for Google Vertex AI Gemini via service account credentials. It serializes service account JSON into an auth file that is consumed by the runtime executor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Label

func Label(projectID, email string) string

Label builds a human-readable label for a Vertex AI credential.

func NormalizeServiceAccountMap

func NormalizeServiceAccountMap(sa map[string]any) (map[string]any, error)

NormalizeServiceAccountMap returns a copy of the given service account map with a sanitized private_key field that is guaranteed to contain a valid RSA PRIVATE KEY PEM block.

func SanitizeFilePart

func SanitizeFilePart(s string) string

SanitizeFilePart replaces path separators and whitespace in s for safe use in file names.

Types

type CredentialStorage

type CredentialStorage struct {
	// ServiceAccount holds the parsed service account JSON content.
	ServiceAccount map[string]any `json:"service_account"`

	// ProjectID is derived from the service account JSON (project_id).
	ProjectID string `json:"project_id"`

	// Email is the client_email from the service account JSON.
	Email string `json:"email"`

	// Location optionally sets a default region (e.g., us-central1) for Vertex endpoints.
	Location string `json:"location,omitempty"`

	// Type is the provider identifier stored alongside credentials. Always "vertex".
	Type string `json:"type"`
}

CredentialStorage stores the service account JSON for Vertex AI access. The content is persisted verbatim under the "service_account" key, together with helper fields for project, location and email to improve logging and discovery.

func (*CredentialStorage) SaveTokenToFile

func (s *CredentialStorage) SaveTokenToFile(authFilePath string) error

SaveTokenToFile writes the credential payload to the given file path in JSON format. It ensures the parent directory exists and logs the operation for transparency.

Jump to

Keyboard shortcuts

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