github.com/openshift/installer@v1.4.17/pkg/explain/printer_test.go (about)

     1  package explain
     2  
     3  import (
     4  	"bytes"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func Test_PrintFields(t *testing.T) {
    12  	schema, err := loadSchema(loadCRD(t))
    13  	assert.NoError(t, err)
    14  
    15  	cases := []struct {
    16  		path []string
    17  
    18  		desc string
    19  		err  string
    20  	}{{
    21  		desc: `FIELDS:
    22      additionalTrustBundle <string>
    23        AdditionalTrustBundle is a PEM-encoded X.509 certificate bundle that will be added to the nodes' trusted certificate store.
    24  
    25      additionalTrustBundlePolicy <string>
    26        Valid Values: "","Proxyonly","Always"
    27        AdditionalTrustBundlePolicy determines when to add the AdditionalTrustBundle to the nodes' trusted certificate store. "Proxyonly" is the default. The field can be set to following specified values. "Proxyonly" : adds the AdditionalTrustBundle to nodes when http/https proxy is configured. "Always" : always adds AdditionalTrustBundle.
    28  
    29      apiVersion <string>
    30        APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
    31  
    32      baseDomain <string> -required-
    33        BaseDomain is the base domain to which the cluster should belong.
    34  
    35      bootstrapInPlace <object>
    36        BootstrapInPlace is the configuration for installing a single node with bootstrap in place installation.
    37  
    38      capabilities <object>
    39        Capabilities configures the installation of optional core cluster components.
    40  
    41      compute <[]object>
    42        Compute is the configuration for the machines that comprise the compute nodes.
    43        MachinePool is a pool of machines to be installed.
    44  
    45      controlPlane <object>
    46        ControlPlane is the configuration for the machines that comprise the control plane.
    47  
    48      cpuPartitioningMode <string>
    49        Default: "None"
    50        Valid Values: "None","AllNodes"
    51        CPUPartitioning determines if a cluster should be setup for CPU workload partitioning at install time. When this field is set the cluster will be flagged for CPU Partitioning allowing users to segregate workloads to specific CPU Sets. This does not make any decisions on workloads it only configures the nodes to allow CPU Partitioning. The "AllNodes" value will setup all nodes for CPU Partitioning, the default is "None".
    52  
    53      credentialsMode <string>
    54        Valid Values: "","Mint","Passthrough","Manual"
    55        CredentialsMode is used to explicitly set the mode with which CredentialRequests are satisfied. 
    56   If this field is set, then the installer will not attempt to query the cloud permissions before attempting installation. If the field is not set or empty, then the installer will perform its normal verification that the credentials provided are sufficient to perform an installation. 
    57   There are three possible values for this field, but the valid values are dependent upon the platform being used. "Mint": create new credentials with a subset of the overall permissions for each CredentialsRequest "Passthrough": copy the credentials with all of the overall permissions for each CredentialsRequest "Manual": CredentialsRequests must be handled manually by the user 
    58   For each of the following platforms, the field can set to the specified values. For all other platforms, the field must not be set. AWS: "Mint", "Passthrough", "Manual" Azure: "Passthrough", "Manual" AzureStack: "Manual" GCP: "Mint", "Passthrough", "Manual" IBMCloud: "Manual" PowerVS: "Manual" Nutanix: "Manual"
    59  
    60      featureGates <[]string>
    61        FeatureGates enables a set of custom feature gates. May only be used in conjunction with FeatureSet "CustomNoUpgrade". Features may be enabled or disabled by providing a true or false value for the feature gate. E.g. "featureGates": ["FeatureGate1=true", "FeatureGate2=false"].
    62  
    63      featureSet <string>
    64        FeatureSet enables features that are not part of the default feature set. Valid values are "Default", "TechPreviewNoUpgrade" and "CustomNoUpgrade". When omitted, the "Default" feature set is used.
    65  
    66      fips <boolean>
    67        Default: false
    68        FIPS configures https://www.nist.gov/itl/fips-general-information
    69  
    70      imageContentSources <[]object>
    71        ImageContentSources lists sources/repositories for the release-image content. The field is deprecated. Please use imageDigestSources.
    72        ImageContentSource defines a list of sources/repositories that can be used to pull content. The field is deprecated. Please use imageDigestSources.
    73  
    74      imageDigestSources <[]object>
    75        ImageDigestSources lists sources/repositories for the release-image content.
    76        ImageDigestSource defines a list of sources/repositories that can be used to pull content.
    77  
    78      kind <string>
    79        Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
    80  
    81      metadata <object> -required-
    82        <empty>
    83  
    84      networking <object>
    85        Networking is the configuration for the pod network provider in the cluster.
    86  
    87      operatorPublishingStrategy <object>
    88        OperatorPublishingStrategy controls the visibility of ingress and apiserver. Defaults to public.
    89  
    90      platform <object> -required-
    91        Platform is the configuration for the specific platform upon which to perform the installation.
    92  
    93      proxy <object>
    94        Proxy defines the proxy settings for the cluster. If unset, the cluster will not be configured to use a proxy.
    95  
    96      publish <string>
    97        Default: "External"
    98        Valid Values: "","External","Internal"
    99        Publish controls how the user facing endpoints of the cluster like the Kubernetes API, OpenShift routes etc. are exposed. When no strategy is specified, the strategy is "External".
   100  
   101      pullSecret <string> -required-
   102        PullSecret is the secret to use when pulling images.
   103  
   104      sshKey <string>
   105        SSHKey is the public Secure Shell (SSH) key to provide access to instances.`,
   106  	}, {
   107  		path: []string{"publish"},
   108  		desc: ``,
   109  	}, {
   110  		path: []string{"platform"},
   111  		desc: `FIELDS:
   112      aws <object>
   113        AWS is the configuration used when installing on AWS.
   114  
   115      azure <object>
   116        Azure is the configuration used when installing on Azure.
   117  
   118      baremetal <object>
   119        BareMetal is the configuration used when installing on bare metal.
   120  
   121      external <object>
   122        External is the configuration used when installing on an external cloud provider.
   123  
   124      gcp <object>
   125        GCP is the configuration used when installing on Google Cloud Platform.
   126  
   127      ibmcloud <object>
   128        IBMCloud is the configuration used when installing on IBM Cloud.
   129  
   130      none <object>
   131        None is the empty configuration used when installing on an unsupported platform.
   132  
   133      nutanix <object>
   134        Nutanix is the configuration used when installing on Nutanix.
   135  
   136      openstack <object>
   137        OpenStack is the configuration used when installing on OpenStack.
   138  
   139      ovirt <object>
   140        Ovirt is the configuration used when installing on oVirt.
   141  
   142      powervs <object>
   143        PowerVS is the configuration used when installing on Power VS.
   144  
   145      vsphere <object>
   146        VSphere is the configuration used when installing on vSphere.`,
   147  	}, {
   148  		path: []string{"platform", "aws"},
   149  		desc: `FIELDS:
   150      amiID <string>
   151        The field is deprecated. AMIID is the AMI that should be used to boot machines for the cluster. If set, the AMI should belong to the same region as the cluster.
   152  
   153      bestEffortDeleteIgnition <boolean>
   154        BestEffortDeleteIgnition is an optional field that can be used to ignore errors from S3 deletion of ignition objects during cluster bootstrap. The default behavior is to fail the installation if ignition objects cannot be deleted. Enable this functionality when there are known reasons disallowing their deletion.
   155  
   156      defaultMachinePlatform <object>
   157        DefaultMachinePlatform is the default configuration used when installing on AWS for machine pools which do not define their own platform configuration.
   158  
   159      experimentalPropagateUserTags <boolean>
   160        The field is deprecated. ExperimentalPropagateUserTags is an experimental flag that directs in-cluster operators to include the specified user tags in the tags of the AWS resources that the operators create.
   161  
   162      hostedZone <string>
   163        HostedZone is the ID of an existing hosted zone into which to add DNS records for the cluster's internal API. An existing hosted zone can only be used when also using existing subnets. The hosted zone must be associated with the VPC containing the subnets. Leave the hosted zone unset to have the installer create the hosted zone on your behalf.
   164  
   165      hostedZoneRole <string>
   166        HostedZoneRole is the ARN of an IAM role to be assumed when performing operations on the provided HostedZone. HostedZoneRole can be used in a shared VPC scenario when the private hosted zone belongs to a different account than the rest of the cluster resources. If HostedZoneRole is set, HostedZone must also be set.
   167  
   168      lbType <string>
   169        LBType is an optional field to specify a load balancer type. When this field is specified, all ingresscontrollers (including the default ingresscontroller) will be created using the specified load-balancer type by default. 
   170   Following are the accepted values: 
   171   * "Classic": A Classic Load Balancer that makes routing decisions at either the transport layer (TCP/SSL) or the application layer (HTTP/HTTPS). See the following for additional details: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/load-balancer-types.html#clb 
   172   * "NLB": A Network Load Balancer that makes routing decisions at the transport layer (TCP/SSL). See the following for additional details: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/load-balancer-types.html#nlb 
   173   If this field is not set explicitly, it defaults to "Classic".  This default is subject to change over time.
   174  
   175      preserveBootstrapIgnition <boolean>
   176        PreserveBootstrapIgnition is deprecated. Use bestEffortDeleteIgnition instead.
   177  
   178      propagateUserTags <boolean>
   179        PropagateUserTags is a flag that directs in-cluster operators to include the specified user tags in the tags of the AWS resources that the operators create.
   180  
   181      publicIpv4Pool <string>
   182        PublicIpv4Pool is an optional field that can be used to tell the installation process to use Public IPv4 address that you bring to your AWS account with BYOIP.
   183  
   184      region <string> -required-
   185        Region specifies the AWS region where the cluster will be created.
   186  
   187      serviceEndpoints <[]object>
   188        ServiceEndpoints list contains custom endpoints which will override default service endpoint of AWS Services. There must be only one ServiceEndpoint for a service.
   189        ServiceEndpoint store the configuration for services to override existing defaults of AWS Services.
   190  
   191      subnets <[]string>
   192        Subnets specifies existing subnets (by ID) where cluster resources will be created.  Leave unset to have the installer create subnets in a new VPC on your behalf.
   193  
   194      userTags <object>
   195        UserTags additional keys and values that the installer will add as tags to all resources that it creates. Resources created by the cluster itself may not include these tags.`,
   196  	}, {
   197  		path: []string{"platform", "azure"},
   198  		desc: `FIELDS:
   199      armEndpoint <string>
   200        ARMEndpoint is the endpoint for the Azure API when installing on Azure Stack.
   201  
   202      baseDomainResourceGroupName <string>
   203        BaseDomainResourceGroupName specifies the resource group where the Azure DNS zone for the base domain is found. This field is optional when creating a private cluster, otherwise required.
   204  
   205      cloudName <string>
   206        Valid Values: "","AzurePublicCloud","AzureUSGovernmentCloud","AzureChinaCloud","AzureGermanCloud","AzureStackCloud"
   207        cloudName is the name of the Azure cloud environment which can be used to configure the Azure SDK with the appropriate Azure API endpoints. If empty, the value is equal to "AzurePublicCloud".
   208  
   209      clusterOSImage <string>
   210        ClusterOSImage is the url of a storage blob in the Azure Stack environment containing an RHCOS VHD. This field is required for Azure Stack and not applicable to Azure.
   211  
   212      computeSubnet <string>
   213        ComputeSubnet specifies an existing subnet for use by compute nodes
   214  
   215      controlPlaneSubnet <string>
   216        ControlPlaneSubnet specifies an existing subnet for use by the control plane nodes
   217  
   218      customerManagedKey <object>
   219        CustomerManagedKey has the keys needed to encrypt the storage account.
   220  
   221      defaultMachinePlatform <object>
   222        DefaultMachinePlatform is the default configuration used when installing on Azure for machine pools which do not define their own platform configuration.
   223  
   224      networkResourceGroupName <string>
   225        NetworkResourceGroupName specifies the network resource group that contains an existing VNet
   226  
   227      outboundType <string>
   228        Default: "Loadbalancer"
   229        Valid Values: "","Loadbalancer","NatGateway","UserDefinedRouting"
   230        OutboundType is a strategy for how egress from cluster is achieved. When not specified default is "Loadbalancer". "NatGateway" is only available in TechPreview.
   231  
   232      region <string> -required-
   233        Region specifies the Azure region where the cluster will be created.
   234  
   235      resourceGroupName <string>
   236        ResourceGroupName is the name of an already existing resource group where the cluster should be installed. This resource group should only be used for this specific cluster and the cluster components will assume ownership of all resources in the resource group. Destroying the cluster using installer will delete this resource group. This resource group must be empty with no other resources when trying to use it for creating a cluster. If empty, a new resource group will created for the cluster.
   237  
   238      userTags <object>
   239        UserTags has additional keys and values that the installer will add as tags to all resources that it creates on AzurePublicCloud alone. Resources created by the cluster itself may not include these tags.
   240  
   241      virtualNetwork <string>
   242        VirtualNetwork specifies the name of an existing VNet for the installer to use`,
   243  	}, {
   244  		path: []string{"platform", "aws", "region"},
   245  		desc: ``,
   246  	}, {
   247  		path: []string{"platform", "aws", "subnets"},
   248  		desc: ``,
   249  	}, {
   250  		path: []string{"platform", "aws", "userTags"},
   251  		desc: ``,
   252  	}, {
   253  		path: []string{"platform", "aws", "serviceEndpoints"},
   254  		desc: `FIELDS:
   255      name <string> -required-
   256        Name is the name of the AWS service. This must be provided and cannot be empty.
   257  
   258      url <string> -required-
   259        URL is fully qualified URI with scheme https, that overrides the default generated endpoint for a client. This must be provided and cannot be empty.`,
   260  	}, {
   261  		path: []string{"platform", "aws", "serviceEndpoints", "url"},
   262  		desc: ``,
   263  	}}
   264  	for _, test := range cases {
   265  		t.Run("", func(t *testing.T) {
   266  			got, err := lookup(schema, test.path)
   267  			assert.NoError(t, err)
   268  			buf := &bytes.Buffer{}
   269  			(printer{Writer: buf}).PrintFields(got)
   270  			assert.Equal(t, test.desc, strings.TrimSpace(buf.String()))
   271  		})
   272  	}
   273  }
   274  
   275  func Test_PrintNonFields(t *testing.T) {
   276  	schema, err := loadSchema(loadCRD(t))
   277  	assert.NoError(t, err)
   278  
   279  	cases := []struct {
   280  		path []string
   281  
   282  		desc string
   283  		err  string
   284  	}{{
   285  		desc: `
   286  KIND:     InstallConfig
   287  VERSION:  v1
   288  
   289  RESOURCE: <object>
   290    InstallConfig is the configuration for an OpenShift install.
   291  		`,
   292  	}, {
   293  		path: []string{"publish"},
   294  		desc: `
   295  KIND:     InstallConfig
   296  VERSION:  v1
   297  
   298  RESOURCE: <string>
   299    Default: "External"
   300    Valid Values: "","External","Internal"
   301    Publish controls how the user facing endpoints of the cluster like the Kubernetes API, OpenShift routes etc. are exposed. When no strategy is specified, the strategy is "External".
   302  		`,
   303  	}, {
   304  		path: []string{"platform"},
   305  		desc: `
   306  KIND:     InstallConfig
   307  VERSION:  v1
   308  
   309  RESOURCE: <object>
   310    Platform is the configuration for the specific platform upon which to perform the installation.
   311  		`,
   312  	}, {
   313  		path: []string{"platform", "aws"},
   314  		desc: `
   315  KIND:     InstallConfig
   316  VERSION:  v1
   317  
   318  RESOURCE: <object>
   319    AWS is the configuration used when installing on AWS.
   320  		`,
   321  	}, {
   322  		path: []string{"platform", "azure"},
   323  		desc: `
   324  KIND:     InstallConfig
   325  VERSION:  v1
   326  
   327  RESOURCE: <object>
   328    Azure is the configuration used when installing on Azure.
   329  		`,
   330  	}, {
   331  		path: []string{"platform", "aws", "region"},
   332  		desc: `
   333  KIND:     InstallConfig
   334  VERSION:  v1
   335  
   336  RESOURCE: <string>
   337    Region specifies the AWS region where the cluster will be created.
   338  		`,
   339  	}, {
   340  		path: []string{"platform", "aws", "subnets"},
   341  		desc: `
   342  KIND:     InstallConfig
   343  VERSION:  v1
   344  
   345  RESOURCE: <[]string>
   346    Subnets specifies existing subnets (by ID) where cluster resources will be created.  Leave unset to have the installer create subnets in a new VPC on your behalf.
   347  		`,
   348  	}, {
   349  		path: []string{"platform", "aws", "userTags"},
   350  		desc: `
   351  KIND:     InstallConfig
   352  VERSION:  v1
   353  
   354  RESOURCE: <object>
   355    UserTags additional keys and values that the installer will add as tags to all resources that it creates. Resources created by the cluster itself may not include these tags.
   356  		`,
   357  	}, {
   358  		path: []string{"platform", "aws", "serviceEndpoints"},
   359  		desc: `
   360  KIND:     InstallConfig
   361  VERSION:  v1
   362  
   363  RESOURCE: <[]object>
   364    ServiceEndpoints list contains custom endpoints which will override default service endpoint of AWS Services. There must be only one ServiceEndpoint for a service.
   365  		`,
   366  	}, {
   367  		path: []string{"platform", "aws", "serviceEndpoints", "url"},
   368  		desc: `
   369  KIND:     InstallConfig
   370  VERSION:  v1
   371  
   372  RESOURCE: <string>
   373    URL is fully qualified URI with scheme https, that overrides the default generated endpoint for a client. This must be provided and cannot be empty.
   374  		`,
   375  	}, {
   376  		path: []string{"compute", "platform", "aws", "iamRole"},
   377  		desc: `
   378  KIND:     InstallConfig
   379  VERSION:  v1
   380  
   381  RESOURCE: <string>
   382    IAMRole is the name of the IAM Role to use for the instance profile of the machine. Leave unset to have the installer create the IAM Role on your behalf. Cannot be specified together with iamProfile.
   383  	`,
   384  	}, {
   385  		path: []string{"controlPlane", "platform", "aws", "iamRole"},
   386  		desc: `
   387  KIND:     InstallConfig
   388  VERSION:  v1
   389  
   390  RESOURCE: <string>
   391    IAMRole is the name of the IAM Role to use for the instance profile of the machine. Leave unset to have the installer create the IAM Role on your behalf. Cannot be specified together with iamProfile.
   392  	`,
   393  	}, {
   394  		path: []string{"platform", "aws", "defaultMachinePlatform", "iamRole"},
   395  		desc: `
   396  KIND:     InstallConfig
   397  VERSION:  v1
   398  
   399  RESOURCE: <string>
   400    IAMRole is the name of the IAM Role to use for the instance profile of the machine. Leave unset to have the installer create the IAM Role on your behalf. Cannot be specified together with iamProfile.
   401  	`,
   402  	}, {
   403  		path: []string{"compute", "platform", "aws", "iamProfile"},
   404  		desc: `
   405  KIND:     InstallConfig
   406  VERSION:  v1
   407  
   408  RESOURCE: <string>
   409    IAMProfile is the name of the IAM instance profile to use for the machine. Leave unset to have the installer create the IAM Profile on your behalf. Cannot be specified together with iamRole.
   410  	`,
   411  	}, {
   412  		path: []string{"controlPlane", "platform", "aws", "iamProfile"},
   413  		desc: `
   414  KIND:     InstallConfig
   415  VERSION:  v1
   416  
   417  RESOURCE: <string>
   418    IAMProfile is the name of the IAM instance profile to use for the machine. Leave unset to have the installer create the IAM Profile on your behalf. Cannot be specified together with iamRole.
   419  	`,
   420  	}, {
   421  		path: []string{"platform", "aws", "defaultMachinePlatform", "iamProfile"},
   422  		desc: `
   423  KIND:     InstallConfig
   424  VERSION:  v1
   425  
   426  RESOURCE: <string>
   427    IAMProfile is the name of the IAM instance profile to use for the machine. Leave unset to have the installer create the IAM Profile on your behalf. Cannot be specified together with iamRole.
   428  	`,
   429  	}}
   430  	for _, test := range cases {
   431  		t.Run("", func(t *testing.T) {
   432  			got, err := lookup(schema, test.path)
   433  			assert.NoError(t, err)
   434  			buf := &bytes.Buffer{}
   435  			p := printer{Writer: buf}
   436  			p.PrintKindAndVersion()
   437  			p.PrintResource(got)
   438  			assert.Equal(t, strings.TrimSpace(test.desc), strings.TrimSpace(buf.String()))
   439  		})
   440  	}
   441  }