github.com/Venafi/vcert/v5@v5.10.2/pkg/domain/gcm.go (about)

     1  package domain
     2  
     3  import "strings"
     4  
     5  // GCMCertificateScope Indicates the Scope for a certificate provisioned to GCP Certificate Manager
     6  type GCMCertificateScope string
     7  
     8  var (
     9  	// GCMCertificateScopeDefault Certificates with default scope are served from core Google data centers.
    10  	// If unsure, choose this option.
    11  	GCMCertificateScopeDefault GCMCertificateScope = addCertificateScope("DEFAULT")
    12  
    13  	// GCMCertificateScopeEdgeCache Certificates with scope EDGE_CACHE are special-purposed certificates,
    14  	// served from Edge Points of Presence.
    15  	// See https://cloud.google.com/vpc/docs/edge-locations.
    16  	GCMCertificateScopeEdgeCache GCMCertificateScope = addCertificateScope("EDGE_CACHE")
    17  
    18  	// GCMCertificateScopeAllRegions Certificates with ALL_REGIONS scope are served from all Google Cloud regions
    19  	// See https://cloud.google.com/compute/docs/regions-zones.
    20  	GCMCertificateScopeAllRegions GCMCertificateScope = addCertificateScope("ALL_REGIONS")
    21  
    22  	// GCMCertificateScopeUnknown value to set that the Certificate Scope was not provided.
    23  	GCMCertificateScopeUnknown GCMCertificateScope = addCertificateScope("UNKNOWN")
    24  
    25  	// GCMCertificateScopeInvalid value to set that the Certificate Scope is not matching to any of the valid scopes.
    26  	GCMCertificateScopeInvalid GCMCertificateScope = addCertificateScope("INVALID")
    27  )
    28  
    29  var GCMCertificateScopes = map[GCMCertificateScope]bool{}
    30  
    31  func addCertificateScope(scope string) GCMCertificateScope {
    32  	scope = strings.ToUpper(scope)
    33  
    34  	certificateScope := GCMCertificateScope(scope)
    35  
    36  	if !GCMCertificateScopes[certificateScope] {
    37  		GCMCertificateScopes[certificateScope] = true
    38  	}
    39  
    40  	return certificateScope
    41  }
    42  
    43  func GetScopeFromString(scope string) GCMCertificateScope {
    44  	scope = strings.ToUpper(scope)
    45  
    46  	if scope == "" {
    47  		return GCMCertificateScopeUnknown
    48  	}
    49  
    50  	certificateScope := GCMCertificateScope(scope)
    51  
    52  	if !GCMCertificateScopes[certificateScope] {
    53  		return GCMCertificateScopeInvalid
    54  	}
    55  
    56  	return certificateScope
    57  }