util

package
v1.37.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package util contains utility functions for use throughout the Cloud SQL Auth proxy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GcloudTokenSource added in v1.12.0

func GcloudTokenSource(ctx context.Context) (oauth2.TokenSource, error)

func SemanticVersion added in v1.33.10

func SemanticVersion() string

SemanticVersion returns the version of the proxy in a semver format.

func SplitName

func SplitName(instance string) (project, region, name string)

SplitName splits a fully qualified instance into its project, region, and instance name components. While we make the transition to regionalized metadata, the region is optional.

Examples:

   "proj:region:my-db" -> ("proj", "region", "my-db")
		"google.com:project:region:instance" -> ("google.com:project", "region", "instance")
		"google.com:missing:part" -> ("google.com:missing", "", "part")

func UserAgentFromVersionString added in v1.33.10

func UserAgentFromVersionString() string

UserAgentFromVersionString returns an appropriate user agent string for identifying this proxy process.

Types

type GcloudConfigData added in v1.12.0

type GcloudConfigData struct {
	Configuration struct {
		Properties struct {
			Core struct {
				Project string
				Account string
			}
		}
	}
	Credential struct {
		AccessToken string    `json:"access_token"`
		TokenExpiry time.Time `json:"token_expiry"`
	}
}

GcloudConfigData represents the data returned by `gcloud config config-helper`.

func GcloudConfig added in v1.12.0

func GcloudConfig() (*GcloudConfigData, error)

GcloudConfig returns a GcloudConfigData object or an error of type *GcloudError.

type GcloudError added in v1.12.0

type GcloudError struct {
	GcloudError error
	Status      GcloudStatusCode
}

func (*GcloudError) Error added in v1.12.0

func (e *GcloudError) Error() string

type GcloudStatusCode added in v1.12.0

type GcloudStatusCode int
const (
	GcloudOk GcloudStatusCode = iota
	GcloudNotFound
	// generic execution failure error not specified above.
	GcloudExecErr
)

Jump to

Keyboard shortcuts

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