Skip to contentSkip to conversation

Fix choice/endchoice kconfig options

PATCH In review Daniel Gomez 2 participants 8 messages Sep 12, 2023 – Sep 13, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20230912194912eucas1p20d99edc0e417cda49b132eb8b7777198@eucas1p2.samsung.com

#1 lore raw

cover Fix choice/endchoice kconfig options

Hi,

As you may know, Jeff Layton found the way to fix the choice/enchoice issue by removing the redundant string the config selected is assigned to [1].

[1] 95f5695f fstests: remove redundant string prompts for fstype

These patches are meant to fix that in the terraform section. While most of the patches are trivial, I'd like to know what you guys think about dropping a choice/endchoice config ("AWS name search") that depends on an previous choice/endchoice option ("AWS AMI owner") but we keep the config that the first multichoice was assigned to (TERRAFORM_AWS_NS).

Hope I explained this correctly. Otherwise, please check patch [2] and ask any question.

[2] terraform: aws: hide TERRAFORM_AWS_AMI_OWNER and drop AWS name search

Patch [3] it's the same but with less choice/endchoice configs and perhaps simpler to see the intention.

[3] terraform: aws: hide AWS availability region option

Note: I did add/merge some spelling corrections. If you think it's too noisy and not appropriate, I can make a separate commit for that.

The other patches remove choice/endchoice if only one option is available as Jeff suggested and/or hide the config by removing the redundant string.

Daniel

Daniel Gomez (5):
terraform: gce: remove redundant string for cpu and mem choice
terraform: aws: hide AWS availability region option
terraform: aws: hide TERRAFORM_AWS_AMI_OWNER and drop AWS name search
terraform: aws: drop multichoice option for TERRAFORM_AWS_VIRT_TYPE
terraform: aws: hide TERRAFORM_AWS_INSTANCE_TYPE

 terraform/aws/Kconfig | 160 ++++++++----------------------------------
 terraform/gce/Kconfig |  56 ++++-----------
 2 files changed, 46 insertions(+), 170 deletions(-)
Signature · 1 line
2.39.2
#2 lore raw

PATCH 1/5 terraform: gce: remove redundant string for cpu and mem choice

This commits is part of the propagation fix found by Jeff Layton in the choice/endchoice Kconfig option. When a CONFIG option is used to assign the selected CONFIG, a string can't be added to that config, otherwise the config is exposed and not updated with user selection. Removing the string makes the config option hide from the menuconfig.

For multichoice menu with single choice, remove choice menu and leave it as standalone option with its default value.

Also, s/gce/GCE/g for Google Compute Engine (GCE) or Google Cloud Platform Provider (GCP) and add documentation link to the terraform variable each option is assigned to.

---
 terraform/gce/Kconfig | 56 ++++++++++++-------------------------------
 1 file changed, 15 insertions(+), 41 deletions(-)
terraform/gce/Kconfig +15 -41
index 2102abd2..95ebd8da 100644
@@ -8,24 +8,15 @@ config TERRAFORM_GCE_PROJECT_NAME
 	  the actual name of the project you have created using the
 	  GCE interface.
 
-choice
-	prompt "Choose GCE region location to use"
-	default TERRAFORM_GCE_WEST_2C
-
-config TERRAFORM_GCE_WEST_2C
-	bool "us-west2-c"
-	help
-	  This option will set the gce region location to us-west2-c.
-
-endchoice
-
 config TERRAFORM_GCE_REGION_LOCATION
 	string "GCE region location"
-	default "us-west2-c" if TERRAFORM_GCE_WEST_2C
+	default "us-west2-c"
 	help
-	  This option will set the gce region location. For more examples:
+	  This option will set the GCE region location. For more examples:
 	  https://cloud.google.com/compute/docs/regions-zones/
 
+	  Documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#zone
+
 choice
 	prompt "Choose GCE Machine type"
 	default TERRAFORM_GCE_MACHINE_N1_STANDARD_8
