common

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2023 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalScratch  BlockDeviceType = "scratch"
	ZonalStandard                 = "pd-standard"
	ZonalBalanced                 = "pd-balanced"
	ZonalSSD                      = "pd-ssd"
	ZonalExtreme                  = "pd-extreme"
)

Variables

View Source
var DriverScopes = []string{
	"https://www.googleapis.com/auth/compute",
	"https://www.googleapis.com/auth/devstorage.full_control",
	"https://www.googleapis.com/auth/userinfo.email",
}

Functions

func GetNetworking

func GetNetworking(c *InstanceConfig) (string, string, error)

This method will build a network and subnetwork ID from the provided instance config, and return them in that order.

func GetRegionFromZone

func GetRegionFromZone(zone string) (string, error)

func IsZoneARegion

func IsZoneARegion(zone string) bool

func NewClientOptionGoogle

func NewClientOptionGoogle(vaultOauth string, impersonatesa string, accessToken string, credentials *google.Credentials, scopes []string) ([]option.ClientOption, error)

Types

type Authentication

type Authentication struct {
	// A temporary [OAuth 2.0 access token](https://developers.google.com/identity/protocols/oauth2)
	// obtained from the Google Authorization server, i.e. the `Authorization: Bearer` token used to
	// authenticate HTTP requests to GCP APIs.
	// This is an alternative to `account_file`, and ignores the `scopes` field.
	// If both are specified, `access_token` will be used over the `account_file` field.
	//
	// These access tokens cannot be renewed by Packer and thus will only work until they expire.
	// If you anticipate Packer needing access for longer than a token's lifetime (default `1 hour`),
	// please use a service account key with `account_file` instead.
	AccessToken string `mapstructure:"access_token" required:"false"`
	// The JSON file containing your account credentials. Not required if you
	// run Packer on a GCE instance with a service account. Instructions for
	// creating the file or using service accounts are above.
	AccountFile string `mapstructure:"account_file" required:"false"`
	// The JSON file containing your account credentials.
	//
	// The file's contents may be anything supported by the Google Go client, i.e.:
	//
	// * Service account JSON
	// * OIDC-provided token for federation
	// * Gcloud user credentials file (refresh-token JSON)
	// * A Google Developers Console client_credentials.json
	CredentialsFile string `mapstructure:"credentials_file" required:"false"`
	// The raw JSON payload for credentials.
	//
	// The accepted data formats are same as those described under
	// [credentials_file](#credentials_file).
	CredentialsJSON string `mapstructure:"credentials_json" required:"false"`
	// This allows service account impersonation as per the [docs](https://cloud.google.com/iam/docs/impersonating-service-accounts).
	ImpersonateServiceAccount string `mapstructure:"impersonate_service_account" required:"false"`
	// Can be set instead of account_file. If set, this builder will use
	// HashiCorp Vault to generate an Oauth token for authenticating against
	// Google Cloud. The value should be the path of the token generator
	// within vault.
	// For information on how to configure your Vault + GCP engine to produce
	// Oauth tokens, see https://www.vaultproject.io/docs/auth/gcp
	// You must have the environment variables VAULT_ADDR and VAULT_TOKEN set,
	// along with any other relevant variables for accessing your vault
	// instance. For more information, see the Vault docs:
	// https://www.vaultproject.io/docs/commands/#environment-variables
	// Example:`"vault_gcp_oauth_engine": "gcp/token/my-project-editor",`
	VaultGCPOauthEngine string `mapstructure:"vault_gcp_oauth_engine"`
	// contains filtered or unexported fields
}

func (Authentication) ApplyDriverConfig

func (a Authentication) ApplyDriverConfig(cfg *GCEDriverConfig)

ApplyDriverConfig applies the authentication configuration to the config for the GCE Driver

func (*Authentication) FlatMapstructure

func (*Authentication) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatAuthentication. FlatAuthentication is an auto-generated flat version of Authentication. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*Authentication) Prepare

