Documentation ¶
Overview ¶
pkg/providers/gcp/provider.go
Index ¶
- Variables
- func ConvertGCPResourceState(state string) models.GCPResourceState
- func GenerateTags(projectID, uniqueID string) map[string]string
- func GetGCPClient(ctx context.Context, organizationID string) (gcp_interface.GCPClienter, func(), error)
- func GetRequiredAPIs() []string
- func NewGCPClient(ctx context.Context, organizationID string) (gcp_interface.GCPClienter, func(), error)
- type CloseableClient
- type GCPProvider
- func (p *GCPProvider) CheckAuthentication(ctx context.Context) error
- func (p *GCPProvider) CheckPermissions(ctx context.Context) error
- func (p *GCPProvider) CreateFirewallRules(ctx context.Context, networkName string) error
- func (p *GCPProvider) CreateResources(ctx context.Context) error
- func (p *GCPProvider) CreateVM(ctx context.Context, vmName string) (string, string, error)
- func (p *GCPProvider) CreateVPCNetwork(ctx context.Context, networkName string) error
- func (p *GCPProvider) DestroyProject(ctx context.Context, projectID string) error
- func (p *GCPProvider) DestroyResources(ctx context.Context, projectID string) error
- func (p *GCPProvider) EnableAPI(ctx context.Context, apiName string) error
- func (p *GCPProvider) EnableRequiredAPIs(ctx context.Context) error
- func (p *GCPProvider) EnsureFirewallRules(ctx context.Context, networkName string) error
- func (p *GCPProvider) EnsureProject(ctx context.Context) error
- func (p *GCPProvider) EnsureVPCNetwork(ctx context.Context, vpcNetworkName string) error
- func (p *GCPProvider) FinalizeDeployment(ctx context.Context) error
- func (p *GCPProvider) GetClusterDeployer() common_interface.ClusterDeployerer
- func (p *GCPProvider) GetGCPClient() gcp_interface.GCPClienter
- func (p *GCPProvider) GetVMExternalIP(ctx context.Context, vmName string, locationData map[string]string) (string, error)
- func (p *GCPProvider) Initialize(ctx context.Context) error
- func (p *GCPProvider) ListAllAssetsInProject(ctx context.Context, projectID string) ([]*assetpb.Asset, error)
- func (p *GCPProvider) ListBillingAccounts(ctx context.Context) ([]string, error)
- func (p *GCPProvider) ListProjects(ctx context.Context) ([]*resourcemanagerpb.Project, error)
- func (p *GCPProvider) PollResources(ctx context.Context) ([]interface{}, error)
- func (p *GCPProvider) PrepareDeployment(ctx context.Context) (*models.Deployment, error)
- func (p *GCPProvider) ProcessMachinesConfig(ctx context.Context) (map[string]models.Machiner, map[string]bool, error)
- func (p *GCPProvider) SetBillingAccount(ctx context.Context, billingAccountID string) error
- func (p *GCPProvider) SetClusterDeployer(deployer common_interface.ClusterDeployerer)
- func (p *GCPProvider) SetGCPClient(client gcp_interface.GCPClienter)
- func (p *GCPProvider) StartResourcePolling(ctx context.Context) <-chan error
- func (p *GCPProvider) ValidateMachineType(ctx context.Context, location, machineType string) (bool, error)
- type GCPVMConfig
- type LiveGCPClient
- func (c *LiveGCPClient) CheckAuthentication(ctx context.Context) error
- func (c *LiveGCPClient) CheckFirewallRuleExists(ctx context.Context, projectID, ruleName string) error
- func (c *LiveGCPClient) CheckPermissions(ctx context.Context) error
- func (c *LiveGCPClient) CheckProjectAccess(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) CheckSpecificPermission(ctx context.Context, permission string) error
- func (c *LiveGCPClient) CreateFirewallRules(ctx context.Context, networkName string) error
- func (c *LiveGCPClient) CreateIP(ctx context.Context, projectID, region string, addressName string) (string, error)
- func (c *LiveGCPClient) CreateServiceAccount(ctx context.Context, projectID string) (*iam.ServiceAccount, error)
- func (c *LiveGCPClient) CreateVM(ctx context.Context, projectID string, machine models.Machiner) (*computepb.Instance, error)
- func (c *LiveGCPClient) CreateVPCNetwork(ctx context.Context, networkName string) error
- func (c *LiveGCPClient) DestroyProject(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) EnableAPI(ctx context.Context, projectID, apiName string) error
- func (c *LiveGCPClient) EnsureFirewallRules(ctx context.Context, networkName string) error
- func (c *LiveGCPClient) EnsureProject(ctx context.Context, organizationID string, projectID string, ...) (string, error)
- func (c *LiveGCPClient) EnsureServiceAccount(ctx context.Context, projectID, serviceAccountName string) error
- func (c *LiveGCPClient) EnsureVPCNetwork(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) GetParentString() string
- func (c *LiveGCPClient) GetVMExternalIP(ctx context.Context, vmName string, locationData map[string]string) (string, error)
- func (c *LiveGCPClient) GetVMZone(ctx context.Context, projectID, vmName string) (string, error)
- func (c *LiveGCPClient) IsAPIEnabled(ctx context.Context, projectID, apiName string) (bool, error)
- func (c *LiveGCPClient) ListAllAssetsInProject(ctx context.Context, projectID string) ([]*assetpb.Asset, error)
- func (c *LiveGCPClient) ListBillingAccounts(ctx context.Context) ([]string, error)
- func (c *LiveGCPClient) ListProjects(ctx context.Context, req *resourcemanagerpb.ListProjectsRequest) ([]*resourcemanagerpb.Project, error)
- func (c *LiveGCPClient) ProjectExists(ctx context.Context, projectID string) (bool, error)
- func (c *LiveGCPClient) SetBillingAccount(ctx context.Context, projectID string, billingAccountID string) error
- func (c *LiveGCPClient) SetParentString(organizationID string)
- func (c *LiveGCPClient) StartResourcePolling(ctx context.Context) error
- func (c *LiveGCPClient) TestCloudStorageAPI(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) TestComputeEngineAPI(ctx context.Context, projectID string, ...) error
- func (c *LiveGCPClient) TestIAMPermissions(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) TestServiceUsageAPI(ctx context.Context, projectID string) error
- func (c *LiveGCPClient) UpdateResourceState(resourceName, resourceType string, state models.MachineResourceState) error
- func (c *LiveGCPClient) ValidateMachineType(ctx context.Context, machineType, location string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var GCPRequiredAPIs = []string{
"compute.googleapis.com",
"networkmanagement.googleapis.com",
"storage-api.googleapis.com",
"file.googleapis.com",
"storage.googleapis.com",
"cloudasset.googleapis.com",
}
Constants related to GCP APIs and configurations
var NewGCPClientFunc = NewGCPClient
var NewGCPProviderFunc = NewGCPProviderFactory
Functions ¶
func ConvertGCPResourceState ¶
func ConvertGCPResourceState(state string) models.GCPResourceState
func GenerateTags ¶
GenerateTags creates a map of tags for GCP resources
func GetGCPClient ¶
func GetGCPClient( ctx context.Context, organizationID string, ) (gcp_interface.GCPClienter, func(), error)
func GetRequiredAPIs ¶
func GetRequiredAPIs() []string
func NewGCPClient ¶
func NewGCPClient( ctx context.Context, organizationID string, ) (gcp_interface.GCPClienter, func(), error)
Types ¶
type CloseableClient ¶
type CloseableClient interface {
Close() error
}
type GCPProvider ¶
type GCPProvider struct { ProjectID string OrganizationID string BillingAccountID string Client gcp_interface.GCPClienter ClusterDeployer common_interface.ClusterDeployerer CleanupClient func() Config *viper.Viper SSHClient sshutils.SSHClienter SSHUser string SSHPort int // contains filtered or unexported fields }
GCPProvider implements the Providerer interface for GCP
func NewGCPProvider ¶
func NewGCPProvider( ctx context.Context, organizationID, billingAccountID string, ) (*GCPProvider, error)
NewGCPProvider creates a new GCP provider
func NewGCPProviderFactory ¶
func NewGCPProviderFactory( ctx context.Context, organizationID, billingAccountID string, ) (*GCPProvider, error)
NewGCPProviderFactory is the factory function for GCPProvider.
func (*GCPProvider) CheckAuthentication ¶
func (p *GCPProvider) CheckAuthentication(ctx context.Context) error
CheckAuthentication verifies GCP authentication
func (*GCPProvider) CheckPermissions ¶
func (p *GCPProvider) CheckPermissions(ctx context.Context) error
CheckPermissions checks the current user's permissions
func (*GCPProvider) CreateFirewallRules ¶
func (p *GCPProvider) CreateFirewallRules( ctx context.Context, networkName string, ) error
CreateFirewallRules creates firewall rules for a specified network
func (*GCPProvider) CreateResources ¶
func (p *GCPProvider) CreateResources(ctx context.Context) error
CreateResources implements the ClusterDeployer interface for GCP
func (*GCPProvider) CreateVPCNetwork ¶
func (p *GCPProvider) CreateVPCNetwork( ctx context.Context, networkName string, ) error
CreateVPCNetwork creates a VPC network in the specified project
func (*GCPProvider) DestroyProject ¶
func (p *GCPProvider) DestroyProject( ctx context.Context, projectID string, ) error
DestroyProject destroys a specified GCP project
func (*GCPProvider) DestroyResources ¶
func (p *GCPProvider) DestroyResources( ctx context.Context, projectID string, ) error
func (*GCPProvider) EnableAPI ¶
func (p *GCPProvider) EnableAPI(ctx context.Context, apiName string) error
EnableAPI enables a specific GCP API for the project
func (*GCPProvider) EnableRequiredAPIs ¶
func (p *GCPProvider) EnableRequiredAPIs(ctx context.Context) error
EnableRequiredAPIs enables all required GCP APIs for the project
func (*GCPProvider) EnsureFirewallRules ¶
func (p *GCPProvider) EnsureFirewallRules( ctx context.Context, networkName string, ) error
EnsureFirewallRules ensures that firewall rules are set for a network
func (*GCPProvider) EnsureProject ¶
func (p *GCPProvider) EnsureProject( ctx context.Context, ) error
EnsureProject ensures that a GCP project exists, creating it if necessary
func (*GCPProvider) EnsureVPCNetwork ¶
func (p *GCPProvider) EnsureVPCNetwork( ctx context.Context, vpcNetworkName string, ) error
func (*GCPProvider) FinalizeDeployment ¶
func (p *GCPProvider) FinalizeDeployment(ctx context.Context) error
FinalizeDeployment finalizes the deployment process
func (*GCPProvider) GetClusterDeployer ¶
func (p *GCPProvider) GetClusterDeployer() common_interface.ClusterDeployerer
GetClusterDeployer returns the current ClusterDeployer
func (*GCPProvider) GetGCPClient ¶
func (p *GCPProvider) GetGCPClient() gcp_interface.GCPClienter
GetGCPClient returns the current GCP client
func (*GCPProvider) GetVMExternalIP ¶
func (p *GCPProvider) GetVMExternalIP( ctx context.Context, vmName string, locationData map[string]string, ) (string, error)
GetVMExternalIP retrieves the external IP of a VM instance
func (*GCPProvider) Initialize ¶
func (p *GCPProvider) Initialize(ctx context.Context) error
Initialize initializes the GCP provider
func (*GCPProvider) ListAllAssetsInProject ¶
func (p *GCPProvider) ListAllAssetsInProject( ctx context.Context, projectID string, ) ([]*assetpb.Asset, error)
ListAllAssetsInProject lists all assets within a GCP project
func (*GCPProvider) ListBillingAccounts ¶
func (p *GCPProvider) ListBillingAccounts(ctx context.Context) ([]string, error)
ListBillingAccounts lists all billing accounts associated with the GCP organization
func (*GCPProvider) ListProjects ¶
func (p *GCPProvider) ListProjects( ctx context.Context, ) ([]*resourcemanagerpb.Project, error)
ListProjects lists all GCP projects
func (*GCPProvider) PollResources ¶
func (p *GCPProvider) PollResources(ctx context.Context) ([]interface{}, error)
PollResources polls resources for updates
func (*GCPProvider) PrepareDeployment ¶
func (p *GCPProvider) PrepareDeployment(ctx context.Context) (*models.Deployment, error)
PrepareDeployment prepares the deployment configuration
func (*GCPProvider) ProcessMachinesConfig ¶
func (*GCPProvider) SetBillingAccount ¶
func (p *GCPProvider) SetBillingAccount( ctx context.Context, billingAccountID string, ) error
SetBillingAccount sets the billing account for the GCP project
func (*GCPProvider) SetClusterDeployer ¶
func (p *GCPProvider) SetClusterDeployer(deployer common_interface.ClusterDeployerer)
SetClusterDeployer sets a new ClusterDeployer
func (*GCPProvider) SetGCPClient ¶
func (p *GCPProvider) SetGCPClient(client gcp_interface.GCPClienter)
SetGCPClient sets a new GCP client
func (*GCPProvider) StartResourcePolling ¶
func (p *GCPProvider) StartResourcePolling(ctx context.Context) <-chan error
StartResourcePolling starts polling resources for updates
func (*GCPProvider) ValidateMachineType ¶
type GCPVMConfig ¶
type GCPVMConfig struct { ProjectID string Region string Zone string VMName string MachineType string SSHUser string PublicKeyMaterial string }
GCPVMConfig holds the configuration for a GCP VM
type LiveGCPClient ¶
type LiveGCPClient struct {
// contains filtered or unexported fields
}
func (*LiveGCPClient) CheckAuthentication ¶
func (c *LiveGCPClient) CheckAuthentication(ctx context.Context) error
func (*LiveGCPClient) CheckFirewallRuleExists ¶
func (c *LiveGCPClient) CheckFirewallRuleExists( ctx context.Context, projectID, ruleName string, ) error
func (*LiveGCPClient) CheckPermissions ¶
func (c *LiveGCPClient) CheckPermissions(ctx context.Context) error
func (*LiveGCPClient) CheckProjectAccess ¶
func (c *LiveGCPClient) CheckProjectAccess(ctx context.Context, projectID string) error
func (*LiveGCPClient) CheckSpecificPermission ¶
func (c *LiveGCPClient) CheckSpecificPermission(ctx context.Context, permission string) error
func (*LiveGCPClient) CreateFirewallRules ¶
func (c *LiveGCPClient) CreateFirewallRules(ctx context.Context, networkName string) error
func (*LiveGCPClient) CreateServiceAccount ¶
func (c *LiveGCPClient) CreateServiceAccount( ctx context.Context, projectID string, ) (*iam.ServiceAccount, error)
func (*LiveGCPClient) CreateVPCNetwork ¶
func (c *LiveGCPClient) CreateVPCNetwork(ctx context.Context, networkName string) error
func (*LiveGCPClient) DestroyProject ¶
func (c *LiveGCPClient) DestroyProject(ctx context.Context, projectID string) error
func (*LiveGCPClient) EnableAPI ¶
func (c *LiveGCPClient) EnableAPI(ctx context.Context, projectID, apiName string) error
func (*LiveGCPClient) EnsureFirewallRules ¶
func (c *LiveGCPClient) EnsureFirewallRules(ctx context.Context, networkName string) error
func (*LiveGCPClient) EnsureProject ¶
func (*LiveGCPClient) EnsureServiceAccount ¶
func (c *LiveGCPClient) EnsureServiceAccount( ctx context.Context, projectID, serviceAccountName string, ) error
func (*LiveGCPClient) EnsureVPCNetwork ¶
func (c *LiveGCPClient) EnsureVPCNetwork(ctx context.Context, projectID string) error
func (*LiveGCPClient) GetParentString ¶
func (c *LiveGCPClient) GetParentString() string
func (*LiveGCPClient) GetVMExternalIP ¶
func (*LiveGCPClient) IsAPIEnabled ¶
func (*LiveGCPClient) ListAllAssetsInProject ¶
func (*LiveGCPClient) ListBillingAccounts ¶
func (c *LiveGCPClient) ListBillingAccounts(ctx context.Context) ([]string, error)
func (*LiveGCPClient) ListProjects ¶
func (c *LiveGCPClient) ListProjects( ctx context.Context, req *resourcemanagerpb.ListProjectsRequest, ) ([]*resourcemanagerpb.Project, error)
func (*LiveGCPClient) ProjectExists ¶
func (*LiveGCPClient) SetBillingAccount ¶
func (*LiveGCPClient) SetParentString ¶
func (c *LiveGCPClient) SetParentString(organizationID string)
func (*LiveGCPClient) StartResourcePolling ¶
func (c *LiveGCPClient) StartResourcePolling(ctx context.Context) error
func (*LiveGCPClient) TestCloudStorageAPI ¶
func (c *LiveGCPClient) TestCloudStorageAPI(ctx context.Context, projectID string) error
func (*LiveGCPClient) TestComputeEngineAPI ¶
func (*LiveGCPClient) TestIAMPermissions ¶
func (c *LiveGCPClient) TestIAMPermissions(ctx context.Context, projectID string) error
func (*LiveGCPClient) TestServiceUsageAPI ¶
func (c *LiveGCPClient) TestServiceUsageAPI(ctx context.Context, projectID string) error
func (*LiveGCPClient) UpdateResourceState ¶
func (c *LiveGCPClient) UpdateResourceState( resourceName, resourceType string, state models.MachineResourceState, ) error