@@ -45,7 +36,7 @@ config TERRAFORM_GCE_MACHINE_N1_STANDARD_8
 endchoice
 
 config TERRAFORM_GCE_MACHINE_TYPE
-	string "GCE Machine type"
+	string
 	default "n1-standard-1" if TERRAFORM_GCE_MACHINE_N1_STANDARD_1
 	default "n1-standard-8" if TERRAFORM_GCE_MACHINE_N1_STANDARD_8
 	help
@@ -54,40 +45,23 @@ config TERRAFORM_GCE_MACHINE_TYPE
 
 	  https://cloud.google.com/compute/docs/machine-types
 
-choice
-	prompt "Choose GCE scratch disk interface to use"
-	default TERRAFORM_GCE_SCRATCH_DISK_NVME
-
-config TERRAFORM_GCE_SCRATCH_DISK_NVME
-	bool "NVME"
-	help
-	  This option sets the scratch disk interface to NVMe.
-
-endchoice
+	  Documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#machine_type
 
 config TERRAFORM_GCE_SCRATCH_DISK_INTERFACE
-	string "GCE scratch disk interface"
-	default "NVME" if TERRAFORM_GCE_SCRATCH_DISK_NVME
+	string "GCE scratch disk interface to use"
+	default "NVME"
 	help
-	  This option will set gce scratch disk interface.
+	  This option will set GCE scratch disk interface.
 
-choice
-	prompt "Choose GCE image to use"
-	default TERRAFORM_GCE_IMAGE_DEBIAN_10
-
-config TERRAFORM_GCE_IMAGE_DEBIAN_10
-	bool "debian-cloud/debian-10"
-	depends on TARGET_ARCH_X86_64
-	help
-	  This option sets the gce image to debian-cloud/debian-10.
-
-endchoice
+	  Documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#scratch_disk
 
 config TERRAFORM_GCE_IMAGE
-	string "GCE image name to use"
-	default "debian-cloud/debian-10" if TERRAFORM_GCE_IMAGE_DEBIAN_10
+	string "GCE image to use"
+	default "debian-cloud/debian-10"
 	help
-	  This option will set gce image to debian-cloud/debian-10.
+	  This option will set GCE image to debian-cloud/debian-10.
+
+	  Documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#image
 
 config TERRAFORM_GCE_JSON_CREDENTIALS_PATH
 	string "GCE json credential file path"
Signature · 1 line
2.39.2
#3 lore raw

PATCH 2/5 terraform: aws: hide AWS availability region option

In reply to Daniel Gomez

This commit is part of the propagation fix found by Jeff Layton in the choice/endchoice Kconfig option.

TERRAFORM_AWS_AV_REGION is a multichoice with single choice option as it depends on AWS region multichoice option. Hide the option by removing the string and assign the value automatically with its AWS region option dependency.

Also, s/aws/AWS/g.

---
 terraform/aws/Kconfig | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)
terraform/aws/Kconfig +9 -27
index 158a0d63..cf3d59f0 100644
@@ -7,21 +7,21 @@ choice
 config TERRAFORM_AWS_US_WEST_1
 	bool "us-west-1 - North California"
 	help
-	  This option will set the aws region to us-west-1.
+	  This option will set the AWS region to us-west-1.
 
 config TERRAFORM_AWS_US_WEST_2
 	bool "us-west-2 - Oregon"
 	help
-	  This option will set the aws region to us-west-2.
+	  This option will set the AWS region to us-west-2.
 
 endchoice
 
 config TERRAFORM_AWS_REGION
-	string "AWS region"
+	string
 	default "us-west-1" if TERRAFORM_AWS_US_WEST_1
 	default "us-west-2" if TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set the aws region to the specified value.
+	  This option will set the AWS region to the specified value.
 
 	  If you wish to expand on this list send a patch after reading
 	  this list:
@@ -30,7 +30,7 @@ config TERRAFORM_AWS_REGION
 
 	  Note that if you change region the AMI may change as well even
 	  for the same distribution. At least that applies to Amazon EC2
