Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CoreOS-enabled option for Satellite location create #3914

Merged
merged 10 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.10
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.2.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.10 h1:NUGZwF5V0j2lFurA5LaigsYyOKDKwz4M0sCpm+YIbig=
github.com/IBM-Cloud/power-go-client v1.1.10/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE=
Expand Down
6 changes: 6 additions & 0 deletions ibm/service/satellite/data_source_ibm_satellite_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func DataSourceIBMSatelliteLocation() *schema.Resource {
Computed: true,
Description: "A description of the new Satellite location",
},
"coreos_enabled": {
bhpratt marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeBool,
Computed: true,
Description: "If Red Hat CoreOS features are enabled within the Satellite location",
},
"logging_account_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -172,6 +177,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)
Expand Down
14 changes: 14 additions & 0 deletions ibm/service/satellite/resource_ibm_satellite_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func ResourceIBMSatelliteLocation() *schema.Resource {
Optional: true,
Description: "A description of the new Satellite location",
},
"coreos_enabled": {
bhpratt marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Enable Red Hat CoreOS features within the Satellite location",
},
"logging_account_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -235,6 +241,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{}))
}
Expand Down Expand Up @@ -317,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)
}
Expand Down
12 changes: 8 additions & 4 deletions ibm/service/satellite/resource_ibm_satellite_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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),
),
},
},
Expand All @@ -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) },
Expand All @@ -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),
Expand Down Expand Up @@ -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" {
Expand All @@ -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)
}
1 change: 1 addition & 0 deletions website/docs/d/satellite_location.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/satellite_location.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down