diff --git a/Makefile b/Makefile index f21f5840420b..c42cf86287d9 100644 --- a/Makefile +++ b/Makefile @@ -392,7 +392,7 @@ test: generate test-changed: @CHANGED_PKGS=$$(git diff --name-only $(PULL_BASE_SHA)...HEAD -- '*.go' | \ while IFS= read -r file; do dirname "$$file"; done | \ - sort -u | sed 's|^|./|' | grep -v '^\./vendor/' | grep -v '^\./hack/tools/' | grep -vE '^\./test/e2e(/|$$)'); \ + sort -u | sed 's|^|./|' | grep -v '^\./vendor/' | grep -v '^\./hack/tools/' | grep -vE '^\./test/e2e(/|$$)' | grep -v '^\./api/'); \ if [ -z "$$CHANGED_PKGS" ]; then \ echo "No Go files changed relative to $(PULL_BASE_SHA), skipping tests."; \ else \ diff --git a/api/hypershift/v1beta1/azure.go b/api/hypershift/v1beta1/azure.go index 7bc2b7839eca..888b840de422 100644 --- a/api/hypershift/v1beta1/azure.go +++ b/api/hypershift/v1beta1/azure.go @@ -131,7 +131,12 @@ type AzureVMImage struct { Type AzureVMImageType `json:"type"` // imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. - // TODO: What is the valid character set for this field? What about minimum and maximum lengths? + // The expected format is an Azure resource ID string. This can be a managed image or an + // Azure Compute Gallery image version, for example: + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + // See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + // Azure resource naming rules and restrictions. // // +optional // +unionMember @@ -166,19 +171,27 @@ type AzureMarketplaceImage struct { ImageGeneration *AzureVMImageGeneration `json:"imageGeneration,omitempty"` // publisher is the name of the organization that created the image. - // It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - // It must start with a lowercase letter or a number. - // TODO: Can we explain where a user might find this value, or provide an example of one they might want to use + // For example, "azureopenshift", "canonical", or "redhat". + // It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + // It must start and end with a lowercase letter or a number. + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image publishers. // - // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9-_]{2,49}$` + // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9-_]*[a-z0-9]$` // +kubebuilder:validation:MinLength=3 // +kubebuilder:validation:MaxLength=50 // +optional Publisher string `json:"publisher,omitempty"` // offer specifies the name of a group of related images created by the publisher. - // TODO: What is the valid character set for this field? What about minimum and maximum lengths? - // + // For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + // The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + // hyphens (-), underscores (_), and periods (.). + // It must start with an alphanumeric character. + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image offers. + // + // +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$')",message="offer must consist of alphanumeric characters, hyphens, underscores, and periods, and must start with an alphanumeric character" // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=255 // +optional @@ -186,8 +199,10 @@ type AzureMarketplaceImage struct { // sku specifies an instance of an offer, such as a major release of a distribution. // For example, 22_04-lts-gen2, 8-lvm-gen2. - // The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). - // TODO: What about length limits? + // The value must be between 1 and 255 characters in length, and consist of only lowercase + // letters, numbers, hyphens (-), and underscores (_). + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image SKUs. // // +kubebuilder:validation:Pattern=`^[a-z0-9-_]+$` // +kubebuilder:validation:MinLength=1 diff --git a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yaml b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yaml index 28b0b76bc4a9..79bded122170 100644 --- a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yaml +++ b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yaml @@ -837,25 +837,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -884,8 +901,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/GCPPlatform.yaml b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/GCPPlatform.yaml index 2705760fb216..1c9b88f8dbbb 100644 --- a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/GCPPlatform.yaml +++ b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/GCPPlatform.yaml @@ -837,25 +837,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -884,8 +901,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml index f795a85dcc42..4da6e1a79d21 100644 --- a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml +++ b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml @@ -870,25 +870,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -917,8 +934,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yaml b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yaml index a7c77a9ab071..f2af738f2484 100644 --- a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yaml +++ b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yaml @@ -837,25 +837,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -884,8 +901,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/stable.nodepools.azure.testsuite.yaml b/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/stable.nodepools.azure.testsuite.yaml index 0258c76de04c..407b17f42c66 100644 --- a/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/stable.nodepools.azure.testsuite.yaml +++ b/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/stable.nodepools.azure.testsuite.yaml @@ -191,3 +191,90 @@ tests: subnetID: "/subscriptions/12345678-1234-5678-9012-123456789012/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet" type: Azure expectedError: "publisher, offer, sku and version must either be all set, or all omitted" + + # --- Azure Marketplace offer field character validation --- + - name: when marketplace offer contains invalid characters it should fail + initial: | + apiVersion: hypershift.openshift.io/v1beta1 + kind: NodePool + spec: + arch: amd64 + clusterName: some-cluster + management: + autoRepair: false + upgradeType: Replace + release: + image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 + replicas: 0 + platform: + azure: + vmSize: Standard_D4s_v5 + image: + type: AzureMarketplace + azureMarketplace: + publisher: azureopenshift + offer: "invalid offer!" + sku: aro_417_rhel8_gen2 + version: "417.94.20240701" + osDisk: + diskStorageAccountType: Premium_LRS + subnetID: "/subscriptions/12345678-1234-5678-9012-123456789012/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet" + type: Azure + expectedError: "offer must consist of alphanumeric characters, hyphens, underscores, and periods, and must start with an alphanumeric character" + + - name: when marketplace offer starts with a hyphen it should fail + initial: | + apiVersion: hypershift.openshift.io/v1beta1 + kind: NodePool + spec: + arch: amd64 + clusterName: some-cluster + management: + autoRepair: false + upgradeType: Replace + release: + image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 + replicas: 0 + platform: + azure: + vmSize: Standard_D4s_v5 + image: + type: AzureMarketplace + azureMarketplace: + publisher: azureopenshift + offer: "-invalid-start" + sku: aro_417_rhel8_gen2 + version: "417.94.20240701" + osDisk: + diskStorageAccountType: Premium_LRS + subnetID: "/subscriptions/12345678-1234-5678-9012-123456789012/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet" + type: Azure + expectedError: "offer must consist of alphanumeric characters, hyphens, underscores, and periods, and must start with an alphanumeric character" + + - name: when marketplace offer has valid characters with hyphens underscores and periods it should pass + initial: | + apiVersion: hypershift.openshift.io/v1beta1 + kind: NodePool + spec: + arch: amd64 + clusterName: some-cluster + management: + autoRepair: false + upgradeType: Replace + release: + image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 + replicas: 0 + platform: + azure: + vmSize: Standard_D4s_v5 + image: + type: AzureMarketplace + azureMarketplace: + publisher: azureopenshift + offer: "0001-com-ubuntu-server.jammy_2204" + sku: aro_417_rhel8_gen2 + version: "417.94.20240701" + osDisk: + diskStorageAccountType: Premium_LRS + subnetID: "/subscriptions/12345678-1234-5678-9012-123456789012/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet" + type: Azure diff --git a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml index 2fa0fb4be0b9..070a6c9e62ac 100644 --- a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml +++ b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml @@ -873,25 +873,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -920,8 +937,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yaml b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yaml index 0df741304192..fc6418156605 100644 --- a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yaml +++ b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yaml @@ -840,25 +840,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -887,8 +904,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml index 8d13378de0e6..1523e7d52a67 100644 --- a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml +++ b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml @@ -873,25 +873,42 @@ spec: - Gen2 type: string offer: - description: offer specifies the name of a group of - related images created by the publisher. + description: |- + offer specifies the name of a group of related images created by the publisher. + For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + hyphens (-), underscores (_), and periods (.). + It must start with an alphanumeric character. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image offers. maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: offer must consist of alphanumeric characters, + hyphens, underscores, and periods, and must start + with an alphanumeric character + rule: self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$') publisher: description: |- publisher is the name of the organization that created the image. - It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - It must start with a lowercase letter or a number. + For example, "azureopenshift", "canonical", or "redhat". + It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + It must start and end with a lowercase letter or a number. + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image publishers. maxLength: 50 minLength: 3 - pattern: ^[a-z0-9][a-z0-9-_]{2,49}$ + pattern: ^[a-z0-9][a-z0-9-_]*[a-z0-9]$ type: string sku: description: |- sku specifies an instance of an offer, such as a major release of a distribution. For example, 22_04-lts-gen2, 8-lvm-gen2. - The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). + The value must be between 1 and 255 characters in length, and consist of only lowercase + letters, numbers, hyphens (-), and underscores (_). + See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + information on Azure Marketplace image SKUs. maxLength: 255 minLength: 1 pattern: ^[a-z0-9-_]+$ @@ -920,8 +937,14 @@ spec: has(self.version)].filter(x, x == true).size() == 4' imageID: - description: imageID is the Azure resource ID of a VHD - image to use to boot the Azure VMs from. + description: |- + imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. + The expected format is an Azure resource ID string. This can be a managed image or an + Azure Compute Gallery image version, for example: + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + Azure resource naming rules and restrictions. maxLength: 255 type: string type: diff --git a/docs/content/reference/aggregated-docs.md b/docs/content/reference/aggregated-docs.md index e3db4b35012e..3c1b512aad46 100644 --- a/docs/content/reference/aggregated-docs.md +++ b/docs/content/reference/aggregated-docs.md @@ -41490,9 +41490,11 @@ string (Optional)

publisher is the name of the organization that created the image. -It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). -It must start with a lowercase letter or a number. -TODO: Can we explain where a user might find this value, or provide an example of one they might want to use