-	  optimized images. Use the aws console, to set that up it will
+	  optimized images. Use the AWS console, to set that up it will
 	  ask you for your credentials and then a region. Before adding
 	  an entry for ami image be sure you are on the region and then
 	  query with something like:
@@ -57,30 +57,12 @@ config TERRAFORM_AWS_REGION
 	  aws ec2 describe-images --image-ids ami-0699f753302dd8b00 | grep OwnerId
 	    "OwnerId": "137112412989",
 
-choice
-	prompt "AWS availability region to use"
-	default TERRAFORM_AWS_AV_US_WEST_1B
-
-config TERRAFORM_AWS_AV_US_WEST_1B
-	bool "us-west-1b"
-	depends on TERRAFORM_AWS_US_WEST_1
-	help
-	  This option will set the aws availiability region to us-west-1b.
-
-config TERRAFORM_AWS_AV_US_WEST_2B
-	bool "us-west-2b"
-	depends on TERRAFORM_AWS_US_WEST_2
-	help
-	  This option will set the aws availiability region to us-west-2b.
-
-endchoice
-
 config TERRAFORM_AWS_AV_REGION
-	string "AWS availablity region"
-	default "us-west-1b" if TERRAFORM_AWS_AV_US_WEST_1B
-	default "us-west-2b" if TERRAFORM_AWS_AV_US_WEST_2B
+	string
+	default "us-west-1b" if TERRAFORM_AWS_US_WEST_1
+	default "us-west-2b" if TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set the aws availablity region to the specified
+	  This option will set the AWS availablity region to the specified
 	  value.
 
 	  If you wish to expand on this list send a patch after reading this
Signature · 1 line
2.39.2
#4 lore raw

PATCH 3/5 terraform: aws: hide TERRAFORM_AWS_AMI_OWNER and drop AWS name search

In reply to Daniel Gomez

Hide TERRAFORM_AWS_AMI_OWNER and drop multichoice option for 'AWS name search' as it directly depends on the option chosen at the 'AWS AMI owner'.

This makes TERRAFORM_AWS_NS option to default to the proper value without exposing it to the user making it non-visible symbol.

Also, 's/aws ami/AWS AMI/g'.

---
 terraform/aws/Kconfig | 107 ++++++++----------------------------------
 1 file changed, 19 insertions(+), 88 deletions(-)
terraform/aws/Kconfig +19 -88
index cf3d59f0..ab734b28 100644
@@ -72,141 +72,72 @@ config TERRAFORM_AWS_AV_REGION
 	  https://gist.github.com/neilstuartcraig/0ccefcf0887f29b7f240
 
 choice
-	prompt "AWS ami owner"
+	prompt "AWS AMI owner"
 	default TERRAFORM_AWS_AMI_AMAZON_X86_64 if TARGET_ARCH_X86_64
 	default TERRAFORM_AWS_AMI_AMAZON_ARM64 if TARGET_ARCH_ARM64
 
 config TERRAFORM_AWS_AMI_DEBIAN
 	bool "Debian - 379101102735"
 	help
-	  This option will set aws ami owner to Debian.
+	  This option will set AWS AMI owner to Debian.
 
 config TERRAFORM_AWS_AMI_AMAZON_X86_64
 	bool "Amazon Linux 2023 x86_64 - ami-0efa651876de2a5ce"
 	depends on TARGET_ARCH_X86_64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to Amazon EC2 images for x86_64.
+	  This option will set AWS AMI owner to Amazon EC2 images for x86_64.
 
 config TERRAFORM_AWS_AMI_AMAZON_ARM64
 	bool "Amazon Linux 2023 ARM64 - ami-0699f753302dd8b00"
 	depends on TARGET_ARCH_ARM64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to Amazon EC2 images for arm64.
