...

Source file src/edge-infra.dev/pkg/edge/api/utils/banner_helper.go

Documentation: edge-infra.dev/pkg/edge/api/utils

     1  package utils
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  
     6  	bannerApi "edge-infra.dev/pkg/edge/apis/banner/v1alpha1"
     7  	"edge-infra.dev/pkg/edge/constants/api/banner"
     8  )
     9  
    10  const (
    11  	// BannerNS is the namespace for the banner k8s resource.
    12  	BannerNS = "banners"
    13  	// BannerKind is the kind for the banner k8s resource.
    14  	BannerKind = "Banner"
    15  )
    16  
    17  // NewBanner returns a new banner resource.
    18  func NewBanner(uuid, name, organizationName, enterpriseUnitID, projectID string, enablements []string) *bannerApi.Banner {
    19  	return &bannerApi.Banner{
    20  		TypeMeta: metav1.TypeMeta{
    21  			Kind:       BannerKind,
    22  			APIVersion: bannerApi.GroupVersion.String(),
    23  		},
    24  		ObjectMeta: metav1.ObjectMeta{
    25  			Name:      uuid,
    26  			Namespace: BannerNS,
    27  		},
    28  		Spec: bannerApi.BannerSpec{
    29  			DisplayName: name,
    30  			BSL: bannerApi.BSLConfig{
    31  				EnterpriseUnit: bannerApi.BSLEnterpriseUnit{
    32  					ID: enterpriseUnitID,
    33  				},
    34  				Organization: bannerApi.BSLOrganization{
    35  					Name: organizationName,
    36  				},
    37  			},
    38  			GCP: bannerApi.GCPConfig{
    39  				ProjectID: projectID,
    40  			},
    41  			Enablements: enablements,
    42  		},
    43  	}
    44  }
    45  
    46  func GetBannerType(isOrgBanner *bool) banner.Type {
    47  	if isOrgBanner != nil && *isOrgBanner {
    48  		return banner.Org
    49  	}
    50  	return banner.EU
    51  }
    52  

View as plain text