+For example, “azureopenshift”, “canonical”, or “redhat”. +It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). +It must start and end with a lowercase letter or a number. +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image publishers.

@@ -41505,7 +41507,12 @@ string (Optional)

offer specifies the name of a group of related images created by the publisher. -TODO: What is the valid character set for this field? What about minimum and maximum lengths?

+For example, “RHEL”, “WindowsServer”, or “0001-com-ubuntu-server-jammy”. +The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), +hyphens (-), underscores (_), and periods (.). +It must start with an alphanumeric character. +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image offers.

@@ -41519,8 +41526,10 @@ string (Optional)

sku specifies an instance of an offer, such as a major release of a distribution. For example, 2204-lts-gen2, 8-lvm-gen2. -The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (). -TODO: What about length limits?

+The value must be between 1 and 255 characters in length, and consist of only lowercase +letters, numbers, hyphens (-), and underscores (). +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image SKUs.

@@ -42616,7 +42625,12 @@ string (Optional)

imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. -TODO: What is the valid character set for this field? What about minimum and maximum lengths?

+The expected format is an Azure resource ID string. This can be a managed image or an +Azure Compute Gallery image version, for example: +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} +See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for +Azure resource naming rules and restrictions.

diff --git a/docs/content/reference/api.md b/docs/content/reference/api.md index 2cab25c30208..0ac5b9e433c5 100644 --- a/docs/content/reference/api.md +++ b/docs/content/reference/api.md @@ -3747,9 +3747,11 @@ string (Optional)

