github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/licensekey.go (about) 1 // Copyright (c) 2018,2021 Tigera, Inc. All rights reserved. 2 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package v3 16 17 import ( 18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 19 ) 20 21 const ( 22 KindLicenseKey = "LicenseKey" 23 KindLicenseKeyList = "LicenseKeyList" 24 ) 25 26 // +kubebuilder:validation:Enum=CloudCommunity;CloudStarter;CloudPro;Enterprise 27 type LicensePackageType string 28 29 const ( 30 CloudCommunity LicensePackageType = "CloudCommunity" 31 CloudStarter LicensePackageType = "CloudStarter" 32 CloudPro LicensePackageType = "CloudPro" 33 Enterprise LicensePackageType = "Enterprise" 34 ) 35 36 // +genclient 37 // +genclient:nonNamespaced 38 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 39 40 // LicenseKey contains the Tigera CNX license key for the cluster. 41 type LicenseKey struct { 42 metav1.TypeMeta `json:",inline"` 43 // Standard object's metadata. This resource is a singleton, always named "default". 44 metav1.ObjectMeta `json:"metadata,omitempty"` 45 // Specification of the LicenseKey. 46 Spec LicenseKeySpec `json:"spec,omitempty"` 47 // Status of the LicenseKey. 48 Status LicenseKeyStatus `json:"status,omitempty"` 49 } 50 51 // LicenseKeySpec contains the license key itself. 52 type LicenseKeySpec struct { 53 // Token is the JWT containing the license claims 54 Token string `json:"token" yaml:"token"` 55 // Certificate is used to validate the token. 56 Certificate string `json:"certificate,omitempty" yaml:"certificate" validate:"omitempty"` 57 } 58 59 // LicenseKeyStatus contains the license key information. 60 type LicenseKeyStatus struct { 61 // Expiry is the expiry date of License 62 // +nullable 63 Expiry metav1.Time `json:"expiry,omitempty" yaml:"expiry"` 64 // Maximum Number of Allowed Nodes 65 MaxNodes int `json:"maxnodes,omitempty" yaml:"maxnodes" validate:"omitempty"` 66 // License package defines type of Calico license that is being enforced 67 Package LicensePackageType `json:"package,omitempty" yaml:"package" validate:"omitempty"` 68 // List of features that are available via the applied license 69 Features []string `json:"features,omitempty" yaml:"features" validate:"omitempty"` 70 } 71 72 // +genclient:nonNamespaced 73 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 74 75 // LicenseKeyList contains a list of LicenseKey resources 76 // (even though there should only be one). 77 type LicenseKeyList struct { 78 metav1.TypeMeta `json:",inline"` 79 metav1.ListMeta `json:"metadata"` 80 Items []LicenseKey `json:"items"` 81 } 82 83 // New LicenseKey creates a new (zeroed) LicenseKey struct with the TypeMetadata 84 // initialized to the current version. 85 func NewLicenseKey() *LicenseKey { 86 return &LicenseKey{ 87 TypeMeta: metav1.TypeMeta{ 88 Kind: KindLicenseKey, 89 APIVersion: GroupVersionCurrent, 90 }, 91 } 92 } 93 94 // NewLicenseKeyList creates a new (zeroed) LicenseKeyList struct with the TypeMetadata 95 // initialized to the current version. 96 func NewLicenseKeyList() *LicenseKeyList { 97 return &LicenseKeyList{ 98 TypeMeta: metav1.TypeMeta{ 99 Kind: KindLicenseKeyList, 100 APIVersion: GroupVersionCurrent, 101 }, 102 } 103 }