func (a *Authentication) Prepare() ([]string, error)

type BlockDevice

type BlockDevice struct {
	// How to attach the volume to the instance
	//
	// Can be either READ_ONLY or READ_WRITE (default).
	AttachmentMode string `mapstructure:"attachment_mode"`
	// If true, an image will be created for this disk, instead of the boot disk.
	//
	// This only applies to non-scratch disks, and can only be specified on one disk at a
	// time.
	CreateImage bool `mapstructure:"create_image"`
	// The device name as exposed to the OS in the /dev/disk/by-id/google-* directory
	//
	// If unspecified, the disk will have a default name in the form
	// persistent-disk-x with 'x' being a number assigned by GCE
	//
	// This field only applies to persistent disks, local SSDs will always
	// be exposed as /dev/disk/by-id/google-local-nvme-ssd-x.
	DeviceName string `mapstructure:"device_name"`
	// Disk encryption key to apply to the requested disk.
	//
	// Possible values:
	// * kmsKeyName -  The name of the encryption key that is stored in Google Cloud KMS.
	// * RawKey: - A 256-bit customer-supplied encryption key, encodes in RFC 4648 base64.
	DiskEncryptionKey CustomerEncryptionKey `mapstructure:"disk_encryption_key"`
	// Name of the disk to create.
	// This only applies to non-scratch disks. If the disk is persistent, and
	// not specified, Packer will generate a unique name for the disk.
	//
	// The name must be 1-63 characters long and comply to the regexp
	// '[a-z]([-a-z0-9]*[a-z0-9])?'
	DiskName string `mapstructure:"disk_name"`
	// The interface to use for attaching the disk.
	// Can be either NVME or SCSI. Defaults to SCSI.
	//
	// The available options depend on the type of disk, SEE: https://cloud.google.com/compute/docs/disks/persistent-disks#choose_an_interface
	InterfaceType string `mapstructure:"interface_type"`
	// The requested IOPS for the disk.
	//
	// This is only available for pd_extreme disks.
	IOPS int `mapstructure:"iops"`
	// Keep the device in the created disks after the instance is terminated.
	// By default, the builder will remove the disks at the end of the build.
	//
	// This cannot be used with 'scratch' volumes.
	KeepDevice bool `mapstructure:"keep_device"`
	// The list of extra zones to replicate the disk into
	//
	// The zone in which the instance is created will automatically be
	// added to the zones in which the disk is replicated.
	ReplicaZones []string `mapstructure:"replica_zones" required:"false"`
	// The URI of the volume to attach
	//
	// If this is specified, it won't be deleted after the instance is shut-down.
	SourceVolume string `mapstructure:"source_volume"`
	// Size of the volume to request, in gigabytes.
	//
	// The size specified must be in range of the sizes for the chosen volume type.
	VolumeSize int `mapstructure:"volume_size" required:"true"`
	// The volume type is the type of storage to reserve and attach to the instance being provisioned.
	//
	// The following values are supported by this builder:
	// * scratch: local SSD data, always 375 GiB (default)
	// * pd_standard: persistent, HDD-backed disk
	// * pd_balanced: persistent, SSD-backed disk
	// * pd_ssd: persistent, SSD-backed disk, with extra performance guarantees
	// * pd_extreme: persistent, fastest SSD-backed disk, with custom IOPS
	//
	// For details on the different types, refer to: https://cloud.google.com/compute/docs/disks#disk-types
	VolumeType BlockDeviceType `mapstructure:"volume_type" required:"true"`
	// Zone is the zone in which to create the disk in.
	//
	// It is not exposed since the parent config already specifies it
	// and it will be set for the block device when preparing it.
	Zone string `mapstructure:"_"`
}

BlockDevice is a block device attachement/creation to an instance when building an image.

func (*BlockDevice) FlatMapstructure

func (*BlockDevice) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatBlockDevice. FlatBlockDevice is an auto-generated flat version of BlockDevice. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (BlockDevice) GenerateComputeDiskPayload

