From 335834a8546084f22f2629747636da45e9fa2e30 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Fri, 24 Jun 2022 15:51:29 -0400 Subject: [PATCH 1/9] initial changes to accept coreos locations --- ibm/service/satellite/resource_ibm_satellite_location.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ibm/service/satellite/resource_ibm_satellite_location.go b/ibm/service/satellite/resource_ibm_satellite_location.go index a06d7a168a..8caa68fde5 100644 --- a/ibm/service/satellite/resource_ibm_satellite_location.go +++ b/ibm/service/satellite/resource_ibm_satellite_location.go @@ -98,6 +98,11 @@ func ResourceIBMSatelliteLocation() *schema.Resource { Optional: true, Description: "A description of the new Satellite location", }, + "coreos_enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "Enable Red Hat CoreOS features within the Satellite location", + }, "logging_account_id": { Type: schema.TypeString, Optional: true, @@ -235,6 +240,10 @@ func resourceIBMSatelliteLocationCreate(d *schema.ResourceData, meta interface{} sateLocZone := d.Get(sateLocZone).(string) createSatLocOptions.Location = &sateLocZone + if v, ok := d.GetOk("coreos_enabled"); ok { + coreosEnabled := v.(bool) + createSatLocOptions.CoreosEnabled = &coreosEnabled + } if v, ok := d.GetOk("cos_config"); ok { createSatLocOptions.CosConfig = flex.ExpandCosConfig(v.([]interface{})) } From 6b9ecb7e01ab7e7d2634547a179bb1eba8c2d847 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Wed, 6 Jul 2022 15:32:01 -0400 Subject: [PATCH 2/9] fixed reference to variable --- ibm/service/satellite/resource_ibm_satellite_location.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/satellite/resource_ibm_satellite_location.go b/ibm/service/satellite/resource_ibm_satellite_location.go index 8caa68fde5..952886092c 100644 --- a/ibm/service/satellite/resource_ibm_satellite_location.go +++ b/ibm/service/satellite/resource_ibm_satellite_location.go @@ -242,7 +242,7 @@ func resourceIBMSatelliteLocationCreate(d *schema.ResourceData, meta interface{} if v, ok := d.GetOk("coreos_enabled"); ok { coreosEnabled := v.(bool) - createSatLocOptions.CoreosEnabled = &coreosEnabled + createSatLocOptions.CoreosEnabled = coreosEnabled } if v, ok := d.GetOk("cos_config"); ok { createSatLocOptions.CosConfig = flex.ExpandCosConfig(v.([]interface{})) From 4b00b4553545786af215a6108ca88a88519885b7 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Wed, 6 Jul 2022 15:36:10 -0400 Subject: [PATCH 3/9] added doc for new variable --- website/docs/r/satellite_location.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/satellite_location.html.markdown b/website/docs/r/satellite_location.html.markdown index 8be4ad3225..e5241a334a 100644 --- a/website/docs/r/satellite_location.html.markdown +++ b/website/docs/r/satellite_location.html.markdown @@ -56,6 +56,7 @@ The `ibm_satellite_location` provides the following [Timeouts](https://www.terra ## Argument reference Review the argument references that you can specify for your resource. +- `coreos_enabled` - (Optional, Bool) Enable Red Hat CoreOS features within the Satellite location. - `cos_config` - (Optional, List) The IBM Cloud Object Storage bucket configuration details. Nested cos_config blocks have the following structure. Nested scheme for `cos_config`: From 91fa2f99f31b4c1a5e1b9dbd3b66751323794536 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Wed, 6 Jul 2022 16:42:33 -0400 Subject: [PATCH 4/9] update to use the latest version of satellite SDK --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d7187b2ceb..c69f994d96 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/IBM-Cloud/bluemix-go v0.0.0-20220523145737-34645883de47 - github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62 + github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220622142911-811d18c8c775 github.com/IBM-Cloud/power-go-client v1.1.9 github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca github.com/IBM/appconfiguration-go-admin-sdk v0.2.3 diff --git a/go.sum b/go.sum index 75ff0ea1a9..a759960c9d 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20220523145737-34645883de47 h1:lpClRYyGuS github.com/IBM-Cloud/bluemix-go v0.0.0-20220523145737-34645883de47/go.mod h1:tfNN3lCKuA2+SQvndt0+5CjPr2qn/wdNLjrue1GrOhY= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62 h1:MOkcr6qQGk4tY542ZJ1DggVh2WUP72EEyLB79llFVH8= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= +github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220622142911-811d18c8c775 h1:hTj8cRqWv76Io/j+fUKq0Rrq1AjBA7uvRLs634ea/+8= +github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220622142911-811d18c8c775/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs= github.com/IBM-Cloud/power-go-client v1.1.9 h1:NKG4lxQNe1HHANC+94mRqgogIkiAHo5COMNsqUGdNqg= github.com/IBM-Cloud/power-go-client v1.1.9/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE= From d20b2ef0c9138fa74309ca02e76d44a662f64be2 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Thu, 7 Jul 2022 12:23:06 -0400 Subject: [PATCH 5/9] updated test to check for coreosenabled --- .../resource_ibm_satellite_location_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ibm/service/satellite/resource_ibm_satellite_location_test.go b/ibm/service/satellite/resource_ibm_satellite_location_test.go index 2015136190..19c534d910 100644 --- a/ibm/service/satellite/resource_ibm_satellite_location_test.go +++ b/ibm/service/satellite/resource_ibm_satellite_location_test.go @@ -20,6 +20,7 @@ func TestAccSatelliteLocation_Basic(t *testing.T) { var instance string name := fmt.Sprintf("tf-satellitelocation-%d", acctest.RandIntRange(10, 100)) managed_from := "wdc04" + coreos_enabled := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -28,11 +29,12 @@ func TestAccSatelliteLocation_Basic(t *testing.T) { Steps: []resource.TestStep{ { - Config: testAccCheckSatelliteLocationCreate(name, managed_from), + Config: testAccCheckSatelliteLocationCreate(name, managed_from, coreos_enabled), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckSatelliteLocationExists("ibm_satellite_location.location", instance), resource.TestCheckResourceAttr("ibm_satellite_location.location", "location", name), resource.TestCheckResourceAttr("ibm_satellite_location.location", "managed_from", managed_from), + resource.TestCheckResourceAttr("ibm_satellite_location.location", "coreos_enabled", coreos_enabled), ), }, }, @@ -43,6 +45,7 @@ func TestAccSatelliteLocation_Import(t *testing.T) { var instance string name := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) managed_from := "wdc04" + coreos_enabled := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -51,7 +54,7 @@ func TestAccSatelliteLocation_Import(t *testing.T) { Steps: []resource.TestStep{ { - Config: testAccCheckSatelliteLocationCreate(name, managed_from), + Config: testAccCheckSatelliteLocationCreate(name, managed_from, coreos_enabled), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckSatelliteLocationExists("ibm_satellite_location.location", instance), resource.TestCheckResourceAttr("ibm_satellite_location.location", "location", name), @@ -123,7 +126,7 @@ func testAccCheckSatelliteLocationDestroy(s *terraform.State) error { return nil } -func testAccCheckSatelliteLocationCreate(name, managed_from string) string { +func testAccCheckSatelliteLocationCreate(name, managed_from string, coreos_enabled string) string { return fmt.Sprintf(` data "ibm_resource_group" "res_group" { @@ -133,11 +136,12 @@ func testAccCheckSatelliteLocationCreate(name, managed_from string) string { resource "ibm_satellite_location" "location" { location = "%s" managed_from = "%s" + coreos_enabled = "%s" description = "test" zones = ["us-east-1", "us-east-2", "us-east-3"] resource_group_id = data.ibm_resource_group.res_group.id tags = ["env:dev"] } -`, name, managed_from) +`, name, managed_from, coreos_enabled) } From 7ba6c5937ce2c2324dbcbf706b35b0b5eae727ce Mon Sep 17 00:00:00 2001 From: bhpratt Date: Tue, 12 Jul 2022 15:35:58 -0400 Subject: [PATCH 6/9] added computed field and added to Read --- ibm/service/satellite/resource_ibm_satellite_location.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ibm/service/satellite/resource_ibm_satellite_location.go b/ibm/service/satellite/resource_ibm_satellite_location.go index 952886092c..e605de1243 100644 --- a/ibm/service/satellite/resource_ibm_satellite_location.go +++ b/ibm/service/satellite/resource_ibm_satellite_location.go @@ -101,6 +101,7 @@ func ResourceIBMSatelliteLocation() *schema.Resource { "coreos_enabled": { Type: schema.TypeBool, Optional: true, + Computed: true, Description: "Enable Red Hat CoreOS features within the Satellite location", }, "logging_account_id": { @@ -326,6 +327,10 @@ func resourceIBMSatelliteLocationRead(d *schema.ResourceData, meta interface{}) d.Set("description", *instance.Description) } + if instance.CoreosEnabled != nil { + d.Set("coreos_enabled", *instance.CoreosEnabled) + } + if instance.Datacenter != nil { d.Set(sateLocZone, *instance.Datacenter) } From 6811da3bd2bc9687bcab73f63ffee398e1afac5b Mon Sep 17 00:00:00 2001 From: bhpratt Date: Tue, 12 Jul 2022 15:43:37 -0400 Subject: [PATCH 7/9] add coreos enabled arguments to data source --- .../satellite/data_source_ibm_satellite_location.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ibm/service/satellite/data_source_ibm_satellite_location.go b/ibm/service/satellite/data_source_ibm_satellite_location.go index e281bd1b27..215ec7b606 100644 --- a/ibm/service/satellite/data_source_ibm_satellite_location.go +++ b/ibm/service/satellite/data_source_ibm_satellite_location.go @@ -36,6 +36,12 @@ func DataSourceIBMSatelliteLocation() *schema.Resource { Computed: true, Description: "A description of the new Satellite location", }, + "coreos_enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "If Red Hat CoreOS features are enabled within the Satellite location", + }, "logging_account_id": { Type: schema.TypeString, Computed: true, @@ -172,6 +178,7 @@ func dataSourceIBMSatelliteLocationRead(d *schema.ResourceData, meta interface{} d.SetId(*instance.ID) d.Set("location", location) d.Set("description", *instance.Description) + d.Set("coreos_enabled", *instance.CoreosEnabled) d.Set("zones", instance.WorkerZones) d.Set("managed_from", *instance.Datacenter) d.Set("crn", *instance.Crn) From d7622327c1756d8581f774d2ba5364fec0e60cfa Mon Sep 17 00:00:00 2001 From: bhpratt Date: Thu, 14 Jul 2022 10:02:16 -0400 Subject: [PATCH 8/9] remove optional as data source is only computed --- ibm/service/satellite/data_source_ibm_satellite_location.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ibm/service/satellite/data_source_ibm_satellite_location.go b/ibm/service/satellite/data_source_ibm_satellite_location.go index 215ec7b606..3c9ea7e58a 100644 --- a/ibm/service/satellite/data_source_ibm_satellite_location.go +++ b/ibm/service/satellite/data_source_ibm_satellite_location.go @@ -38,7 +38,6 @@ func DataSourceIBMSatelliteLocation() *schema.Resource { }, "coreos_enabled": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: "If Red Hat CoreOS features are enabled within the Satellite location", }, From 83a9f763a4cc7a5074cc0a2abce869637d990d36 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Thu, 14 Jul 2022 10:05:51 -0400 Subject: [PATCH 9/9] add core_enabled attribute to data source docs --- website/docs/d/satellite_location.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/d/satellite_location.html.markdown b/website/docs/d/satellite_location.html.markdown index 1c799a7a92..614d034919 100644 --- a/website/docs/d/satellite_location.html.markdown +++ b/website/docs/d/satellite_location.html.markdown @@ -26,6 +26,7 @@ Review the argument references that you can specify for your data source. ## Attribute reference In addition to all argument reference list, you can access the following attribute reference after your resource is created. +- `coreos_enabled` - (Bool) If Red Hat CoreOS features are enabled within the Satellite location. - `crn` - (String) The CRN for this satellite location. - `created_on` - (Timestamp) The created time of the satellite location. - `description` - (String) Description of the new Satellite location.