+	  This option will set AWS AMI owner to Amazon EC2 images for arm64.
 
 config TERRAFORM_AWS_RHEL9_X86_64
 	bool "RHEL9 x86_64 - ami-0dda7e535b65b6469"
 	depends on TARGET_ARCH_X86_64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to RHEL9 for x86_64.
+	  This option will set AWS AMI owner to RHEL9 for x86_64.
 
 config TERRAFORM_AWS_RHEL9_ARM64
 	bool "RHEL9 x86_64 - ami-08911268ee09cb08e"
 	depends on TARGET_ARCH_ARM64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to RHEL9 for ARM64
+	  This option will set AWS AMI owner to RHEL9 for ARM64
 
 config TERRAFORM_AWS_SLE15_SP4_X86_64
 	bool "SUSE Linux Enterprise Server 15 SP4 x86_64 - ami-079ba66a5e9f2b70e"
 	depends on TARGET_ARCH_X86_64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to SLE15-SP4 for x86_64.
+	  This option will set AWS AMI owner to SLE15-SP4 for x86_64.
 
 config TERRAFORM_AWS_SLE15_SP4_ARM64
 	bool "SUSE Linux Enterprise Server 15 SP4 ARM64 - ami-00f902c807805f51a"
 	depends on TARGET_ARCH_ARM64 && TERRAFORM_AWS_US_WEST_2
 	help
-	  This option will set aws ami owner to SLE15-SP4 for arm64.
+	  This option will set AWS AMI owner to SLE15-SP4 for arm64.
 
 endchoice
 
 config TERRAFORM_AWS_AMI_OWNER
-	string "AWS AMI owner"
+	string
 	default "379101102735" if TERRAFORM_AWS_AMI_DEBIAN
 	default "137112412989" if TERRAFORM_AWS_AMI_AMAZON_X86_64 || TERRAFORM_AWS_AMI_AMAZON_ARM64
 	default "309956199498" if TERRAFORM_AWS_RHEL9_X86_64 || TERRAFORM_AWS_RHEL9_ARM64
 	default "013907871322" if TERRAFORM_AWS_SLE15_SP4_X86_64 || TERRAFORM_AWS_SLE15_SP4_ARM64
 	help
-	  This option will set aws AMI owner.
-
-choice
-	prompt "AWS name search"
-	default TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_X86_64 if TARGET_ARCH_X86_64 && TERRAFORM_AWS_AMI_DEBIAN
-	default TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_ARM64 if TERRAFORM_AWS_AMI_DEBIAN
-	default TERRAFORM_AWS_NS_AMAZON_2023_X86_64 if TARGET_ARCH_X86_64 && TERRAFORM_AWS_AMI_AMAZON_X86_64
-	default TERRAFORM_AWS_NS_AMAZON_2023_ARM64 if TARGET_ARCH_ARM64 && TERRAFORM_AWS_AMI_AMAZON_ARM64
-	default TERRAFORM_NS_RHEL9_X86_64 if TARGET_ARCH_X86_64 && TERRAFORM_AWS_RHEL9_X86_64
-	default TERRAFORM_NS_RHEL9_ARM64 if TARGET_ARCH_ARM64 && TERRAFORM_AWS_RHEL9_ARM64
-	default TERRAFORM_NS_SLE15SP4_X86_64 if TARGET_ARCH_X86_64 && TERRAFORM_AWS_SLE15_SP4_X86_64
-	default TERRAFORM_NS_SLE15SP4_ARM64 if TARGET_ARCH_ARM64 && TERRAFORM_AWS_SLE15_SP4_ARM64
-
-config TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_X86_64
-	bool "debian-stretch-hvm-x86_64-*"
-	depends on TARGET_ARCH_X86_64
-	help
-	  This option will set aws name search to debian-stretch-hvm-x86_64-*
-
-config TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_ARM64
-	bool "debian-stretch-hvm-arm64-*"
-	depends on TARGET_ARCH_ARM64
-	help
-	  This option will set aws name search to debian-stretch-hvm-arm64-*
-
-config TERRAFORM_AWS_NS_AMAZON_2023_X86_64
-	bool "al2023-*-x86_64"
-	select HAVE_SUPPORTS_PURE_IOMAP
-	depends on TARGET_ARCH_X86_64
-	help
-	  This option will set aws name search to the latest amazon 2023
-	  optimized image for x86_64.
-
-config TERRAFORM_AWS_NS_AMAZON_2023_ARM64
-	bool "al2023-*-arm64"
-	depends on TARGET_ARCH_ARM64
-	select HAVE_SUPPORTS_PURE_IOMAP
-	help
-	  This option will set aws name search to the latest amazon 2023
-	  optimized image arm64.
-
-config TERRAFORM_NS_RHEL9_X86_64
-	bool "RHEL-9.*x86_64-*"
-	depends on TARGET_ARCH_X86_64
-	help
-	  This option will set aws name search to the latest RHEL9
-	  image for x86_64.
-
-config TERRAFORM_NS_RHEL9_ARM64
-	bool "RHEL-9.*arm64-*"
-	depends on TARGET_ARCH_ARM64
-	help
-	  This option will set aws name search to the latest RHEL9
-	  image for arm64.
-
-config TERRAFORM_NS_SLE15SP4_X86_64
-	bool "suse-sles-15-sp4-*x86_64"
-	depends on TARGET_ARCH_X86_64
-	help
-	  This option will set aws name search to the latest SLE15-SP4
-	  image for x86_64.
-
-config TERRAFORM_NS_SLE15SP4_ARM64
-	bool "suse-sles-15-sp4-*arm64"
-	depends on TARGET_ARCH_ARM64
-	help
-	  This option will set aws name search to the latest SLE15-SP4
-	  image for arm64.
-
-endchoice
+	  This option will set AWS AMI owner.
 
 config TERRAFORM_AWS_NS
