Documentation ¶
Index ¶
- Constants
- Variables
- func BucketName(serviceName string) string
- func FindLatestImageTag(output string) (string, error)
- func GcpServiceAccountSecretName(serviceName string) string
- func GetCurrentProject() (string, error)
- func GetGoogleMachineTypes() []string
- func GetGoogleProjects() ([]string, error)
- func GetGoogleRegions(project string) ([]string, error)
- func GetGoogleZones(project string) ([]string, error)
- func GetRegionFromZone(zone string) string
- func KeyName(serviceName string) string
- func KeyringName(serviceName string) string
- func ParseContext(context string) (string, string, string, error)
- func ServiceAccountName(clusterName, serviceAbbreviation string) string
- func StreamTransferFileFromBucket(fullBucketURL string) (io.ReadCloser, error)
- type Cluster
- type GCloud
- func (g *GCloud) AddBucketLabel(bucketName string, label string)
- func (g *GCloud) BucketExists(projectID string, bucketName string) (bool, error)
- func (g *GCloud) CheckPermission(perm string, projectID string) (bool, error)
- func (g *GCloud) CleanupServiceAccountKeys(serviceAccount string, projectID string) error
- func (g *GCloud) ClusterZone(cluster string) (string, error)
- func (g *GCloud) ConfigureBucketRoles(projectID string, serviceAccount string, bucketURL string, roles []string) error
- func (g *GCloud) ConnectToCluster(projectID, zone, clusterName string) error
- func (g *GCloud) ConnectToRegionCluster(projectID, region, clusterName string) error
- func (g *GCloud) CreateBucket(projectID string, bucketName string, location string) error
- func (g *GCloud) CreateDNSZone(projectID string, domain string) (string, []string, error)
- func (g *GCloud) CreateGCPServiceAccount(kubeClient kubernetes.Interface, ...) (string, error)
- func (g *GCloud) CreateKmsKey(keyName string, keyringName string, projectID string) error
- func (g *GCloud) CreateKmsKeyring(keyringName string, projectID string) error
- func (g *GCloud) CreateManagedZone(projectID string, domain string) error
- func (g *GCloud) CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error
- func (g *GCloud) CurrentProject() (string, error)
- func (g *GCloud) DeleteAllObjectsInBucket(bucketName string) error
- func (g *GCloud) DeleteBucket(bucketName string) error
- func (g *GCloud) DeleteServiceAccount(serviceAccount string, projectID string, roles []string) error
- func (g *GCloud) DeleteServiceAccountKey(serviceAccount string, projectID string, key string) error
- func (g *GCloud) EnableAPIs(projectID string, apis ...string) error
- func (g *GCloud) FindBucket(bucketName string) bool
- func (g *GCloud) FindServiceAccount(serviceAccount string, projectID string) bool
- func (g *GCloud) GetEnabledApis(projectID string) ([]string, error)
- func (g *GCloud) GetManagedZoneNameServers(projectID string, domain string) (string, []string, error)
- func (g *GCloud) GetOrCreateServiceAccount(serviceAccount string, projectID string, clusterConfigDir string, ...) (string, error)
- func (g *GCloud) GetProjectNumber(projectID string) (string, error)
- func (g *GCloud) GetServiceAccountKeys(serviceAccount string, projectID string) ([]string, error)
- func (g *GCloud) IsGCSWriteRoleEnabled(cluster string, zone string) (bool, error)
- func (g *GCloud) IsKmsKeyAvailable(keyName string, keyringName string, projectID string) bool
- func (g *GCloud) IsKmsKeyringAvailable(keyringName string, projectID string) bool
- func (g *GCloud) ListClusters(region string, projectID string) ([]Cluster, error)
- func (g *GCloud) ListObjects(bucketName string, path string) ([]string, error)
- func (g *GCloud) LoadGkeCluster(region string, projectID string, clusterName string) (*Cluster, error)
- func (g *GCloud) Login(serviceAccountKeyPath string, skipLogin bool) error
- func (g *GCloud) UpdateGkeClusterLabels(region string, projectID string, clusterName string, labels []string) error
- func (g *GCloud) UserLabel() string
- type GClouder
- type ImageTagInfo
Constants ¶
const KmsLocation = "global"
KmsLocation indicates the location used by the Google KMS service
Variables ¶
var ( // RequiredServiceAccountRoles the roles required to create a cluster with terraform RequiredServiceAccountRoles = []string{"roles/owner"} // KanikoServiceAccountRoles the roles required to run kaniko with GCS KanikoServiceAccountRoles = []string{"roles/storage.admin", "roles/storage.objectAdmin", "roles/storage.objectCreator"} // VeleroServiceAccountRoles the roles required to run velero with GCS VeleroServiceAccountRoles = []string{ "roles/storage.admin", "roles/storage.objectAdmin", "roles/storage.objectCreator"} )
var PROJECT_LIST_HEADER = "PROJECT_ID"
Functions ¶
func BucketName ¶
BucketName creates a Bucket name for a given service name
func FindLatestImageTag ¶
FindLatestImageTag returns the latest image tag from the JSON output of the command ` gcloud container images list-tags gcr.io/jenkinsxio/builder-maven --format jsonhig`
func GcpServiceAccountSecretName ¶
GcpServiceAccountSecretName builds the secret name where the GCP service account is stored
func GetCurrentProject ¶
func GetGoogleMachineTypes ¶
func GetGoogleMachineTypes() []string
func GetGoogleProjects ¶
func GetGoogleRegions ¶
func GetGoogleZones ¶
func GetRegionFromZone ¶
GetRegionFromZone parses the region from a GCP zone name. TODO: Return an error if the format of the zone is not correct
func KeyringName ¶
KeyringName creates a keyring name for a given service and cluster name
func ParseContext ¶
ParseContext parses the context string for GKE and gets the GKE project, GKE zone and cluster name
func ServiceAccountName ¶
ServiceAccountName creates a service account name for a given service and cluster name
func StreamTransferFileFromBucket ¶
func StreamTransferFileFromBucket(fullBucketURL string) (io.ReadCloser, error)
StreamTransferFileFromBucket will perform a stream transfer from the GCS bucket to stdout and return a scanner with the piped result
Types ¶
type Cluster ¶
type Cluster struct { Name string `json:"name,omitempty"` ResourceLabels map[string]string `json:"resourceLabels,omitempty"` Status string `json:"status,omitempty"` Location string `json:"location,omitempty"` }
Cluster struct to represent a cluster on gcloud
type GCloud ¶
type GCloud struct { }
GCloud real implementation of the gcloud helper
func (*GCloud) AddBucketLabel ¶
AddBucketLabel adds a label to a Google Storage bucket
func (*GCloud) BucketExists ¶
BucketExists checks if a Google Storage bucket exists
func (*GCloud) CheckPermission ¶
CheckPermission checks permission on the given project
func (*GCloud) CleanupServiceAccountKeys ¶
CleanupServiceAccountKeys remove all keys from given service account
func (*GCloud) ClusterZone ¶
ClusterZone retrives the zone of GKE cluster description
func (*GCloud) ConfigureBucketRoles ¶
func (g *GCloud) ConfigureBucketRoles(projectID string, serviceAccount string, bucketURL string, roles []string) error
ConfigureBucketRoles gives the given roles to the given service account
func (*GCloud) ConnectToCluster ¶
ConnectToCluster connects to the specified cluster
func (*GCloud) ConnectToRegionCluster ¶
ConnectToRegionCluster connects to the specified regional cluster
func (*GCloud) CreateBucket ¶
CreateBucket creates a new Google Storage bucket
func (*GCloud) CreateDNSZone ¶
CreateDNSZone creates the DNS zone if it doesn't exist and returns the list of name servers for the given domain and project
func (*GCloud) CreateGCPServiceAccount ¶
func (g *GCloud) CreateGCPServiceAccount(kubeClient kubernetes.Interface, serviceName, serviceAbbreviation, namespace, clusterName, projectID string, serviceAccountRoles []string, serviceAccountSecretKey string) (string, error)
CreateGCPServiceAccount creates a service account in GCP for a service using the account roles specified
func (*GCloud) CreateKmsKey ¶
CreateKmsKey creates a new KMS key in the given keyring
func (*GCloud) CreateKmsKeyring ¶
CreateKmsKeyring creates a new KMS keyring
func (*GCloud) CreateManagedZone ¶
CreateManagedZone creates a managed zone for the given domain in the specified project
func (*GCloud) CreateServiceAccountKey ¶
func (g *GCloud) CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error
CreateServiceAccountKey creates a new service account key and downloads into the given file
func (*GCloud) CurrentProject ¶
CurrentProject returns the current GKE project name if it can be detected
func (*GCloud) DeleteAllObjectsInBucket ¶
DeleteAllObjectsInBucket deletes all objects in a Google Storage bucket
func (*GCloud) DeleteBucket ¶
DeleteBucket deletes a Google storage bucket
func (*GCloud) DeleteServiceAccount ¶
func (g *GCloud) DeleteServiceAccount(serviceAccount string, projectID string, roles []string) error
DeleteServiceAccount deletes a service account and its role bindings
func (*GCloud) DeleteServiceAccountKey ¶
DeleteServiceAccountKey deletes a service account key
func (*GCloud) EnableAPIs ¶
EnableAPIs enables APIs for the given services
func (*GCloud) FindBucket ¶
FindBucket finds a Google Storage bucket
func (*GCloud) FindServiceAccount ¶
FindServiceAccount checks if a service account exists
func (*GCloud) GetEnabledApis ¶
GetEnabledApis returns which services have the API enabled
func (*GCloud) GetManagedZoneNameServers ¶
func (g *GCloud) GetManagedZoneNameServers(projectID string, domain string) (string, []string, error)
GetManagedZoneNameServers retrieves a list of name servers associated with a zone
func (*GCloud) GetOrCreateServiceAccount ¶
func (g *GCloud) GetOrCreateServiceAccount(serviceAccount string, projectID string, clusterConfigDir string, roles []string) (string, error)
GetOrCreateServiceAccount retrieves or creates a GCP service account. It will return the path to the file where the service account token is stored
func (*GCloud) GetProjectNumber ¶
func (*GCloud) GetServiceAccountKeys ¶
GetServiceAccountKeys returns all keys of a service account
func (*GCloud) IsGCSWriteRoleEnabled ¶
IsGCSWriteRoleEnabled will check if the devstorage.full_control scope is enabled in the cluster in order to use GCS
func (*GCloud) IsKmsKeyAvailable ¶
IsKmsKeyAvailable checks if the KMS key is already available
func (*GCloud) IsKmsKeyringAvailable ¶
IsKmsKeyringAvailable checks if the KMS keyring is already available
func (*GCloud) ListClusters ¶
ListClusters returns the clusters in a GKE project
func (*GCloud) ListObjects ¶
ListObjects checks if a Google Storage bucket exists
func (*GCloud) LoadGkeCluster ¶
func (g *GCloud) LoadGkeCluster(region string, projectID string, clusterName string) (*Cluster, error)
LoadGkeCluster load a gke cluster from a GKE project
func (*GCloud) Login ¶
Login login an user into Google account. It skips the interactive login using the browser when the skipLogin flag is active
type GClouder ¶
type GClouder interface { CreateManagedZone(projectID string, domain string) error CreateDNSZone(projectID string, domain string) (string, []string, error) GetManagedZoneNameServers(projectID string, domain string) (string, []string, error) ClusterZone(cluster string) (string, error) BucketExists(projectID string, bucketName string) (bool, error) CreateBucket(projectID string, bucketName string, location string) error AddBucketLabel(bucketName string, label string) FindBucket(bucketName string) bool DeleteAllObjectsInBucket(bucketName string) error DeleteBucket(bucketName string) error FindServiceAccount(serviceAccount string, projectID string) bool GetOrCreateServiceAccount(serviceAccount string, projectID string, clusterConfigDir string, roles []string) (string, error) CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error GetServiceAccountKeys(serviceAccount string, projectID string) ([]string, error) ListClusters(region string, projectID string) ([]Cluster, error) LoadGkeCluster(region string, projectID string, clusterName string) (*Cluster, error) UpdateGkeClusterLabels(region string, projectID string, clusterName string, labels []string) error DeleteServiceAccountKey(serviceAccount string, projectID string, key string) error CleanupServiceAccountKeys(serviceAccount string, projectID string) error DeleteServiceAccount(serviceAccount string, projectID string, roles []string) error GetEnabledApis(projectID string) ([]string, error) EnableAPIs(projectID string, apis ...string) error Login(serviceAccountKeyPath string, skipLogin bool) error CheckPermission(perm string, projectID string) (bool, error) CreateKmsKeyring(keyringName string, projectID string) error IsKmsKeyringAvailable(keyringName string, projectID string) bool CreateKmsKey(keyName string, keyringName string, projectID string) error IsKmsKeyAvailable(keyName string, keyringName string, projectID string) bool IsGCSWriteRoleEnabled(cluster string, zone string) (bool, error) UserLabel() string CreateGCPServiceAccount(kubeClient kubernetes.Interface, serviceName, serviceAbbreviation, namespace, clusterName, projectID string, serviceAccountRoles []string, serviceAccountSecretKey string) (string, error) ConnectToCluster(projectID, zone, clusterName string) error ConnectToRegionCluster(projectID, region, clusterName string) error ConfigureBucketRoles(projectID string, serviceAccount string, bucketURL string, roles []string) error GetProjectNumber(projectID string) (string, error) }
GClouder interface to define interactions with the gcloud command
type ImageTagInfo ¶
ImageTagInfo contains tag information for container images