func (bd BlockDevice) GenerateComputeDiskPayload() (*compute.Disk, error)

func (BlockDevice) GenerateDiskAttachment

func (bd BlockDevice) GenerateDiskAttachment() *compute.AttachedDisk

func (*BlockDevice) Prepare

func (bd *BlockDevice) Prepare() []error

type BlockDeviceType

type BlockDeviceType string

type CustomerEncryptionKey

type CustomerEncryptionKey struct {
	// KmsKeyName: The name of the encryption key that is stored in Google
	// Cloud KMS.
	KmsKeyName string `mapstructure:"kmsKeyName" json:"kmsKeyName,omitempty"`

	// RawKey: Specifies a 256-bit customer-supplied encryption key, encoded
	// in RFC 4648 base64 to either encrypt or decrypt this resource.
	RawKey string `mapstructure:"rawKey" json:"rawKey,omitempty"`
}

func (*CustomerEncryptionKey) ComputeType

func (*CustomerEncryptionKey) FlatMapstructure

func (*CustomerEncryptionKey) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatCustomerEncryptionKey. FlatCustomerEncryptionKey is an auto-generated flat version of CustomerEncryptionKey. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type Driver

type Driver interface {
	// CreateDisk creates a persistent disk from the specified config.
	CreateDisk(diskConfig BlockDevice) (<-chan *compute.Disk, <-chan error)

	// CreateImage creates an image from the given disk in Google Compute
	// Engine.
	CreateImage(project string, imageSpec *compute.Image) (<-chan *Image, <-chan error)

	// DeleteImage deletes the image with the given name.
	DeleteImage(project, name string) <-chan error

	// DeleteInstance deletes the given instance, keeping the boot disk.
	DeleteInstance(zone, name string) (<-chan error, error)

	// DeleteDisk deletes the disk with the given name.
	DeleteDisk(zone, name string) <-chan error

	// GetDisk gets the disk with the given name in a zone/region.
	GetDisk(zone, name string) (*compute.Disk, error)

	// GetImage gets an image; tries the default and public projects. If
	// fromFamily is true, name designates an image family instead of a
	// particular image.
	GetImage(name string, fromFamily bool) (*Image, error)

	// GetImageFromProject gets an image from a specific projects.
	// Returns the image from the first project in slice it can find one
	// If fromFamily is true, name designates an image family instead of a particular image.
	GetImageFromProjects(project []string, name string, fromFamily bool) (*Image, error)

	// GetImageFromProject gets an image from a specific project. If fromFamily
	// is true, name designates an image family instead of a particular image.
	GetImageFromProject(project, name string, fromFamily bool) (*Image, error)

	// GetInstanceMetadata gets a metadata variable for the instance, name.
	GetInstanceMetadata(zone, name, key string) (string, error)

	// GetInternalIP gets the GCE-internal IP address for the instance.
	GetInternalIP(zone, name string) (string, error)

	// GetNatIP gets the NAT IP address for the instance.
	GetNatIP(zone, name string) (string, error)

	// GetSerialPortOutput gets the Serial Port contents for the instance.
	GetSerialPortOutput(zone, name string) (string, error)

	// GetTokenInfo gets the information about the token used for authentication
	GetTokenInfo() (*oauth2_svc.Tokeninfo, error)

	// ImageExists returns true if the specified image exists. If an error
	// occurs calling the API, this method returns false.
	ImageExists(project, name string) bool

	// RunInstance takes the given config and launches an instance.
	RunInstance(*InstanceConfig) (<-chan error, error)

	// WaitForInstance waits for an instance to reach the given state.
	WaitForInstance(state, zone, name string) <-chan error

	// CreateOrResetWindowsPassword creates or resets the password for a user on an Windows instance.
	CreateOrResetWindowsPassword(zone, name string, config *WindowsPasswordConfig) (<-chan error, error)

	// ImportOSLoginSSHKey imports SSH public key for OSLogin.
	ImportOSLoginSSHKey(user, sshPublicKey string) (*oslogin.LoginProfile, error)

	// DeleteOSLoginSSHKey deletes the SSH public key for OSLogin with the given key.
	DeleteOSLoginSSHKey(user, fingerprint string) error

	// Add to the instance metadata for the existing instance
	AddToInstanceMetadata(zone string, name string, metadata map[string]string) error

	// UploadToBucket uploads an artifact to a bucket on GCS.
	UploadToBucket(bucket, objectName string, data io.Reader) (string, error)

	// DeleteFromBucket deletes an object from a bucket on GCS.
	DeleteFromBucket(bucket, objectName string) error
}

