// Package gcp provides test fraemwork utilities and configuration for integration // tests against GCP. package gcp import ( gcpinfra "edge-infra.dev/pkg/edge/gcpinfra/constants" "edge-infra.dev/test/framework" "edge-infra.dev/test/framework/config" ) // GCloud contains all of the configuration options related to GCP. If your specific // test suites configuration options wouldn't be used by other tests, they should // be put in the suite config, not here. // This struct is registered with the test framework config module so that its // values can be set by ff. var GCloud struct { ProjectID string `name:"project-id" description:"gcp project to use for tests"` StorageBucket string `name:"storage-bucket" description:"google cloud storage bucket name"` FolderID string `name:"folder-id" description:"gcp folder id to use for tests"` BillingAccount string `name:"billing-account" description:"gcp billing account"` ArtifactRegistry struct { ProjectID string `name:"registry-project-id" description:"gcp project hosting the artifact registry" default:"ret-edge-pltf-preprod-infra"` Location string `name:"registry-location" description:"location where artifact registry lives" default:"us-east1"` ResourceID string `name:"registry-resource-id" description:"the gcp resource id" default:"preprod"` } } func init() { _ = config.AddOptions(&GCloud, "gcp") } // Defaults initializes default values that aren't set, should be called after // framework.HandleFlags(). These values aren't set as defaults via the configuration // struct field tags because they are computed or defined as constants in other // packages. func Defaults() { if GCloud.BillingAccount == "" { GCloud.BillingAccount = gcpinfra.DefaultBillingAccountID } } // NeedsProjectID skips a test if a project ID isn't provided. func NeedsProjectID(f *framework.Framework) { if GCloud.ProjectID == "" { f.Skip("GCloud", "no gcloud project ID was provided via -gcp.project-id") } } // NeedsStorageBubkcet skips a test if a storage bucket isn't provided func NeedsStorageBucket(f *framework.Framework) { if GCloud.StorageBucket == "" { f.Skip("GCloud", "no GCS bucket name was provided via -gcp.storage-bucket") } } // NeedsFolderID skips a test if the folder ID isn't provided func NeedsFolderID(f *framework.Framework) { if GCloud.FolderID == "" { f.Skip("GCloud", "no folder ID was provided via -gcp.folder-id") } } // NeedsBillingAaccount skips a test if a billing account isn't provided func NeedsBillingAccount(f *framework.Framework) { if GCloud.BillingAccount == "" { f.Skip("GCloud", "no billing account ID was provided via -gcp.billing-account") } }