publisher is the name of the organization that created the image. -It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). -It must start with a lowercase letter or a number. -TODO: Can we explain where a user might find this value, or provide an example of one they might want to use

+For example, “azureopenshift”, “canonical”, or “redhat”. +It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). +It must start and end with a lowercase letter or a number. +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image publishers.

@@ -3762,7 +3764,12 @@ string (Optional)

offer specifies the name of a group of related images created by the publisher. -TODO: What is the valid character set for this field? What about minimum and maximum lengths?

+For example, “RHEL”, “WindowsServer”, or “0001-com-ubuntu-server-jammy”. +The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), +hyphens (-), underscores (_), and periods (.). +It must start with an alphanumeric character. +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image offers.

@@ -3776,8 +3783,10 @@ string (Optional)

sku specifies an instance of an offer, such as a major release of a distribution. For example, 2204-lts-gen2, 8-lvm-gen2. -The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (). -TODO: What about length limits?

+The value must be between 1 and 255 characters in length, and consist of only lowercase +letters, numbers, hyphens (-), and underscores (). +See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more +information on Azure Marketplace image SKUs.

@@ -4873,7 +4882,12 @@ string (Optional)

imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. -TODO: What is the valid character set for this field? What about minimum and maximum lengths?

+The expected format is an Azure resource ID string. This can be a managed image or an +Azure Compute Gallery image version, for example: +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} +See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for +Azure resource naming rules and restrictions.