Driver is the interface that has to be implemented to communicate with GCE. The Driver interface exists mostly to allow a mock implementation to be used to test the steps.

func NewDriverGCE

func NewDriverGCE(config GCEDriverConfig) (Driver, error)

type DriverMock

type DriverMock struct {
	CreateDiskConfig   BlockDevice
	CreateDiskResultCh <-chan *compute.Disk
	CreateDiskErrCh    <-chan error

	CreateImageProjectId      string
	CreateImageSpec           *compute.Image
	CreateImageReturnDiskSize int64
	CreateImageReturnSelfLink string
	CreateImageErrCh          <-chan error
	CreateImageResultCh       <-chan *Image

	DeleteProjectId  string
	DeleteImageName  string
	DeleteImageErrCh <-chan error

	DeleteInstanceZone  string
	DeleteInstanceName  string
	DeleteInstanceErrCh <-chan error
	DeleteInstanceErr   error

	DeleteDiskZone  string
	DeleteDiskName  string
	DeleteDiskErrCh chan error
	DeleteDiskErr   error

	DeleteFromBucketBucket     string
	DeleteFromBucketObjectName string
	DeleteFromBucketErr        error

	GetDiskName   string
	GetDiskZone   string
	GetDiskResult *compute.Disk
	GetDiskErr    error

	GetImageName           string
	GetImageSourceProjects []string
	GetImageFromFamily     bool
	GetImageResult         *Image
	GetImageErr            error

	GetImageFromProjectProject    string
	GetImageFromProjectName       string
	GetImageFromProjectFromFamily bool
	GetImageFromProjectResult     *Image
	GetImageFromProjectErr        error

	GetInstanceMetadataZone   string
	GetInstanceMetadataName   string
	GetInstanceMetadataKey    string
	GetInstanceMetadataResult string
	GetInstanceMetadataErr    error

	GetTokenInfoResult *oauth2_svc.Tokeninfo
	GetTokenInfoErr    error

	GetNatIPZone   string
	GetNatIPName   string
	GetNatIPResult string
	GetNatIPErr    error

	GetInternalIPZone   string
	GetInternalIPName   string
	GetInternalIPResult string
	GetInternalIPErr    error

	GetSerialPortOutputZone   string
	GetSerialPortOutputName   string
	GetSerialPortOutputResult string
	GetSerialPortOutputErr    error

	ImageExistsProjectId string
	ImageExistsName      string
	ImageExistsResult    bool

	RunInstanceConfig *InstanceConfig
	RunInstanceErrCh  <-chan error
	RunInstanceErr    error

	CreateOrResetWindowsPasswordZone     string
	CreateOrResetWindowsPasswordInstance string
	CreateOrResetWindowsPasswordConfig   *WindowsPasswordConfig
	CreateOrResetWindowsPasswordErr      error
	CreateOrResetWindowsPasswordErrCh    <-chan error

	WaitForInstanceState string
	WaitForInstanceZone  string
	WaitForInstanceName  string
	WaitForInstanceErrCh <-chan error

	AddToInstanceMetadataZone    string
	AddToInstanceMetadataName    string
	AddToInstanceMetadataKVPairs map[string]string
	AddToInstanceMetadataErrCh   <-chan error
	AddToInstanceMetadataErr     error

	UploadToBucketBucket     string
	UploadToBucketObjectName string
	UploadToBucketData       io.Reader
	UploadToBucketResult     string
	UploadToBucketError      error
}

