package util

import "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/util"

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

Index

Functions

func GcloudTokenSource

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

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")

Types

type GcloudConfigData

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

func GcloudConfig() (*GcloudConfigData, error)

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

type GcloudError

type GcloudError struct {
	GcloudError error
	Status      GcloudStatusCode
}

func (*GcloudError) Error

func (e *GcloudError) Error() string

type GcloudStatusCode

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

Source Files

cloudsqlutil.go gcloudutil.go

Version
v1.20.2
Published
Mar 5, 2021
Platform
js/wasm
Imports
10 packages
Last checked
2 months ago

Tools for package owners.