-	string "AWS name search"
-	default "debian-stretch-hvm-x86_64-*" if TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_X86_64
-	default "debian-stretch-hvm-arm64-*" if TERRAFORM_AWS_NS_DEBIAN_STRETCH_HVM_ARM64
-	default "al2023-*-x86_64" if TERRAFORM_AWS_NS_AMAZON_2023_X86_64
-	default "al2023-*-arm64" if TERRAFORM_AWS_NS_AMAZON_2023_ARM64
-	default "RHEL-9.*x86_64-*" if TERRAFORM_NS_RHEL9_X86_64
-	default "RHEL-9.*arm64-*" if TERRAFORM_NS_RHEL9_ARM64
-	default "suse-sles-15-sp4-*x86_64" if TERRAFORM_NS_SLE15SP4_X86_64
-	default "suse-sles-15-sp4-*arm64" if TERRAFORM_NS_SLE15SP4_ARM64
+	string
+	default "debian-stretch-hvm-x86_64-*" if TARGET_ARCH_X86_64 && TERRAFORM_AWS_AMI_DEBIAN
+	default "debian-stretch-hvm-arm64-*" if TARGET_ARCH_ARM64 && TERRAFORM_AWS_AMI_DEBIAN
+	default "al2023-*-x86_64" if TARGET_ARCH_X86_64 && TERRAFORM_AWS_AMI_AMAZON_X86_64
+	default "al2023-*-arm64" if TARGET_ARCH_ARM64 && TERRAFORM_AWS_AMI_AMAZON_ARM64
+	default "RHEL-9.*x86_64-*" if TARGET_ARCH_X86_64 && TERRAFORM_AWS_RHEL9_X86_64
+	default "RHEL-9.*arm64-*" if TARGET_ARCH_ARM64 && TERRAFORM_AWS_RHEL9_ARM64
+	default "suse-sles-15-sp4-*x86_64" if TARGET_ARCH_X86_64 && TERRAFORM_AWS_SLE15_SP4_X86_64
+	default "suse-sles-15-sp4-*arm64" if TARGET_ARCH_ARM64 && TERRAFORM_AWS_SLE15_SP4_ARM64
 	help
 	  This option will set aws image search to use. Using this filter glob
 	  lets us get the latest ami for this owner / release.
