Documentation ¶
Index ¶
- Variables
- func DefaultInstanceTypeForArch(arch types.Architecture) string
- func GetBaseDomain(project string) (string, error)
- func GetMachineTypeList(ctx context.Context, svc *compute.Service, ...) ([]*compute.MachineType, error)
- func GetZones(ctx context.Context, svc *compute.Service, project, filter string) ([]*compute.Zone, error)
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsThrottled(err error) bool
- func Platform() (*gcp.Platform, error)
- func Validate(client API, ic *types.InstallConfig) error
- func ValidateCredentialMode(client API, ic *types.InstallConfig) field.ErrorList
- func ValidateEnabledServices(ctx context.Context, client API, project string) error
- func ValidateForProvisioning(ic *types.InstallConfig) error
- func ValidateInstanceType(client API, fieldPath *field.Path, project, region string, zones []string, ...) field.ErrorList
- func ValidatePreExistingPublicDNS(client API, ic *types.InstallConfig) *field.Error
- func ValidatePrivateDNSZone(client API, ic *types.InstallConfig) *field.Error
- type API
- type Client
- func (c *Client) GetCredentials() *googleoauth.Credentials
- func (c *Client) GetDNSZone(ctx context.Context, project, baseDomain string, isPublic bool) (*dns.ManagedZone, error)
- func (c *Client) GetDNSZoneByName(ctx context.Context, project, zoneName string) (*dns.ManagedZone, error)
- func (c *Client) GetEnabledServices(ctx context.Context, project string) ([]string, error)
- func (c *Client) GetImage(ctx context.Context, name string, project string) (*compute.Image, error)
- func (c *Client) GetMachineType(ctx context.Context, project, zone, machineType string) (*compute.MachineType, error)
- func (c *Client) GetMachineTypeWithZones(ctx context.Context, project, region, machineType string) (*compute.MachineType, sets.Set[string], error)
- func (c *Client) GetNamespacedTagValue(ctx context.Context, tagNamespacedName string) (*cloudresourcemanager.TagValue, error)
- func (c *Client) GetNetwork(ctx context.Context, network, project string) (*compute.Network, error)
- func (c *Client) GetProjectByID(ctx context.Context, project string) (*cloudresourcemanager.Project, error)
- func (c *Client) GetProjectPermissions(ctx context.Context, project string, permissions []string) (sets.Set[string], error)
- func (c *Client) GetProjectTags(ctx context.Context, projectID string) (sets.Set[string], error)
- func (c *Client) GetProjects(ctx context.Context) (map[string]string, error)
- func (c *Client) GetPublicDomains(ctx context.Context, project string) ([]string, error)
- func (c *Client) GetRecordSets(ctx context.Context, project, zone string) ([]*dns.ResourceRecordSet, error)
- func (c *Client) GetRegions(ctx context.Context, project string) ([]string, error)
- func (c *Client) GetServiceAccount(ctx context.Context, project, serviceAccount string) (string, error)
- func (c *Client) GetSubnetworks(ctx context.Context, network, project, region string) ([]*compute.Subnetwork, error)
- func (c *Client) GetZones(ctx context.Context, project, filter string) ([]*compute.Zone, error)
- func (c *Client) ValidateServiceAccountHasPermissions(ctx context.Context, project string, permissions []string) (bool, error)
- type Session
- type TagManager
Constants ¶
This section is empty.
Variables ¶
var ( // RequiredBasePermissions is the list of permissions required for an installation. // A list of valid permissions can be found at https://cloud.google.com/iam/docs/understanding-roles. RequiredBasePermissions = []string{} )
Functions ¶
func DefaultInstanceTypeForArch ¶ added in v0.9.153
func DefaultInstanceTypeForArch(arch types.Architecture) string
DefaultInstanceTypeForArch returns the appropriate instance type based on the target architecture.
func GetBaseDomain ¶
GetBaseDomain returns a base domain chosen from among the project's public DNS zones.
func GetMachineTypeList ¶ added in v0.9.153
func GetMachineTypeList(ctx context.Context, svc *compute.Service, project, region, machineType, fields string) ([]*compute.MachineType, error)
GetMachineTypeList retrieves the machine type with the specified fields.
func GetZones ¶ added in v0.9.153
func GetZones(ctx context.Context, svc *compute.Service, project, filter string) ([]*compute.Zone, error)
GetZones uses the GCP Compute Service API to get a list of zones from a project.
func IsForbidden ¶
IsForbidden checks whether a response from the GPC API was forbidden, indicating that a given service account cannot access the specified project.
func IsNotFound ¶
IsNotFound checks whether a response from the GPC API was not found.
func IsThrottled ¶
IsThrottled checks whether a response from the GPC API returns Too Many Requests
func Validate ¶
func Validate(client API, ic *types.InstallConfig) error
Validate executes platform-specific validation.
func ValidateCredentialMode ¶
func ValidateCredentialMode(client API, ic *types.InstallConfig) field.ErrorList
ValidateCredentialMode The presence of `authorized_user` in the credentials indicates that no service account was used for authentication and requires Manual credential mode.
func ValidateEnabledServices ¶
ValidateEnabledServices gets all the enabled services for a project and validate if any of the required services are not enabled. also warns the user if optional services are not enabled.
func ValidateForProvisioning ¶
func ValidateForProvisioning(ic *types.InstallConfig) error
ValidateForProvisioning validates that the install config is valid for provisioning the cluster.
func ValidateInstanceType ¶
func ValidateInstanceType(client API, fieldPath *field.Path, project, region string, zones []string, diskType string, instanceType string, req resourceRequirements, arch string) field.ErrorList
ValidateInstanceType ensures the instance type has sufficient Vcpu and Memory.
func ValidatePreExistingPublicDNS ¶
func ValidatePreExistingPublicDNS(client API, ic *types.InstallConfig) *field.Error
ValidatePreExistingPublicDNS ensure no pre-existing DNS record exists in the public DNS zone for cluster's Kubernetes API. If a PublicDNSZone is provided, the provided zone is verified against the BaseDomain. If no zone is provided, the base domain is checked for any public zone that can be used.
func ValidatePrivateDNSZone ¶
func ValidatePrivateDNSZone(client API, ic *types.InstallConfig) *field.Error
ValidatePrivateDNSZone ensure no pre-existing DNS record exists in the private dns zone matching the name that will be used for this installation.
Types ¶
type API ¶
type API interface { GetNetwork(ctx context.Context, network, project string) (*compute.Network, error) GetMachineType(ctx context.Context, project, zone, machineType string) (*compute.MachineType, error) GetMachineTypeWithZones(ctx context.Context, project, region, machineType string) (*compute.MachineType, sets.Set[string], error) GetPublicDomains(ctx context.Context, project string) ([]string, error) GetDNSZone(ctx context.Context, project, baseDomain string, isPublic bool) (*dns.ManagedZone, error) GetDNSZoneByName(ctx context.Context, project, zoneName string) (*dns.ManagedZone, error) GetSubnetworks(ctx context.Context, network, project, region string) ([]*compute.Subnetwork, error) GetProjects(ctx context.Context) (map[string]string, error) GetRegions(ctx context.Context, project string) ([]string, error) GetRecordSets(ctx context.Context, project, zone string) ([]*dns.ResourceRecordSet, error) GetZones(ctx context.Context, project, filter string) ([]*compute.Zone, error) GetEnabledServices(ctx context.Context, project string) ([]string, error) GetServiceAccount(ctx context.Context, project, serviceAccount string) (string, error) GetCredentials() *googleoauth.Credentials GetImage(ctx context.Context, name string, project string) (*compute.Image, error) GetProjectPermissions(ctx context.Context, project string, permissions []string) (sets.Set[string], error) GetProjectByID(ctx context.Context, project string) (*cloudresourcemanager.Project, error) ValidateServiceAccountHasPermissions(ctx context.Context, project string, permissions []string) (bool, error) GetProjectTags(ctx context.Context, projectID string) (sets.Set[string], error) GetNamespacedTagValue(ctx context.Context, tagNamespacedName string) (*cloudresourcemanager.TagValue, error) }
API represents the calls made to the API.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client makes calls to the GCP API.
func (*Client) GetCredentials ¶
func (c *Client) GetCredentials() *googleoauth.Credentials
GetCredentials returns the credentials used to authenticate the GCP session.
func (*Client) GetDNSZone ¶
func (c *Client) GetDNSZone(ctx context.Context, project, baseDomain string, isPublic bool) (*dns.ManagedZone, error)
GetDNSZone returns a DNS zone for a basedomain.
func (*Client) GetDNSZoneByName ¶
func (c *Client) GetDNSZoneByName(ctx context.Context, project, zoneName string) (*dns.ManagedZone, error)
GetDNSZoneByName returns a DNS zone matching the `zoneName` if the DNS zone exists and can be seen (correct permissions for a private zone) in the project.
func (*Client) GetEnabledServices ¶
GetEnabledServices gets the list of enabled services for a project.
func (*Client) GetImage ¶ added in v0.9.153
GetImage returns the marketplace image specified by the user.
func (*Client) GetMachineType ¶
func (c *Client) GetMachineType(ctx context.Context, project, zone, machineType string) (*compute.MachineType, error)
GetMachineType uses the GCP Compute Service API to get the specified machine type.
func (*Client) GetMachineTypeWithZones ¶ added in v0.9.153
func (c *Client) GetMachineTypeWithZones(ctx context.Context, project, region, machineType string) (*compute.MachineType, sets.Set[string], error)
GetMachineTypeWithZones retrieves the specified machine type and the zones in which it is available.
func (*Client) GetNamespacedTagValue ¶ added in v0.90.0
func (c *Client) GetNamespacedTagValue(ctx context.Context, tagNamespacedName string) (*cloudresourcemanager.TagValue, error)
GetNamespacedTagValue returns the Tag Value metadata fetched using the tag's NamespacedName.
func (*Client) GetNetwork ¶
GetNetwork uses the GCP Compute Service API to get a network by name from a project.
func (*Client) GetProjectByID ¶ added in v0.9.153
func (c *Client) GetProjectByID(ctx context.Context, project string) (*cloudresourcemanager.Project, error)
GetProjectByID retrieves the project specified by its ID.
func (*Client) GetProjectPermissions ¶
func (c *Client) GetProjectPermissions(ctx context.Context, project string, permissions []string) (sets.Set[string], error)
GetProjectPermissions consumes a set of permissions and returns the set of found permissions for the service account (in the provided project). A list of valid permissions can be found at https://cloud.google.com/iam/docs/understanding-roles.
func (*Client) GetProjectTags ¶ added in v0.90.0
GetProjectTags returns the list of effective tags attached to the provided project resource.
func (*Client) GetProjects ¶
GetProjects gets the list of project names and ids associated with the current user in the form of a map whose keys are ids and values are names.
func (*Client) GetPublicDomains ¶
GetPublicDomains returns all of the domains from among the project's public DNS zones.
func (*Client) GetRecordSets ¶
func (c *Client) GetRecordSets(ctx context.Context, project, zone string) ([]*dns.ResourceRecordSet, error)
GetRecordSets returns all the records for a DNS zone.
func (*Client) GetRegions ¶
GetRegions gets the regions that are valid for the project. An error is returned when unsuccessful
func (*Client) GetServiceAccount ¶ added in v0.9.153
func (c *Client) GetServiceAccount(ctx context.Context, project, serviceAccount string) (string, error)
GetServiceAccount retrieves a service account from a project if it exists.
func (*Client) GetSubnetworks ¶
func (c *Client) GetSubnetworks(ctx context.Context, network, project, region string) ([]*compute.Subnetwork, error)
GetSubnetworks uses the GCP Compute Service API to retrieve all subnetworks in a given network.
func (*Client) GetZones ¶
GetZones uses the GCP Compute Service API to get a list of zones from a project.
func (*Client) ValidateServiceAccountHasPermissions ¶
func (c *Client) ValidateServiceAccountHasPermissions(ctx context.Context, project string, permissions []string) (bool, error)
ValidateServiceAccountHasPermissions compares the permissions to the set returned from the GCP API. Returns true if all permissions are available to the service account in the project.
type Session ¶
type Session struct { Credentials *googleoauth.Credentials // Path contains the filepath for provided credentials. When authenticating with // Default Application Credentials, Path will be empty. Path string }
Session is an object representing session for GCP API.
func GetSession ¶
GetSession returns a GCP session by using credentials found in default locations in order: env GOOGLE_CREDENTIALS, env GOOGLE_CLOUD_KEYFILE_JSON, env GCLOUD_KEYFILE_JSON, file ~/.gcp/osServiceAccount.json, and gcloud cli defaults and, if no creds are found, asks for them and stores them on disk in a config file
type TagManager ¶ added in v0.90.0
type TagManager struct {
// contains filtered or unexported fields
}
TagManager handles resource tagging.
func NewTagManager ¶ added in v0.90.0
func NewTagManager(client API) *TagManager
NewTagManager creates a TagManager instance.
func (*TagManager) GetUserTags ¶ added in v0.90.0
func (t *TagManager) GetUserTags(ctx context.Context, projectID string, userTags []gcp.UserTag) (map[string]string, error)
GetUserTags returns the processed list of user provided tags if already available, else validates, persists in-memory and returns the processed tags.