...

Source file src/edge-infra.dev/test/framework/gcp/config.go

Documentation: edge-infra.dev/test/framework/gcp

     1  // Package gcp provides test fraemwork utilities and configuration for integration
     2  // tests against GCP.
     3  package gcp
     4  
     5  import (
     6  	gcpinfra "edge-infra.dev/pkg/edge/gcpinfra/constants"
     7  	"edge-infra.dev/test/framework"
     8  	"edge-infra.dev/test/framework/config"
     9  )
    10  
    11  // GCloud contains all of the configuration options related to GCP.  If your specific
    12  // test suites configuration options wouldn't be used by other tests, they should
    13  // be put in the suite config, not here.
    14  // This struct is registered with the test framework config module so that its
    15  // values can be set by ff.
    16  var GCloud struct {
    17  	ProjectID        string `name:"project-id" description:"gcp project to use for tests"`
    18  	StorageBucket    string `name:"storage-bucket" description:"google cloud storage bucket name"`
    19  	FolderID         string `name:"folder-id" description:"gcp folder id to use for tests"`
    20  	BillingAccount   string `name:"billing-account" description:"gcp billing account"`
    21  	ArtifactRegistry struct {
    22  		ProjectID  string `name:"registry-project-id" description:"gcp project hosting the artifact registry" default:"ret-edge-pltf-preprod-infra"`
    23  		Location   string `name:"registry-location" description:"location where artifact registry lives" default:"us-east1"`
    24  		ResourceID string `name:"registry-resource-id" description:"the gcp resource id" default:"preprod"`
    25  	}
    26  }
    27  
    28  func init() {
    29  	_ = config.AddOptions(&GCloud, "gcp")
    30  }
    31  
    32  // Defaults initializes default values that aren't set, should be called after
    33  // framework.HandleFlags().  These values aren't set as defaults via the configuration
    34  // struct field tags because they are computed or defined as constants in other
    35  // packages.
    36  func Defaults() {
    37  	if GCloud.BillingAccount == "" {
    38  		GCloud.BillingAccount = gcpinfra.DefaultBillingAccountID
    39  	}
    40  }
    41  
    42  // NeedsProjectID skips a test if a project ID isn't provided.
    43  func NeedsProjectID(f *framework.Framework) {
    44  	if GCloud.ProjectID == "" {
    45  		f.Skip("GCloud", "no gcloud project ID was provided via -gcp.project-id")
    46  	}
    47  }
    48  
    49  // NeedsStorageBubkcet skips a test if a storage bucket isn't provided
    50  func NeedsStorageBucket(f *framework.Framework) {
    51  	if GCloud.StorageBucket == "" {
    52  		f.Skip("GCloud", "no GCS bucket name was provided via -gcp.storage-bucket")
    53  	}
    54  }
    55  
    56  // NeedsFolderID skips a test if the folder ID isn't provided
    57  func NeedsFolderID(f *framework.Framework) {
    58  	if GCloud.FolderID == "" {
    59  		f.Skip("GCloud", "no folder ID was provided via -gcp.folder-id")
    60  	}
    61  }
    62  
    63  // NeedsBillingAaccount skips a test if a billing account isn't provided
    64  func NeedsBillingAccount(f *framework.Framework) {
    65  	if GCloud.BillingAccount == "" {
    66  		f.Skip("GCloud", "no billing account ID was provided via -gcp.billing-account")
    67  	}
    68  }
    69  

View as plain text