Signature · 1 line
2.39.2
#5 lore raw

PATCH 4/5 terraform: aws: drop multichoice option for TERRAFORM_AWS_VIRT_TYPE

In reply to Daniel Gomez

TERRAFORM_AWS_VIRT_TYPE is single choice option. Drop multichoice in favor of string option.

---
 terraform/aws/Kconfig | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
terraform/aws/Kconfig +2 -13
index ab734b28..18a96349 100644
@@ -164,22 +164,11 @@ config TERRAFORM_AWS_NS
 
 	  https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html
 
-choice
-	prompt "AWS virt type"
-	default TERRAFORM_AWS_VIRT_TYPE_HVM
-
-config TERRAFORM_AWS_VIRT_TYPE_HVM
-	bool "hvm"
-	help
-	  This option will set aws virt type to hvm.
-
-endchoice
-
 config TERRAFORM_AWS_VIRT_TYPE
 	string "AWS virt type"
-	default "hvm" if TERRAFORM_AWS_VIRT_TYPE_HVM
+	default "hvm"
 	help
-	  This option will set aws virt type. It must match your your
+	  This option will set AWS virt type. It must match your your
 	  preferred image filter used above for name search.
 
 choice
Signature · 1 line
2.39.2
#6 lore raw

PATCH 5/5 terraform: aws: hide TERRAFORM_AWS_INSTANCE_TYPE

In reply to Daniel Gomez

This commit is part of the propagation fix found by Jeff Layton in the choice/endchoice Kconfig option.

Hide the config TERRAFORM_AWS_INSTANCE_TYPE by removing the string and assign the value automatically with option selected in 'AWS instance type'.

---
 terraform/aws/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
terraform/aws/Kconfig +1 -1
index 18a96349..401d92ea 100644
@@ -243,7 +243,7 @@ config TERRAFORM_AWS_INSTANCE_I4I_METAL
 endchoice
 
 config TERRAFORM_AWS_INSTANCE_TYPE
-	string "AWS AMI owner"
+	string
 	default "m5ad.4xlarge" if TERRAFORM_AWS_INSTANCE_M5AD_4XLARGE
 	default "is4gen.medium" if TERRAFORM_AWS_INSTANCE_IS4GEN_MEDIUM
 	default "is4gen.8xlarge" if TERRAFORM_AWS_INSTANCE_IS4GEN_8XLARGE
Signature · 1 line
2.39.2
Acked-by Tested-by on the v1 series
#7 lore raw
In reply to Daniel Gomez
Quoted 21 lines · Daniel Gomez

Hi,

As you may know, Jeff Layton found the way to fix the choice/enchoice issue by removing the redundant string the config selected is assigned to [1].

[1] 95f5695f fstests: remove redundant string prompts for fstype

These patches are meant to fix that in the terraform section. While most of the patches are trivial, I'd like to know what you guys think about dropping a choice/endchoice config ("AWS name search") that depends on an previous choice/endchoice option ("AWS AMI owner") but we keep the config that the first multichoice was assigned to (TERRAFORM_AWS_NS).

Hope I explained this correctly. Otherwise, please check patch [2] and ask any question.

[2] terraform: aws: hide TERRAFORM_AWS_AMI_OWNER and drop AWS name search

Patch [3] it's the same but with less choice/endchoice configs and perhaps simpler to see the intention.

Quoted 7 lines

[3] terraform: aws: hide AWS availability region option

Note: I did add/merge some spelling corrections. If you think it's too noisy and not appropriate, I can make a separate commit for that.

The other patches remove choice/endchoice if only one option is available as Jeff suggested and/or hide the config by removing the redundant string.

Looks all good, and goes tested by me, so:

Please push!

Luis

#8 lore raw
Quoted 1 line · Luis Chamberlain

Please push!

I had a patch pending on this so I just pushed it myself.

Luis