DriverMock is a Driver implementation that is a mocked out so that it can be used for tests.

func (*DriverMock) AddToInstanceMetadata

func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata map[string]string) error

func (*DriverMock) CreateDisk

func (d *DriverMock) CreateDisk(diskConfig BlockDevice) (<-chan *compute.Disk, <-chan error)

func (*DriverMock) CreateImage

func (d *DriverMock) CreateImage(project string, imageSpec *compute.Image) (<-chan *Image, <-chan error)

func (*DriverMock) CreateImageFromRaw

func (d *DriverMock) CreateImageFromRaw(
	project string,
	rawImageURL string,
	imageName string,
	imageDescription string,
	imageFamily string,
	imageLabels map[string]string,
	imageGuestOsFeatures []string,
	shieldedVMStateConfig *compute.InitialStateConfig,
	imageStorageLocations []string,
	imageArchitecture string,
) (<-chan *Image, <-chan error)

CreateImageFromRaw is very similar to CreateImage, so we'll merge the two together in a later commit.

Let's not spend time mocking it now, we'll make it mockable after merging the two functions.

func (*DriverMock) CreateOrResetWindowsPassword

func (d *DriverMock) CreateOrResetWindowsPassword(instance, zone string, c *WindowsPasswordConfig) (<-chan error, error)

func (*DriverMock) DeleteDisk

func (d *DriverMock) DeleteDisk(zone, name string) <-chan error

func (*DriverMock) DeleteFromBucket

func (d *DriverMock) DeleteFromBucket(bucket, objectName string) error

func (*DriverMock) DeleteImage

func (d *DriverMock) DeleteImage(project, name string) <-chan error

func (*DriverMock) DeleteInstance

func (d *DriverMock) DeleteInstance(zone, name string) (<-chan error, error)

func (*DriverMock) DeleteOSLoginSSHKey

func (d *DriverMock) DeleteOSLoginSSHKey(user, fingerprint string) error

func (*DriverMock) GetDisk

func (d *DriverMock) GetDisk(zoneOrRegion, name string) (*compute.Disk, error)

func (*DriverMock) GetImage

func (d *DriverMock) GetImage(name string, fromFamily bool) (*Image, error)

func (*DriverMock) GetImageFromProject

func (d *DriverMock) GetImageFromProject(project, name string, fromFamily bool) (*Image, error)

func (*DriverMock) GetImageFromProjects

func (d *DriverMock) GetImageFromProjects(projects []string, name string, fromFamily bool) (*Image, error)

func (*DriverMock) GetInstanceMetadata

func (d *DriverMock) GetInstanceMetadata(zone, name, key string) (string, error)

func (*DriverMock) GetInternalIP

func (d *DriverMock) GetInternalIP(zone, name string) (string, error)

func (*DriverMock) GetNatIP

func (d *DriverMock) GetNatIP(zone, name string) (string, error)

func (*DriverMock) GetSerialPortOutput

func (d *DriverMock) GetSerialPortOutput(zone, name string) (string, error)

func (*DriverMock) GetTokenInfo

func (d *DriverMock) GetTokenInfo() (*oauth2_svc.Tokeninfo, error)

func (*DriverMock) GetWindowsPassword

func (d *DriverMock) GetWindowsPassword() (string, error)

func (*DriverMock) ImageExists

func (d *DriverMock) ImageExists(project, name string) bool

func (*DriverMock) ImportOSLoginSSHKey

func (d *DriverMock) ImportOSLoginSSHKey(user, key string) (*oslogin.LoginProfile, error)

func (*DriverMock) RunInstance

func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error)

func (*DriverMock) UploadToBucket

func (d *DriverMock) UploadToBucket(bucket, object string, data io.Reader) (string, error)

