Documentation ¶
Overview ¶
Package gcloud wraps up all of the cloud operations for DeployStack into one client. It's mostly used to drive querying GCP projects and settings for DeployStack ui. But it is also used to drive some of the authoring tooling
Index ¶
- Variables
- type Client
- func (c *Client) BillingAccountAttach(project, account string) error
- func (c *Client) BillingAccountList() ([]*cloudbilling.BillingAccount, error)
- func (c *Client) CloudBuildTriggerCreate(project string, trigger cloudbuild.BuildTrigger) (*cloudbuild.BuildTrigger, error)
- func (c *Client) CloudBuildTriggerDelete(project string, triggerid string) error
- func (c *Client) ComputeRegionList(project string) ([]string, error)
- func (c Client) DomainIsAvailable(project, domain string) (*domainspb.RegisterParameters, error)
- func (c Client) DomainIsVerified(project, domain string) (bool, error)
- func (c Client) DomainRegister(project string, domaininfo *domainspb.RegisterParameters, contact ContactData) error
- func (c Client) DomainsSearch(project, domain string) ([]*domainspb.RegisterParameters, error)
- func (c *Client) FunctionDelete(project, region, name string) error
- func (c *Client) FunctionDeploy(project, region string, f cloudfunctions.CloudFunction) error
- func (c *Client) FunctionGenerateSignedURL(project, region string) (string, error)
- func (c *Client) FunctionGet(project, region, name string) (*cloudfunctions.CloudFunction, error)
- func (c *Client) FunctionRegionList(project string) ([]string, error)
- func (c *Client) ImageFamilyList(imgs *compute.ImageList) LabeledValues
- func (c *Client) ImageLatestGet(project, imageproject, imagefamily string) (string, error)
- func (c *Client) ImageList(project, imageproject string) (*compute.ImageList, error)
- func (c *Client) ImageTypeListByFamily(imgs *compute.ImageList, project, family string) LabeledValues
- func (c *Client) JobDelete(project, region, job string) error
- func (c *Client) JobSchedule(project, region string, job schedulerpb.Job) error
- func (c *Client) MachineTypeFamilyList(imgs *compute.MachineTypeList) LabeledValues
- func (c *Client) MachineTypeList(project, zone string) (*compute.MachineTypeList, error)
- func (c *Client) MachineTypeListByFamily(imgs *compute.MachineTypeList, family string) LabeledValues
- func (c *Client) ProjectCreate(project, parent, parentType string) error
- func (c *Client) ProjectDelete(project string) error
- func (c *Client) ProjectExists(project string) bool
- func (c *Client) ProjectGet(project string) (*cloudresourcemanager.Project, error)
- func (c *Client) ProjectGrantIAMRole(project, role, principal string) error
- func (c Client) ProjectIDGet() (string, error)
- func (c *Client) ProjectIDSet(project string) error
- func (c *Client) ProjectList() ([]ProjectWithBilling, error)
- func (c *Client) ProjectListWithBilling(p []*cloudresourcemanager.Project) ([]ProjectWithBilling, error)
- func (c *Client) ProjectListWithBillingEnabled() (map[string]bool, error)
- func (c *Client) ProjectNumberGet(id string) (string, error)
- func (c *Client) ProjectParentGet(id string) (*cloudresourcemanager.ResourceId, error)
- func (c *Client) RegionList(project, product string) ([]string, error)
- func (c *Client) RunRegionList(project string) ([]string, error)
- func (c *Client) SecretCreate(project, name, payload string) error
- func (c *Client) SecretDelete(project, name string) error
- func (c *Client) ServiceAccountCreate(project, username, displayName string) (string, error)
- func (c *Client) ServiceAccountDelete(project, email string) error
- func (c *Client) ServiceDisable(project, service string) error
- func (c *Client) ServiceEnable(project, service string) error
- func (c *Client) ServiceIsEnabled(project, service string) (bool, error)
- func (c *Client) StorageBucketCreate(project, bucket string) error
- func (c *Client) StorageBucketDelete(project, bucket string) error
- func (c *Client) StorageObjectCreate(project, bucket, path string) (string, error)
- func (c *Client) StorageObjectDelete(project, bucket, gspath string) error
- func (c *Client) ZoneList(project, region string) ([]string, error)
- type ContactData
- type DomainRegistrarContact
- type LabeledValue
- type LabeledValues
- type PostalAddress
- type ProjectWithBilling
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorDomainUntenable is returned when a domain isn't available for registration, but // is also not owned by the user. It can't be used in this app ErrorDomainUntenable = fmt.Errorf("domain is not available, and not owned by attempting user") // ErrorDomainUserDeny is returned when an user declines the choice to purchase. ErrorDomainUserDeny = fmt.Errorf("user said no to buying the domain") )
var ( // DefaultRegion is the default compute region used in compute calls. DefaultRegion = "us-central1" // DefaultMachineType is the default compute machine type used in compute calls. DefaultMachineType = "n1-standard" // DefaultMachineFamily is the default compute machine type used in compute calls. DefaultMachineFamily = "n1" // DefaultImageProject is the default project for images used in compute calls. DefaultImageProject = "debian-cloud" // DefaultImageFamily is the default project for images used in compute calls. DefaultImageFamily = "debian-11" // DefaultDiskSize is the default size for making disks for Compute Engine DefaultDiskSize = "200" // DefaultDiskType is the default style of disk DefaultDiskType = "pd-standard" // DefaultInstanceType is the default machine type of compute engine DefaultInstanceType = "n1-standard-1" // HTTPServerTags are the instance tags to open up the instance to be a // http server HTTPServerTags = "[http-server,https-server]" // DefaultZone is the default zone used in compute calls. DefaultZone = "us-central1-a" // ErrorBillingInvalidAccount is the error you get if you pass in a bad // Billing Account ID ErrorBillingInvalidAccount = fmt.Errorf("not a valid billing account") // ErrorBillingNoPermission is the error you get if the user lacks billing // related permissions ErrorBillingNoPermission = fmt.Errorf("user lacks permission") // ErrorProjectCreateTooLong is an error when you try to create a project // wuth more than 30 characters ErrorProjectCreateTooLong = fmt.Errorf("project_id contains too many characters, limit 30") // ErrorProjectCreateTooShort is an error when you try to create a project // wuth less than 6 characters ErrorProjectCreateTooShort = fmt.Errorf("project_id contains too few characters, minimum 6") // ErrorProjectInvalidCharacters is an error when you try and pass bad // characters into a CreateProjectCall ErrorProjectInvalidCharacters = fmt.Errorf("project_id contains invalid characters") // ErrorProjectAlreadyExists is an error when you try and create a project // That already exists ErrorProjectAlreadyExists = fmt.Errorf("project_id already exists") // ErrorProjectDidNotFinish is an error we cannot confirm that project completion actually occured ErrorProjectDidNotFinish = fmt.Errorf("project creation did not complete in a timely manner") )
var DiskProjects = LabeledValues{ LabeledValue{Label: "CentOS", Value: "centos-cloud"}, LabeledValue{Label: "Container-Optimized OS (COS)", Value: "cos-cloud"}, LabeledValue{Label: "Debian", Value: "debian-cloud", IsDefault: true}, LabeledValue{Label: "Fedora CoreOS", Value: "fedora-coreos-cloud"}, LabeledValue{Label: "Red Hat Enterprise Linux (RHEL)", Value: "rhel-cloud"}, LabeledValue{Label: "Red Hat Enterprise Linux (RHEL) for SAP", Value: "rhel-sap-cloud"}, LabeledValue{Label: "Rocky Linux", Value: "rocky-linux-cloud"}, LabeledValue{Label: "SQL Server", Value: "windows-sql-cloud"}, LabeledValue{Label: "SUSE Linux Enterprise Server (SLES)", Value: "suse-cloud"}, LabeledValue{Label: "SUSE Linux Enterprise Server (SLES) for SAP", Value: "suse-cloud"}, LabeledValue{Label: "SUSE Linux Enterprise Server (SLES) BYOS", Value: "suse-byos-cloud"}, LabeledValue{Label: "Ubuntu LTS", Value: "ubuntu-os-cloud"}, LabeledValue{Label: "Ubuntu Pro", Value: "ubuntu-os-pro-cloud"}, LabeledValue{Label: "Windows Server", Value: "windows-cloud"}, }
DiskProjects are the list of projects for disk images for Compute Engine
var ErrorServiceNotExistOrNotAllowed = fmt.Errorf("Not found or permission denied for service")
ErrorServiceNotExistOrNotAllowed occurs when the user running this code doesn't have permission to enable the service in the project or it's a nonexistent service name.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the tool that will handle all of the communication between gcloud and the various product areas
func (*Client) BillingAccountAttach ¶
BillingAccountAttach will enable billing in a given project
func (*Client) BillingAccountList ¶
BillingAccountList gets a list of the billing accounts a user has access to
func (*Client) CloudBuildTriggerCreate ¶
func (c *Client) CloudBuildTriggerCreate(project string, trigger cloudbuild.BuildTrigger) (*cloudbuild.BuildTrigger, error)
CloudBuildTriggerCreate creates a build trigger in a given project
func (*Client) CloudBuildTriggerDelete ¶
CloudBuildTriggerDelete deletes a build trigger in a given project
func (*Client) ComputeRegionList ¶
ComputeRegionList will return a list of regions for Compute Engine
func (Client) DomainIsAvailable ¶
func (c Client) DomainIsAvailable(project, domain string) (*domainspb.RegisterParameters, error)
DomainIsAvailable checks to see if a given domain is available for registration
func (Client) DomainIsVerified ¶
DomainIsVerified checks to see if a given domain belongs to this user
func (Client) DomainRegister ¶
func (c Client) DomainRegister(project string, domaininfo *domainspb.RegisterParameters, contact ContactData) error
DomainRegister handles registring a domain on behalf of the user.
func (Client) DomainsSearch ¶
func (c Client) DomainsSearch(project, domain string) ([]*domainspb.RegisterParameters, error)
DomainsSearch checks the Cloud Domain api for the input domain
func (*Client) FunctionDelete ¶
FunctionDelete deletes a Cloud Function.
func (*Client) FunctionDeploy ¶
FunctionDeploy deploys a Cloud Function.
func (*Client) FunctionGenerateSignedURL ¶
FunctionGenerateSignedURL generates a signed url for use with uploading to Cloud Storage
func (*Client) FunctionGet ¶
FunctionGet gets the details of a Cloud Function.
func (*Client) FunctionRegionList ¶
FunctionRegionList will return a list of regions for Cloud Functions
func (*Client) ImageFamilyList ¶
func (c *Client) ImageFamilyList(imgs *compute.ImageList) LabeledValues
ImageFamilyList gets a list of image families
func (*Client) ImageLatestGet ¶
ImageLatestGet retrieves the latest image from a particular family
func (*Client) ImageList ¶
ImageList gets the list of disk images available for a given image project
func (*Client) ImageTypeListByFamily ¶
func (c *Client) ImageTypeListByFamily(imgs *compute.ImageList, project, family string) LabeledValues
ImageTypeListByFamily retrieves a list of iamge types by the family
func (*Client) JobSchedule ¶
func (c *Client) JobSchedule(project, region string, job schedulerpb.Job) error
JobSchedule creates a Cloud Scheduler Job
func (*Client) MachineTypeFamilyList ¶
func (c *Client) MachineTypeFamilyList(imgs *compute.MachineTypeList) LabeledValues
MachineTypeFamilyList gets the list of machine type families
func (*Client) MachineTypeList ¶
MachineTypeList retrieves the list of Machine Types available in a given zone
func (*Client) MachineTypeListByFamily ¶
func (c *Client) MachineTypeListByFamily(imgs *compute.MachineTypeList, family string) LabeledValues
MachineTypeListByFamily retrieves the list of machine types available for each family
func (*Client) ProjectCreate ¶
ProjectCreate does the work of actually creating a new project in your GCP account
func (*Client) ProjectDelete ¶
ProjectDelete does the work of actually deleting an existing project in your GCP account
func (*Client) ProjectExists ¶
ProjectExists confirms that a project actually exists
func (*Client) ProjectGet ¶
ProjectGet returns the details of a single project
func (*Client) ProjectGrantIAMRole ¶
ProjectGrantIAMRole grants a given principal a given role in a given project
func (Client) ProjectIDGet ¶
ProjectIDGet gets the currently set default project
func (*Client) ProjectIDSet ¶
ProjectIDSet sets the currently set default project
func (*Client) ProjectList ¶
func (c *Client) ProjectList() ([]ProjectWithBilling, error)
ProjectList gets a list of the ProjectList a user has access to
func (*Client) ProjectListWithBilling ¶
func (c *Client) ProjectListWithBilling(p []*cloudresourcemanager.Project) ([]ProjectWithBilling, error)
ProjectListWithBilling gets a list of projects with their billing information
func (*Client) ProjectListWithBillingEnabled ¶
ProjectListWithBillingEnabled queries the billing accounts a user has access to to generate a list of projects for each billing account. Will hopefully reduce the number of calls made to billing api
func (*Client) ProjectNumberGet ¶
ProjectNumberGet will get the project_number for the input projectid
func (*Client) ProjectParentGet ¶
ProjectParentGet returns the parent of an input project
func (*Client) RegionList ¶
RegionList will return a list of RegionsList depending on product type
func (*Client) RunRegionList ¶
RunRegionList will return a list of regions for Cloud Run
func (*Client) SecretCreate ¶
SecretCreate creates a secret and populates the lastest version with a payload.
func (*Client) SecretDelete ¶
SecretDelete deletes a secret
func (*Client) ServiceAccountCreate ¶
ServiceAccountCreate creates a service account. A little on the nose
func (*Client) ServiceAccountDelete ¶
ServiceAccountDelete deletes a service account. A little on the nose
func (*Client) ServiceDisable ¶
ServiceDisable disables a service in the selected project
func (*Client) ServiceEnable ¶
ServiceEnable enable a service in the selected project so that query calls to various lists will work.
func (*Client) ServiceIsEnabled ¶
ServiceIsEnabled checks to see if the existing service is already enabled in the project we are trying to enable it in.
func (*Client) StorageBucketCreate ¶
StorageBucketCreate creates a storage bucket in Cloud Storage
func (*Client) StorageBucketDelete ¶
StorageBucketDelete deletes a storage bucket in Cloud Storage
func (*Client) StorageObjectCreate ¶
StorageObjectCreate creates an object in a particular bucket in Cloud Storage
func (*Client) StorageObjectDelete ¶
StorageObjectDelete deletes an object in a particular bucket in Cloud Storage
type ContactData ¶
type ContactData struct {
AllContacts DomainRegistrarContact `yaml:"allContacts"`
}
ContactData represents the structure that we need for Registrar Contact Data
func NewContactData ¶
func NewContactData() ContactData
NewContactData returns a properly initialized ContactData
func (ContactData) DomainContact ¶
func (c ContactData) DomainContact() (domainspb.ContactSettings, error)
DomainContact outputs a varible in the format that Domain Registration API needs.
func (*ContactData) ReadFrom ¶ added in v1.10.0
func (c *ContactData) ReadFrom(r io.Reader) (int64, error)
ReadFrom populates the content of ContactData from a reader
func (ContactData) WriteTo ¶ added in v1.10.0
func (c ContactData) WriteTo(w io.Writer) (int64, error)
WriteTo writes the content of ContactData to a writer
func (ContactData) YAML ¶
func (c ContactData) YAML() (string, error)
YAML outputs the content of this structure into the contact format needed for domain registration
type DomainRegistrarContact ¶
type DomainRegistrarContact struct { Email string `yaml:"email"` Phone string `yaml:"phoneNumber"` PostalAddress PostalAddress `yaml:"postalAddress"` }
DomainRegistrarContact represents the data required to register a domain with a public registrar.
type LabeledValue ¶
LabeledValue is a struct that contains a label/value pair
func NewLabeledValue ¶
func NewLabeledValue(s string) LabeledValue
NewLabeledValue takes a string and converts it to a LabeledValue. If a | delimiter is present it will split into a different label/value
type LabeledValues ¶
type LabeledValues []LabeledValue
LabeledValues is collection of LabledValue structs
func NewLabeledValues ¶
func NewLabeledValues(sl []string, defaultValue string) LabeledValues
NewLabeledValues takes a slice of strings and returns a list of LabeledValues
func (*LabeledValues) GetDefault ¶
func (l *LabeledValues) GetDefault() LabeledValue
GetDefault returns the deafult value of the LabeledValues list
func (*LabeledValues) LongestLen ¶
func (l *LabeledValues) LongestLen() int
LongestLen returns the length of longest LABEL in the list
func (*LabeledValues) SetDefault ¶
func (l *LabeledValues) SetDefault(value string)
SetDefault sets the default value of the list
type PostalAddress ¶
type PostalAddress struct { RegionCode string `yaml:"regionCode"` PostalCode string `yaml:"postalCode"` AdministrativeArea string `yaml:"administrativeArea"` Locality string `yaml:"locality"` AddressLines []string `yaml:"addressLines"` Recipients []string `yaml:"recipients"` }
PostalAddress represents the mail address in a DomainRegistrarContact
type ProjectWithBilling ¶
ProjectWithBilling is a project with it's billing status