diff --git a/hack/tools/crd-schema-check/crdify-config.yaml b/hack/tools/crd-schema-check/crdify-config.yaml index bc73b8da1477..cefd1ec350dc 100644 --- a/hack/tools/crd-schema-check/crdify-config.yaml +++ b/hack/tools/crd-schema-check/crdify-config.yaml @@ -21,3 +21,7 @@ validations: enforcement: Error configuration: additionPolicy: Allow + - name: description + enforcement: Warn + - name: pattern + enforcement: Warn diff --git a/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/azure.go b/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/azure.go index 7bc2b7839eca..888b840de422 100644 --- a/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/azure.go +++ b/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/azure.go @@ -131,7 +131,12 @@ type AzureVMImage struct { Type AzureVMImageType `json:"type"` // imageID is the Azure resource ID of a VHD image to use to boot the Azure VMs from. - // TODO: What is the valid character set for this field? What about minimum and maximum lengths? + // The expected format is an Azure resource ID string. This can be a managed image or an + // Azure Compute Gallery image version, for example: + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{imageVersionName} + // See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules for + // Azure resource naming rules and restrictions. // // +optional // +unionMember @@ -166,19 +171,27 @@ type AzureMarketplaceImage struct { ImageGeneration *AzureVMImageGeneration `json:"imageGeneration,omitempty"` // publisher is the name of the organization that created the image. - // It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, and hyphens (-) and underscores (_). - // It must start with a lowercase letter or a number. - // TODO: Can we explain where a user might find this value, or provide an example of one they might want to use + // For example, "azureopenshift", "canonical", or "redhat". + // It must be between 3 and 50 characters in length, and consist of only lowercase letters, numbers, hyphens (-), and underscores (_). + // It must start and end with a lowercase letter or a number. + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image publishers. // - // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9-_]{2,49}$` + // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9-_]*[a-z0-9]$` // +kubebuilder:validation:MinLength=3 // +kubebuilder:validation:MaxLength=50 // +optional Publisher string `json:"publisher,omitempty"` // offer specifies the name of a group of related images created by the publisher. - // TODO: What is the valid character set for this field? What about minimum and maximum lengths? - // + // For example, "RHEL", "WindowsServer", or "0001-com-ubuntu-server-jammy". + // The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), + // hyphens (-), underscores (_), and periods (.). + // It must start with an alphanumeric character. + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image offers. + // + // +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$')",message="offer must consist of alphanumeric characters, hyphens, underscores, and periods, and must start with an alphanumeric character" // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=255 // +optional @@ -186,8 +199,10 @@ type AzureMarketplaceImage struct { // sku specifies an instance of an offer, such as a major release of a distribution. // For example, 22_04-lts-gen2, 8-lvm-gen2. - // The value must consist only of lowercase letters, numbers, and hyphens (-) and underscores (_). - // TODO: What about length limits? + // The value must be between 1 and 255 characters in length, and consist of only lowercase + // letters, numbers, hyphens (-), and underscores (_). + // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more + // information on Azure Marketplace image SKUs. // // +kubebuilder:validation:Pattern=`^[a-z0-9-_]+$` // +kubebuilder:validation:MinLength=1