func (*DriverMock) WaitForInstance

func (d *DriverMock) WaitForInstance(state, zone, name string) <-chan error

type FlatAuthentication

type FlatAuthentication struct {
	AccessToken               *string `mapstructure:"access_token" required:"false" cty:"access_token" hcl:"access_token"`
	AccountFile               *string `mapstructure:"account_file" required:"false" cty:"account_file" hcl:"account_file"`
	CredentialsFile           *string `mapstructure:"credentials_file" required:"false" cty:"credentials_file" hcl:"credentials_file"`
	CredentialsJSON           *string `mapstructure:"credentials_json" required:"false" cty:"credentials_json" hcl:"credentials_json"`
	ImpersonateServiceAccount *string `` /* 127-byte string literal not displayed */
	VaultGCPOauthEngine       *string `mapstructure:"vault_gcp_oauth_engine" cty:"vault_gcp_oauth_engine" hcl:"vault_gcp_oauth_engine"`
}

FlatAuthentication is an auto-generated flat version of Authentication. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatAuthentication) HCL2Spec

func (*FlatAuthentication) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Authentication. This spec is used by HCL to read the fields of Authentication. The decoded values from this spec will then be applied to a FlatAuthentication.

type FlatBlockDevice

type FlatBlockDevice struct {
	AttachmentMode    *string                    `mapstructure:"attachment_mode" cty:"attachment_mode" hcl:"attachment_mode"`
	CreateImage       *bool                      `mapstructure:"create_image" cty:"create_image" hcl:"create_image"`
	DeviceName        *string                    `mapstructure:"device_name" cty:"device_name" hcl:"device_name"`
	DiskEncryptionKey *FlatCustomerEncryptionKey `mapstructure:"disk_encryption_key" cty:"disk_encryption_key" hcl:"disk_encryption_key"`
	DiskName          *string                    `mapstructure:"disk_name" cty:"disk_name" hcl:"disk_name"`
	InterfaceType     *string                    `mapstructure:"interface_type" cty:"interface_type" hcl:"interface_type"`
	IOPS              *int                       `mapstructure:"iops" cty:"iops" hcl:"iops"`
	KeepDevice        *bool                      `mapstructure:"keep_device" cty:"keep_device" hcl:"keep_device"`
	ReplicaZones      []string                   `mapstructure:"replica_zones" required:"false" cty:"replica_zones" hcl:"replica_zones"`
	SourceVolume      *string                    `mapstructure:"source_volume" cty:"source_volume" hcl:"source_volume"`
	VolumeSize        *int                       `mapstructure:"volume_size" required:"true" cty:"volume_size" hcl:"volume_size"`
	VolumeType        *BlockDeviceType           `mapstructure:"volume_type" required:"true" cty:"volume_type" hcl:"volume_type"`
	Zone              *string                    `mapstructure:"_" cty:"_" hcl:"_"`
}

FlatBlockDevice is an auto-generated flat version of BlockDevice. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatBlockDevice) HCL2Spec

func (*FlatBlockDevice) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a BlockDevice. This spec is used by HCL to read the fields of BlockDevice. The decoded values from this spec will then be applied to a FlatBlockDevice.

type FlatCustomerEncryptionKey

type FlatCustomerEncryptionKey struct {
	KmsKeyName *string `mapstructure:"kmsKeyName" json:"kmsKeyName,omitempty" cty:"kmsKeyName" hcl:"kmsKeyName"`
	RawKey     *string `mapstructure:"rawKey" json:"rawKey,omitempty" cty:"rawKey" hcl:"rawKey"`
}

FlatCustomerEncryptionKey is an auto-generated flat version of CustomerEncryptionKey. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatCustomerEncryptionKey) HCL2Spec

func (*FlatCustomerEncryptionKey) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a CustomerEncryptionKey. This spec is used by HCL to read the fields of CustomerEncryptionKey. The decoded values from this spec will then be applied to a FlatCustomerEncryptionKey.

