Documentation
¶
Index ¶
- Constants
- func ConvertLocalTimeToUTC(timezone, shutdownAt string) (time.Time, error)
- func CreateVMXEnabledImage(ctx context.Context, cc *ComputeCLIClient, baseImageProject, baseImage string) error
- func MakeVMXEnabledImageURL(projectID string) string
- func RetryWithSleep(ctx context.Context, max int, d time.Duration, ...) error
- func SleepContext(ctx context.Context, d time.Duration) error
- type AppConfig
- type AutoShutdownConfig
- type CommonConfig
- type ComputeCLIClient
- func (cc *ComputeCLIClient) AttachHomeDisk(ctx context.Context) error
- func (cc *ComputeCLIClient) CreateHomeDisk(ctx context.Context) error
- func (cc *ComputeCLIClient) CreateHostVMInstance(ctx context.Context) error
- func (cc *ComputeCLIClient) CreateVMXEnabledImage(ctx context.Context) error
- func (cc *ComputeCLIClient) CreateVMXEnabledInstance(ctx context.Context, baseImageProject, baseImage string) error
- func (cc *ComputeCLIClient) CreateVolumeSnapshot(ctx context.Context) error
- func (cc *ComputeCLIClient) DeleteInstance(ctx context.Context) error
- func (cc *ComputeCLIClient) DeleteVMXEnabledImage(ctx context.Context) error
- func (cc *ComputeCLIClient) ExtendInstance(ctx context.Context) error
- func (cc *ComputeCLIClient) ResizeHomeDisk(ctx context.Context) error
- func (cc *ComputeCLIClient) RestoreVolumeFromSnapshot(ctx context.Context, destZone string) error
- func (cc *ComputeCLIClient) RunSetupHostVM(ctx context.Context) error
- func (cc *ComputeCLIClient) RunSetupVMXEnabled(ctx context.Context, optionalPackages []string) error
- func (cc *ComputeCLIClient) StopInstance(ctx context.Context) error
- func (cc *ComputeCLIClient) Upload(ctx context.Context, file, target, mode string) error
- func (cc *ComputeCLIClient) UploadSetupCommand(ctx context.Context) error
- func (cc *ComputeCLIClient) WaitInstance(ctx context.Context) error
- type ComputeClient
- func (c *ComputeClient) Create(instanceName string, serviceAccountEmail string, machineType string, ...) error
- func (c *ComputeClient) Delete(name string) error
- func (c *ComputeClient) DeleteWithZone(zone, name string) error
- func (c *ComputeClient) GetAggregatedNameList(filter string) (map[string][]string, error)
- func (c *ComputeClient) GetNameSet(filter string) (map[string]struct{}, error)
- type ComputeConfig
- type Config
- type HostVMConfig
- type SecretClient
- type ShutdownConfig
- type Snapshot
Constants ¶
const (
// MetadataKeyShutdownAt is the instance key to represents the time that this instance should be deleted.
MetadataKeyShutdownAt = "shutdown-at"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertLocalTimeToUTC ¶
ConvertLocalTimeToUTC converts local time to UTC
func CreateVMXEnabledImage ¶
func CreateVMXEnabledImage(ctx context.Context, cc *ComputeCLIClient, baseImageProject, baseImage string) error
CreateVMXEnabledImage creates vmx-enabled image
func MakeVMXEnabledImageURL ¶
MakeVMXEnabledImageURL returns vmx-enabled image URL in the project
Types ¶
type AppConfig ¶
type AppConfig struct {
Shutdown ShutdownConfig `yaml:"shutdown"`
}
AppConfig is configuration for GAE app
type AutoShutdownConfig ¶
type AutoShutdownConfig struct { Timezone string `yaml:"timezone"` ShutdownAt string `yaml:"shutdown-at"` }
AutoShutdownConfig is configuration for automatically shutting down host-vm instance
type CommonConfig ¶
type CommonConfig struct { Project string `yaml:"project"` ServiceAccount string `yaml:"serviceaccount"` Zone string `yaml:"zone"` }
CommonConfig is common configuration for GCP
type ComputeCLIClient ¶
type ComputeCLIClient struct {
// contains filtered or unexported fields
}
ComputeCLIClient is GCP compute client using "gcloud compute"
func NewComputeCLIClient ¶
func NewComputeCLIClient(cfg *Config, instance string) *ComputeCLIClient
NewComputeCLIClient returns ComputeCLIClient
func (*ComputeCLIClient) AttachHomeDisk ¶
func (cc *ComputeCLIClient) AttachHomeDisk(ctx context.Context) error
AttachHomeDisk attaches home disk image to host-vm instance
func (*ComputeCLIClient) CreateHomeDisk ¶
func (cc *ComputeCLIClient) CreateHomeDisk(ctx context.Context) error
CreateHomeDisk creates home disk image
func (*ComputeCLIClient) CreateHostVMInstance ¶
func (cc *ComputeCLIClient) CreateHostVMInstance(ctx context.Context) error
CreateHostVMInstance creates host-vm instance
func (*ComputeCLIClient) CreateVMXEnabledImage ¶
func (cc *ComputeCLIClient) CreateVMXEnabledImage(ctx context.Context) error
CreateVMXEnabledImage create GCE vmx-enabled image
func (*ComputeCLIClient) CreateVMXEnabledInstance ¶
func (cc *ComputeCLIClient) CreateVMXEnabledInstance(ctx context.Context, baseImageProject, baseImage string) error
CreateVMXEnabledInstance creates vmx-enabled instance
func (*ComputeCLIClient) CreateVolumeSnapshot ¶
func (cc *ComputeCLIClient) CreateVolumeSnapshot(ctx context.Context) error
CreateVolumeSnapshot creates home volume snapshot
func (*ComputeCLIClient) DeleteInstance ¶
func (cc *ComputeCLIClient) DeleteInstance(ctx context.Context) error
DeleteInstance deletes given instance
func (*ComputeCLIClient) DeleteVMXEnabledImage ¶
func (cc *ComputeCLIClient) DeleteVMXEnabledImage(ctx context.Context) error
DeleteVMXEnabledImage create GCE vmx-enabled image
func (*ComputeCLIClient) ExtendInstance ¶
func (cc *ComputeCLIClient) ExtendInstance(ctx context.Context) error
ExtendInstance extends 2 hours from now for given instance to prevent auto deletion
func (*ComputeCLIClient) ResizeHomeDisk ¶
func (cc *ComputeCLIClient) ResizeHomeDisk(ctx context.Context) error
ResizeHomeDisk resizes home disk image
func (*ComputeCLIClient) RestoreVolumeFromSnapshot ¶
func (cc *ComputeCLIClient) RestoreVolumeFromSnapshot(ctx context.Context, destZone string) error
RestoreVolumeFromSnapshot restores home volume in the target zone
func (*ComputeCLIClient) RunSetupHostVM ¶
func (cc *ComputeCLIClient) RunSetupHostVM(ctx context.Context) error
RunSetupHostVM executes "setup host-vm" on the instance through ssh
func (*ComputeCLIClient) RunSetupVMXEnabled ¶
func (cc *ComputeCLIClient) RunSetupVMXEnabled(ctx context.Context, optionalPackages []string) error
RunSetupVMXEnabled executes "setup vmx-enabled" on the instance through ssh
func (*ComputeCLIClient) StopInstance ¶
func (cc *ComputeCLIClient) StopInstance(ctx context.Context) error
StopInstance stops given instance
func (*ComputeCLIClient) Upload ¶
func (cc *ComputeCLIClient) Upload(ctx context.Context, file, target, mode string) error
Upload uploads a file to the instance through ssh
func (*ComputeCLIClient) UploadSetupCommand ¶
func (cc *ComputeCLIClient) UploadSetupCommand(ctx context.Context) error
UploadSetupCommand uploads the "setup" command on the instance through ssh
func (*ComputeCLIClient) WaitInstance ¶
func (cc *ComputeCLIClient) WaitInstance(ctx context.Context) error
WaitInstance waits given instance until online
type ComputeClient ¶
type ComputeClient struct {
// contains filtered or unexported fields
}
ComputeClient is GCP compute client with go client
func NewComputeClient ¶
func NewComputeClient( ctx context.Context, projectID string, zone string, ) (*ComputeClient, error)
NewComputeClient returns ComputeClient
func (*ComputeClient) Create ¶
func (c *ComputeClient) Create( instanceName string, serviceAccountEmail string, machineType string, numLocalSSDs int, imageURL string, startupScript string, ) error
Create creates a compute instance with running startup script
func (*ComputeClient) Delete ¶
func (c *ComputeClient) Delete(name string) error
Delete deletes a GCP instance
func (*ComputeClient) DeleteWithZone ¶
func (c *ComputeClient) DeleteWithZone(zone, name string) error
DeleteWithZone deletes a GCP instance in the zone
func (*ComputeClient) GetAggregatedNameList ¶
func (c *ComputeClient) GetAggregatedNameList(filter string) (map[string][]string, error)
GetAggregatedNameList gets a list of existing GCP instances with the given filter from all zones
func (*ComputeClient) GetNameSet ¶
func (c *ComputeClient) GetNameSet(filter string) (map[string]struct{}, error)
GetNameSet gets a list of existing GCP instances with the given filter
type ComputeConfig ¶
type ComputeConfig struct { MachineType string `yaml:"machine-type"` NumLocalSSDs int `yaml:"local-ssd"` BootDiskSizeGB int `yaml:"boot-disk-sizeGB"` OptionalPackages []string `yaml:"optional-packages"` HostVM HostVMConfig `yaml:"host-vm"` AutoShutdown AutoShutdownConfig `yaml:"auto-shutdown"` // backward compatibility VMXEnabled struct { OptionalPackages []string `yaml:"optional-packages"` } `yaml:"vmx-enabled"` }
ComputeConfig is configuration for GCE
type Config ¶
type Config struct { Common CommonConfig `yaml:"common"` App AppConfig `yaml:"app"` Compute ComputeConfig `yaml:"compute"` }
Config is configuration for necogcp command and GAE app
func NecoTestConfig ¶
NecoTestConfig returns configuration for neco-test
type HostVMConfig ¶
type HostVMConfig struct { HomeDisk bool `yaml:"home-disk"` HomeDiskSizeGB int `yaml:"home-disk-sizeGB"` Preemptible bool `yaml:"preemptible"` }
HostVMConfig is configuration for host-vm instance
type SecretClient ¶
type SecretClient struct {
// contains filtered or unexported fields
}
func NewSecretClient ¶
func NewSecretClient( ctx context.Context, projectID string, ) (*SecretClient, error)
NewSecretClient returns SecretClient
func (*SecretClient) CreateSecretFromData ¶
func (*SecretClient) GetSecret ¶
func (c *SecretClient) GetSecret(secretID string) (*secretmanagerpb.Secret, error)
type ShutdownConfig ¶
type ShutdownConfig struct { Stop []string `yaml:"stop"` Exclude []string `yaml:"exclude"` Expiration time.Duration `yaml:"expiration"` Timezone string `yaml:"timezone"` ShutdownAt string `yaml:"shutdown-at"` AdditionalZones []string `yaml:"additional-zones"` }
ShutdownConfig is automatic shutdown configuration