type FlatNodeAffinity

type FlatNodeAffinity struct {
	Key      *string  `mapstructure:"key" json:"key" cty:"key" hcl:"key"`
	Operator *string  `mapstructure:"operator" json:"operator" cty:"operator" hcl:"operator"`
	Values   []string `mapstructure:"values" json:"values" cty:"values" hcl:"values"`
}

FlatNodeAffinity is an auto-generated flat version of NodeAffinity. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatNodeAffinity) HCL2Spec

func (*FlatNodeAffinity) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a NodeAffinity. This spec is used by HCL to read the fields of NodeAffinity. The decoded values from this spec will then be applied to a FlatNodeAffinity.

type GCEDriverConfig

type GCEDriverConfig struct {
	Ui                            packersdk.Ui
	ProjectId                     string
	ImpersonateServiceAccountName string
	Scopes                        []string
	AccessToken                   string
	VaultOauthEngineName          string
	Credentials                   *google.Credentials
}

type Image

type Image struct {
	GuestOsFeatures []*compute.GuestOsFeature
	Labels          map[string]string
	Licenses        []string
	Name            string
	ProjectId       string
	SelfLink        string
	SizeGb          int64
}

func (*Image) IsSecureBootCompatible

func (i *Image) IsSecureBootCompatible() bool

func (*Image) IsWindows

func (i *Image) IsWindows() bool

type InstanceConfig

type InstanceConfig struct {
	AcceleratorType              string
	AcceleratorCount             int64
	Address                      string
	Description                  string
	DisableDefaultServiceAccount bool
	DiskName                     string
	DiskSizeGb                   int64
	DiskType                     string
	DiskEncryptionKey            *CustomerEncryptionKey
	EnableNestedVirtualization   bool
	EnableSecureBoot             bool
	EnableVtpm                   bool
	EnableIntegrityMonitoring    bool
	ExtraBlockDevices            []BlockDevice
	Image                        *Image
	Labels                       map[string]string
	MachineType                  string
	Metadata                     map[string]string
	MinCpuPlatform               string
	Name                         string
	Network                      string
	NetworkProjectId             string
	OmitExternalIP               bool
	OnHostMaintenance            string
	Preemptible                  bool
	NodeAffinities               []NodeAffinity
	Region                       string
	ServiceAccountEmail          string
	Scopes                       []string
	Subnetwork                   string
	Tags                         []string
	Zone                         string
}

type NodeAffinity

type NodeAffinity struct {
	// Key: Corresponds to the label key of Node resource.
	Key string `mapstructure:"key" json:"key"`

	// Operator: Defines the operation of node selection. Valid operators are IN for affinity and
	// NOT_IN for anti-affinity.
	Operator string `mapstructure:"operator" json:"operator"`

	// Values: Corresponds to the label values of Node resource.
	Values []string `mapstructure:"values" json:"values"`
}

Node affinity label configuration

func (*NodeAffinity) ComputeType

func (a *NodeAffinity) ComputeType() *compute.SchedulingNodeAffinity

func (*NodeAffinity) FlatMapstructure

func (*NodeAffinity) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatNodeAffinity. FlatNodeAffinity is an auto-generated flat version of NodeAffinity. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type OauthTokenSource

type OauthTokenSource struct {
	Path string
}

Define a TokenSource that gets tokens from Vault

func (OauthTokenSource) Token

func (ots OauthTokenSource) Token() (*oauth2.Token, error)

type WindowsPasswordConfig

type WindowsPasswordConfig struct {
	Key                    *rsa.PrivateKey
	Password               string
	UserName               string        `json:"userName"`
	Modulus                string        `json:"modulus"`
	Exponent               string        `json:"exponent"`
	Email                  string        `json:"email"`
	ExpireOn               time.Time     `json:"expireOn"`
	WindowsPasswordTimeout time.Duration `json:"timeout"`
}

WindowsPasswordConfig is the data structure that GCE needs to encrypt the created windows password.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL