From ed8e99b3a29a78fa1e18241cf9296da556047864 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 10 May 2024 12:25:48 -0500 Subject: [PATCH 01/25] Refactor ibm_pi_volume_clone data source --- .../power/data_source_ibm_pi_volume_clone.go | 71 ++++++++++++------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_volume_clone.go b/ibm/service/power/data_source_ibm_pi_volume_clone.go index 3692be175f..6d1142f302 100644 --- a/ibm/service/power/data_source_ibm_pi_volume_clone.go +++ b/ibm/service/power/data_source_ibm_pi_volume_clone.go @@ -6,46 +6,65 @@ package power import ( "context" + "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - st "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" ) func DataSourceIBMPIVolumeClone() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceIBMPIVolumeCloneRead, Schema: map[string]*schema.Schema{ - PIVolumeCloneTaskID: { - Type: schema.TypeString, + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", Required: true, - Description: "The ID of the volume clone task.", + Type: schema.TypeString, ValidateFunc: validation.NoZeroValues, }, - Arg_CloudInstanceID: { - Type: schema.TypeString, + Arg_VolumeCloneTaskID: { + Description: "The ID of the volume clone task.", Required: true, + Type: schema.TypeString, ValidateFunc: validation.NoZeroValues, - Description: "The GUID of the service instance associated with an account.", }, - // Computed attributes - "cloned_volumes": clonedVolumesSchema(), - "failure_reason": { - Type: schema.TypeString, + + // Attributes + Attr_ClonedVolumes: { + Computed: true, + Description: "The List of cloned volumes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_CloneVolumeID: { + Computed: true, + Description: "The ID of the newly cloned volume.", + Type: schema.TypeString, + }, + Attr_SourceVolumeID: { + Computed: true, + Description: "The ID of the source volume.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + Attr_FailureReason: { Computed: true, Description: "The reason the clone volumes task has failed.", + Type: schema.TypeString, }, - "percent_complete": { - Type: schema.TypeInt, + Attr_PercentComplete: { Computed: true, Description: "The completion percentage of the volume clone task.", + Type: schema.TypeInt, }, - "status": { - Type: schema.TypeString, + Attr_Status: { Computed: true, Description: "The status of the volume clone task.", + Type: schema.TypeString, }, }, } @@ -58,21 +77,21 @@ func dataSourceIBMPIVolumeCloneRead(ctx context.Context, d *schema.ResourceData, } cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) - client := st.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) - volClone, err := client.Get(d.Get(PIVolumeCloneTaskID).(string)) + client := instance.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) + volClone, err := client.Get(d.Get(Arg_VolumeCloneTaskID).(string)) if err != nil { return diag.FromErr(err) } - d.SetId(d.Get(PIVolumeCloneTaskID).(string)) - if volClone.Status != nil { - d.Set("status", *volClone.Status) - } - d.Set("failure_reason", volClone.FailedReason) + d.SetId(d.Get(Arg_VolumeCloneTaskID).(string)) + d.Set(Attr_FailureReason, volClone.FailedReason) if volClone.PercentComplete != nil { - d.Set("percent_complete", *volClone.PercentComplete) + d.Set(Attr_PercentComplete, *volClone.PercentComplete) + } + if volClone.Status != nil { + d.Set(Attr_Status, *volClone.Status) } - d.Set("cloned_volumes", flattenClonedVolumes(volClone.ClonedVolumes)) + d.Set(Attr_ClonedVolumes, flattenClonedVolumes(volClone.ClonedVolumes)) return nil } From b78e3973fe94c865c88a5cd1776f37be8828ee8f Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 10 May 2024 12:26:58 -0500 Subject: [PATCH 02/25] Refactor ibm_pi_volume_clone resource --- .../power/resource_ibm_pi_volume_clone.go | 168 +++++++++--------- 1 file changed, 83 insertions(+), 85 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_volume_clone.go b/ibm/service/power/resource_ibm_pi_volume_clone.go index 6d43f4efba..f2a1d33ea2 100644 --- a/ibm/service/power/resource_ibm_pi_volume_clone.go +++ b/ibm/service/power/resource_ibm_pi_volume_clone.go @@ -9,14 +9,14 @@ import ( "log" "time" - st "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/power-go-client/helpers" + "github.com/IBM-Cloud/power-go-client/clients/instance" "github.com/IBM-Cloud/power-go-client/power/models" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func ResourceIBMPIVolumeClone() *schema.Resource { @@ -32,60 +32,81 @@ func ResourceIBMPIVolumeClone() *schema.Resource { }, Schema: map[string]*schema.Schema{ + // Arguments Arg_CloudInstanceID: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The GUID of the service instance associated with an account.", + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - PIVolumeCloneName: { - Type: schema.TypeString, - Required: true, + Arg_TargetStorageTier: { + Description: "The storage tier for the cloned volume(s).", ForceNew: true, - Description: "The base name of the newly cloned volume(s).", + Optional: true, + Type: schema.TypeString, }, - PIVolumeIds: { - Type: schema.TypeSet, - Required: true, + Arg_ReplicationEnabled: { + Description: "Indicates whether the cloned volume should have replication enabled. If no value is provided, it will default to the replication status of the source volume(s).", ForceNew: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, - Description: "List of volumes to be cloned.", - }, - PITargetStorageTier: { - Type: schema.TypeString, Optional: true, - ForceNew: true, - Description: "The storage tier for the cloned volume(s).", - }, - helpers.PIReplicationEnabled: { Type: schema.TypeBool, - Optional: true, + }, + Arg_VolumeCloneName: { + Description: "The base name of the newly cloned volume(s).", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + Arg_VolumeIDs: { + Description: "List of volumes to be cloned.", + Elem: &schema.Schema{Type: schema.TypeString}, ForceNew: true, - Description: "Indicates whether the cloned volume should have replication enabled. If no value is provided, it will default to the replication status of the source volume(s).", + Required: true, + Set: schema.HashString, + Type: schema.TypeSet, }, - // Computed attributes - "task_id": { - Type: schema.TypeString, + // Attributes + Attr_ClonedVolumes: { Computed: true, - Description: "The ID of the volume clone task.", + Description: "The List of cloned volumes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_CloneVolumeID: { + Computed: true, + Description: "The ID of the newly cloned volume.", + Type: schema.TypeString, + }, + Attr_SourceVolumeID: { + Computed: true, + Description: "The ID of the source volume.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, }, - "cloned_volumes": clonedVolumesSchema(), - "failure_reason": { - Type: schema.TypeString, + Attr_FailureReason: { Computed: true, - Description: "The reason for the failure of the volume clone task.", + Description: "The reason the clone volumes task has failed.", + Type: schema.TypeString, }, - "percent_complete": { - Type: schema.TypeInt, + Attr_PercentComplete: { Computed: true, Description: "The completion percentage of the volume clone task.", + Type: schema.TypeInt, }, - "status": { - Type: schema.TypeString, + Attr_Status: { Computed: true, Description: "The status of the volume clone task.", + Type: schema.TypeString, + }, + Attr_TaskID: { + Computed: true, + Description: "The ID of the volume clone task.", + Type: schema.TypeString, }, }, } @@ -98,23 +119,23 @@ func resourceIBMPIVolumeCloneCreate(ctx context.Context, d *schema.ResourceData, } cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) - vcName := d.Get(PIVolumeCloneName).(string) - volids := flex.ExpandStringList((d.Get(PIVolumeIds).(*schema.Set)).List()) + vcName := d.Get(Arg_VolumeCloneName).(string) + volids := flex.ExpandStringList((d.Get(Arg_VolumeIDs).(*schema.Set)).List()) body := &models.VolumesCloneAsyncRequest{ Name: &vcName, VolumeIDs: volids, } - if v, ok := d.GetOk(PITargetStorageTier); ok { + if v, ok := d.GetOk(Arg_TargetStorageTier); ok { body.TargetStorageTier = v.(string) } - if !d.GetRawConfig().GetAttr(helpers.PIReplicationEnabled).IsNull() { - body.TargetReplicationEnabled = flex.PtrToBool(d.Get(helpers.PIReplicationEnabled).(bool)) + if !d.GetRawConfig().GetAttr(Arg_ReplicationEnabled).IsNull() { + body.TargetReplicationEnabled = flex.PtrToBool(d.Get(Arg_ReplicationEnabled).(bool)) } - client := st.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) volClone, err := client.Create(body) if err != nil { return diag.FromErr(err) @@ -131,7 +152,6 @@ func resourceIBMPIVolumeCloneCreate(ctx context.Context, d *schema.ResourceData, } func resourceIBMPIVolumeCloneRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - sess, err := meta.(conns.ClientSession).IBMPISession() if err != nil { return diag.FromErr(err) @@ -142,21 +162,21 @@ func resourceIBMPIVolumeCloneRead(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } - client := st.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) volCloneTask, err := client.Get(vcTaskID) if err != nil { return diag.FromErr(err) } - d.Set("task_id", vcTaskID) - if volCloneTask.Status != nil { - d.Set("status", *volCloneTask.Status) - } - d.Set("failure_reason", volCloneTask.FailedReason) + d.Set(Attr_FailureReason, volCloneTask.FailedReason) if volCloneTask.PercentComplete != nil { - d.Set("percent_complete", *volCloneTask.PercentComplete) + d.Set(Attr_PercentComplete, *volCloneTask.PercentComplete) } - d.Set("cloned_volumes", flattenClonedVolumes(volCloneTask.ClonedVolumes)) + if volCloneTask.Status != nil { + d.Set(Attr_Status, *volCloneTask.Status) + } + d.Set(Attr_TaskID, vcTaskID) + d.Set(Attr_ClonedVolumes, flattenClonedVolumes(volCloneTask.ClonedVolumes)) return nil } @@ -172,8 +192,8 @@ func flattenClonedVolumes(list []*models.ClonedVolume) (cloneVolumes []map[strin cloneVolumes := make([]map[string]interface{}, len(list)) for i, data := range list { l := map[string]interface{}{ - "clone_volume_id": data.ClonedVolumeID, - "source_volume_id": data.SourceVolumeID, + Attr_CloneVolumeID: data.ClonedVolumeID, + Attr_SourceVolumeID: data.SourceVolumeID, } cloneVolumes[i] = l } @@ -182,12 +202,12 @@ func flattenClonedVolumes(list []*models.ClonedVolume) (cloneVolumes []map[strin return } -func isWaitForIBMPIVolumeCloneCompletion(ctx context.Context, client *st.IBMPICloneVolumeClient, id string, timeout time.Duration) (interface{}, error) { +func isWaitForIBMPIVolumeCloneCompletion(ctx context.Context, client *instance.IBMPICloneVolumeClient, id string, timeout time.Duration) (interface{}, error) { log.Printf("Waiting for Volume clone (%s) to be completed.", id) - stateConf := &resource.StateChangeConf{ - Pending: []string{VolumeCloneRunning}, - Target: []string{VolumeCloneCompleted}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Creating}, + Target: []string{State_Completed}, Refresh: isIBMPIVolumeCloneRefreshFunc(client, id), Delay: 10 * time.Second, MinTimeout: 2 * time.Minute, @@ -197,39 +217,17 @@ func isWaitForIBMPIVolumeCloneCompletion(ctx context.Context, client *st.IBMPICl return stateConf.WaitForStateContext(ctx) } -func isIBMPIVolumeCloneRefreshFunc(client *st.IBMPICloneVolumeClient, id string) resource.StateRefreshFunc { +func isIBMPIVolumeCloneRefreshFunc(client *instance.IBMPICloneVolumeClient, id string) retry.StateRefreshFunc { return func() (interface{}, string, error) { volClone, err := client.Get(id) if err != nil { return nil, "", err } - if *volClone.Status == VolumeCloneCompleted { - return volClone, VolumeCloneCompleted, nil + if *volClone.Status == State_Completed { + return volClone, State_Completed, nil } - return volClone, VolumeCloneRunning, nil - } -} - -func clonedVolumesSchema() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The List of cloned volumes.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "clone_volume_id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the newly cloned volume.", - }, - "source_volume_id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the source volume.", - }, - }, - }, + return volClone, State_Creating, nil } } From 0acf2aaab6c7aeb88191d4dba7d4f54f09e93dfe Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 10 May 2024 12:29:19 -0500 Subject: [PATCH 03/25] Add volume clone tests --- .../data_source_ibm_pi_volume_clone_test.go | 9 ++--- .../resource_ibm_pi_volume_clone_test.go | 38 +++++++++---------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_volume_clone_test.go b/ibm/service/power/data_source_ibm_pi_volume_clone_test.go index a8b8d805d4..22ba0259ab 100644 --- a/ibm/service/power/data_source_ibm_pi_volume_clone_test.go +++ b/ibm/service/power/data_source_ibm_pi_volume_clone_test.go @@ -30,9 +30,8 @@ func TestAccIBMPIVolumeClone_basic(t *testing.T) { func testAccCheckIBMPIVolumeCloneBasicConfig() string { return fmt.Sprintf(` -data "ibm_pi_volume_clone" "testacc_ds_volume_clone" { - pi_volume_clone_task_id = "%s" - pi_cloud_instance_id = "%s" -}`, acc.Pi_volume_clone_task_id, acc.Pi_cloud_instance_id) - + data "ibm_pi_volume_clone" "testacc_ds_volume_clone" { + pi_cloud_instance_id = "%s" + pi_volume_clone_task_id = "%s" + }`, acc.Pi_cloud_instance_id, acc.Pi_volume_clone_task_id) } diff --git a/ibm/service/power/resource_ibm_pi_volume_clone_test.go b/ibm/service/power/resource_ibm_pi_volume_clone_test.go index 4a5da2446f..fc7c485786 100644 --- a/ibm/service/power/resource_ibm_pi_volume_clone_test.go +++ b/ibm/service/power/resource_ibm_pi_volume_clone_test.go @@ -9,8 +9,9 @@ import ( "fmt" "testing" - st "github.com/IBM-Cloud/power-go-client/clients/instance" acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + + "github.com/IBM-Cloud/power-go-client/clients/instance" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -42,7 +43,6 @@ func TestAccIBMPIVolumeClone(t *testing.T) { func testAccCheckIBMPIVolumeCloneExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] if !ok { @@ -63,7 +63,7 @@ func testAccCheckIBMPIVolumeCloneExists(n string) resource.TestCheckFunc { return err } cloudInstanceID, vcTaskID := ids[0], ids[1] - client := st.NewIBMPICloneVolumeClient(context.Background(), sess, cloudInstanceID) + client := instance.NewIBMPICloneVolumeClient(context.Background(), sess, cloudInstanceID) _, err = client.Get(vcTaskID) if err != nil { @@ -75,25 +75,23 @@ func testAccCheckIBMPIVolumeCloneExists(n string) resource.TestCheckFunc { func testAccCheckIBMPIVolumeCloneConfig(name string) string { return volumesCloneConfig(name, true) + fmt.Sprintf(` - resource "ibm_pi_volume_clone" "power_volume_clone" { - pi_cloud_instance_id = "%[1]s" - pi_volume_clone_name = "%[2]s" - pi_volume_ids = ibm_pi_volume.power_volume.*.volume_id - pi_target_storage_tier = "%[3]s" - pi_replication_enabled = %[4]v - } - `, acc.Pi_cloud_instance_id, name, acc.Pi_target_storage_tier, false) + resource "ibm_pi_volume_clone" "power_volume_clone" { + pi_cloud_instance_id = "%[1]s" + pi_replication_enabled = %[4]v + pi_target_storage_tier = "%[3]s" + pi_volume_clone_name = "%[2]s" + pi_volume_ids = ibm_pi_volume.power_volume.*.volume_id + } `, acc.Pi_cloud_instance_id, name, acc.Pi_target_storage_tier, false) } func volumesCloneConfig(name string, volumeReplicationEnabled bool) string { return fmt.Sprintf(` - resource "ibm_pi_volume" "power_volume" { - count = 2 - pi_volume_size = 2 - pi_volume_name = "%[1]s-${count.index}" - pi_volume_pool = "%[3]s" - pi_cloud_instance_id = "%[2]s" - pi_replication_enabled = %[4]v - } - `, name, acc.Pi_cloud_instance_id, acc.PiStoragePool, volumeReplicationEnabled) + resource "ibm_pi_volume" "power_volume" { + count = 2 + pi_cloud_instance_id = "%[2]s" + pi_replication_enabled = %[4]v + pi_volume_name = "%[1]s-${count.index}" + pi_volume_pool = "%[3]s" + pi_volume_size = 2 + } `, name, acc.Pi_cloud_instance_id, acc.PiStoragePool, volumeReplicationEnabled) } From f4d7150112fe2eb6c7665bb7b181e6bc4b0d2ce9 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 10 May 2024 12:32:06 -0500 Subject: [PATCH 04/25] Fix volume id issue --- ...ata_source_ibm_pi_volume_group_details_test.go | 4 ++-- ibm/service/power/ibm_pi_constants.go | 15 +++++++++++---- ibm/service/power/resource_ibm_pi_volume.go | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_volume_group_details_test.go b/ibm/service/power/data_source_ibm_pi_volume_group_details_test.go index 91d93a34d7..90153d4b73 100644 --- a/ibm/service/power/data_source_ibm_pi_volume_group_details_test.go +++ b/ibm/service/power/data_source_ibm_pi_volume_group_details_test.go @@ -30,7 +30,7 @@ func TestAccIBMPIVolumeGroupDetailsDataSource_basic(t *testing.T) { func testAccCheckIBMPIVolumeGroupDetailsDataSourceConfig() string { return fmt.Sprintf(` data "ibm_pi_volume_group_details" "testacc_volume_group_details" { - pi_volume_group_id = "%s" pi_cloud_instance_id = "%s" - }`, acc.Pi_volume_group_id, acc.Pi_cloud_instance_id) + pi_volume_group_id = "%s" + }`, acc.Pi_cloud_instance_id, acc.Pi_volume_group_id) } diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index e57ffc3b06..95b90ab49c 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -46,8 +46,12 @@ const ( Arg_SSHKey = "pi_ssh_key" Arg_StoragePool = "pi_storage_pool" Arg_StorageType = "pi_storage_type" + Arg_TargetStorageTier = "pi_target_storage_tier" + Arg_VolumeCloneName = "pi_volume_clone_name" + Arg_VolumeCloneTaskID = "pi_volume_clone_task_id" Arg_VolumeGroupID = "pi_volume_group_id" Arg_VolumeID = "pi_volume_id" + Arg_VolumeIDs = "pi_volume_ids" Arg_VolumeName = "pi_volume_name" Arg_VolumeOnboardingID = "pi_volume_onboarding_id" Arg_VolumePool = "pi_volume_pool" @@ -75,6 +79,8 @@ const ( Attr_Certified = "certified" Attr_CIDR = "cidr" Attr_ClassicEnabled = "classic_enabled" + Attr_ClonedVolumes = "clone_volumes" + Attr_CloneVolumeID = "clone_volume_id" Attr_CloudConnectionID = "cloud_connection_id" Attr_CloudInstanceID = "cloud_instance_id" Attr_CloudInstances = "cloud_instances" @@ -122,6 +128,7 @@ const ( Attr_Endianness = "endianness" Attr_ExternalIP = "external_ip" Attr_FailureMessage = "failure_message" + Attr_FailureReason = "failure_reason" Attr_FlashCopyMappings = "flash_copy_mappings" Attr_FlashCopyName = "flash_copy_name" Attr_FreezeTime = "freeze_time" @@ -254,6 +261,7 @@ const ( Attr_SharedProcessorPoolStatus = "status" Attr_SharedProcessorPoolStatusDetail = "status_detail" Attr_Size = "size" + Attr_SourceVolumeID = "source_volume_id" Attr_SourceVolumeName = "source_volume_name" Attr_Speed = "speed" Attr_SPPPlacementGroupID = "spp_placement_group_id" @@ -278,6 +286,7 @@ const ( Attr_Systems = "systems" Attr_SysType = "systype" Attr_TargetVolumeName = "target_volume_name" + Attr_TaskID = "task_id" Attr_TenantID = "tenant_id" Attr_TenantName = "tenant_name" Attr_TotalCapacity = "total_capacity" @@ -297,6 +306,7 @@ const ( Attr_VLanID = "vlan_id" Attr_VolumeGroupName = "volume_group_name" Attr_VolumeGroups = "volume_groups" + Attr_VolumeID = "volume_id" Attr_VolumeIDs = "volume_ids" Attr_VolumePool = "volume_pool" Attr_Volumes = "volumes" @@ -318,6 +328,7 @@ const ( // States State_Active = "active" State_Available = "available" + State_Completed = "completed" State_Creating = "creating" State_Deleted = "deleted" State_Deleting = "deleting" @@ -423,10 +434,6 @@ const ( SctionStart = "start" SctionStop = "stop" - // volume clone task status - VolumeCloneCompleted = "completed" - VolumeCloneRunning = "running" - // IBM PI Workspace PIWorkspaceName = "pi_name" PIWorkspaceDatacenter = "pi_datacenter" diff --git a/ibm/service/power/resource_ibm_pi_volume.go b/ibm/service/power/resource_ibm_pi_volume.go index 318d83615d..7810c6f67e 100644 --- a/ibm/service/power/resource_ibm_pi_volume.go +++ b/ibm/service/power/resource_ibm_pi_volume.go @@ -176,7 +176,7 @@ func ResourceIBMPIVolume() *schema.Resource { Description: "The replication type of the volume 'metro' or 'global'.", Type: schema.TypeString, }, - Attr_VolumeIDs: { + Attr_VolumeID: { Computed: true, Description: "The unique identifier of the volume.", Type: schema.TypeString, @@ -302,7 +302,7 @@ func resourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta i } d.Set(Arg_CloudInstanceID, cloudInstanceID) if vol.VolumeID != nil { - d.Set(Attr_VolumeIDs, vol.VolumeID) + d.Set(Attr_VolumeID, vol.VolumeID) } d.Set(Arg_VolumeName, vol.Name) d.Set(Arg_VolumePool, vol.VolumePool) From 535063e86992a85d0869140c29713db70a28429c Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 10 May 2024 12:32:24 -0500 Subject: [PATCH 05/25] Update volume clone documentation --- website/docs/d/pi_volume_clone.html.markdown | 22 ++++++++++------- website/docs/r/pi_volume_clone.html.markdown | 26 +++++++++++--------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/website/docs/d/pi_volume_clone.html.markdown b/website/docs/d/pi_volume_clone.html.markdown index 995cac79ac..38ae981fde 100644 --- a/website/docs/d/pi_volume_clone.html.markdown +++ b/website/docs/d/pi_volume_clone.html.markdown @@ -1,5 +1,4 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_volume_clone" @@ -8,9 +7,11 @@ description: |- --- # ibm_pi_volume_clone + Retrieves information about a volume clone. For more information, about managing volume clone, see [getting started with IBM Power Systems Virtual Servers](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-getting-started). ## Example usage + The following example retrieves information about the volume clone task that is present in Power Systems Virtual Server. ```terraform @@ -20,13 +21,14 @@ data "ibm_pi_volume_clone" "ds_volume_clone" { } ``` -**Note** -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +### Notes - Example usage: +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` + +Example usage: ```terraform provider "ibm" { @@ -35,13 +37,15 @@ data "ibm_pi_volume_clone" "ds_volume_clone" { } ``` -## Argument reference -Review the argument references that you can specify for your resource. +## Argument reference + +Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_volume_clone_task_id` - (Required, String) The ID of the volume clone task. ## Attribute reference + In addition to all argument reference list, you can access the following attribute reference after your resource is created. - `cloned_volumes` - (List of objects) The List of cloned volumes. diff --git a/website/docs/r/pi_volume_clone.html.markdown b/website/docs/r/pi_volume_clone.html.markdown index 616b6b2f39..58ca385888 100644 --- a/website/docs/r/pi_volume_clone.html.markdown +++ b/website/docs/r/pi_volume_clone.html.markdown @@ -1,5 +1,4 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_volume_clone" @@ -8,9 +7,11 @@ description: |- --- # ibm_pi_volume_clone + Create a volume clone. For more information, about managing volume clone, see [getting started with IBM Power Systems Virtual Servers](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-getting-started). ## Example usage + The following example creates a volume clone. ```terraform @@ -23,11 +24,12 @@ resource "ibm_pi_volume_clone" "testacc_volume_clone" { } ``` -**Note** -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +### Notes + +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` Example usage: @@ -45,8 +47,9 @@ ibm_pi_volume_clone provides the following [timeouts](https://www.terraform.io/d - **create** - (Default 15 minutes) Used for creating volume clone. - **delete** - (Default 15 minutes) Used for deleting volume clone. -## Argument reference -Review the argument references that you can specify for your resource. +## Argument reference + +Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_replication_enabled` - (Optional, Boolean) Indicates whether the cloned volume should have replication enabled. If no value is provided, it will default to the replication status of the source volume(s). @@ -55,6 +58,7 @@ Review the argument references that you can specify for your resource. - `pi_volume_ids` - (Required, Set of String) List of volumes to be cloned. ## Attribute reference + In addition to all argument reference list, you can access the following attribute reference after your resource is created. - `cloned_volumes` - (List of objects) The List of cloned volumes. @@ -72,8 +76,8 @@ In addition to all argument reference list, you can access the following attribu The `ibm_pi_volume_clone` resource can be imported by using `pi_cloud_instance_id` and `task_id`. -**Example** +### Example -``` -$ terraform import ibm_pi_volume_clone.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb +```bash +terraform import ibm_pi_volume_clone.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb ``` From 30fd2ba08aa2e780516c9a9323a64bfff43e9aa0 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 19 Jun 2024 16:28:04 -0500 Subject: [PATCH 06/25] Fix merge typo --- ibm/service/power/ibm_pi_constants.go | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index cb1f94ab32..c49f75f8a4 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -343,26 +343,26 @@ const ( Public = "public" // States - State_Active = "active" - State_ACTIVE = "ACTIVE" - State_Added = "added" - State_Adding = "adding" - State_Available = "available" - State_BUILD = "BUILD" - State_Completed = "completed" - State_Creating = "creating" - State_Deleted = "deleted" - State_Deleting = "deleting" - State_DELETING = "DELETING" - State_Failed = "failed" - State_Inactive = "inactive" - State_InProgress = "in progress" - State_InUse = "in-use" - State_NotFound = "Not Found" - State_PendingReclaimation = "pending_reclamation" - State_Provisioning = "provisioning" - State_Removed = "removed" - State_Retry = "retry" + State_Active = "active" + State_ACTIVE = "ACTIVE" + State_Added = "added" + State_Adding = "adding" + State_Available = "available" + State_BUILD = "BUILD" + State_Completed = "completed" + State_Creating = "creating" + State_Deleted = "deleted" + State_Deleting = "deleting" + State_DELETING = "DELETING" + State_Failed = "failed" + State_Inactive = "inactive" + State_InProgress = "in progress" + State_InUse = "in-use" + State_NotFound = "Not Found" + State_PendingReclamation = "pending_reclamation" + State_Provisioning = "provisioning" + State_Removed = "removed" + State_Retry = "retry" // Health Health_OK = "OK" From d0df58a77b4675fe9110df8eabbb4fbbb0ce7762 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 21 Jun 2024 11:49:58 -0500 Subject: [PATCH 07/25] Add dhcp-vlan to supported network types for stratos --- ibm/service/power/resource_ibm_pi_network.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 51006a68a3..2e303d5d27 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -47,7 +47,7 @@ func ResourceIBMPINetwork() *schema.Resource { helpers.PINetworkType: { Type: schema.TypeString, Required: true, - ValidateFunc: validate.ValidateAllowedStringValues([]string{"vlan", "pub-vlan"}), + ValidateFunc: validate.ValidateAllowedStringValues([]string{"vlan", "pub-vlan", "dhcp-vlan"}), Description: "PI network type", }, helpers.PINetworkName: { @@ -169,7 +169,7 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met body.AccessConfig = models.AccessConfig(v.(string)) } - if networktype == "vlan" { + if networktype == "vlan" || networktype == "dhcp-vlan" { var networkcidr string var ipBodyRanges []*models.IPAddressRange if v, ok := d.GetOk(helpers.PINetworkCidr); ok { From 4ec30dcc028d513b240c6143bc0ad42abc8f051d Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 21 Jun 2024 11:50:18 -0500 Subject: [PATCH 08/25] Add dhcp test for stratos --- .../power/resource_ibm_pi_network_test.go | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_network_test.go b/ibm/service/power/resource_ibm_pi_network_test.go index 249ce65615..cc55a7af24 100644 --- a/ibm/service/power/resource_ibm_pi_network_test.go +++ b/ibm/service/power/resource_ibm_pi_network_test.go @@ -125,8 +125,39 @@ func TestAccIBMPINetworkGatewaybasicSatellite(t *testing.T) { }) } -func testAccCheckIBMPINetworkDestroy(s *terraform.State) error { +func TestAccIBMPINetworkDHCPbasic(t *testing.T) { + name := fmt.Sprintf("tf-pi-network-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPINetworkDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPINetworDHCPConfig(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPINetworkExists("ibm_pi_network.power_networks"), + resource.TestCheckResourceAttr( + "ibm_pi_network.power_networks", "pi_network_name", name), + resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "pi_gateway"), + resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "id"), + resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "pi_ipaddress_range.#"), + ), + }, + { + Config: testAccCheckIBMPINetworkConfigGatewayDHCPUpdateDNS(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPINetworkExists("ibm_pi_network.power_networks"), + resource.TestCheckResourceAttr( + "ibm_pi_network.power_networks", "pi_network_name", name), + resource.TestCheckResourceAttr( + "ibm_pi_network.power_networks", "pi_dns.#", "1"), + ), + }, + }, + }) +} +func testAccCheckIBMPINetworkDestroy(s *terraform.State) error { sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession() if err != nil { return err @@ -148,6 +179,7 @@ func testAccCheckIBMPINetworkDestroy(s *terraform.State) error { return nil } + func testAccCheckIBMPINetworkExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { @@ -211,6 +243,19 @@ func testAccCheckIBMPINetworkGatewayConfig(name string) string { `, acc.Pi_cloud_instance_id, name) } +func testAccCheckIBMPINetworkGatewayConfigSatellite(name string) string { + return fmt.Sprintf(` + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%s" + pi_network_name = "%s" + pi_network_type = "vlan" + pi_cidr = "192.168.17.0/24" + pi_network_mtu = 6500 + pi_network_access_config = "outbound-only" + } + `, acc.Pi_cloud_instance_id, name) +} + func testAccCheckIBMPINetworkConfigGatewayUpdateDNS(name string) string { return fmt.Sprintf(` resource "ibm_pi_network" "power_networks" { @@ -228,15 +273,26 @@ func testAccCheckIBMPINetworkConfigGatewayUpdateDNS(name string) string { `, acc.Pi_cloud_instance_id, name) } -func testAccCheckIBMPINetworkGatewayConfigSatellite(name string) string { +func testAccCheckIBMPINetworDHCPConfig(name string) string { return fmt.Sprintf(` resource "ibm_pi_network" "power_networks" { pi_cloud_instance_id = "%s" pi_network_name = "%s" - pi_network_type = "vlan" - pi_cidr = "192.168.17.0/24" - pi_network_mtu = 6500 - pi_network_access_config = "outbound-only" + pi_network_type = "dhcp-vlan" + pi_cidr = "10.1.2.0/26" + pi_dns = ["10.1.0.68"] + } + `, acc.Pi_cloud_instance_id, name) +} + +func testAccCheckIBMPINetworkConfigGatewayDHCPUpdateDNS(name string) string { + return fmt.Sprintf(` + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%s" + pi_network_name = "%s" + pi_network_type = "dhcp-vlan" + pi_cidr = "10.1.2.0/26" + pi_dns = ["10.1.0.69"] } `, acc.Pi_cloud_instance_id, name) } From 53930bcc673e5f9966802c67d163c9f28e817325 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 21 Jun 2024 11:50:34 -0500 Subject: [PATCH 09/25] Update markdown --- website/docs/r/pi_network.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/docs/r/pi_network.html.markdown b/website/docs/r/pi_network.html.markdown index a48ce11c10..b74018f7c4 100644 --- a/website/docs/r/pi_network.html.markdown +++ b/website/docs/r/pi_network.html.markdown @@ -30,7 +30,7 @@ resource "ibm_pi_network" "power_networks" { } ``` -**Note** +### Notes - Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. - If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: @@ -61,7 +61,7 @@ Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_network_name` - (Required, String) The name of the network. -- `pi_network_type` - (Required, String) The type of network that you want to create, such as `pub-vlan` or `vlan`. +- `pi_network_type` - (Required, String) The type of network that you want to create. Valid values are `pub-vlan`, `vlan` and `dhcp-vlan`. - `pi_dns` - (Optional, Set of String) The DNS Servers for the network. If not specified, default is 127.0.0.1 for 'vlan' (private network) and 9.9.9.9 for 'pub-vlan' (public network). A maximum of one DNS server can be specified for private networks in Power Edge Router workspaces. - `pi_cidr` - (Optional, String) The network CIDR. Required for `vlan` network type. - `pi_gateway` - (Optional, String) The gateway ip address. @@ -85,8 +85,8 @@ In addition to all argument reference list, you can access the following attribu The `ibm_pi_network` resource can be imported by using `power_instance_id` and `network_id`. -**Example** +## Example -``` -$ terraform import ibm_pi_network.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb +```bash +terraform import ibm_pi_network.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb ``` From 670422ba823d07add5b1d4d1f1de1dcc22d6322b Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 21 Jun 2024 16:14:46 -0500 Subject: [PATCH 10/25] Add network value constants --- ibm/service/power/ibm_pi_constants.go | 5 +++++ ibm/service/power/resource_ibm_pi_network.go | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index b9ec88a7ff..6b3e370c65 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -334,6 +334,11 @@ const ( Private = "private" Public = "public" + // Network Values + DHCPNetwork = "dhcp-vlan" + PrivateNetwork = "vlan" + PublicNetwork = "pub-vlan" + // States State_Active = "active" State_ACTIVE = "ACTIVE" diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 2e303d5d27..ccb80be306 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -47,7 +47,7 @@ func ResourceIBMPINetwork() *schema.Resource { helpers.PINetworkType: { Type: schema.TypeString, Required: true, - ValidateFunc: validate.ValidateAllowedStringValues([]string{"vlan", "pub-vlan", "dhcp-vlan"}), + ValidateFunc: validate.ValidateAllowedStringValues([]string{DHCPNetwork, PrivateNetwork, PublicNetwork}), Description: "PI network type", }, helpers.PINetworkName: { @@ -169,7 +169,7 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met body.AccessConfig = models.AccessConfig(v.(string)) } - if networktype == "vlan" || networktype == "dhcp-vlan" { + if networktype == DHCPNetwork || networktype == PrivateNetwork { var networkcidr string var ipBodyRanges []*models.IPAddressRange if v, ok := d.GetOk(helpers.PINetworkCidr); ok { @@ -276,7 +276,7 @@ func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, met body := &models.NetworkUpdate{ DNSServers: flex.ExpandStringList((d.Get(helpers.PINetworkDNS).(*schema.Set)).List()), } - if d.Get(helpers.PINetworkType).(string) == "vlan" { + if d.Get(helpers.PINetworkType).(string) == PrivateNetwork { body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) } From d9ebcb39886176931eece36ecb1dd67c005a26a3 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 21 Jun 2024 16:29:48 -0500 Subject: [PATCH 11/25] Resort and rename constants --- ibm/service/power/ibm_pi_constants.go | 19 +++++++++---------- ibm/service/power/resource_ibm_pi_network.go | 6 +++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 18779cec99..b8f2a5e678 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -29,6 +29,7 @@ const ( Arg_InstanceName = "pi_instance_name" Arg_KeyName = "pi_key_name" Arg_LanguageCode = "pi_language_code" + Arg_LicenseRepositoryCapacity = "pi_license_repository_capacity" Arg_Name = "pi_name" Arg_NetworkName = "pi_network_name" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" @@ -65,13 +66,8 @@ const ( Arg_VolumeSize = "pi_volume_size" Arg_VolumeType = "pi_volume_type" Arg_VTL = "vtl" - Arg_LicenseRepositoryCapacity = "pi_license_repository_capacity" // Attributes - Attr_MinProcessors = "min_processors" - Attr_MinMemory = "min_memory" - Attr_MaxMemory = "max_memory" - Attr_MaxProcessors = "max_processors" Attr_AccessConfig = "access_config" Attr_Action = "action" Attr_Addresses = "addresses" @@ -199,8 +195,10 @@ const ( Attr_MaxCoresAvailable = "max_cores_available" Attr_MaximumStorageAllocation = "max_storage_allocation" Attr_MaxMem = "maxmem" + Attr_MaxMemory = "max_memory" Attr_MaxMemoryAvailable = "max_memory_available" Attr_MaxProc = "maxproc" + Attr_MaxProcessors = "max_processors" Attr_MaxVirtualCores = "max_virtual_cores" Attr_Members = "members" Attr_Memory = "memory" @@ -209,7 +207,9 @@ const ( Attr_MigrationStatus = "migration_status" Attr_Min = "min" Attr_MinMem = "minmem" + Attr_MinMemory = "min_memory" Attr_MinProc = "minproc" + Attr_MinProcessors = "min_processors" Attr_MinVirtualCores = "min_virtual_cores" Attr_MirroringState = "mirroring_state" Attr_MTU = "mtu" @@ -354,11 +354,6 @@ const ( Private = "private" Public = "public" - // Network Values - DHCPNetwork = "dhcp-vlan" - PrivateNetwork = "vlan" - PublicNetwork = "pub-vlan" - // States State_Active = "active" State_ACTIVE = "ACTIVE" @@ -381,8 +376,12 @@ const ( State_Retry = "retry" // Allowed Values + DHCPVlan = "dhcp-vlan" Host = "host" HostGroup = "hostGroup" + PubVlan = "pub-vlan" + Vlan = "vlan" + // Health Health_OK = "OK" diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index ccb80be306..6bcb875ce2 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -47,7 +47,7 @@ func ResourceIBMPINetwork() *schema.Resource { helpers.PINetworkType: { Type: schema.TypeString, Required: true, - ValidateFunc: validate.ValidateAllowedStringValues([]string{DHCPNetwork, PrivateNetwork, PublicNetwork}), + ValidateFunc: validate.ValidateAllowedStringValues([]string{DHCPVlan, PubVlan, Vlan}), Description: "PI network type", }, helpers.PINetworkName: { @@ -169,7 +169,7 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met body.AccessConfig = models.AccessConfig(v.(string)) } - if networktype == DHCPNetwork || networktype == PrivateNetwork { + if networktype == DHCPVlan || networktype == Vlan { var networkcidr string var ipBodyRanges []*models.IPAddressRange if v, ok := d.GetOk(helpers.PINetworkCidr); ok { @@ -276,7 +276,7 @@ func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, met body := &models.NetworkUpdate{ DNSServers: flex.ExpandStringList((d.Get(helpers.PINetworkDNS).(*schema.Set)).List()), } - if d.Get(helpers.PINetworkType).(string) == PrivateNetwork { + if d.Get(helpers.PINetworkType).(string) == Vlan { body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) } From f6de766055f86f19872a4ebf4395ed42e246cbb1 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 24 Jun 2024 08:27:46 -0500 Subject: [PATCH 12/25] Add error checking to gateway and iprange update --- ibm/service/power/resource_ibm_pi_network.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 6bcb875ce2..1e4508e665 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -276,9 +276,12 @@ func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, met body := &models.NetworkUpdate{ DNSServers: flex.ExpandStringList((d.Get(helpers.PINetworkDNS).(*schema.Set)).List()), } - if d.Get(helpers.PINetworkType).(string) == Vlan { + networkType := d.Get(helpers.PINetworkType).(string) + if networkType == Vlan { body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) + } else { + return diag.Errorf("%v type does not allow gateway or ip-address range update", networkType) } if d.HasChange(helpers.PINetworkName) { From 5f40566ff9f84e8a82a8d68ea39a961aa711effe Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 24 Jun 2024 08:37:14 -0500 Subject: [PATCH 13/25] Fix gateway and ip-range check --- ibm/service/power/resource_ibm_pi_network.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 1e4508e665..149e7c769f 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -277,11 +277,13 @@ func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, met DNSServers: flex.ExpandStringList((d.Get(helpers.PINetworkDNS).(*schema.Set)).List()), } networkType := d.Get(helpers.PINetworkType).(string) - if networkType == Vlan { - body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) - body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) - } else { - return diag.Errorf("%v type does not allow gateway or ip-address range update", networkType) + if d.HasChange(helpers.PINetworkGateway) || d.HasChange(helpers.PINetworkIPAddressRange) { + if networkType == Vlan { + body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) + body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) + } else { + return diag.Errorf("%v type does not allow gateway or ip-address range update", networkType) + } } if d.HasChange(helpers.PINetworkName) { From 0b3a6f68b35a13fdf2cf595a78e1fb721db953ee Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 24 Jun 2024 13:51:32 -0500 Subject: [PATCH 14/25] Merge state and status variables --- ibm/service/power/ibm_pi_constants.go | 29 +++++-------------- ibm/service/power/resource_ibm_pi_dhcp.go | 2 +- ibm/service/power/resource_ibm_pi_instance.go | 10 +++---- .../power/resource_ibm_pi_instance_action.go | 6 ++-- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 6721eb7102..e48751ac78 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -370,9 +370,9 @@ const ( Public = "public" // States - NotFound = "not found" - SctionStart = "start" - SctionStop = "stop" + NotFound = "not found" + SctionStart = "start" + SctionStop = "stop" State_Active = "active" State_ACTIVE = "ACTIVE" State_Added = "added" @@ -384,22 +384,19 @@ const ( State_Deleted = "deleted" State_Deleting = "deleting" State_DELETING = "DELETING" + State_ERROR = "ERROR" State_Failed = "failed" State_Inactive = "inactive" State_InProgress = "in progress" State_InUse = "in-use" State_NotFound = "Not Found" + State_PENDING = "PENDING" State_PendingReclamation = "pending_reclamation" State_Provisioning = "provisioning" State_Removed = "removed" + State_RESIZE = "RESIZE" State_Retry = "retry" - StatusActive = "ACTIVE" - StatusBuild = "BUILD" - Status_Deleting = "deleting" - StatusError = "ERROR" - StatusPending = "PENDING" - StatusResize = "RESIZE" - StatusShutoff = "SHUTOFF" + State_SHUTOFF = "SHUTOFF" // Allowed Values Host = "host" @@ -488,17 +485,7 @@ const ( // Cloud Connections PICloudConnectionTransitEnabled = "pi_cloud_connection_transit_enabled" - // Status states - StatusShutoff = "SHUTOFF" - StatusActive = "ACTIVE" - StatusResize = "RESIZE" - StatusError = "ERROR" - StatusBuild = "BUILD" - StatusPending = "PENDING" - SctionStart = "start" - SctionStop = "stop" - - // Volume clone task status + // Volume clone task status VolumeCloneCompleted = "completed" VolumeCloneRunning = "running" diff --git a/ibm/service/power/resource_ibm_pi_dhcp.go b/ibm/service/power/resource_ibm_pi_dhcp.go index 071b3d80ad..f60dfba79d 100644 --- a/ibm/service/power/resource_ibm_pi_dhcp.go +++ b/ibm/service/power/resource_ibm_pi_dhcp.go @@ -274,7 +274,7 @@ func waitForIBMPIDhcpStatus(ctx context.Context, client *st.IBMPIDhcpClient, dhc log.Printf("[DEBUG] get DHCP failed %v", err) return nil, "", err } - if *dhcpServer.Status != StatusActive { + if *dhcpServer.Status != State_ACTIVE { return dhcpServer, "building", nil } return dhcpServer, "active", nil diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index cb55c3b1da..0a65956c4c 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -1111,8 +1111,8 @@ func isWaitForPIInstanceShutoff(ctx context.Context, client *st.IBMPIInstanceCli } stateConf := &retry.StateChangeConf{ - Pending: []string{StatusPending, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, - Target: []string{helpers.PIInstanceHealthOk, StatusError, "", StatusShutoff}, + Pending: []string{State_PENDING, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, + Target: []string{helpers.PIInstanceHealthOk, State_ERROR, "", State_SHUTOFF}, Refresh: isPIInstanceShutoffRefreshFunc(client, id, instanceReadyStatus), Delay: 30 * time.Second, MinTimeout: queryTimeOut, @@ -1129,10 +1129,10 @@ func isPIInstanceShutoffRefreshFunc(client *st.IBMPIInstanceClient, id, instance if err != nil { return nil, "", err } - if *pvm.Status == StatusShutoff && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { - return pvm, StatusShutoff, nil + if *pvm.Status == State_SHUTOFF && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { + return pvm, State_SHUTOFF, nil } - if *pvm.Status == StatusError { + if *pvm.Status == State_ERROR { if pvm.Fault != nil { err = fmt.Errorf("failed to create the lpar: %s", pvm.Fault.Message) } else { diff --git a/ibm/service/power/resource_ibm_pi_instance_action.go b/ibm/service/power/resource_ibm_pi_instance_action.go index 1bab4ee701..9d6d3b4b2e 100644 --- a/ibm/service/power/resource_ibm_pi_instance_action.go +++ b/ibm/service/power/resource_ibm_pi_instance_action.go @@ -200,8 +200,8 @@ func isWaitForPIInstanceActionStatus(ctx context.Context, client *st.IBMPIInstan log.Printf("Waiting for the action to be performed on the instance %s", id) stateConf := &resource.StateChangeConf{ - Pending: []string{StatusPending}, - Target: []string{targetStatus, StatusError, ""}, + Pending: []string{State_PENDING}, + Target: []string{targetStatus, State_ERROR, ""}, Refresh: isPIActionRefreshFunc(client, id, targetStatus, targetHealthStatus), Delay: 30 * time.Second, MinTimeout: 2 * time.Minute, @@ -233,6 +233,6 @@ func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, tar return pvm, *pvm.Status, err } - return pvm, StatusPending, nil + return pvm, State_PENDING, nil } } From d8aa8b97fa9509ab74b635cd2e9efdd271899c0f Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 24 Jun 2024 13:56:28 -0500 Subject: [PATCH 15/25] Remove unneeded constants --- ibm/service/power/ibm_pi_constants.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index e48751ac78..70869d21a6 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -371,8 +371,6 @@ const ( // States NotFound = "not found" - SctionStart = "start" - SctionStop = "stop" State_Active = "active" State_ACTIVE = "ACTIVE" State_Added = "added" From 093c3b2957437b95ab1f2d6ed6719ccc6561ce48 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Tue, 25 Jun 2024 13:16:50 -0500 Subject: [PATCH 16/25] Update format --- ibm/service/power/ibm_pi_constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 36f906f04a..7128f31c42 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -403,7 +403,7 @@ const ( State_Deleted = "deleted" State_Deleting = "deleting" State_DELETING = "DELETING" - State_Down = "down" + State_Down = "down" State_ERROR = "ERROR" State_Failed = "failed" State_Inactive = "inactive" From 3b4ee2b8ad6bac932317fe804e2e29f097c411bf Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 26 Jun 2024 13:39:43 -0500 Subject: [PATCH 17/25] Remove duplicate constants --- ibm/service/power/ibm_pi_constants.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 7128f31c42..9661cfd8ea 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -503,10 +503,6 @@ const ( // Cloud Connections PICloudConnectionTransitEnabled = "pi_cloud_connection_transit_enabled" - // Volume clone task status - VolumeCloneCompleted = "completed" - VolumeCloneRunning = "running" - // IBM PI Workspace PIWorkspaceName = "pi_name" PIWorkspaceDatacenter = "pi_datacenter" From 4c7cf66371a64d87360bee0f3b87a7f8680b5d6f Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 26 Jun 2024 15:19:38 -0500 Subject: [PATCH 18/25] Undo non-volume-clone-changes --- ibm/service/power/ibm_pi_constants.go | 7 +++++++ ibm/service/power/resource_ibm_pi_dhcp.go | 2 +- ibm/service/power/resource_ibm_pi_instance.go | 10 +++++----- ibm/service/power/resource_ibm_pi_instance_action.go | 6 +++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 9661cfd8ea..94add18075 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -418,6 +418,13 @@ const ( State_Retry = "retry" State_SHUTOFF = "SHUTOFF" State_Up = "up" + Status_Deleting = "deleting" + StatusActive = "ACTIVE" + StatusBuild = "BUILD" + StatusError = "ERROR" + StatusPending = "PENDING" + StatusResize = "RESIZE" + StatusShutoff = "SHUTOFF" // Health Health_OK = "OK" diff --git a/ibm/service/power/resource_ibm_pi_dhcp.go b/ibm/service/power/resource_ibm_pi_dhcp.go index f60dfba79d..071b3d80ad 100644 --- a/ibm/service/power/resource_ibm_pi_dhcp.go +++ b/ibm/service/power/resource_ibm_pi_dhcp.go @@ -274,7 +274,7 @@ func waitForIBMPIDhcpStatus(ctx context.Context, client *st.IBMPIDhcpClient, dhc log.Printf("[DEBUG] get DHCP failed %v", err) return nil, "", err } - if *dhcpServer.Status != State_ACTIVE { + if *dhcpServer.Status != StatusActive { return dhcpServer, "building", nil } return dhcpServer, "active", nil diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 0a65956c4c..cb55c3b1da 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -1111,8 +1111,8 @@ func isWaitForPIInstanceShutoff(ctx context.Context, client *st.IBMPIInstanceCli } stateConf := &retry.StateChangeConf{ - Pending: []string{State_PENDING, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, - Target: []string{helpers.PIInstanceHealthOk, State_ERROR, "", State_SHUTOFF}, + Pending: []string{StatusPending, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, + Target: []string{helpers.PIInstanceHealthOk, StatusError, "", StatusShutoff}, Refresh: isPIInstanceShutoffRefreshFunc(client, id, instanceReadyStatus), Delay: 30 * time.Second, MinTimeout: queryTimeOut, @@ -1129,10 +1129,10 @@ func isPIInstanceShutoffRefreshFunc(client *st.IBMPIInstanceClient, id, instance if err != nil { return nil, "", err } - if *pvm.Status == State_SHUTOFF && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { - return pvm, State_SHUTOFF, nil + if *pvm.Status == StatusShutoff && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { + return pvm, StatusShutoff, nil } - if *pvm.Status == State_ERROR { + if *pvm.Status == StatusError { if pvm.Fault != nil { err = fmt.Errorf("failed to create the lpar: %s", pvm.Fault.Message) } else { diff --git a/ibm/service/power/resource_ibm_pi_instance_action.go b/ibm/service/power/resource_ibm_pi_instance_action.go index 9d6d3b4b2e..1bab4ee701 100644 --- a/ibm/service/power/resource_ibm_pi_instance_action.go +++ b/ibm/service/power/resource_ibm_pi_instance_action.go @@ -200,8 +200,8 @@ func isWaitForPIInstanceActionStatus(ctx context.Context, client *st.IBMPIInstan log.Printf("Waiting for the action to be performed on the instance %s", id) stateConf := &resource.StateChangeConf{ - Pending: []string{State_PENDING}, - Target: []string{targetStatus, State_ERROR, ""}, + Pending: []string{StatusPending}, + Target: []string{targetStatus, StatusError, ""}, Refresh: isPIActionRefreshFunc(client, id, targetStatus, targetHealthStatus), Delay: 30 * time.Second, MinTimeout: 2 * time.Minute, @@ -233,6 +233,6 @@ func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, tar return pvm, *pvm.Status, err } - return pvm, State_PENDING, nil + return pvm, StatusPending, nil } } From 07267dc7ced4f05fce15031ca94f79eb2b1973a9 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Tue, 9 Jul 2024 14:40:27 -0500 Subject: [PATCH 19/25] Remove gateway from updateable fields --- ibm/service/power/resource_ibm_pi_network.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 149e7c769f..81f97b1954 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -73,6 +73,7 @@ func ResourceIBMPINetwork() *schema.Resource { Optional: true, Computed: true, Description: "PI network gateway", + ForceNew: true, }, helpers.PINetworkJumbo: { Type: schema.TypeBool, @@ -271,18 +272,17 @@ func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, met return diag.FromErr(err) } - if d.HasChanges(helpers.PINetworkName, helpers.PINetworkDNS, helpers.PINetworkGateway, helpers.PINetworkIPAddressRange) { + if d.HasChanges(helpers.PINetworkName, helpers.PINetworkDNS, helpers.PINetworkIPAddressRange) { networkC := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) body := &models.NetworkUpdate{ DNSServers: flex.ExpandStringList((d.Get(helpers.PINetworkDNS).(*schema.Set)).List()), } networkType := d.Get(helpers.PINetworkType).(string) - if d.HasChange(helpers.PINetworkGateway) || d.HasChange(helpers.PINetworkIPAddressRange) { + if d.HasChange(helpers.PINetworkIPAddressRange) { if networkType == Vlan { - body.Gateway = flex.PtrToString(d.Get(helpers.PINetworkGateway).(string)) body.IPAddressRanges = getIPAddressRanges(d.Get(helpers.PINetworkIPAddressRange).([]interface{})) } else { - return diag.Errorf("%v type does not allow gateway or ip-address range update", networkType) + return diag.Errorf("%v type does not allow ip-address range update", networkType) } } From a97af6859a443544301be7108f96ccc3c4ebf55a Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Tue, 9 Jul 2024 15:00:42 -0500 Subject: [PATCH 20/25] Add wait on delete for forcenew field --- ibm/service/power/ibm_pi_constants.go | 1 + ibm/service/power/resource_ibm_pi_network.go | 34 ++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index b311e58fc9..24995cfdc4 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -401,6 +401,7 @@ const ( State_DELETING = "DELETING" State_Down = "down" State_Failed = "failed" + State_Found = "Found" State_Inactive = "inactive" State_InProgress = "in progress" State_InUse = "in-use" diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 81f97b1954..51ba24ea98 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -14,6 +14,7 @@ import ( "github.com/apparentlymart/go-cidr/cidr" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" st "github.com/IBM-Cloud/power-go-client/clients/instance" @@ -258,7 +259,6 @@ func resourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, meta d.Set(helpers.PINetworkIPAddressRange, ipRangesMap) return nil - } func resourceIBMPINetworkUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { @@ -312,12 +312,17 @@ func resourceIBMPINetworkDelete(ctx context.Context, d *schema.ResourceData, met return diag.FromErr(err) } - networkC := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) - err = networkC.Delete(networkID) + client := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + err = client.Delete(networkID) + if err != nil { + return diag.FromErr(err) + } + _, err = isWaitForIBMPINetworkDeleted(ctx, client, networkID, d.Timeout(schema.TimeoutDelete)) if err != nil { return diag.FromErr(err) } + d.SetId("") return nil } @@ -350,6 +355,29 @@ func isIBMPINetworkRefreshFunc(client *st.IBMPINetworkClient, id string) resourc } } +func isWaitForIBMPINetworkDeleted(ctx context.Context, client *st.IBMPINetworkClient, id string, timeout time.Duration) (interface{}, error) { + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Found}, + Target: []string{State_NotFound}, + Refresh: isIBMPINetworkRefreshDeleteFunc(client, id), + Timeout: timeout, + Delay: 10 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForStateContext(ctx) +} + +func isIBMPINetworkRefreshDeleteFunc(client *st.IBMPINetworkClient, id string) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + network, err := client.Get(id) + if err != nil { + return network, State_NotFound, nil + } + return network, State_Found, nil + } +} + func generateIPData(cdir string) (gway, firstip, lastip string, err error) { _, ipv4Net, err := net.ParseCIDR(cdir) From a1ec7d6775a07bf4ed5d584a82475d93543c64f4 Mon Sep 17 00:00:00 2001 From: michaelkad Date: Fri, 10 May 2024 15:44:15 -0500 Subject: [PATCH 21/25] Refactor Instance Action Sync with master --- go.sum | 129 ++++++++++++++++++ ibm/service/power/ibm_pi_constants.go | 87 +++++++++--- ibm/service/power/resource_ibm_pi_dhcp.go | 2 +- ibm/service/power/resource_ibm_pi_instance.go | 10 +- .../power/resource_ibm_pi_instance_action.go | 82 +++++------ .../resource_ibm_pi_instance_action_test.go | 102 ++++++++++---- .../power/resource_ibm_pi_snapshot_test.go | 2 +- .../docs/r/pi_instance_action.html.markdown | 39 +++--- 8 files changed, 341 insertions(+), 112 deletions(-) diff --git a/go.sum b/go.sum index f9ee37b41a..beef1742b2 100644 --- a/go.sum +++ b/go.sum @@ -29,11 +29,14 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= +cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k= +cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= cloud.google.com/go/kms v1.10.1 h1:7hm1bRqGCA1GBRQUrp831TwJ9TWhP+tvLuP497CQS2g= cloud.google.com/go/kms v1.10.1/go.mod h1:rIWk/TryCkR59GMC3YtHtXeLzd634lBbKenvyySAyYI= cloud.google.com/go/monitoring v1.13.0 h1:2qsrgXGVoRXpP7otZ14eE1I568zAa92sJSDPyOJvwjM= @@ -49,10 +52,12 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f/go.mod h1:sk5LnIjB/nIEU7yP5sDQExVm62wu0pBh3yrElngUisI= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/Azure/azure-sdk-for-go v36.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v67.2.0+incompatible h1:Uu/Ww6ernvPTrpq31kITVTIm/I5jlJ1wjtEH/bmSB2k= +github.com/Azure/azure-sdk-for-go v67.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= @@ -62,6 +67,7 @@ github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdA github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM= +github.com/Azure/go-autorest/autorest v0.11.28/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.6.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= github.com/Azure/go-autorest/autorest/adal v0.7.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= @@ -70,10 +76,13 @@ github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQW github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/adal v0.9.20 h1:gJ3E98kMpFB1MFqQCvA1yFab8vthOeD4VlFRQULxahg= +github.com/Azure/go-autorest/autorest/adal v0.9.20/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ= github.com/Azure/go-autorest/autorest/azure/auth v0.4.0/go.mod h1:Oo5cRhLvZteXzI2itUm5ziqsoIxRkzrt3t61FeZaS18= github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 h1:wkAZRgT/pn8HhFyzfe9UnqOjJYqlembgCTi72Bm/xKk= +github.com/Azure/go-autorest/autorest/azure/auth v0.5.12/go.mod h1:84w/uV8E37feW2NCJ08uT9VBfjfUHpgLVnG2InYD6cg= github.com/Azure/go-autorest/autorest/azure/cli v0.3.0/go.mod h1:rNYMNAefZMRowqCV0cVhr/YDW5dD7afFq9nXAXL4ykE= github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 h1:0W/yGmFdTIT77fvdlGZ0LMISoLHFJ7Tx4U0yeB+uFs4= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.5/go.mod h1:ADQAXrkgm7acgWVUNamOgh8YNrv4p27l3Wc55oVfpzg= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= @@ -85,8 +94,10 @@ github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935 github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= +github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE= github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= +github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= @@ -96,6 +107,7 @@ github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUM github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= +github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= @@ -185,13 +197,17 @@ github.com/Jeffail/gabs v1.1.1/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/ github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig/v3 v3.2.1 h1:n6EPaDyLSvCEa3frruQvAiHuNp2dhBlMSmkEr+HuzGc= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.4.13/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= @@ -215,6 +231,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= @@ -230,6 +247,7 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190412020505-60e2075261b6/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190620160927-9418d7b0cd0f/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= github.com/aliyun/alibaba-cloud-sdk-go v1.62.146 h1:zAH0YjWzonbKHvNkfbxqTmX51uHbkQYu+jJah2IAiCA= +github.com/aliyun/alibaba-cloud-sdk-go v1.62.146/go.mod h1:Api2AkmMgGaSUAhmk76oaFObkoeCPc/bKAqcyplPODs= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg= @@ -263,6 +281,7 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= @@ -275,7 +294,9 @@ github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/aws/aws-sdk-go v1.44.191 h1:GnbkalCx/AgobaorDMFCa248acmk+91+aHBQOk7ljzU= +github.com/aws/aws-sdk-go v1.44.191/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/axiomhq/hyperloglog v0.0.0-20220105174342-98591331716a h1:eqjiAL3qooftPm8b9C1GsSSRcmlw7iOva8vdBTmV2PY= +github.com/axiomhq/hyperloglog v0.0.0-20220105174342-98591331716a/go.mod h1:2stgcRjl6QmW+gU2h5E7BQXg4HU0gzxKWDuT5HviN9s= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -292,8 +313,10 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs= +github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f/go.mod h1:HQhVmdUf7dBNwIIdBTivnCDxcf6IZY3/zrb+uKSJz6Y= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -302,6 +325,7 @@ github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4r github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -358,6 +382,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -366,20 +391,27 @@ github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFn github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0= github.com/denisenkom/go-mssqldb v0.0.0-20190412130859-3b1d194e553a/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba h1:p6poVbjHDkKa+wtC8frBMwQtT3BmqGYBjzMwJ63tuR4= +github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8= +github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/digitalocean/godo v1.65.0 h1:3SywGJBC18HaYtPQF+T36jYzXBi+a6eIMonSjDll7TA= +github.com/digitalocean/godo v1.65.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= +github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= +github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= @@ -408,6 +440,7 @@ github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT github.com/emicklei/go-restful/v3 v3.10.0 h1:X4gma4HM7hFm6WMeAsTfqA0GOfdNoCzBIkHGoRLGXuM= github.com/emicklei/go-restful/v3 v3.10.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -423,6 +456,7 @@ github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= +github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.5.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= @@ -436,6 +470,7 @@ github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.4.0/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= @@ -461,8 +496,11 @@ github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0 github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= +github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -491,9 +529,11 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= +github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= @@ -571,9 +611,11 @@ github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85n github.com/go-openapi/validate v0.22.4 h1:5v3jmMyIPKTR8Lv9syBAIRxG6lY0RqeBPB1LKEijzk8= github.com/go-openapi/validate v0.22.4/go.mod h1:qm6O8ZIcPVdSY5219468Jv7kBdGvkiZLPOmqnqTUZ2A= github.com/go-ozzo/ozzo-validation v3.6.0+incompatible h1:msy24VGS42fKO9K1vLz82/GeYW1cILu7Nuuj1N3BBkE= +github.com/go-ozzo/ozzo-validation v3.6.0+incompatible/go.mod h1:gsEKFIVnabGBt6mXmxK0MoFy+cZoTJY6mu5Ll3LVLBU= github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es= github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= @@ -589,6 +631,7 @@ github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaC github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= @@ -597,6 +640,7 @@ github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= +github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= @@ -635,6 +679,7 @@ github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -727,6 +772,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8= +github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -736,9 +782,11 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.7.1 h1:gF4c0zjUP2H/s/hEGyLA3I0fA2ZWjzYiONAD6cvPr8A= +github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= @@ -781,6 +829,7 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/eventlogger v0.1.1 h1:zyCjxsy7KunFsMPZKU5PnwWEakSrp1zjj2vPFmrDaeo= +github.com/hashicorp/eventlogger v0.1.1/go.mod h1://CHt6/j+Q2lc0NlUB5af4aS2M0c0aVBg9/JfcpAyhM= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -790,6 +839,7 @@ github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/S github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-discover v0.0.0-20210818145131-c573d69da192 h1:eje2KOX8Sf7aYPiAsLnpWdAIrGRMcpFjN/Go/Exb7Zo= +github.com/hashicorp/go-discover v0.0.0-20210818145131-c573d69da192/go.mod h1:3/4dzY4lR1Hzt9bBqMhBzG7lngZ0GKx/nL6G/ad62wE= github.com/hashicorp/go-gatedio v0.5.0/go.mod h1:Lr3t8L6IyxD3DAeaUxGcgl2JnRUpWMCsmBl4Omu/2t4= github.com/hashicorp/go-gcp-common v0.5.0/go.mod h1:IDGUI2N/OS3PiU4qZcXJeWKPI6O/9Y8hOrbSiMcqyYw= github.com/hashicorp/go-gcp-common v0.6.0/go.mod h1:RuZi18562/z30wxOzpjeRrGcmk9Ro/rBzixaSZDhIhY= @@ -816,18 +866,28 @@ github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jU github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0 h1:pSjQfW3vPtrOTcasTUKgCTQT7OGPPTTMVRrOfU6FJD8= github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0/go.mod h1:xvb32K2keAc+R8DSFG2IwDcydK9DBQE+fGA5fsw6hSk= github.com/hashicorp/go-kms-wrapping/v2 v2.0.9-0.20230228100945-740d2999c798 h1:22yjMhn+kJ7u8RaP5qcYEn02zHWnIg1/JxE4BL8JLtQ= +github.com/hashicorp/go-kms-wrapping/v2 v2.0.9-0.20230228100945-740d2999c798/go.mod h1:iRHxwFG8L24HhemSuvDYtuwVkjkl+OkTLvQ5bmqzAqE= github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.7-1 h1:ZV26VJYcITBom0QqYSUOIj4HOHCVPEFjLqjxyXV/AbA= +github.com/hashicorp/go-kms-wrapping/wrappers/aead/v2 v2.0.7-1/go.mod h1:b99cDSA+OzcyRoBZroSf174/ss/e6gUuS45wue9ZQfc= github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.1 h1:ydUCtmr8f9F+mHZ1iCsvzqFTXqNVpewX3s9zcYipMKI= +github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.1/go.mod h1:Sl/ffzV57UAyjtSg1h5Km0rN5+dtzZJm1CUztkoCW2c= github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.7 h1:E3eEWpkofgPNrYyYznfS1+drq4/jFcqHQVNcL7WhUCo= +github.com/hashicorp/go-kms-wrapping/wrappers/awskms/v2 v2.0.7/go.mod h1:j5vefRoguQUG7iM4reS/hKIZssU1lZRqNPM5Wow6UnM= github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.8-0.20230905162003-bfa3347a7c85 h1:yZqD2ZQ4kWyVI2reKGC8Hl78ywWBtl1iLz/Bb5GBvMA= +github.com/hashicorp/go-kms-wrapping/wrappers/azurekeyvault/v2 v2.0.8-0.20230905162003-bfa3347a7c85/go.mod h1:0mKsr+G70TGABNbdS5dGiZTVoXe9qM/mhEIQL3lOQRc= github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.8 h1:16I8OqBEuxZIowwn3jiLvhlx+z+ia4dJc9stvz0yUBU= +github.com/hashicorp/go-kms-wrapping/wrappers/gcpckms/v2 v2.0.8/go.mod h1:6QUMo5BrXAtbzSuZilqmx0A4px2u6PeFK7vfp2WIzeM= github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7 h1:KeG3QGrbxbr2qAqCJdf3NR4ijAYwdcWLTmwSbR0yusM= +github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7/go.mod h1:rXxYzjjGw4HltEwxPp9zYSRIo6R+rBf1MSPk01bvodc= github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.7 h1:G25tZFw/LrAzJWxvS0/BFI7V1xAP/UsAIsgBwiE0mwo= +github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.7/go.mod h1:hxNA5oTfAvwPacWVg1axtF/lvTafwlAa6a6K4uzWHhw= github.com/hashicorp/go-memdb v1.0.2/go.mod h1:I6dKdmYhZqU0RJSheVEWgTNWdVQH5QvTgIUQ0t/t32M= github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c= +github.com/hashicorp/go-memdb v1.3.4/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= +github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= @@ -851,10 +911,13 @@ github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR3 github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-secure-stdlib/awsutil v0.1.6 h1:W9WN8p6moV1fjKLkeqEgkAMu5rauy9QeYDAmIaPuuiA= +github.com/hashicorp/go-secure-stdlib/awsutil v0.1.6/go.mod h1:MpCPSPGLDILGb4JMm94/mMi3YysIqsXzGCzkEZjcjXg= github.com/hashicorp/go-secure-stdlib/base62 v0.1.1/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw= github.com/hashicorp/go-secure-stdlib/base62 v0.1.2 h1:ET4pqyjiGmY09R5y+rSd70J2w45CtbWDNvGqWp/R3Ng= +github.com/hashicorp/go-secure-stdlib/base62 v0.1.2/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 h1:p4AKXPPS24tO8Wc8i1gLvSKdmkiSY5xuju57czJ/IJQ= +github.com/hashicorp/go-secure-stdlib/mlock v0.1.2/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 h1:UpiO20jno/eV1eVZcxqWnUohyKRe1g8FPV/xH1s/2qs= @@ -862,12 +925,15 @@ github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7/go.mod h1:QmrqtbKuxxSWTN3 github.com/hashicorp/go-secure-stdlib/password v0.1.1 h1:6JzmBqXprakgFEHwBgdchsjaA9x3GyjdI568bXKxa60= github.com/hashicorp/go-secure-stdlib/password v0.1.1/go.mod h1:9hH302QllNwu1o2TGYtSk8I8kTAN0ca1EHpwhm5Mmzo= github.com/hashicorp/go-secure-stdlib/plugincontainer v0.1.1 h1:1F0n5stk5uz4yIw2elN3k6bGbIv95OQaJVR2sVQ1kk0= +github.com/hashicorp/go-secure-stdlib/plugincontainer v0.1.1/go.mod h1:kRpzC4wHYXc2+sjXA9vuKawXYs0x0d0HuqqbaW1fj1w= github.com/hashicorp/go-secure-stdlib/reloadutil v0.1.1 h1:SMGUnbpAcat8rIKHkBPjfv81yC46a8eCNZ2hsR2l1EI= +github.com/hashicorp/go-secure-stdlib/reloadutil v0.1.1/go.mod h1:Ch/bf00Qnx77MZd49JRgHYqHQjtEmTgGU2faufpVZb0= github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs= github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.2 h1:phcbL8urUzF/kxA/Oj6awENaRwfWsjP59GW7u2qlDyY= +github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.2/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= @@ -897,22 +963,28 @@ github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06A github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/hcp-sdk-go v0.23.0 h1:3WarkQSK0VzxJaH6psHIGQagag3ujL+NjWagZZHpiZM= +github.com/hashicorp/hcp-sdk-go v0.23.0/go.mod h1:/9UoDY2FYYA8lFaKBb2HmM/jKYZGANmf65q9QRc/cVw= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.4 h1:sY0CMhFmjIPDMlTB+HfymFHCaYLhgifZ0QhjaYKD/UQ= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.1.4/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/nomad/api v0.0.0-20191220223628-edc62acd919d/go.mod h1:WKCL+tLVhN1D+APwH3JiTRZoxcdwRk86bWu1LVCUPaE= github.com/hashicorp/raft v1.0.1/go.mod h1:DVSAWItjLjTOkVbSpWQ0j0kUADIvDaCtBxIcbNAQLkI= github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= github.com/hashicorp/raft v1.3.10 h1:LR5QZX1VQd0DFWZfeCwWawyeKfpS/Tm1yjnJIY5X4Tw= +github.com/hashicorp/raft v1.3.10/go.mod h1:J8naEwc6XaaCfts7+28whSeRvCqTd6e20BlCU3LtEO4= github.com/hashicorp/raft-autopilot v0.2.0 h1:2/R2RPgamgRKgNWGQioULZvjeKXQZmDuw5Ty+6c+H7Y= +github.com/hashicorp/raft-autopilot v0.2.0/go.mod h1:q6tZ8UAZ5xio2gv2JvjgmtOlh80M6ic8xQYBe2Egkg8= github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea h1:xykPFhrBAS2J0VBzVa5e80b5ZtYuNQtgXjN40qBZlD4= github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= github.com/hashicorp/raft-boltdb/v2 v2.0.0-20210421194847-a7e34179d62c h1:oiKun9QlrOz5yQxMZJ3tf1kWtFYuKSJzxzEDxDPevj4= +github.com/hashicorp/raft-boltdb/v2 v2.0.0-20210421194847-a7e34179d62c/go.mod h1:kiPs9g148eLShc2TYagUAyKDnD+dH9U+CQKsXzlY9xo= github.com/hashicorp/raft-snapshot v1.0.2-0.20190827162939-8117efcc5aab/go.mod h1:5sL9eUn72lH5DzsFIJ9jaysITbHksSSszImWSOTC8Ic= github.com/hashicorp/raft-snapshot v1.0.4 h1:EuDuayAJPdiDmVk1ygTDnG2zDzrs0/6/yBuma1IYSow= +github.com/hashicorp/raft-snapshot v1.0.4/go.mod h1:5sL9eUn72lH5DzsFIJ9jaysITbHksSSszImWSOTC8Ic= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.8.3/go.mod h1:UpNcs7fFbpKIyZaUuSW6EPiH+eZC7OuyFD+wc1oal+k= github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= @@ -978,6 +1050,7 @@ github.com/hashicorp/vault/sdk v0.6.0/go.mod h1:+DRpzoXIdMvKc88R4qxr+edwy/RvH5QK github.com/hashicorp/vault/sdk v0.10.0 h1:dDAe1mMG7Qqor1h3i7TU70ykwJy8ijyWeZZkN2CB0j4= github.com/hashicorp/vault/sdk v0.10.0/go.mod h1:s9F8+FF/Q9HuChoi1OWnIPoHRU6V675qHhCYkXVPPQE= github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 h1:O/pT5C1Q3mVXMyuqg7yuAWUg/jMZR1/0QTzTRdNR6Uw= +github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= @@ -986,6 +1059,7 @@ github.com/hokaccha/go-prettyjson v0.0.0-20170213120834-e6b9231a2b1c h1:vlXZsaTg github.com/hokaccha/go-prettyjson v0.0.0-20170213120834-e6b9231a2b1c/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -1001,6 +1075,7 @@ github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT github.com/jarcoal/httpmock v1.0.7 h1:d1a2VFpSdm5gtjhCPWsQHSnx8+5V3ms5431YwvmkuNk= github.com/jarcoal/httpmock v1.0.7/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts v1.0.1/go.mod h1:k9gJoDUf1GH5r2IBtBjwjDCoLELYxOcEhitdP8RL7qQ= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= @@ -1026,6 +1101,7 @@ github.com/jefferai/jsonx v1.0.0/go.mod h1:OGmqmi2tTeI/PS+qQfBDToLHHJIy/RMp24fPo github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/jinzhu/copier v0.3.2 h1:QdBOCbaouLDYaIPFfi1bKv5F5tPpeTwXe4sD0jqtz5w= github.com/jinzhu/copier v0.3.2/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -1040,6 +1116,7 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/joyent/triton-go v0.0.0-20190112182421-51ffac552869/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f h1:ENpDacvnr8faw5ugQmEF1QYk+f/Y9lXFvuYmRxykago= +github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk= github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -1062,7 +1139,9 @@ github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaR github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= +github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -1083,6 +1162,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -1092,6 +1172,7 @@ github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8 github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1/go.mod h1:my+EVjOJLeQ9lUR9uVkxRvNNkhO2saSGIgzV8GZT9HY= github.com/kubernetes-csi/external-snapshotter/client/v4 v4.0.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= @@ -1104,7 +1185,9 @@ github.com/libopenstorage/secrets v0.0.0-20220823020833-2ecadaf59d8a h1:dHCYranr github.com/libopenstorage/secrets v0.0.0-20220823020833-2ecadaf59d8a/go.mod h1:JqaGrr4zerBaTqX04dajFE14AHcDDrxvCq8nZ5/r4AU= github.com/libopenstorage/stork v1.3.0-beta1.0.20200630005842-9255e7a98775/go.mod h1:qBSzYTJVHlOMg5RINNiHD1kBzlasnrc2uKLPZLgu1Qs= github.com/linode/linodego v0.7.1 h1:4WZmMpSA2NRwlPZcc0+4Gyn7rr99Evk9bnr0B3gXRKE= +github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -1151,10 +1234,12 @@ github.com/michaelklishin/rabbit-hole v0.0.0-20191008194146-93d9988f0cd5/go.mod github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/minsikl/netscaler-nitro-go v0.0.0-20170827154432-5b14ce3643e3 h1:PHPBYVeLuR7/2XSOfVwDpW+70KNuxMWygsyOZSKK15Y= github.com/minsikl/netscaler-nitro-go v0.0.0-20170827154432-5b14ce3643e3/go.mod h1:jh28TRFZwBumf7OjMQbRb8TNtDuuX7QNAGRjFEt+h6I= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= @@ -1208,11 +1293,13 @@ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ github.com/nicksnyder/go-i18n v1.10.0 h1:5AzlPKvXBH4qBzmZ09Ua9Gipyruv6uApMcrNZdo96+Q= github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= +github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= @@ -1221,6 +1308,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/okta/okta-sdk-golang v1.0.1 h1:1DGm5+h2JvfdHz07yVVM7+LgUVSwxnk+6RoLUOB6CwI= github.com/okta/okta-sdk-golang v1.0.1/go.mod h1:8k//sN2mFTq8Ayo90DqGbcumCkSmYjF0+2zkIbZysec= github.com/okta/okta-sdk-golang/v2 v2.12.1 h1:U+smE7trkHSZO8Mval3Ow85dbxawO+pMAr692VZq9gM= +github.com/okta/okta-sdk-golang/v2 v2.12.1/go.mod h1:KRoAArk1H216oiRnQT77UN6JAhBOnOWkK27yA1SM7FQ= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -1286,10 +1374,13 @@ github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3ev github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8= +github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/openshift/api v0.0.0-20210105115604-44119421ec6b/go.mod h1:aqU5Cq+kqKKPbDMqxo9FojgDeSpNJI7iuskjXjtojDg= github.com/openshift/api v0.0.0-20230329202819-04d4fb776982 h1:WQ6AkeLlqh6OrGuric5yYJ7j29QpsDiDNkdMKIqq3Dc= @@ -1306,10 +1397,12 @@ github.com/oracle/oci-go-sdk v7.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukw github.com/oracle/oci-go-sdk v12.5.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/oracle/oci-go-sdk v24.3.0+incompatible h1:x4mcfb4agelf1O4/1/auGlZ1lr97jXRSSN5MxTgG/zU= github.com/oracle/oci-go-sdk/v60 v60.0.0 h1:EJAWjEi4SY5Raha6iUzq4LTQ0uM5YFw/wat/L1ehIEM= +github.com/oracle/oci-go-sdk/v60 v60.0.0/go.mod h1:krz+2gkSzlSL/L4PvP0Z9pZpag9HYLNtsMd1PmxlA2w= github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/oxtoacart/bpool v0.0.0-20150712133111-4e1c5567d7c2/go.mod h1:L3UMQOThbttwfYRNFOWLLVXMhk5Lkio4GGOtw5UrxS0= github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c h1:vwpFWvAO8DeIZfFeqASzZfsxuWPno9ncAebBEP0N3uE= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -1324,6 +1417,7 @@ github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIG github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.2.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -1333,7 +1427,9 @@ github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pires/go-proxyproto v0.6.1 h1:EBupykFmo22SDjv4fQVQd2J9NOoLPmyZA/15ldOGkPw= +github.com/pires/go-proxyproto v0.6.1/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -1348,7 +1444,9 @@ github.com/portworx/talisman v0.0.0-20191007232806-837747f38224/go.mod h1:OjpMH9 github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/pquerna/otp v1.2.1-0.20191009055518-468c2dd2b58d h1:PinQItctnaL2LtkaSM678+ZLLy5TajwOeXzWvYC7tII= @@ -1402,6 +1500,7 @@ github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5 github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rboyer/safeio v0.2.1 h1:05xhhdRNAdS3apYm7JRjOqngf4xruaW959jmRxGDuSU= +github.com/rboyer/safeio v0.2.1/go.mod h1:Cq/cEPK+YXFn622lsQ0K4KsPZSPtaptHHEldsy7Fmig= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -1414,6 +1513,7 @@ github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rook/rook v1.11.4 h1:V5+r8JnVpSCdWGZ8eV5zUX1SnMTgCnz3azux+7Jefzc= github.com/rook/rook v1.11.4/go.mod h1:RwQdIZvb7BGomy9yR9caWYCoT8pHngYsxBXg6Fl8LZk= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -1424,17 +1524,22 @@ github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkB github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= +github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sethvargo/go-limiter v0.7.2 h1:FgC4N7RMpV5gMrUdda15FaFTkQ/L4fEqM7seXMs4oO8= +github.com/sethvargo/go-limiter v0.7.2/go.mod h1:C0kbSFbiriE5k2FFOe18M1YZbAR2Fiwf72uGu0CXCcU= github.com/shirou/gopsutil v2.19.9+incompatible h1:IrPVlK4nfwW10DF7pW+7YJKws9NkgNzWozwwWv9FsgY= github.com/shirou/gopsutil v2.19.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.22.6 h1:FnHOFOh+cYAM0C30P+zysPISzlknLC5Z1G4EAElznfQ= +github.com/shirou/gopsutil/v3 v3.22.6/go.mod h1:EdIubSnZhbAvBS1yJ7Xi+AShB/hxwLHOMz4MCYz7yMs= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -1444,6 +1549,7 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= +github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/smartystreets/assertions v0.0.0-20180725160413-e900ae048470/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -1456,11 +1562,13 @@ github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e h1:3OgWYFw7jxCZPc github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e/go.mod h1:fKZCUVdirrxrBpwd9wb+lSoVixvpwAu8eHzbQB2tums= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b h1:br+bPNZsJWKicw/5rALEo67QHs5weyD5tf8WST+4sJ0= +github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= @@ -1497,6 +1605,7 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tencentcloud/tencentcloud-sdk-go v3.0.171+incompatible h1:K3fcS92NS8cRntIdu8Uqy2ZSePvX73nNhOkKuPGJLXQ= +github.com/tencentcloud/tencentcloud-sdk-go v3.0.171+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0= github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk= @@ -1506,11 +1615,14 @@ github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eN github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c h1:u6SKchux2yDvFQnDHS3lPnIRmfVJ5Sxy3ao2SIdysLQ= +github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= @@ -1524,7 +1636,9 @@ github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= +github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= @@ -1548,12 +1662,14 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= @@ -1580,9 +1696,11 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= +go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1591,13 +1709,16 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/ratelimit v0.2.0 h1:UQE2Bgi7p2B85uP5dC2bbRtig0C+OeNRnNEafLjsLPA= go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6mUg= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -2083,6 +2204,7 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= google.golang.org/api v0.114.0 h1:1xQPji6cO2E2vLiI+C/XiFAnsn1WV3mjaEwGLhi3grE= +google.golang.org/api v0.114.0/go.mod h1:ifYI2ZsFK6/uGddGfAD5BMxlnkBqCmqHSDUVi45N5Yg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2142,7 +2264,9 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 h1:9NWlQfY2ePejTmfwUH1OWwmznFa+0kKcHGPDvcPza9M= +google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 h1:m8v1xLLLzMe1m5P+gCTF8nJB9epwZQUBERm20Oy1poQ= +google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -2231,9 +2355,11 @@ gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76 gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= +gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -2277,6 +2403,7 @@ k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:Ixke k8s.io/apiextensions-apiserver v0.18.3/go.mod h1:TMsNGs7DYpMXd+8MOCX8KzPOCx8fnZMoIGB24m03+JE= k8s.io/apiextensions-apiserver v0.20.1/go.mod h1:ntnrZV+6a3dB504qwC5PN/Yg9PBiDNt1EVqbW2kORVk= k8s.io/apiextensions-apiserver v0.26.0 h1:Gy93Xo1eg2ZIkNX/8vy5xviVSxwQulsnUdQ00nEdpDo= +k8s.io/apiextensions-apiserver v0.26.0/go.mod h1:7ez0LTiyW5nq3vADtK6C3kMESxadD51Bh6uz3JOlqWQ= k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= k8s.io/apimachinery v0.0.0-20190409092423-760d1845f48b/go.mod h1:FW86P8YXVLsbuplGMZeb20J3jYHscrDqw4jELaFJvRU= k8s.io/apimachinery v0.18.3/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= @@ -2305,6 +2432,7 @@ k8s.io/code-generator v0.20.1/go.mod h1:UsqdF+VX4PU2g46NC2JRs4gc+IfrctnwHb76RNbW k8s.io/component-base v0.18.3/go.mod h1:bp5GzGR0aGkYEfTj+eTY0AN/vXTgkJdQXjNTTVUaa3k= k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk= k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4= +k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= @@ -2340,6 +2468,7 @@ k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 h1:xMMXJlJbsU8w3V5N2FLDQ8YgU8s1E k8s.io/utils v0.0.0-20230313181309-38a27ef9d749/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= layeh.com/radius v0.0.0-20190322222518-890bc1058917/go.mod h1:fywZKyu//X7iRzaxLgPWsvc0L26IUpVvE/aeIL2JtIQ= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= +nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index bb711f778f..7833fc0192 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -4,6 +4,7 @@ import "time" const ( // Arguments + Arg_Action = "pi_action" Arg_AffinityInstance = "pi_affinity_instance" Arg_AffinityPolicy = "pi_affinity_policy" Arg_AffinityVolume = "pi_affinity_volume" @@ -14,6 +15,7 @@ const ( Arg_Datacenter = "pi_datacenter" Arg_DatacenterZone = "pi_datacenter_zone" Arg_DeploymentTarget = "pi_deployment_target" + Arg_DeploymentType = "pi_deployment_type" Arg_Description = "pi_description" Arg_DhcpCidr = "pi_cidr" Arg_DhcpCloudConnectionID = "pi_cloud_connection_id" @@ -21,6 +23,7 @@ const ( Arg_DhcpID = "pi_dhcp_id" Arg_DhcpName = "pi_dhcp_name" Arg_DhcpSnatEnabled = "pi_dhcp_snat_enabled" + Arg_HealthStatus = "pi_health_status" Arg_Host = "pi_host" Arg_HostGroupID = "pi_host_group_id" Arg_HostID = "pi_host_id" @@ -28,28 +31,42 @@ const ( Arg_IBMiCSS = "pi_ibmi_css" Arg_IBMiPHA = "pi_ibmi_pha" Arg_IBMiRDSUsers = "pi_ibmi_rds_users" + Arg_ImageID = "pi_image_id" Arg_ImageImportDetails = "pi_image_import_details" Arg_ImageName = "pi_image_name" + Arg_InstanceID = "pi_instance_id" Arg_InstanceName = "pi_instance_name" Arg_Key = "pi_ssh_key" Arg_KeyName = "pi_key_name" + Arg_KeyPairName = "pi_key_pair_name" Arg_LanguageCode = "pi_language_code" Arg_LicenseRepositoryCapacity = "pi_license_repository_capacity" + Arg_Memory = "pi_memory" Arg_Name = "pi_name" + Arg_Network = "pi_network" Arg_NetworkName = "pi_network_name" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" + Arg_PinPolicy = "pi_pin_policy" + Arg_PlacementGroupID = "pi_placement_group_id" Arg_PlacementGroupName = "pi_placement_group_name" Arg_PlacementGroupPolicy = "pi_placement_group_policy" Arg_Plan = "pi_plan" + Arg_Processors = "pi_processors" + Arg_ProcType = "pi_proc_type" Arg_PVMInstanceActionType = "pi_action" Arg_PVMInstanceHealthStatus = "pi_health_status" Arg_PVMInstanceId = "pi_instance_id" Arg_Remove = "pi_remove" + Arg_Replicants = "pi_replicants" Arg_ReplicationEnabled = "pi_replication_enabled" + Arg_ReplicationPolicy = "pi_replication_policy" + Arg_ReplicationScheme = "pi_replication_scheme" Arg_ResourceGroupID = "pi_resource_group_id" Arg_SAP = "sap" + Arg_SAPDeploymentType = "pi_sap_deployment_type" Arg_SAPProfileID = "pi_sap_profile_id" Arg_Secondaries = "pi_secondaries" + Arg_SharedProcessorPool = "pi_shared_processor_pool" Arg_SharedProcessorPoolHostGroup = "pi_shared_processor_pool_host_group" Arg_SharedProcessorPoolID = "pi_shared_processor_pool_id" Arg_SharedProcessorPoolName = "pi_shared_processor_pool_name" @@ -61,8 +78,14 @@ const ( Arg_SPPPlacementGroupName = "pi_spp_placement_group_name" Arg_SPPPlacementGroupPolicy = "pi_spp_placement_group_policy" Arg_SSHKey = "pi_ssh_key" + Arg_StorageConnection = "pi_storage_connection" Arg_StoragePool = "pi_storage_pool" + Arg_StoragePoolAffinity = "pi_storage_pool_affinity" Arg_StorageType = "pi_storage_type" + Arg_SysType = "pi_sys_type" + Arg_UserData = "pi_user_data" + Arg_VirtualCoresAssigned = "pi_virtual_cores_assigned" + Arg_VirtualOpticalDevice = "pi_virtual_optical_device" Arg_VolumeGroupID = "pi_volume_group_id" Arg_VolumeID = "pi_volume_id" Arg_VolumeIDs = "pi_volume_ids" @@ -368,24 +391,47 @@ const ( Attr_WWN = "wwn" // OS Type - OS_IBMI = "ibmi" + OS_IBMI = "ibmi" + StockVTL = "stock-vtl" // Allowed Values - Affinity = "affinity" - AntiAffinity = "anti-affinity" - BYOL = "byol" - Hana = "Hana" - Host = "host" - HostGroup = "hostGroup" - Netweaver = "Netweaver" - Private = "private" - Public = "public" - SAP = "SAP" + Affinity = "affinity" + AntiAffinity = "anti-affinity" + Attach = "attach" + BYOL = "byol" + Capped = "capped" + Critical = "CRITICAL" + CUSTOM_VIRTUAL_CORES = "custom-virtualcores" + Dedicated = "dedicated" + DeploymentTypeEpic = "EPIC" + DeploymentTypeVMNoStorage = "VMNoStorage" + Hana = "Hana" + Hard = "hard" + Host = "host" + HostGroup = "hostGroup" + Netweaver = "Netweaver" + None = "none" + OK = "OK" + Prefix = "prefix" + Private = "private" + Public = "public" + SAP = "SAP" + Shared = "shared" + Soft = "soft" + Suffix = "suffix" + vSCSI = "vSCSI" + Warning = "WARNING" + + // Actions + Action_HardReboot = "hard-reboot" + Action_ImmediateShutdown = "immediate-shutdown" + Action_ResetState = "reset-state" + Action_SoftReboot = "soft-reboot" + Action_Start = "start" + Action_Stop = "stop" // States NotFound = "not found" - SctionStart = "start" - SctionStop = "stop" State_Active = "active" State_ACTIVE = "ACTIVE" State_Added = "added" @@ -397,17 +443,24 @@ const ( State_Deleting = "deleting" State_DELETING = "DELETING" State_Down = "down" + State_Error = "error" State_Failed = "failed" State_Inactive = "inactive" State_InProgress = "in progress" State_InUse = "in-use" State_NotFound = "Not Found" + State_Pending = "pending" State_PendingReclamation = "pending_reclamation" State_Provisioning = "provisioning" State_Removed = "removed" State_Retry = "retry" + State_Shutoff = "shutoff" State_Up = "up" + Status_Active = "ACTIVE" Status_Deleting = "deleting" + Status_Error = "ERROR" + Status_Pending = "PENDING" + Status_Shutoff = "SHUTOFF" StatusActive = "ACTIVE" StatusBuild = "BUILD" StatusError = "ERROR" @@ -415,9 +468,6 @@ const ( StatusResize = "RESIZE" StatusShutoff = "SHUTOFF" - // Health - Health_OK = "OK" - // TODO: Second Half Cleanup, remove extra variables // SAP Profile @@ -428,14 +478,9 @@ const ( PISAPProfileID = "profile_id" PISAPProfileType = "type" - PVMInstanceHealthOk = "OK" - PVMInstanceHealthWarning = "WARNING" - //Added timeout values for warning and active status warningTimeOut = 60 * time.Second activeTimeOut = 2 * time.Minute - // power service instance capabilities - CUSTOM_VIRTUAL_CORES = "custom-virtualcores" PIConsoleLanguageCode = "pi_language_code" PICloudConnectionId = "cloud_connection_id" diff --git a/ibm/service/power/resource_ibm_pi_dhcp.go b/ibm/service/power/resource_ibm_pi_dhcp.go index 071b3d80ad..595ea85cf4 100644 --- a/ibm/service/power/resource_ibm_pi_dhcp.go +++ b/ibm/service/power/resource_ibm_pi_dhcp.go @@ -274,7 +274,7 @@ func waitForIBMPIDhcpStatus(ctx context.Context, client *st.IBMPIDhcpClient, dhc log.Printf("[DEBUG] get DHCP failed %v", err) return nil, "", err } - if *dhcpServer.Status != StatusActive { + if *dhcpServer.Status != Status_Active { return dhcpServer, "building", nil } return dhcpServer, "active", nil diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index cb55c3b1da..8aa1bffb7c 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -1111,8 +1111,8 @@ func isWaitForPIInstanceShutoff(ctx context.Context, client *st.IBMPIInstanceCli } stateConf := &retry.StateChangeConf{ - Pending: []string{StatusPending, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, - Target: []string{helpers.PIInstanceHealthOk, StatusError, "", StatusShutoff}, + Pending: []string{Status_Pending, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning}, + Target: []string{helpers.PIInstanceHealthOk, Status_Error, "", Status_Shutoff}, Refresh: isPIInstanceShutoffRefreshFunc(client, id, instanceReadyStatus), Delay: 30 * time.Second, MinTimeout: queryTimeOut, @@ -1129,10 +1129,10 @@ func isPIInstanceShutoffRefreshFunc(client *st.IBMPIInstanceClient, id, instance if err != nil { return nil, "", err } - if *pvm.Status == StatusShutoff && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { - return pvm, StatusShutoff, nil + if *pvm.Status == Status_Shutoff && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) { + return pvm, Status_Shutoff, nil } - if *pvm.Status == StatusError { + if *pvm.Status == Status_Error { if pvm.Fault != nil { err = fmt.Errorf("failed to create the lpar: %s", pvm.Fault.Message) } else { diff --git a/ibm/service/power/resource_ibm_pi_instance_action.go b/ibm/service/power/resource_ibm_pi_instance_action.go index 1bab4ee701..25071cfae3 100644 --- a/ibm/service/power/resource_ibm_pi_instance_action.go +++ b/ibm/service/power/resource_ibm_pi_instance_action.go @@ -6,6 +6,7 @@ package power import ( "context" "fmt" + "strings" st "github.com/IBM-Cloud/power-go-client/clients/instance" @@ -13,7 +14,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "log" @@ -36,45 +37,44 @@ func ResourceIBMPIInstanceAction() *schema.Resource { Schema: map[string]*schema.Schema{ // Arguments + Arg_Action: { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.ValidateAllowedStringValues([]string{Action_HardReboot, Action_ImmediateShutdown, Action_ResetState, Action_Start, Action_Stop, Action_SoftReboot}), + Description: "PVM instance action type", + }, Arg_CloudInstanceID: { Type: schema.TypeString, Required: true, Description: "PI Cloud instance id", }, - Arg_PVMInstanceId: { - Type: schema.TypeString, - Required: true, - Description: "PVM instance ID", - }, - Arg_PVMInstanceActionType: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.ValidateAllowedStringValues([]string{"start", "stop", "hard-reboot", "soft-reboot", "immediate-shutdown", "reset-state"}), - Description: "PVM instance action type", - }, - Arg_PVMInstanceHealthStatus: { + Arg_HealthStatus: { Type: schema.TypeString, Optional: true, - ValidateFunc: validate.ValidateAllowedStringValues([]string{PVMInstanceHealthOk, PVMInstanceHealthWarning}), - Default: PVMInstanceHealthOk, + ValidateFunc: validate.ValidateAllowedStringValues([]string{OK, Warning}), + Default: OK, Description: "Set the health status of the PVM instance to connect it faster", }, - - // Computed - Attr_Status: { + Arg_InstanceID: { + Type: schema.TypeString, + Required: true, + Description: "PVM instance ID", + }, + // Attributes + Attr_HealthStatus: { Type: schema.TypeString, Computed: true, - Description: "The status of the PVM instance", + Description: "The PVM's health status value", }, Attr_Progress: { Type: schema.TypeFloat, Computed: true, Description: "The progress of an operation", }, - Attr_HealthStatus: { + Attr_Status: { Type: schema.TypeString, Computed: true, - Description: "The PVM's health status value", + Description: "The status of the PVM instance", }, }, } @@ -88,7 +88,7 @@ func resourceIBMPIInstanceActionCreate(ctx context.Context, d *schema.ResourceDa } cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) - id := d.Get(Arg_PVMInstanceId).(string) + id := d.Get(Arg_InstanceID).(string) d.SetId(fmt.Sprintf("%s/%s", cloudInstanceID, id)) return resourceIBMPIInstanceActionRead(ctx, d, meta) @@ -122,7 +122,7 @@ func resourceIBMPIInstanceActionRead(ctx context.Context, d *schema.ResourceData func resourceIBMPIInstanceActionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - if d.HasChange(Arg_PVMInstanceActionType) { + if d.HasChange(Arg_Action) { adiag := takeInstanceAction(ctx, d, meta, d.Timeout(schema.TimeoutUpdate)) if adiag != nil { return adiag @@ -145,32 +145,32 @@ func takeInstanceAction(ctx context.Context, d *schema.ResourceData, meta interf } cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) - id := d.Get(Arg_PVMInstanceId).(string) - action := d.Get(Arg_PVMInstanceActionType).(string) - targetHealthStatus := d.Get(Arg_PVMInstanceHealthStatus).(string) + id := d.Get(Arg_InstanceID).(string) + action := d.Get(Arg_Action).(string) + targetHealthStatus := d.Get(Arg_HealthStatus).(string) var targetStatus string - if action == "stop" || action == "immediate-shutdown" { - targetStatus = "SHUTOFF" - } else if action == "reset-state" { - targetStatus = "ACTIVE" - targetHealthStatus = "CRITICAL" + if action == Action_Stop || action == Action_ImmediateShutdown { + targetStatus = State_Shutoff + } else if action == Action_ResetState { + targetStatus = State_Active + targetHealthStatus = Critical } else { // action is "start" or "soft-reboot" or "hard-reboot" - targetStatus = "ACTIVE" + targetStatus = State_Active } client := st.NewIBMPIInstanceClient(ctx, sess, cloudInstanceID) // special case for action "start", "stop", "immediate-shutdown" // skip calling action if instance is already in desired state - if action == "start" || action == "stop" || action == "immediate-shutdown" { + if action == Action_Start || action == Action_Stop || action == Action_ImmediateShutdown { pvm, err := client.Get(id) if err != nil { return diag.FromErr(err) } - if *pvm.Status == targetStatus && pvm.Health != nil && (pvm.Health.Status == targetHealthStatus || pvm.Health.Status == PVMInstanceHealthOk) { + if strings.ToLower(*pvm.Status) == targetStatus && pvm.Health != nil && (pvm.Health.Status == targetHealthStatus || pvm.Health.Status == OK) { log.Printf("[DEBUG] skipping as action %s not needed on the instance %s", action, id) return nil } @@ -199,9 +199,9 @@ func takeInstanceAction(ctx context.Context, d *schema.ResourceData, meta interf func isWaitForPIInstanceActionStatus(ctx context.Context, client *st.IBMPIInstanceClient, id string, timeout time.Duration, targetStatus, targetHealthStatus string) (interface{}, error) { log.Printf("Waiting for the action to be performed on the instance %s", id) - stateConf := &resource.StateChangeConf{ - Pending: []string{StatusPending}, - Target: []string{targetStatus, StatusError, ""}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Pending}, + Target: []string{targetStatus, State_Error, ""}, Refresh: isPIActionRefreshFunc(client, id, targetStatus, targetHealthStatus), Delay: 30 * time.Second, MinTimeout: 2 * time.Minute, @@ -211,7 +211,7 @@ func isWaitForPIInstanceActionStatus(ctx context.Context, client *st.IBMPIInstan return stateConf.WaitForStateContext(ctx) } -func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, targetHealthStatus string) resource.StateRefreshFunc { +func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, targetHealthStatus string) retry.StateRefreshFunc { return func() (interface{}, string, error) { log.Printf("Waiting for the target status to be [ %s ]", targetStatus) pvm, err := client.Get(id) @@ -219,12 +219,12 @@ func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, tar return nil, "", err } - if *pvm.Status == targetStatus && (pvm.Health.Status == targetHealthStatus || pvm.Health.Status == PVMInstanceHealthOk) { + if strings.ToLower(*pvm.Status) == targetStatus && (pvm.Health.Status == targetHealthStatus || pvm.Health.Status == OK) { log.Printf("The health status is now %s", pvm.Health.Status) return pvm, targetStatus, nil } - if *pvm.Status == "ERROR" { + if strings.ToLower(*pvm.Status) == State_Error { if pvm.Fault != nil { err = fmt.Errorf("failed to perform the action on the instance: %s", pvm.Fault.Message) } else { @@ -233,6 +233,6 @@ func isPIActionRefreshFunc(client *st.IBMPIInstanceClient, id, targetStatus, tar return pvm, *pvm.Status, err } - return pvm, StatusPending, nil + return pvm, State_Pending, nil } } diff --git a/ibm/service/power/resource_ibm_pi_instance_action_test.go b/ibm/service/power/resource_ibm_pi_instance_action_test.go index 901af8cf54..48fe0832dd 100644 --- a/ibm/service/power/resource_ibm_pi_instance_action_test.go +++ b/ibm/service/power/resource_ibm_pi_instance_action_test.go @@ -5,46 +5,50 @@ package power_test import ( "fmt" + "strings" "testing" acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/power" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccIBMPIInstanceAction(t *testing.T) { + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPIInstanceActionConfig("stop"), + Config: testAccCheckIBMPIInstanceActionConfig(name, power.Action_Stop), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "SHUTOFF"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Shutoff)), ), }, { // Try to stop already stopped instance - Config: testAccCheckIBMPIInstanceActionConfig("stop"), + Config: testAccCheckIBMPIInstanceActionConfig(name, power.Action_Stop), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "SHUTOFF"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Shutoff)), ), }, { - Config: testAccCheckIBMPIInstanceActionConfig("start"), + Config: testAccCheckIBMPIInstanceActionConfig(name, power.Action_Start), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "ACTIVE"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Active)), ), }, { // Try to start already started instance - Config: testAccCheckIBMPIInstanceActionConfig("start"), + Config: testAccCheckIBMPIInstanceActionConfig(name, power.Action_Start), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "ACTIVE"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Active)), ), }, }, @@ -52,17 +56,18 @@ func TestAccIBMPIInstanceAction(t *testing.T) { } func TestAccIBMPIInstanceActionHardReboot(t *testing.T) { + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPIInstanceActionWithHealthStatusConfig("hard-reboot"), + Config: testAccCheckIBMPIInstanceActionWithHealthStatusConfig(name, power.Action_HardReboot, power.Warning), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "ACTIVE"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Active)), resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "health_status", "WARNING"), + "ibm_pi_instance_action.example", "health_status", power.Warning), ), }, }, @@ -70,40 +75,87 @@ func TestAccIBMPIInstanceActionHardReboot(t *testing.T) { } func TestAccIBMPIInstanceActionResetState(t *testing.T) { + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPIInstanceActionWithHealthStatusConfig("reset-state"), + Config: testAccCheckIBMPIInstanceActionWithHealthStatusConfig(name, power.Action_ResetState, power.Warning), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "status", "ACTIVE"), + "ibm_pi_instance_action.example", "status", strings.ToUpper(power.State_Active)), resource.TestCheckResourceAttr( - "ibm_pi_instance_action.example", "health_status", "CRITICAL"), + "ibm_pi_instance_action.example", "health_status", power.Critical), ), }, }, }) } -func testAccCheckIBMPIInstanceActionConfig(action string) string { +func testAccCheckIBMPIInstanceActionConfig(name, action string) string { return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[4]s" + } + data "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[5]s" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[6]s" + pi_sys_type = "s922" + pi_network { + network_id = data.ibm_pi_network.power_networks.id + } + } + resource "ibm_pi_instance_action" "example" { - pi_cloud_instance_id = "%s" - pi_instance_id = "%s" - pi_action = "%s" + pi_action = "%[3]s" + pi_cloud_instance_id = "%[1]s" + pi_instance_id = resource.ibm_pi_instance.power_instance.pi_instance_name } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name, action) + `, acc.Pi_cloud_instance_id, name, action, acc.Pi_image, acc.Pi_network_name, acc.PiStorageType) } -func testAccCheckIBMPIInstanceActionWithHealthStatusConfig(action string) string { +func testAccCheckIBMPIInstanceActionWithHealthStatusConfig(name, action, instanceHealthStatus string) string { return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[4]s" + } + data "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[5]s" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_health_status = "%[7]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[6]s" + pi_sys_type = "s922" + pi_network { + network_id = data.ibm_pi_network.power_networks.id + } + } resource "ibm_pi_instance_action" "example" { - pi_cloud_instance_id = "%s" - pi_instance_id = "%s" - pi_action = "%s" - pi_health_status = "WARNING" + pi_action = "%[3]s" + pi_cloud_instance_id = "%[1]s" + pi_health_status = "%[7]s" + pi_instance_id = resource.ibm_pi_instance.power_instance.pi_instance_name } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name, action) + `, acc.Pi_cloud_instance_id, name, action, acc.Pi_image, acc.Pi_network_name, acc.PiStorageType, instanceHealthStatus) } diff --git a/ibm/service/power/resource_ibm_pi_snapshot_test.go b/ibm/service/power/resource_ibm_pi_snapshot_test.go index bb6370eaff..82d9bdfe25 100644 --- a/ibm/service/power/resource_ibm_pi_snapshot_test.go +++ b/ibm/service/power/resource_ibm_pi_snapshot_test.go @@ -28,7 +28,7 @@ func TestAccIBMPIInstanceSnapshotbasic(t *testing.T) { CheckDestroy: testAccCheckIBMPIInstanceSnapshotDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPIInstanceSnapshotConfig(name, power.Health_OK), + Config: testAccCheckIBMPIInstanceSnapshotConfig(name, power.OK), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPIInstanceSnapshotExists(snapshotRes), resource.TestCheckResourceAttr(snapshotRes, "pi_snap_shot_name", name), diff --git a/website/docs/r/pi_instance_action.html.markdown b/website/docs/r/pi_instance_action.html.markdown index 1b8d0b99bf..a75332e79d 100644 --- a/website/docs/r/pi_instance_action.html.markdown +++ b/website/docs/r/pi_instance_action.html.markdown @@ -1,16 +1,17 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_instance_action" description: |- - Performs an action start, stop, reboot, immediate-shutdown, reset on a p VM instance. + Performs an action start, stop, reboot, immediate-shutdown, reset on a PVM instance. --- # ibm_pi_instance_action + Performs an action on a [Power Systems Virtual Server instance](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server). ## Example usage + The following example perform an action "hard-reboot" on a Power Systems Virtual Server instance. ```terraform @@ -22,7 +23,8 @@ resource "ibm_pi_instance_action" "example" { ``` -**Note** +### Notes + * Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. * If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: * `region` - `lon` @@ -41,32 +43,33 @@ resource "ibm_pi_instance_action" "example" { The `ibm_pi_instance_action` provides the following [timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options: -- **create** - The action on the instance is considered failed if no response is received for 15 minutes. -- **Update** The update action on the instance is considered failed if no response is received for 15 minutes. +* **create** - (Default 15 minutes) Used for taking action on the instance. +* **update** - (Default 15 minutes) Used for updating action on the instance. +## Argument references -## Argument reference Review the argument references that you can specify for your resource. -- `pi_action` - (Required, String) Name of the action to take. Allowed values are `start`, `stop`, `hard-reboot`, `soft-reboot`, `immediate-shutdown`, `reset-state`. -- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. -- `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. Ignored for `pi_action = "reset-state"`. -- `pi_instance_id` - (Required, String) Custom deployment type information (For Internal Use Only). +* `pi_action` - (Required, String) Name of the action to take. Allowed values are `start`, `stop`, `hard-reboot`, `soft-reboot`, `immediate-shutdown`, `reset-state`. +* `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. +* `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. Ignored for `pi_action = "reset-state"`. +* `pi_instance_id` - (Required, String) The ID of the pvm instance to perform an action on. ## Attribute reference + In addition to all argument reference list, you can access the following attribute reference after your resource is created. -- `health_status` - (String) The health status of the VM. -- `id` - (String) The unique identifier of the instance. The ID is composed of `/`. -- `progress` - (Float) - The progress of the instance. -- `status` - (String) - The status of the instance. +* `health_status` - (String) The health status of the VM. +* `id` - (String) The unique identifier of the instance. The ID is composed of `/`. +* `progress` - (Float) - The progress of the instance. +* `status` - (String) - The status of the instance. ## Import -The `ibm_pi_instance_action` can be imported using `cloud_instance_id` and `instance_id`. +The `ibm_pi_instance_action` can be imported using `pi_cloud_instance_id` and `pi_instance_id`. -**Example** +### Example -``` -$ terraform import ibm_pi_instance_action.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770b112ebb +```bash +terraform import ibm_pi_instance_action.example d7bec597-4726-451f-8a63-e62e6f19c32c/cea6651a-bc0a-4438-9f8a-a0770b112ebb ``` From 553c6709f8bb821f360cc857cd5dfea0691bbb07 Mon Sep 17 00:00:00 2001 From: siddhuvarma1997 <49102413+siddhuvarma1997@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:41:40 +0530 Subject: [PATCH 22/25] IAM Policy Assignment: S2S Policy Assignments (#5499) * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma * IAM Policy Assignment: S2S Policy Assignments Signed-off-by: Alluri-Varma --------- Signed-off-by: Alluri-Varma Co-authored-by: Alluri-Varma --- go.mod | 4 +- go.sum | 8 +- .../data_source_ibm_iam_policy_assignment.go | 98 ------- .../data_source_ibm_iam_policy_assignments.go | 117 +------- .../resource_ibm_iam_policy_assignment.go | 99 ------- ...resource_ibm_iam_policy_assignment_test.go | 90 +++++- .../resource_ibm_iam_policy_template.go | 273 ++++++++++-------- .../resource_ibm_iam_policy_template_test.go | 150 ++++++++++ ...esource_ibm_iam_policy_template_version.go | 4 +- ...ce_ibm_iam_policy_template_version_test.go | 38 +++ .../d/iam_policy_assignment.html.markdown | 10 - .../docs/r/policy_assignment.html.markdown | 30 +- 12 files changed, 434 insertions(+), 487 deletions(-) diff --git a/go.mod b/go.mod index c4e53b2d0d..3c217e3a20 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/IBM/event-notifications-go-admin-sdk v0.6.1 github.com/IBM/eventstreams-go-sdk v1.4.0 github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/go-sdk-core/v5 v5.17.3 + github.com/IBM/go-sdk-core/v5 v5.17.4 github.com/IBM/ibm-cos-sdk-go v1.10.3 github.com/IBM/ibm-cos-sdk-go-config/v2 v2.1.0 github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 @@ -26,7 +26,7 @@ require ( github.com/IBM/keyprotect-go-client v0.14.0 github.com/IBM/logs-go-sdk v0.3.0 github.com/IBM/networking-go-sdk v0.47.1 - github.com/IBM/platform-services-go-sdk v0.62.11 + github.com/IBM/platform-services-go-sdk v0.64.3 github.com/IBM/project-go-sdk v0.3.5 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.6 diff --git a/go.sum b/go.sum index beef1742b2..8ad87a2ca0 100644 --- a/go.sum +++ b/go.sum @@ -155,6 +155,8 @@ github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.17.3 h1:CZSVCKzhQc/hRQZOtuEmi9dlNtWMnxJvOsPtQKP7cZ4= github.com/IBM/go-sdk-core/v5 v5.17.3/go.mod h1:GatGZpxlo1KaxiRN6E10/rNgWtUtx1hN/GoHSCaSPKA= +github.com/IBM/go-sdk-core/v5 v5.17.4 h1:VGb9+mRrnS2HpHZFM5hy4J6ppIWnwNrw0G+tLSgcJLc= +github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns= github.com/IBM/ibm-cos-sdk-go v1.10.3 h1:YfZSLqMiCrqDPbr3r+amY2sicIXlrd+3L5pok6QRXIQ= github.com/IBM/ibm-cos-sdk-go v1.10.3/go.mod h1:T9x7pC47DUd5jD/TMFzlvly39P6EdW5wOemA78XEo2g= github.com/IBM/ibm-cos-sdk-go-config/v2 v2.1.0 h1:U7EmXSfv7jtugRpTpOkPUmgS/xiNKtGfKVH3BGyC1hg= @@ -174,8 +176,10 @@ github.com/IBM/networking-go-sdk v0.47.1 h1:Zqqu9CrZ86jkjMyuIJtBLLOE0D7YtirxnlFy github.com/IBM/networking-go-sdk v0.47.1/go.mod h1:yF4XStkswGgVwQVqPUk6b4YTP0dVap52q8HDYwY4gXQ= github.com/IBM/platform-services-go-sdk v0.62.11 h1:EGsiY90bM9M9sSdBVgpsX4QK1z99JZzedVDlrY2gzmc= github.com/IBM/platform-services-go-sdk v0.62.11/go.mod h1:M26dloj9C48k9AjfMcKGsgH/acEjaUvxjVS8z41Q8dg= -github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM= -github.com/IBM/project-go-sdk v0.3.5/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo= +github.com/IBM/platform-services-go-sdk v0.64.3 h1:AKDrLXjybG09i5MyqptY0UpyejeiYrTbdylDC7FQM1k= +github.com/IBM/platform-services-go-sdk v0.64.3/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4= +github.com/IBM/project-go-sdk v0.3.4 h1:VJqGdrWZLlb+f5/fH5mcSpt8t0QoYEq4QgFWVnn8mCs= +github.com/IBM/project-go-sdk v0.3.4/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5/go.mod h1:b07XHUVh0XYnQE9s2mqgjYST1h9buaQNqN4EcKhOsX0= github.com/IBM/sarama v1.41.2 h1:ZDBZfGPHAD4uuAtSv4U22fRZBgst0eEwGFzLj0fb85c= diff --git a/ibm/service/iampolicy/data_source_ibm_iam_policy_assignment.go b/ibm/service/iampolicy/data_source_ibm_iam_policy_assignment.go index 2aaef64f9e..768c996f98 100644 --- a/ibm/service/iampolicy/data_source_ibm_iam_policy_assignment.go +++ b/ibm/service/iampolicy/data_source_ibm_iam_policy_assignment.go @@ -207,50 +207,6 @@ func DataSourceIBMIAMPolicyAssignment() *schema.Resource { }, }, }, - "options": { - Type: schema.TypeList, - Computed: true, - Description: "The set of properties required for a policy assignment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "root": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "requester_id": { - Type: schema.TypeString, - Computed: true, - }, - "assignment_id": { - Type: schema.TypeString, - Computed: true, - Description: "Passed in value to correlate with other assignments.", - }, - "template": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The template id where this policy is being assigned from.", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "The template version where this policy is being assigned from.", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "account_id": { Type: schema.TypeString, Computed: true, @@ -301,13 +257,6 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res return diag.FromErr(fmt.Errorf("error setting template: %s", err)) } } - optionsMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(policyAssignmentRecord.Options) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("options", []map[string]interface{}{optionsMap}); err != nil { - return diag.FromErr(fmt.Errorf("error setting options: %s", err)) - } if err = d.Set("href", policyAssignmentRecord.Href); err != nil { return diag.FromErr(fmt.Errorf("error setting href: %s", err)) @@ -317,18 +266,10 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } - if err = d.Set("created_by_id", policyAssignmentRecord.CreatedByID); err != nil { - return diag.FromErr(fmt.Errorf("error setting created_by_id: %s", err)) - } - if err = d.Set("last_modified_at", flex.DateTimeToString(policyAssignmentRecord.LastModifiedAt)); err != nil { return diag.FromErr(fmt.Errorf("error setting last_modified_at: %s", err)) } - if err = d.Set("last_modified_by_id", policyAssignmentRecord.LastModifiedByID); err != nil { - return diag.FromErr(fmt.Errorf("error setting last_modified_by_id: %s", err)) - } - if err = d.Set("account_id", policyAssignmentRecord.AccountID); err != nil { return diag.FromErr(fmt.Errorf("error setting account_id: %s", err)) } @@ -474,45 +415,6 @@ func ResourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolic } return modelMap, nil } -func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = *model.ID - } - if model.Version != nil { - modelMap["version"] = *model.Version - } - return modelMap, nil -} - -func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.RequesterID != nil { - modelMap["requester_id"] = *model.RequesterID - } - if model.AssignmentID != nil { - modelMap["assignment_id"] = *model.AssignmentID - } - if model.Template != nil { - templateMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template) - if err != nil { - return modelMap, err - } - modelMap["template"] = []map[string]interface{}{templateMap} - } - return modelMap, nil -} - -func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - rootMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root) - if err != nil { - return modelMap, err - } - modelMap["root"] = []map[string]interface{}{rootMap} - return modelMap, nil -} - func DataSourceIBMPolicyAssignmentPolicyAssignmentV1Subject(model *iampolicymanagementv1.GetPolicyAssignmentResponseSubject) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { diff --git a/ibm/service/iampolicy/data_source_ibm_iam_policy_assignments.go b/ibm/service/iampolicy/data_source_ibm_iam_policy_assignments.go index d3cb74ae4a..eeb0bbc765 100644 --- a/ibm/service/iampolicy/data_source_ibm_iam_policy_assignments.go +++ b/ibm/service/iampolicy/data_source_ibm_iam_policy_assignments.go @@ -58,50 +58,6 @@ func DataSourceIBMIAMPolicyAssignments() *schema.Resource { Type: schema.TypeString, }, }, - "options": { - Type: schema.TypeList, - Computed: true, - Description: "The set of properties required for a policy assignment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "root": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "requester_id": { - Type: schema.TypeString, - Computed: true, - }, - "assignment_id": { - Type: schema.TypeString, - Computed: true, - Description: "Passed in value to correlate with other assignments.", - }, - "template": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The template id where this policy is being assigned from.", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "The template version where this policy is being assigned from.", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "id": { Type: schema.TypeString, Computed: true, @@ -370,7 +326,7 @@ func ResourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicyman func ResourceIBMPolicyAssignmentResourceTargetDetailsToMap(model *iampolicymanagementv1.AssignmentTargetDetails) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Type != nil { - modelMap["version"] = *model.Type + modelMap["type"] = *model.Type } if model.ID != nil { modelMap["id"] = *model.ID @@ -394,13 +350,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsToMap(model iampo } modelMap["target"] = targetMap } - if model.Options != nil { - optionsMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model.Options) - if err != nil { - return modelMap, err - } - modelMap["options"] = []map[string]interface{}{optionsMap} - } if model.ID != nil { modelMap["id"] = *model.ID } @@ -476,45 +425,6 @@ func DataSourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicym return modelMap, nil } -func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - rootMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root) - if err != nil { - return modelMap, err - } - modelMap["root"] = []map[string]interface{}{rootMap} - return modelMap, nil -} - -func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.RequesterID != nil { - modelMap["requester_id"] = *model.RequesterID - } - if model.AssignmentID != nil { - modelMap["assignment_id"] = *model.AssignmentID - } - if model.Template != nil { - templateMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template) - if err != nil { - return modelMap, err - } - modelMap["template"] = []map[string]interface{}{templateMap} - } - return modelMap, nil -} - -func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = *model.ID - } - if model.Version != nil { - modelMap["version"] = *model.Version - } - return modelMap, nil -} - func DataSourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentV1Resources) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Target != nil { @@ -665,17 +575,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT if model.Target != nil { modelMap["target"] = *model.Target } - if model.Options != nil { - options := []map[string]interface{}{} - for _, optionsItem := range model.Options { - optionsItemMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(&optionsItem) - if err != nil { - return modelMap, err - } - options = append(options, optionsItemMap) - } - modelMap["options"] = options - } if model.ID != nil { modelMap["id"] = *model.ID } @@ -714,20 +613,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT return modelMap, nil } -func DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(model *iampolicymanagementv1.PolicyAssignmentOptions) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["subject_type"] = *model.SubjectType - modelMap["subject_id"] = *model.SubjectID - modelMap["root_requester_id"] = *model.RootRequesterID - if model.RootTemplateID != nil { - modelMap["root_template_id"] = *model.RootTemplateID - } - if model.RootTemplateVersion != nil { - modelMap["root_template_version"] = *model.RootTemplateVersion - } - return modelMap, nil -} - func DataSourceIBMPolicyAssignmentPolicyAssignmentResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentResources) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Target != nil { diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_assignment.go b/ibm/service/iampolicy/resource_ibm_iam_policy_assignment.go index 1c16558551..9072c9f76d 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_assignment.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_assignment.go @@ -66,54 +66,6 @@ func ResourceIBMIAMPolicyAssignment() *schema.Resource { }, }, }, - "options": { - Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, - Required: true, - Description: "The set of properties required for a policy assignment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "root": { - Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "requester_id": { - Type: schema.TypeString, - Required: true, - }, - "assignment_id": { - Type: schema.TypeString, - Optional: true, - Description: "Passed in value to correlate with other assignments.", - }, - "template": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Optional: true, - Description: "The template id where this policy is being assigned from.", - }, - "version": { - Type: schema.TypeString, - Optional: true, - Description: "The template version where this policy is being assigned from.", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "account_id": { Type: schema.TypeString, Computed: true, @@ -304,11 +256,6 @@ func resourceIBMPolicyAssignmentCreate(context context.Context, d *schema.Resour return diag.FromErr(err) } createPolicyTemplateAssignmentOptions.SetTarget(targetModel) - optionsModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1Options(d.Get("options.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createPolicyTemplateAssignmentOptions.SetOptions(optionsModel) var templates []iampolicymanagementv1.AssignmentTemplateDetails for _, v := range d.Get("templates").([]interface{}) { value := v.(map[string]interface{}) @@ -368,13 +315,6 @@ func resourceIBMPolicyAssignmentRead(context context.Context, d *schema.Resource if err = d.Set("target", targetMap); err != nil { return diag.FromErr(fmt.Errorf("error setting target: %s", err)) } - optionsMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(assignmentDetails.Options) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("options", []map[string]interface{}{optionsMap}); err != nil { - return diag.FromErr(fmt.Errorf("error setting options: %s", err)) - } if !core.IsNil(assignmentDetails.AccountID) { if err = d.Set("account_id", assignmentDetails.AccountID); err != nil { return diag.FromErr(fmt.Errorf("error setting account_id: %s", err)) @@ -516,45 +456,6 @@ func ResourceIBMPolicyAssignmentMapToAssignmentTargetDetails(modelMap map[string return model, nil } -func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1Options(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1Options, error) { - model := &iampolicymanagementv1.PolicyAssignmentV1Options{} - RootModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRoot(modelMap["root"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Root = RootModel - return model, nil -} - -func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRoot(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1OptionsRoot, error) { - model := &iampolicymanagementv1.PolicyAssignmentV1OptionsRoot{} - if modelMap["requester_id"] != nil && modelMap["requester_id"].(string) != "" { - model.RequesterID = core.StringPtr(modelMap["requester_id"].(string)) - } - if modelMap["assignment_id"] != nil && modelMap["assignment_id"].(string) != "" { - model.AssignmentID = core.StringPtr(modelMap["assignment_id"].(string)) - } - if modelMap["template"] != nil && len(modelMap["template"].([]interface{})) > 0 { - TemplateModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRootTemplate(modelMap["template"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Template = TemplateModel - } - return model, nil -} - -func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRootTemplate(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate, error) { - model := &iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } - if modelMap["version"] != nil && modelMap["version"].(string) != "" { - model.Version = core.StringPtr(modelMap["version"].(string)) - } - return model, nil -} - func ResourceIBMPolicyAssignmentMapToAssignmentTemplateDetails(modelMap map[string]interface{}) (*iampolicymanagementv1.AssignmentTemplateDetails, error) { model := &iampolicymanagementv1.AssignmentTemplateDetails{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_assignment_test.go b/ibm/service/iampolicy/resource_ibm_iam_policy_assignment_test.go index aa01ea03ad..925fe756b1 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_assignment_test.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_assignment_test.go @@ -46,6 +46,30 @@ func TestAccIBMPolicyAssignmentBasic(t *testing.T) { }) } +func TestAccIBMPolicyAssignmentS2SBasic(t *testing.T) { + var conf iampolicymanagementv1.GetPolicyAssignmentResponse + var name string = fmt.Sprintf("TerraformTemplateTest%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPolicyAssignmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPolicyAssignmentS2SConfigBasic(name, acc.TargetAccountId), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyAssignmentExists("ibm_iam_policy_assignment.policy_assignment", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_s2s_template", "name", name), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_s2s_template", "policy.0.resource.0.attributes.0.value", "is"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_s2s_template", "policy.0.resource.0.attributes.1.value", "true"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_s2s_template", "policy.0.subject.0.attributes.0.value", "is"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_s2s_template", "policy.0.subject.0.attributes.1.value", "backup-policy"), + ), + }, + }, + }) +} + func testAccCheckIBMPolicyAssignmentConfigBasic(name string, targetId string) string { return fmt.Sprintf(` resource "ibm_iam_policy_template" "policy_s2s_template" { @@ -77,23 +101,66 @@ func testAccCheckIBMPolicyAssignmentConfigBasic(name string, targetId string) st type = "Account" id = "%s" } + templates{ + id = ibm_iam_policy_template.policy_s2s_template.template_id + version = ibm_iam_policy_template.policy_s2s_template.version + } + }`, name, targetId) +} - options { - root { - requester_id = "orchestrator" - assignment_id = "test" +func testAccCheckIBMPolicyAssignmentS2SConfigBasic(name string, targetId string) string { + return fmt.Sprintf(` + resource "ibm_iam_policy_template" "policy_s2s_template" { + name = "%s" + policy { + type = "authorization" + description = "Test terraform enterprise S2S" + resource { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "is" + } + attributes { + key = "volumeId" + operator = "stringExists" + value = "true" + } + } + subject { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "is" + } + attributes { + key = "resourceType" + operator = "stringEquals" + value = "backup-policy" + } } + roles = ["Operator"] + } + committed=true + } + resource "ibm_iam_policy_assignment" "policy_assignment" { + version = "1.0" + target ={ + type = "Account" + id = "%s" } templates{ id = ibm_iam_policy_template.policy_s2s_template.template_id version = ibm_iam_policy_template.policy_s2s_template.version } - }`, name, targetId) + } + + `, name, targetId) } func testAccCheckIBMPolicyAssignmentConfigUpdate(name string, targetId string) string { return fmt.Sprintf(` - resource "ibm_iam_policy_template" "policy_s2s_template" { + resource "ibm_iam_policy_template" "policy_s2stemplate" { name = "%s" policy { type = "authorization" @@ -147,17 +214,10 @@ func testAccCheckIBMPolicyAssignmentConfigUpdate(name string, targetId string) s id = "%s" } - options { - root { - requester_id = "orchestrator" - assignment_id = "test" - } - } templates{ - id = ibm_iam_policy_template.policy_s2s_template.template_id - version = ibm_iam_policy_template.policy_s2s_template.version + id = ibm_iam_policy_template.policy_s2stemplate.template_id + version = ibm_iam_policy_template.policy_s2stemplate.version } - template_version=ibm_iam_policy_template_version.template_version.version }`, name, targetId) } diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_template.go b/ibm/service/iampolicy/resource_ibm_iam_policy_template.go index b43d37ca6a..a00617d4e6 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_template.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_template.go @@ -55,7 +55,7 @@ func ResourceIBMIAMPolicyTemplate() *schema.Resource { }, "resource": { Type: schema.TypeList, - Required: true, + Optional: true, Description: "The resource attributes to which the policy grants access.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -173,7 +173,7 @@ func ResourceIBMIAMPolicyTemplate() *schema.Resource { }, "roles": { Type: schema.TypeList, - Required: true, + Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, Description: "Role names of the policy definition", }, @@ -310,6 +310,7 @@ func resourceIBMIAMPolicyTemplateCreate(context context.Context, d *schema.Resou } func generateTemplatePolicy(d *schema.ResourceData, iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (*iampolicymanagementv1.TemplatePolicy, error) { + var sourceServiceName, targetServiceName, serviceGroupID string model := &iampolicymanagementv1.TemplatePolicy{} modelMap := d.Get("policy.0").(map[string]interface{}) model.Type = core.StringPtr(modelMap["type"].(string)) @@ -317,19 +318,125 @@ func generateTemplatePolicy(d *schema.ResourceData, iamPolicyManagementClient *i if modelMap["description"] != nil && modelMap["description"].(string) != "" { model.Description = core.StringPtr(modelMap["description"].(string)) } - ResourceModel, roleList, err := generateTemplatePolicyResource(modelMap["resource"].([]interface{})[0].(map[string]interface{}), iamPolicyManagementClient) + var roleList *iampolicymanagementv1.RoleCollection + listRoleOptions := &iampolicymanagementv1.ListRolesOptions{} + var err error + if _, ok := d.GetOk("policy.0.resource"); ok { + modelMap := modelMap["resource"].([]interface{})[0].(map[string]interface{}) + modelResource := &iampolicymanagementv1.V2PolicyResource{} + attributes := []iampolicymanagementv1.V2PolicyResourceAttribute{} + for _, attributesItem := range modelMap["attributes"].([]interface{}) { + attributesItemModel := &iampolicymanagementv1.V2PolicyResourceAttribute{} + attributesItemModel.Key = core.StringPtr(attributesItem.(map[string]interface{})["key"].(string)) + attributesItemModel.Operator = core.StringPtr(attributesItem.(map[string]interface{})["operator"].(string)) + attributesItemModel.Value = attributesItem.(map[string]interface{})["value"].(string) + + if *attributesItemModel.Key == "serviceName" && + (*attributesItemModel.Operator == "stringMatch" || + *attributesItemModel.Operator == "stringEquals") { + targetServiceName = fmt.Sprintf("%v", attributesItemModel.Value) + } + + if *attributesItemModel.Key == "service_group_id" && (*attributesItemModel.Operator == "stringMatch" || + *attributesItemModel.Operator == "stringEquals") { + serviceGroupID = fmt.Sprintf("%v", attributesItemModel.Value) + } + + if *attributesItemModel.Key == "serviceType" && attributesItemModel.Value.(string) == "service" && (*attributesItemModel.Operator == "stringMatch" || + *attributesItemModel.Operator == "stringEquals") { + listRoleOptions.ServiceName = core.StringPtr("alliamserviceroles") + } + + if *model.Type == "authorization" && *attributesItemModel.Key == "resourceType" && targetServiceName == "" { + targetServiceName = "resource-controller" + } + + if *attributesItemModel.Operator == "stringExists" { + if attributesItemModel.Value == "true" { + attributesItemModel.Value = true + } else if attributesItemModel.Value == "false" { + attributesItemModel.Value = false + } else { + return model, fmt.Errorf("[ERROR] When operator equals stringExists, value should be either \"true\" or \"false\", instead of %s", + attributesItemModel.Value) + } + } + + attributes = append(attributes, *attributesItemModel) + } + modelResource.Attributes = attributes + if modelMap["tags"] != nil { + tags := []iampolicymanagementv1.V2PolicyResourceTag{} + for _, tagsItem := range modelMap["tags"].([]interface{}) { + tagsItemModel, err := generateTemplatePolicyTag(tagsItem.(map[string]interface{})) + if err != nil { + return model, err + } + tags = append(tags, *tagsItemModel) + } + modelResource.Tags = tags + } + model.Resource = modelResource + } + + // check subject only for authorization type + if _, ok := d.GetOk("policy.0.subject"); ok { + modelMap := (modelMap["subject"]).(*schema.Set).List() + modelSubject := &iampolicymanagementv1.V2PolicySubject{} + attributes := []iampolicymanagementv1.V2PolicySubjectAttribute{} + for _, attributesItem := range modelMap { + attribute := (attributesItem.(map[string]interface{}))["attributes"] + for _, item := range (attribute).([]interface{}) { + attributesItemModel := &iampolicymanagementv1.V2PolicySubjectAttribute{} + attributesItemModel.Key = core.StringPtr((item.((map[string]interface{}))["key"].(string))) + attributesItemModel.Operator = core.StringPtr(item.(map[string]interface{})["operator"].(string)) + attributesItemModel.Value = core.StringPtr(item.((map[string]interface{}))["value"].(string)) + if *attributesItemModel.Key == "serviceName" { + sourceServiceName = item.((map[string]interface{}))["value"].(string) + } + if *attributesItemModel.Operator == "stringExists" { + if attributesItemModel.Value == "true" { + attributesItemModel.Value = true + } else if attributesItemModel.Value == "false" { + attributesItemModel.Value = false + } else { + return model, fmt.Errorf("[ERROR] Only values \"true\" and \"false\" are allowed when operator is \"stringExists\". Received %s.", attributesItemModel.Value) + } + } + if *model.Type == "authorization" && *attributesItemModel.Operator == "" && attributesItemModel.Value == "*" && *attributesItemModel.Key == "resourceGroupId" { + attributesItemModel.Value = true + *attributesItemModel.Operator = "stringExists" + } + attributes = append(attributes, *attributesItemModel) + } + } + modelSubject.Attributes = attributes + model.Subject = modelSubject + } + + if targetServiceName != "" { + listRoleOptions.ServiceName = &targetServiceName + } + if serviceGroupID != "" { + listRoleOptions.ServiceGroupID = &serviceGroupID + } + if sourceServiceName != "" { + listRoleOptions.SourceServiceName = &sourceServiceName + listRoleOptions.PolicyType = core.StringPtr("authorization") + } + roles, _, err := iamPolicyManagementClient.ListRoles(listRoleOptions) + roleList = roles if err != nil { return model, err } - model.Resource = ResourceModel - if _, ok := d.GetOk("policy.0.subject"); ok { - subjectModel, err := generateTemplatePolicySubject(((modelMap["subject"]).(*schema.Set).List()), - iamPolicyManagementClient) + if _, ok := d.GetOk("policy.0.roles"); ok && roleList != nil { + controlModel, err := generateTemplatePolicyControl(modelMap["roles"].([]interface{}), roleList) if err != nil { - return model, err + return nil, err } - model.Subject = subjectModel + + model.Control = controlModel } if modelMap["pattern"] != nil && modelMap["pattern"].(string) != "" { @@ -376,83 +483,6 @@ func generateTemplatePolicy(d *schema.ResourceData, iamPolicyManagementClient *i } model.Rule = rule } - - controlModel, err := generateTemplatePolicyControl(modelMap["roles"].([]interface{}), roleList) - if err != nil { - return nil, err - } - - model.Control = controlModel - return model, nil -} - -func generateTemplatePolicyResource(modelMap map[string]interface{}, - iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (*iampolicymanagementv1.V2PolicyResource, *iampolicymanagementv1.RoleCollection, error) { - model := &iampolicymanagementv1.V2PolicyResource{} - attributes := []iampolicymanagementv1.V2PolicyResourceAttribute{} - roleList := &iampolicymanagementv1.RoleCollection{} - listRoleOptions := &iampolicymanagementv1.ListRolesOptions{} - for _, attributesItem := range modelMap["attributes"].([]interface{}) { - attributesItemModel := &iampolicymanagementv1.V2PolicyResourceAttribute{} - attributesItemModel.Key = core.StringPtr(attributesItem.(map[string]interface{})["key"].(string)) - attributesItemModel.Operator = core.StringPtr(attributesItem.(map[string]interface{})["operator"].(string)) - attributesItemModel.Value = attributesItem.(map[string]interface{})["value"].(string) - - if *attributesItemModel.Key == "serviceName" && - (*attributesItemModel.Operator == "stringMatch" || - *attributesItemModel.Operator == "stringEquals") { - listRoleOptions.ServiceName = core.StringPtr(attributesItemModel.Value.(string)) - } - - if *attributesItemModel.Key == "service_group_id" && (*attributesItemModel.Operator == "stringMatch" || - *attributesItemModel.Operator == "stringEquals") { - listRoleOptions.ServiceGroupID = core.StringPtr(attributesItemModel.Value.(string)) - } - - if *attributesItemModel.Key == "serviceType" && attributesItemModel.Value.(string) == "service" && (*attributesItemModel.Operator == "stringMatch" || - *attributesItemModel.Operator == "stringEquals") { - listRoleOptions.ServiceName = core.StringPtr("alliamserviceroles") - } - - roles, _, err := iamPolicyManagementClient.ListRoles(listRoleOptions) - if err != nil { - return model, nil, err - } - - attributes = append(attributes, *attributesItemModel) - roleList = roles - } - model.Attributes = attributes - if modelMap["tags"] != nil { - tags := []iampolicymanagementv1.V2PolicyResourceTag{} - for _, tagsItem := range modelMap["tags"].([]interface{}) { - tagsItemModel, err := generateTemplatePolicyTag(tagsItem.(map[string]interface{})) - if err != nil { - return model, nil, err - } - tags = append(tags, *tagsItemModel) - } - model.Tags = tags - } - return model, roleList, nil -} - -func generateTemplatePolicySubject(modelMap []interface{}, - iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (*iampolicymanagementv1.V2PolicySubject, error) { - model := &iampolicymanagementv1.V2PolicySubject{} - attributes := []iampolicymanagementv1.V2PolicySubjectAttribute{} - for _, attributesItem := range modelMap { - attribute := (attributesItem.(map[string]interface{}))["attributes"] - for _, item := range (attribute).([]interface{}) { - attributesItemModel := &iampolicymanagementv1.V2PolicySubjectAttribute{} - attributesItemModel.Key = core.StringPtr((item.((map[string]interface{}))["key"].(string))) - attributesItemModel.Operator = core.StringPtr(item.(map[string]interface{})["operator"].(string)) - attributesItemModel.Value = core.StringPtr(item.(map[string]interface{})["value"].(string)) - - attributes = append(attributes, *attributesItemModel) - } - } - model.Attributes = attributes return model, nil } @@ -486,34 +516,42 @@ func flattenTemplatePolicy(model *iampolicymanagementv1.TemplatePolicy, iamPolic if model.Description != nil { modelMap["description"] = model.Description } - resourceMap, roleList, err := flattenTemplatePolicyResource(model.Resource, iamPolicyManagementClient) - - if err != nil { - return nil, err - } - + var subjectMap map[string]interface{} + var err error + listRoleOptions := &iampolicymanagementv1.ListRolesOptions{} // Check subject details exists if model.Subject != nil { - subjectMap, err := flattenTemplatePolicySubject(model.Subject, iamPolicyManagementClient) + subjectMap, listRoleOptions, err = flattenTemplatePolicySubject(model.Subject, listRoleOptions) if err != nil { return nil, err } modelMap["subject"] = []map[string]interface{}{subjectMap} } - controlResponse := model.Control - policyRoles := flex.MapRolesToPolicyRoles(controlResponse.Grant.Roles) - roles := flex.MapRoleListToPolicyRoles(*roleList) - - roleNames := []string{} - for _, role := range policyRoles { - role, err := flex.FindRoleByCRN(roles, *role.RoleID) + if *model.Type == "authorization" { + listRoleOptions.SetPolicyType("authorization") + } + if model.Resource != nil { + resourceMap, roleList, err := flattenTemplatePolicyResource(model.Resource, listRoleOptions, iamPolicyManagementClient) if err != nil { return nil, err } - roleNames = append(roleNames, *role.DisplayName) + controlResponse := model.Control + policyRoles := flex.MapRolesToPolicyRoles(controlResponse.Grant.Roles) + + rolesWithCrn := flex.MapRoleListToPolicyRoles(*roleList) + roleNames := []string{} + for _, role := range policyRoles { + role, err := flex.FindRoleByCRN(rolesWithCrn, *role.RoleID) + if err != nil { + return nil, err + } + roleNames = append(roleNames, *role.DisplayName) + } + modelMap["resource"] = []map[string]interface{}{resourceMap} + modelMap["roles"] = roleNames } - modelMap["resource"] = []map[string]interface{}{resourceMap} + if model.Pattern != nil { modelMap["pattern"] = model.Pattern } @@ -523,16 +561,12 @@ func flattenTemplatePolicy(model *iampolicymanagementv1.TemplatePolicy, iamPolic modelMap["rule_operator"] = model.Rule.(*iampolicymanagementv1.V2PolicyRule).Operator } } - modelMap["roles"] = roleNames return modelMap, nil } -func flattenTemplatePolicyResource(model *iampolicymanagementv1.V2PolicyResource, - iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (map[string]interface{}, *iampolicymanagementv1.RoleCollection, error) { +func flattenTemplatePolicyResource(model *iampolicymanagementv1.V2PolicyResource, listRoleOptions *iampolicymanagementv1.ListRolesOptions, iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (map[string]interface{}, *iampolicymanagementv1.RoleCollection, error) { modelMap := make(map[string]interface{}) attributes := []map[string]interface{}{} - listRoleOptions := &iampolicymanagementv1.ListRolesOptions{} - var roles *iampolicymanagementv1.RoleCollection for _, attributesItem := range model.Attributes { if *attributesItem.Key == "serviceName" && @@ -550,17 +584,10 @@ func flattenTemplatePolicyResource(model *iampolicymanagementv1.V2PolicyResource *attributesItem.Operator == "stringEquals") { listRoleOptions.ServiceName = core.StringPtr("alliamserviceroles") } - - roleList, _, err := iamPolicyManagementClient.ListRoles(listRoleOptions) - roles = roleList - if err != nil { - return nil, nil, err - } attributesItemMap := make(map[string]interface{}) attributesItemMap["key"] = *attributesItem.Key attributesItemMap["operator"] = *attributesItem.Operator - attributesItemMap["value"] = *&attributesItem.Value - + attributesItemMap["value"] = fmt.Sprintf("%v", attributesItem.Value) attributes = append(attributes, attributesItemMap) } modelMap["attributes"] = attributes @@ -575,23 +602,27 @@ func flattenTemplatePolicyResource(model *iampolicymanagementv1.V2PolicyResource } modelMap["tags"] = tags } - return modelMap, roles, nil + roleList, _, err := iamPolicyManagementClient.ListRoles(listRoleOptions) + if err != nil { + return nil, nil, err + } + return modelMap, roleList, nil } -func flattenTemplatePolicySubject(model *iampolicymanagementv1.V2PolicySubject, - iamPolicyManagementClient *iampolicymanagementv1.IamPolicyManagementV1) (map[string]interface{}, error) { +func flattenTemplatePolicySubject(model *iampolicymanagementv1.V2PolicySubject, listRoleOptions *iampolicymanagementv1.ListRolesOptions) (map[string]interface{}, *iampolicymanagementv1.ListRolesOptions, error) { modelMap := make(map[string]interface{}) attributes := []map[string]interface{}{} - for _, attributesItem := range model.Attributes { attributesItemMap := make(map[string]interface{}) attributesItemMap["key"] = *attributesItem.Key attributesItemMap["operator"] = *attributesItem.Operator attributesItemMap["value"] = *&attributesItem.Value - + if *attributesItem.Key == "serviceName" { + listRoleOptions.SourceServiceName = core.StringPtr(fmt.Sprintf("%v", attributesItem.Value)) + } attributes = append(attributes, attributesItemMap) } modelMap["attributes"] = attributes - return modelMap, nil + return modelMap, listRoleOptions, nil } diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_template_test.go b/ibm/service/iampolicy/resource_ibm_iam_policy_template_test.go index 4106668c9a..65e82dae13 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_template_test.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_template_test.go @@ -44,6 +44,34 @@ func TestAccIBMIAMPolicyTemplateBasic(t *testing.T) { }) } +func TestAccIBMIAMPolicyTemplateBasicS2SUpdateTest(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPolicyTemplateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPolicyS2STemplateUpdateConfigBasicTest(name, "Service ID creator", "iam-identity", "secrets-manager"), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyTemplateExists("ibm_iam_policy_template.policy_template", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "name", name), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.resource.0.attributes.0.value", "iam-identity"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.subject.0.attributes.0.value", "secrets-manager"), + ), + }, + { + Config: testAccCheckIBMPolicyS2STemplateUpdateConfigBasicTest(name, "Operator", "iam-identity", "secrets-manager"), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyTemplateExists("ibm_iam_policy_template.policy_template", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "name", name), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.resource.0.attributes.0.value", "iam-identity"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.subject.0.attributes.0.value", "secrets-manager"), + ), + }, + }, + }) +} + func TestAccIBMIAMPolicyTemplateBasicUpdate(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -108,6 +136,23 @@ func TestAccIBMIAMPolicyTemplateBasicCommit(t *testing.T) { }) } +func TestAccIBMIAMPolicyTemplateBasicCommitWithPolicyType(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPolicyTemplateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPolicyTemplateConfigBasicTest(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyTemplateExists("ibm_iam_policy_template.policy_template", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "name", name), + ), + }, + }, + }) +} + func TestAccIBMIAMPolicyTemplateBasicS2S(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -127,6 +172,27 @@ func TestAccIBMIAMPolicyTemplateBasicS2S(t *testing.T) { }) } +func TestAccIBMIAMPolicyTemplateBasicS2STest(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPolicyTemplateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPolicyS2STemplateConfigBasicTest("TerraformS2STest", "is", "true", "is", "backup-policy"), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyTemplateExists("ibm_iam_policy_template.policy_template", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "name", "TerraformS2STest"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.resource.0.attributes.0.value", "is"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.resource.0.attributes.1.value", "true"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.subject.0.attributes.0.value", "is"), + resource.TestCheckResourceAttr("ibm_iam_policy_template.policy_template", "policy.0.subject.0.attributes.1.value", "backup-policy"), + ), + }, + }, + }) +} + func TestAccIBMIAMPolicyTemplateBasicS2SUpdate(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -241,6 +307,77 @@ func testAccCheckIBMPolicyTemplateConfigBasic(name string, serviceName string) s `, name, serviceName) } +func testAccCheckIBMPolicyS2STemplateUpdateConfigBasicTest(name string, role string, resourceServiceName string, subjectServiceName string) string { + return fmt.Sprintf(` + + resource "ibm_iam_policy_template" "policy_template" { + name = "%s" + policy { + description = "description" + roles = [ + "%s", + ] + type = "authorization" + + resource { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "%s" + } + } + + subject { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "%s" + } + } + } + } + `, name, role, resourceServiceName, subjectServiceName) +} + +func testAccCheckIBMPolicyS2STemplateConfigBasicTest(name string, sourceServiceName string, volumeId string, serviceName string, resourceServiceName string) string { + return fmt.Sprintf(` + + resource "ibm_iam_policy_template" "policy_template" { + name = "%s" + policy { + type = "authorization" + description = "Test terraform enterprise S2S" + resource { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "%s" + } + attributes { + key = "volumeId" + operator = "stringExists" + value = "%s" + } + } + subject { + attributes { + key = "serviceName" + operator = "stringEquals" + value = "%s" + } + attributes { + key = "resourceType" + operator = "stringEquals" + value = "%s" + } + } + roles = ["Operator"] + } + committed=true + } + `, name, sourceServiceName, volumeId, serviceName, resourceServiceName) +} + func testAccCheckIBMPolicyS2STemplateConfigBasic(name string, sourceServiceName string, resourceServiceName string) string { return fmt.Sprintf(` @@ -340,6 +477,19 @@ func testAccCheckIBMPolicyTemplateConfigBasicCommit(name string, serviceName str `, name, serviceName) } +func testAccCheckIBMPolicyTemplateConfigBasicTest(name string) string { + return fmt.Sprintf(` + + resource "ibm_iam_policy_template" "policy_template" { + name = "%s" + policy { + type = "access" + description = "description" + } + } + `, name) +} + func testAccCheckIBMPolicyTemplateConfigBasicWithTags(name string, serviceName string, tagValue string) string { return fmt.Sprintf(` diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_template_version.go b/ibm/service/iampolicy/resource_ibm_iam_policy_template_version.go index 7cd83aeac1..f13dbc5a13 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_template_version.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_template_version.go @@ -55,7 +55,7 @@ func ResourceIBMIAMPolicyTemplateVersion() *schema.Resource { Type: schema.TypeList, MinItems: 1, MaxItems: 1, - Required: true, + Optional: true, Description: "The resource attributes to which the policy grants access.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -206,7 +206,7 @@ func ResourceIBMIAMPolicyTemplateVersion() *schema.Resource { }, "roles": { Type: schema.TypeList, - Required: true, + Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, Description: "Role names of the policy definition", }, diff --git a/ibm/service/iampolicy/resource_ibm_iam_policy_template_version_test.go b/ibm/service/iampolicy/resource_ibm_iam_policy_template_version_test.go index 28de7a1be6..c12060b51d 100644 --- a/ibm/service/iampolicy/resource_ibm_iam_policy_template_version_test.go +++ b/ibm/service/iampolicy/resource_ibm_iam_policy_template_version_test.go @@ -36,6 +36,23 @@ func TestAccIBMIAMPolicyTemplateVersionBasic(t *testing.T) { }) } +func TestAccIBMIAMPolicyTemplateVersionBasicWithPolcyType(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPolicyTemplateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPolicyTemplateVersionConfigBasicWithPolicyType(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMPolicyTemplateExists("ibm_iam_policy_template.policy_template", conf), + resource.TestCheckResourceAttr("ibm_iam_policy_template_version.template_version", "name", name), + ), + }, + }, + }) +} + func TestAccIBMIAMPolicyTemplateVersionUpdateCommit(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -149,6 +166,27 @@ func testAccCheckIBMPolicyTemplateVersionConfigBasic(name string, serviceName st `, name, serviceName, updatedService) } +func testAccCheckIBMPolicyTemplateVersionConfigBasicWithPolicyType(name string) string { + return fmt.Sprintf(` + resource "ibm_iam_policy_template" "policy_template" { + name = "%s" + policy { + type = "access" + description = "description" + } + } + + resource "ibm_iam_policy_template_version" "template_version" { + template_id = ibm_iam_policy_template.policy_template.template_id + policy { + type = "access" + description = "template description" + } + description = "Template version" + } + `, name) +} + func testAccCheckIBMPolicyTemplateVersionUpdateCommit(name string, serviceName string, updatedService string) string { return fmt.Sprintf(` resource "ibm_iam_policy_template" "policy_template" { diff --git a/website/docs/d/iam_policy_assignment.html.markdown b/website/docs/d/iam_policy_assignment.html.markdown index 0d7af5d256..a309ddb4cf 100644 --- a/website/docs/d/iam_policy_assignment.html.markdown +++ b/website/docs/d/iam_policy_assignment.html.markdown @@ -36,16 +36,6 @@ Nested schema for **assignments**: * `id` - (String) Policy assignment ID. * `last_modified_at` - (String) The UTC timestamp when the policy assignment was last modified. * `last_modified_by_id` - (String) The iam ID of the entity that last modified the policy assignment. - * `options` - (Map) objects with required properties for a policy assignment. - Nested schema for **options**: - * `root` - (Map) Assignment root details - Nested schema for **root**: - * `requester_id` - (String) The policy assignment requester id. - * `assignment_id` - (String) The orchestrator assignment id. - * `template` - (Map) template details - Nested schema for **template**: - * `id` - (String) The policy assignment template id. - * `version` - (String) The orchestrator template version. * `resources` - (List) Object for each account assigned. * Constraints: The minimum length is `1` item. Nested schema for **resources**: diff --git a/website/docs/r/policy_assignment.html.markdown b/website/docs/r/policy_assignment.html.markdown index b8be035ad5..cea35cb8bc 100644 --- a/website/docs/r/policy_assignment.html.markdown +++ b/website/docs/r/policy_assignment.html.markdown @@ -67,12 +67,6 @@ resource "ibm_iam_policy_assignment" "policy_assignment" { id = "" } - options { - root { - requester_id = "orchestrator" - assignment_id = "test" - } - } templates{ id = ibm_iam_policy_template.policy_s2s_template.template_id version = ibm_iam_policy_template.policy_s2s_template.version @@ -89,25 +83,17 @@ You can specify the following arguments for this resource. * `accept_language` - (Optional, String) Language code for translations* `default` - English* `de` - German (Standard)* `en` - English* `es` - Spanish (Spain)* `fr` - French (Standard)* `it` - Italian (Standard)* `ja` - Japanese* `ko` - Korean* `pt-br` - Portuguese (Brazil)* `zh-cn` - Chinese (Simplified, PRC)* `zh-tw` - (Chinese, Taiwan). * Constraints: The default value is `default`. The minimum length is `1` character. -* `options` - (Required, List) The set of properties required for a policy assignment. -Nested schema for **options**: - * `root` - (Required, List) - Nested schema for **root**: - * `assignment_id` - (Optional, String) Passed in value to correlate with other assignments. - * Constraints: The maximum length is `122` characters. The minimum length is `1` character. - * `requester_id` - (Required, String) - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^((IBMid)|(iam-ServiceId)|(AccessGroupId)|(iam-Profile)|(SL)|([a-zA-Z0-9]{3,10}))-/`. - * `template` - (Optional, List) - Nested schema for **template**: - * `id` - (Required, String) The template id where this policy is being assigned from. - * Constraints: The maximum length is `300` characters. The minimum length is `1` character. - * `version` - (Required, String) The template version where this policy is being assigned from. - * Constraints: The maximum length is `2` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. +* `templates` - (Required, List) The set of properties required for a policy assignment. +Nested schema for **templates**: + * `id` - (Required, String) ID of the template. + * Constraints: The maximum length is `51` characters. The minimum length is `1` character. The value must match regular expression `/^policyTemplate-[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + * `version` - (Required, String) template version . + * Constraints: The maximum length is `2` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. * `target` - (Required, List) assignment target account and type. Nested schema for **target**: - * `id` - (Optional, String) ID of the target account. + * `id` - (Required, String) ID of the target account. * Constraints: The maximum length is `32` characters. The minimum length is `1` character. The value must match regular expression `/^[A-Za-z0-9-]*$/`. - * `type` - (Optional, String) Assignment target type. + * `type` - (Required, String) Assignment target type. * Constraints: Allowable values are: `Account`. The maximum length is `30` characters. The minimum length is `1` character. * `version` - (Required, String) specify version of response body format. * Constraints: Allowable values are: `1.0`. The minimum length is `1` character. From 3fd0f2e3e6c5cfecfd454e0d88c875b087d512e7 Mon Sep 17 00:00:00 2001 From: jaksart1 Date: Mon, 15 Jul 2024 05:26:33 -0400 Subject: [PATCH 23/25] Code Engine Provider and Documentation Update (#5347) * docs(all): Update documentation with the latest generation * Update proider with the latest generation * Bump sdk version --------- Co-authored-by: John Sartore --- go.mod | 2 +- go.sum | 2 + ibm/service/codeengine/README.md | 2 +- .../data_source_ibm_code_engine_app.go | 378 ++++++++--- .../data_source_ibm_code_engine_app_test.go | 8 +- .../data_source_ibm_code_engine_binding.go | 39 +- ...ata_source_ibm_code_engine_binding_test.go | 4 +- .../data_source_ibm_code_engine_build.go | 126 ++-- .../data_source_ibm_code_engine_config_map.go | 61 +- ...a_source_ibm_code_engine_domain_mapping.go | 110 ++-- ...rce_ibm_code_engine_domain_mapping_test.go | 19 +- .../data_source_ibm_code_engine_job.go | 179 +++-- .../data_source_ibm_code_engine_job_test.go | 14 + .../data_source_ibm_code_engine_project.go | 67 +- .../data_source_ibm_code_engine_secret.go | 206 ++++-- ...data_source_ibm_code_engine_secret_test.go | 7 +- .../resource_ibm_code_engine_app.go | 611 ++++++++++++------ .../resource_ibm_code_engine_app_test.go | 10 +- .../resource_ibm_code_engine_binding.go | 79 ++- .../resource_ibm_code_engine_binding_test.go | 4 +- .../resource_ibm_code_engine_build.go | 210 +++--- .../resource_ibm_code_engine_config_map.go | 124 ++-- ...resource_ibm_code_engine_domain_mapping.go | 169 ++--- ...rce_ibm_code_engine_domain_mapping_test.go | 37 +- .../resource_ibm_code_engine_job.go | 268 ++++---- .../resource_ibm_code_engine_job_test.go | 15 + .../resource_ibm_code_engine_project.go | 100 +-- .../resource_ibm_code_engine_project_test.go | 94 +++ .../resource_ibm_code_engine_secret.go | 302 +++++++-- .../resource_ibm_code_engine_secret_test.go | 9 +- website/docs/d/code_engine_app.html.markdown | 76 ++- .../docs/d/code_engine_binding.html.markdown | 10 +- .../docs/d/code_engine_build.html.markdown | 19 +- .../d/code_engine_config_map.html.markdown | 9 +- .../code_engine_domain_mapping.html.markdown | 23 +- website/docs/d/code_engine_job.html.markdown | 34 +- .../docs/d/code_engine_project.html.markdown | 16 +- .../docs/d/code_engine_secret.html.markdown | 43 +- website/docs/r/code_engine_app.html.markdown | 71 +- .../docs/r/code_engine_binding.html.markdown | 26 +- .../docs/r/code_engine_build.html.markdown | 39 +- .../r/code_engine_config_map.html.markdown | 28 +- .../code_engine_domain_mapping.html.markdown | 42 +- website/docs/r/code_engine_job.html.markdown | 34 +- .../docs/r/code_engine_project.html.markdown | 27 +- .../docs/r/code_engine_secret.html.markdown | 53 +- 46 files changed, 2563 insertions(+), 1243 deletions(-) diff --git a/go.mod b/go.mod index 3c217e3a20..9e3a441b9f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f github.com/IBM/cloud-databases-go-sdk v0.7.0 github.com/IBM/cloudant-go-sdk v0.0.43 - github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752 + github.com/IBM/code-engine-go-sdk v0.0.0-20240126185534-a6e054aa01ed github.com/IBM/container-registry-go-sdk v1.1.0 github.com/IBM/continuous-delivery-go-sdk v1.5.0 github.com/IBM/event-notifications-go-admin-sdk v0.6.1 diff --git a/go.sum b/go.sum index 8ad87a2ca0..e1c72557dc 100644 --- a/go.sum +++ b/go.sum @@ -134,6 +134,8 @@ github.com/IBM/cloudant-go-sdk v0.0.43 h1:YxTy4RpAEezX32YIWnds76hrBREmO4u6IkBz1W github.com/IBM/cloudant-go-sdk v0.0.43/go.mod h1:WeYrJPaHTw19943ndWnVfwMIlZ5z0XUM2uEXNBrwZ1M= github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752 h1:S5NT0aKKUqd9hnIrPN/qUijKx9cZjJi3kfFpog0ByDA= github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752/go.mod h1:noWxHQUgW9msjOrDpV17gnwWbTbUlSmWMGq7/Vi/n9I= +github.com/IBM/code-engine-go-sdk v0.0.0-20240126185534-a6e054aa01ed h1:X0VrZW5ulbqxbOmy5JoZcH0A+tw80k0/ZmRZz1NqogM= +github.com/IBM/code-engine-go-sdk v0.0.0-20240126185534-a6e054aa01ed/go.mod h1:m4pD/58c6NVzlAFkN3XCYXpmDFmUyTG31ivLy/loyHQ= github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTphE9Ag8ho28yXjc= github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs= github.com/IBM/continuous-delivery-go-sdk v1.5.0 h1:FHSRruNt9WK7SavpIVuV6N+xll90UgZsuQjZvQ+slB4= diff --git a/ibm/service/codeengine/README.md b/ibm/service/codeengine/README.md index e4283df92a..ba10429863 100644 --- a/ibm/service/codeengine/README.md +++ b/ibm/service/codeengine/README.md @@ -8,4 +8,4 @@ This area is primarily for IBM provider contributors and maintainers. For inform * IBM Provider Docs: [Home](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs) * IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/code_engine_app) * IBM API Docs: [IBM API Docs for ]() -* IBM SDK: [IBM SDK for ](https://github.com/IBM/code-engine-go-sdk/tree/main/codeenginev2) +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/codeenginev2) diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_app.go b/ibm/service/codeengine/data_source_ibm_code_engine_app.go index 216d104e3c..91370052c2 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_app.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_app.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -21,72 +21,175 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { ReadContext: dataSourceIbmCodeEngineAppRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your application.", }, - "created_at": &schema.Schema{ + "build": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build that is associated with the application.", + }, + "build_run": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build run that is associated with the application.", + }, + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "endpoint": &schema.Schema{ + "endpoint": { Type: schema.TypeString, Computed: true, - Description: "Optional URL to invoke app. Depending on visibility this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'.", + Description: "Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'.", }, - "endpoint_internal": &schema.Schema{ + "endpoint_internal": { Type: schema.TypeString, Computed: true, - Description: "URL to app that is only visible within the project.", + Description: "The URL to the app that is only visible within the project.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the app instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new app, a URL is created identifying the location of the instance.", }, - "app_id": &schema.Schema{ + "app_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "image_port": &schema.Schema{ + "image_port": { Type: schema.TypeInt, Computed: true, Description: "Optional port the app listens on. While the app will always be exposed via port `443` for end users, this port is used to connect to the port that is exposed by the container image.", }, - "image_reference": &schema.Schema{ + "image_reference": { Type: schema.TypeString, Computed: true, Description: "The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`.", }, - "image_secret": &schema.Schema{ + "image_secret": { Type: schema.TypeString, Computed: true, Description: "Optional name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the app will be created but cannot reach the ready status, until this property is provided, too.", }, - "managed_domain_mappings": &schema.Schema{ + "managed_domain_mappings": { Type: schema.TypeString, Computed: true, Description: "Optional value controlling which of the system managed domain mappings will be setup for the application. Valid values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports application private visibility.", }, - "resource_type": &schema.Schema{ + "probe_liveness": { + Type: schema.TypeList, + Computed: true, + Description: "Response model for probes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failure_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "The number of consecutive, unsuccessful checks for the probe to be considered failed.", + }, + "initial_delay": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds to wait before the first probe check is performed.", + }, + "interval": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds between probe checks.", + }, + "path": { + Type: schema.TypeString, + Computed: true, + Description: "The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`.", + }, + "port": { + Type: schema.TypeInt, + Computed: true, + Description: "The port on which to probe the resource.", + }, + "timeout": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds that the probe waits for a response from the application before it times out and fails.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specifies whether to use HTTP or TCP for the probe checks. The default is TCP.", + }, + }, + }, + }, + "probe_readiness": { + Type: schema.TypeList, + Computed: true, + Description: "Response model for probes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failure_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "The number of consecutive, unsuccessful checks for the probe to be considered failed.", + }, + "initial_delay": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds to wait before the first probe check is performed.", + }, + "interval": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds between probe checks.", + }, + "path": { + Type: schema.TypeString, + Computed: true, + Description: "The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`.", + }, + "port": { + Type: schema.TypeInt, + Computed: true, + Description: "The port on which to probe the resource.", + }, + "timeout": { + Type: schema.TypeInt, + Computed: true, + Description: "The amount of time in seconds that the probe waits for a response from the application before it times out and fails.", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Specifies whether to use HTTP or TCP for the probe checks. The default is TCP.", + }, + }, + }, + }, + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the app.", }, - "run_arguments": &schema.Schema{ + "run_arguments": { Type: schema.TypeList, Computed: true, Description: "Optional arguments for the app that are passed to start the container. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container.", @@ -94,12 +197,12 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { Type: schema.TypeString, }, }, - "run_as_user": &schema.Schema{ + "run_as_user": { Type: schema.TypeInt, Computed: true, - Description: "Optional user ID (UID) to run the app (e.g., `1001`).", + Description: "Optional user ID (UID) to run the app.", }, - "run_commands": &schema.Schema{ + "run_commands": { Type: schema.TypeList, Computed: true, Description: "Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container.", @@ -107,38 +210,38 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { Type: schema.TypeString, }, }, - "run_env_variables": &schema.Schema{ + "run_env_variables": { Type: schema.TypeList, Computed: true, Description: "References to config maps, secrets or literal values, which are exposed as environment variables in the application.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "key": &schema.Schema{ + "key": { Type: schema.TypeString, Computed: true, Description: "The key to reference as environment variable.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the environment variable.", }, - "prefix": &schema.Schema{ + "prefix": { Type: schema.TypeString, Computed: true, Description: "A prefix that can be added to all keys of a full secret or config map reference.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Computed: true, Description: "The name of the secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Computed: true, Description: "Specify the type of the environment variable.", }, - "value": &schema.Schema{ + "value": { Type: schema.TypeString, Computed: true, Description: "The literal value of the environment variable.", @@ -146,33 +249,33 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { }, }, }, - "run_service_account": &schema.Schema{ + "run_service_account": { Type: schema.TypeString, Computed: true, Description: "Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , `none`, `reader`, and `writer`.", }, - "run_volume_mounts": &schema.Schema{ + "run_volume_mounts": { Type: schema.TypeList, Computed: true, Description: "Mounts of config maps or secrets.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "mount_path": &schema.Schema{ + "mount_path": { Type: schema.TypeString, Computed: true, Description: "The path that should be mounted.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the mount.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Computed: true, Description: "The name of the referenced secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Computed: true, Description: "Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'.", @@ -180,73 +283,78 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { }, }, }, - "scale_concurrency": &schema.Schema{ + "scale_concurrency": { Type: schema.TypeInt, Computed: true, Description: "Optional maximum number of requests that can be processed concurrently per instance.", }, - "scale_concurrency_target": &schema.Schema{ + "scale_concurrency_target": { Type: schema.TypeInt, Computed: true, Description: "Optional threshold of concurrent requests per instance at which one or more additional instances are created. Use this value to scale up instances based on concurrent number of requests. This option defaults to the value of the `scale_concurrency` option, if not specified.", }, - "scale_cpu_limit": &schema.Schema{ + "scale_cpu_limit": { Type: schema.TypeString, Computed: true, Description: "Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo).", }, - "scale_ephemeral_storage_limit": &schema.Schema{ + "scale_down_delay": { + Type: schema.TypeInt, + Computed: true, + Description: "Optional amount of time in seconds that delays the scale-down behavior for an app instance.", + }, + "scale_ephemeral_storage_limit": { Type: schema.TypeString, Computed: true, Description: "Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_initial_instances": &schema.Schema{ + "scale_initial_instances": { Type: schema.TypeInt, Computed: true, Description: "Optional initial number of instances that are created upon app creation or app update.", }, - "scale_max_instances": &schema.Schema{ + "scale_max_instances": { Type: schema.TypeInt, Computed: true, Description: "Optional maximum number of instances for this app. If you set this value to `0`, this property does not set a upper scaling limit. However, the app scaling is still limited by the project quota for instances. See [Limits and quotas for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits).", }, - "scale_memory_limit": &schema.Schema{ + "scale_memory_limit": { Type: schema.TypeString, Computed: true, Description: "Optional amount of memory set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_min_instances": &schema.Schema{ + "scale_min_instances": { Type: schema.TypeInt, Computed: true, Description: "Optional minimum number of instances for this app. If you set this value to `0`, the app will scale down to zero, if not hit by any request for some time.", }, - "scale_request_timeout": &schema.Schema{ + "scale_request_timeout": { Type: schema.TypeInt, Computed: true, Description: "Optional amount of time in seconds that is allowed for a running app to respond to a request.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the app.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the application.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "latest_created_revision": &schema.Schema{ + "latest_created_revision": { Type: schema.TypeString, Computed: true, Description: "Latest app revision that has been created.", }, - "latest_ready_revision": &schema.Schema{ + "latest_ready_revision": { Type: schema.TypeString, Computed: true, Description: "Latest app revision that reached a ready state.", }, - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -261,7 +369,9 @@ func DataSourceIbmCodeEngineApp() *schema.Resource { func dataSourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAppOptions := &codeenginev2.GetAppOptions{} @@ -269,149 +379,253 @@ func dataSourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceD getAppOptions.SetProjectID(d.Get("project_id").(string)) getAppOptions.SetName(d.Get("name").(string)) - app, response, err := codeEngineClient.GetAppWithContext(context, getAppOptions) + app, _, err := codeEngineClient.GetAppWithContext(context, getAppOptions) if err != nil { - log.Printf("[DEBUG] GetAppWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetAppWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetAppWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_app", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getAppOptions.ProjectID, *getAppOptions.Name)) + if err = d.Set("build", app.Build); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting build: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + + if err = d.Set("build_run", app.BuildRun); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting build_run: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + if err = d.Set("created_at", app.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("endpoint", app.Endpoint); err != nil { - return diag.FromErr(fmt.Errorf("Error setting endpoint: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting endpoint: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("endpoint_internal", app.EndpointInternal); err != nil { - return diag.FromErr(fmt.Errorf("Error setting endpoint_internal: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting endpoint_internal: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("entity_tag", app.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting entity_tag: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("href", app.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("app_id", app.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting app_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting app_id: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("image_port", flex.IntValue(app.ImagePort)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_port: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting image_port: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("image_reference", app.ImageReference); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_reference: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting image_reference: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("image_secret", app.ImageSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_secret: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting image_secret: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("managed_domain_mappings", app.ManagedDomainMappings); err != nil { - return diag.FromErr(fmt.Errorf("Error setting managed_domain_mappings: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting managed_domain_mappings: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + + probeLiveness := []map[string]interface{}{} + if app.ProbeLiveness != nil { + modelMap, err := dataSourceIbmCodeEngineAppProbeToMap(app.ProbeLiveness) + if err != nil { + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + probeLiveness = append(probeLiveness, modelMap) + } + if err = d.Set("probe_liveness", probeLiveness); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting probe_liveness: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + + probeReadiness := []map[string]interface{}{} + if app.ProbeReadiness != nil { + modelMap, err := dataSourceIbmCodeEngineAppProbeToMap(app.ProbeReadiness) + if err != nil { + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + probeReadiness = append(probeReadiness, modelMap) + } + if err = d.Set("probe_readiness", probeReadiness); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting probe_readiness: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", app.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", app.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("run_as_user", flex.IntValue(app.RunAsUser)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_as_user: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_as_user: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } runEnvVariables := []map[string]interface{}{} if app.RunEnvVariables != nil { for _, modelItem := range app.RunEnvVariables { - modelMap, err := dataSourceIbmCodeEngineAppEnvVarToMap(&modelItem) + modelMap, err := dataSourceIbmCodeEngineAppEnvVarToMap(&modelItem) /* #nosec G601 */ if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } runEnvVariables = append(runEnvVariables, modelMap) } } if err = d.Set("run_env_variables", runEnvVariables); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_env_variables %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_env_variables: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("run_service_account", app.RunServiceAccount); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_service_account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_service_account: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } runVolumeMounts := []map[string]interface{}{} if app.RunVolumeMounts != nil { for _, modelItem := range app.RunVolumeMounts { - modelMap, err := dataSourceIbmCodeEngineAppVolumeMountToMap(&modelItem) + modelMap, err := dataSourceIbmCodeEngineAppVolumeMountToMap(&modelItem) /* #nosec G601 */ if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } runVolumeMounts = append(runVolumeMounts, modelMap) } } if err = d.Set("run_volume_mounts", runVolumeMounts); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_volume_mounts %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_volume_mounts: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_concurrency", flex.IntValue(app.ScaleConcurrency)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_concurrency: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_concurrency: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_concurrency_target", flex.IntValue(app.ScaleConcurrencyTarget)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_concurrency_target: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_concurrency_target: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_cpu_limit", app.ScaleCpuLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_cpu_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_cpu_limit: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() + } + + if err = d.Set("scale_down_delay", flex.IntValue(app.ScaleDownDelay)); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_down_delay: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_ephemeral_storage_limit", app.ScaleEphemeralStorageLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_ephemeral_storage_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_ephemeral_storage_limit: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_initial_instances", flex.IntValue(app.ScaleInitialInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_initial_instances: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_initial_instances: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_max_instances", flex.IntValue(app.ScaleMaxInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_max_instances: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_max_instances: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_memory_limit", app.ScaleMemoryLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_memory_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_memory_limit: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_min_instances", flex.IntValue(app.ScaleMinInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_min_instances: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_min_instances: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("scale_request_timeout", flex.IntValue(app.ScaleRequestTimeout)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_request_timeout: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_request_timeout: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } if err = d.Set("status", app.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } statusDetails := []map[string]interface{}{} if app.StatusDetails != nil { modelMap, err := dataSourceIbmCodeEngineAppAppStatusToMap(app.StatusDetails) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } statusDetails = append(statusDetails, modelMap) } if err = d.Set("status_details", statusDetails); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status_details: %s", err), "(Data) ibm_code_engine_app", "read") + return tfErr.GetDiag() } return nil } +func dataSourceIbmCodeEngineAppProbeToMap(model *codeenginev2.Probe) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.FailureThreshold != nil { + modelMap["failure_threshold"] = flex.IntValue(model.FailureThreshold) + } + if model.InitialDelay != nil { + modelMap["initial_delay"] = flex.IntValue(model.InitialDelay) + } + if model.Interval != nil { + modelMap["interval"] = flex.IntValue(model.Interval) + } + if model.Path != nil { + modelMap["path"] = model.Path + } + if model.Port != nil { + modelMap["port"] = flex.IntValue(model.Port) + } + if model.Timeout != nil { + modelMap["timeout"] = flex.IntValue(model.Timeout) + } + if model.Type != nil { + modelMap["type"] = model.Type + } + return modelMap, nil +} + func dataSourceIbmCodeEngineAppEnvVarToMap(model *codeenginev2.EnvVar) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Key != nil { diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go index d919b89272..9410a51e3b 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_app_test.go @@ -109,7 +109,9 @@ func testAccCheckIbmCodeEngineAppDataSourceConfigBasic(projectID string, appImag lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } @@ -153,7 +155,9 @@ func testAccCheckIbmCodeEngineAppDataSourceConfig(projectID string, appImageRefe lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_binding.go b/ibm/service/codeengine/data_source_ibm_code_engine_binding.go index 88f358b0ba..bd51ae770b 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_binding.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_binding.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/code-engine-go-sdk/codeenginev2" ) @@ -57,7 +58,7 @@ func DataSourceIbmCodeEngineBinding() *schema.Resource { "prefix": { Type: schema.TypeString, Computed: true, - Description: "The value that is set as prefix in the component that is bound.", + Description: "The value that is set as a prefix in the component that is bound.", }, "resource_type": { Type: schema.TypeString, @@ -81,7 +82,9 @@ func DataSourceIbmCodeEngineBinding() *schema.Resource { func dataSourceIbmCodeEngineBindingRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_binding", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getBindingOptions := &codeenginev2.GetBindingOptions{} @@ -89,10 +92,11 @@ func dataSourceIbmCodeEngineBindingRead(context context.Context, d *schema.Resou getBindingOptions.SetProjectID(d.Get("project_id").(string)) getBindingOptions.SetID(d.Get("binding_id").(string)) - binding, response, err := codeEngineClient.GetBindingWithContext(context, getBindingOptions) + binding, _, err := codeEngineClient.GetBindingWithContext(context, getBindingOptions) if err != nil { - log.Printf("[DEBUG] GetBindingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetBindingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetBindingWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_binding", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getBindingOptions.ProjectID, *getBindingOptions.ID)) @@ -101,34 +105,39 @@ func dataSourceIbmCodeEngineBindingRead(context context.Context, d *schema.Resou if binding.Component != nil { modelMap, err := dataSourceIbmCodeEngineBindingComponentRefToMap(binding.Component) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } component = append(component, modelMap) } - - errString := "Error setting %s %s" if err = d.Set("component", component); err != nil { - return diag.FromErr(fmt.Errorf(errString, "component", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting component: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } if err = d.Set("href", binding.Href); err != nil { - return diag.FromErr(fmt.Errorf(errString, "href", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } if err = d.Set("prefix", binding.Prefix); err != nil { - return diag.FromErr(fmt.Errorf(errString, "prefix", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting prefix: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", binding.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf(errString, "resource_type", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } if err = d.Set("secret_name", binding.SecretName); err != nil { - return diag.FromErr(fmt.Errorf(errString, "secret_name", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting secret_name: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } if err = d.Set("status", binding.Status); err != nil { - return diag.FromErr(fmt.Errorf(errString, "status", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status: %s", err), "(Data) ibm_code_engine_binding", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go index 6309ec2221..0caab6d1c7 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_binding_test.go @@ -57,7 +57,9 @@ func testAccCheckIbmCodeEngineBindingDataSourceConfigBasic(projectID string, app lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_build.go b/ibm/service/codeengine/data_source_ibm_code_engine_build.go index 8d21289d6d..8fb5e96ffe 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_build.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_build.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -21,88 +21,93 @@ func DataSourceIbmCodeEngineBuild() *schema.Resource { ReadContext: dataSourceIbmCodeEngineBuildRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your build.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the build instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new build, a URL is created identifying the location of the instance.", }, - "build_id": &schema.Schema{ + "build_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "output_image": &schema.Schema{ + "output_image": { Type: schema.TypeString, Computed: true, Description: "The name of the image.", }, - "output_secret": &schema.Schema{ + "output_secret": { Type: schema.TypeString, Computed: true, Description: "The secret that is required to access the image registry. Make sure that the secret is granted with push permissions towards the specified container registry namespace.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the build.", }, - "source_context_dir": &schema.Schema{ + "source_context_dir": { Type: schema.TypeString, Computed: true, - Description: "Option directory in the repository that contains the buildpacks file or the Dockerfile.", + Description: "Optional directory in the repository that contains the buildpacks file or the Dockerfile.", }, - "source_revision": &schema.Schema{ + "source_revision": { Type: schema.TypeString, Computed: true, Description: "Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and uses the HEAD of default branch if not specified. If the `source_type` value is `local`, this field must be omitted.", }, - "source_secret": &schema.Schema{ + "source_secret": { Type: schema.TypeString, Computed: true, Description: "Name of the secret that is used access the repository source. This field is optional if the `source_type` is `git`. Additionally, if the `source_url` points to a repository that requires authentication, the build will be created but cannot access any source code, until this property is provided, too. If the `source_type` value is `local`, this field must be omitted.", }, - "source_type": &schema.Schema{ + "source_type": { Type: schema.TypeString, Computed: true, Description: "Specifies the type of source to determine if your build source is in a repository or based on local source code.* local - For builds from local source code.* git - For builds from git version controlled source code.", }, - "source_url": &schema.Schema{ + "source_url": { Type: schema.TypeString, Computed: true, Description: "The URL of the code repository. This field is required if the `source_type` is `git`. If the `source_type` value is `local`, this field must be omitted. If the repository is publicly available you can provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the repository requires authentication, you need to provide a 'ssh' URL like `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to a secret of format `ssh_auth`.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the build.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the build.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -110,22 +115,22 @@ func DataSourceIbmCodeEngineBuild() *schema.Resource { }, }, }, - "strategy_size": &schema.Schema{ + "strategy_size": { Type: schema.TypeString, Computed: true, - Description: "Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`.", + Description: "Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`.", }, - "strategy_spec_file": &schema.Schema{ + "strategy_spec_file": { Type: schema.TypeString, Computed: true, Description: "Optional path to the specification file that is used for build strategies for building an image.", }, - "strategy_type": &schema.Schema{ + "strategy_type": { Type: schema.TypeString, Computed: true, Description: "The strategy to use for building the image.", }, - "timeout": &schema.Schema{ + "timeout": { Type: schema.TypeInt, Computed: true, Description: "The maximum amount of time, in seconds, that can pass before the build must succeed or fail.", @@ -137,7 +142,9 @@ func DataSourceIbmCodeEngineBuild() *schema.Resource { func dataSourceIbmCodeEngineBuildRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_build", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getBuildOptions := &codeenginev2.GetBuildOptions{} @@ -145,92 +152,117 @@ func dataSourceIbmCodeEngineBuildRead(context context.Context, d *schema.Resourc getBuildOptions.SetProjectID(d.Get("project_id").(string)) getBuildOptions.SetName(d.Get("name").(string)) - build, response, err := codeEngineClient.GetBuildWithContext(context, getBuildOptions) + build, _, err := codeEngineClient.GetBuildWithContext(context, getBuildOptions) if err != nil { - log.Printf("[DEBUG] GetBuildWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetBuildWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetBuildWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_build", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getBuildOptions.ProjectID, *getBuildOptions.Name)) if err = d.Set("created_at", build.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("entity_tag", build.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting entity_tag: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("href", build.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("build_id", build.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting build_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting build_id: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("output_image", build.OutputImage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output_image: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting output_image: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("output_secret", build.OutputSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output_secret: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting output_secret: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", build.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", build.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("source_context_dir", build.SourceContextDir); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_context_dir: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting source_context_dir: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("source_revision", build.SourceRevision); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_revision: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting source_revision: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("source_secret", build.SourceSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_secret: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting source_secret: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("source_type", build.SourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting source_type: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("source_url", build.SourceURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_url: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting source_url: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("status", build.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } statusDetails := []map[string]interface{}{} if build.StatusDetails != nil { modelMap, err := dataSourceIbmCodeEngineBuildBuildStatusToMap(build.StatusDetails) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } statusDetails = append(statusDetails, modelMap) } if err = d.Set("status_details", statusDetails); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status_details: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("strategy_size", build.StrategySize); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_size: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting strategy_size: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("strategy_spec_file", build.StrategySpecFile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_spec_file: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting strategy_spec_file: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("strategy_type", build.StrategyType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting strategy_type: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } if err = d.Set("timeout", flex.IntValue(build.Timeout)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting timeout: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting timeout: %s", err), "(Data) ibm_code_engine_build", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_config_map.go b/ibm/service/codeengine/data_source_ibm_code_engine_config_map.go index c8cb9ffcd2..0a15bc7cd6 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_config_map.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_config_map.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/code-engine-go-sdk/codeenginev2" ) @@ -20,22 +21,22 @@ func DataSourceIbmCodeEngineConfigMap() *schema.Resource { ReadContext: dataSourceIbmCodeEngineConfigMapRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your configmap.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "data": &schema.Schema{ + "data": { Type: schema.TypeMap, Computed: true, Description: "The key-value pair for the config map. Values must be specified in `KEY=VALUE` format.", @@ -43,22 +44,27 @@ func DataSourceIbmCodeEngineConfigMap() *schema.Resource { Type: schema.TypeString, }, }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the config map instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new config map, a URL is created identifying the location of the instance.", }, - "config_map_id": &schema.Schema{ + "config_map_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the config map.", @@ -70,7 +76,9 @@ func DataSourceIbmCodeEngineConfigMap() *schema.Resource { func dataSourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_config_map", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getConfigMapOptions := &codeenginev2.GetConfigMapOptions{} @@ -78,41 +86,54 @@ func dataSourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.Res getConfigMapOptions.SetProjectID(d.Get("project_id").(string)) getConfigMapOptions.SetName(d.Get("name").(string)) - configMap, response, err := codeEngineClient.GetConfigMapWithContext(context, getConfigMapOptions) + configMap, _, err := codeEngineClient.GetConfigMapWithContext(context, getConfigMapOptions) if err != nil { - log.Printf("[DEBUG] GetConfigMapWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetConfigMapWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetConfigMapWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_config_map", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getConfigMapOptions.ProjectID, *getConfigMapOptions.Name)) if err = d.Set("created_at", configMap.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting created_at: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } if configMap.Data != nil { if err = d.Set("data", configMap.Data); err != nil { - return diag.FromErr(fmt.Errorf("Error setting data: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting data: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } if err != nil { - return diag.FromErr(fmt.Errorf("Error setting data %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting data: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } } if err = d.Set("entity_tag", configMap.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting entity_tag: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } if err = d.Set("href", configMap.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting href: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", configMap.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting region: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } if err = d.Set("config_map_id", configMap.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting config_map_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting config_map_id: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", configMap.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("error setting resource_type: %s", err), "(Data) ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping.go b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping.go index af313eb1fd..b9f611fc69 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/code-engine-go-sdk/codeenginev2" ) @@ -20,33 +21,33 @@ func DataSourceIbmCodeEngineDomainMapping() *schema.Resource { ReadContext: dataSourceIbmCodeEngineDomainMappingRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your domain mapping.", }, - "cname_target": &schema.Schema{ + "cname_target": { Type: schema.TypeString, Computed: true, - Description: "Exposes the value of the CNAME record that needs to be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region.", + Description: "The value of the CNAME record that must be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region.", }, - "component": &schema.Schema{ + "component": { Type: schema.TypeList, Computed: true, Description: "A reference to another component.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the referenced component.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the referenced resource.", @@ -54,43 +55,48 @@ func DataSourceIbmCodeEngineDomainMapping() *schema.Resource { }, }, }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "domain_mapping_id": &schema.Schema{ + "domain_mapping_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the domain mapping instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new domain mapping, a URL is created identifying the location of the instance.", }, - "resource_type": &schema.Schema{ + "region": { Type: schema.TypeString, Computed: true, - Description: "The type of the CE Resource.", + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", }, - "status": &schema.Schema{ + "resource_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of the Code Engine resource.", + }, + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the domain mapping.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the domain mapping.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -98,20 +104,20 @@ func DataSourceIbmCodeEngineDomainMapping() *schema.Resource { }, }, }, - "tls_secret": &schema.Schema{ + "tls_secret": { Type: schema.TypeString, Computed: true, - Description: "The name of the TLS secret that holds the certificate and private key of this domain mapping.", + Description: "The name of the TLS secret that includes the certificate and private key of this domain mapping.", }, - "user_managed": &schema.Schema{ + "user_managed": { Type: schema.TypeBool, Computed: true, - Description: "Exposes whether the domain mapping is managed by the user or by Code Engine.", + Description: "Specifies whether the domain mapping is managed by the user or by Code Engine.", }, - "visibility": &schema.Schema{ + "visibility": { Type: schema.TypeString, Computed: true, - Description: "Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project.", + Description: "Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project.", }, }, } @@ -120,7 +126,9 @@ func DataSourceIbmCodeEngineDomainMapping() *schema.Resource { func dataSourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_domain_mapping", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getDomainMappingOptions := &codeenginev2.GetDomainMappingOptions{} @@ -128,76 +136,96 @@ func dataSourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema getDomainMappingOptions.SetProjectID(d.Get("project_id").(string)) getDomainMappingOptions.SetName(d.Get("name").(string)) - domainMapping, response, err := codeEngineClient.GetDomainMappingWithContext(context, getDomainMappingOptions) + domainMapping, _, err := codeEngineClient.GetDomainMappingWithContext(context, getDomainMappingOptions) if err != nil { - log.Printf("[DEBUG] GetDomainMappingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetDomainMappingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetDomainMappingWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_domain_mapping", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getDomainMappingOptions.ProjectID, *getDomainMappingOptions.Name)) if err = d.Set("cname_target", domainMapping.CnameTarget); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cname_target: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting cname_target: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } component := []map[string]interface{}{} if domainMapping.Component != nil { modelMap, err := dataSourceIbmCodeEngineDomainMappingComponentRefToMap(domainMapping.Component) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } component = append(component, modelMap) } if err = d.Set("component", component); err != nil { - return diag.FromErr(fmt.Errorf("Error setting component %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting component: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("created_at", domainMapping.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("entity_tag", domainMapping.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting entity_tag: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("href", domainMapping.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("domain_mapping_id", domainMapping.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting domain_mapping_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting domain_mapping_id: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", domainMapping.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", domainMapping.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("status", domainMapping.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } statusDetails := []map[string]interface{}{} if domainMapping.StatusDetails != nil { modelMap, err := dataSourceIbmCodeEngineDomainMappingDomainMappingStatusToMap(domainMapping.StatusDetails) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } statusDetails = append(statusDetails, modelMap) } if err = d.Set("status_details", statusDetails); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status_details: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("tls_secret", domainMapping.TlsSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tls_secret: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting tls_secret: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("user_managed", domainMapping.UserManaged); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_managed: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting user_managed: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } if err = d.Set("visibility", domainMapping.Visibility); err != nil { - return diag.FromErr(fmt.Errorf("Error setting visibility: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting visibility: %s", err), "(Data) ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go index 9a852e3f14..8c71886b34 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_domain_mapping_test.go @@ -5,9 +5,10 @@ package codeengine_test import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "os" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" @@ -19,15 +20,15 @@ func TestAccIbmCodeEngineDomainMappingDataSourceBasic(t *testing.T) { projectID := acc.CeProjectId domainMappingName := acc.CeDomainMappingName - domainMappingTLSKey := decodeBase64EnvVar(acc.CeTLSKey, CeTlsKey) - domainMappingTLSCert := decodeBase64EnvVar(acc.CeTLSCert, CeTlsCert) + domainMappingTLSKey, _ := os.ReadFile(acc.CeTLSKeyFilePath) + domainMappingTLSCert, _ := os.ReadFile(acc.CeTLSCertFilePath) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheckCodeEngine(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID, appName, domainMappingTLSKey, domainMappingTLSCert, secretName, domainMappingName), + { + Config: testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID, appName, string(domainMappingTLSKey), string(domainMappingTLSCert), secretName, domainMappingName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", "href"), @@ -47,7 +48,7 @@ func TestAccIbmCodeEngineDomainMappingDataSourceBasic(t *testing.T) { }) } -func testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID string, appName string, tlsKey string, tslCert string, secretName string, domainMappingName string) string { +func testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID string, appName string, tlsKey string, tlsCert string, secretName string, domainMappingName string) string { return fmt.Sprintf(` data "ibm_code_engine_project" "code_engine_project_instance" { project_id = "%s" @@ -60,7 +61,9 @@ func testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID strin lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } @@ -103,5 +106,5 @@ EOT name = ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance.name } - `, projectID, appName, tlsKey, tslCert, secretName, domainMappingName) + `, projectID, appName, tlsKey, tlsCert, secretName, domainMappingName) } diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_job.go b/ibm/service/codeengine/data_source_ibm_code_engine_job.go index 6182556bb5..798c5eefb5 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_job.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_job.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -21,52 +21,67 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { ReadContext: dataSourceIbmCodeEngineJobRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your job.", }, - "created_at": &schema.Schema{ + "build": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build that is associated with the job.", + }, + "build_run": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build run that is associated with the job.", + }, + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the job instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new job, a URL is created identifying the location of the instance.", }, - "job_id": &schema.Schema{ + "job_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "image_reference": &schema.Schema{ + "image_reference": { Type: schema.TypeString, Computed: true, Description: "The name of the image that is used for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`.", }, - "image_secret": &schema.Schema{ + "image_secret": { Type: schema.TypeString, Computed: true, Description: "The name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the job / job runs will be created but submitted job runs will fail, until this property is provided, too. This property must not be set on a job run, which references a job template.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the job.", }, - "run_arguments": &schema.Schema{ + "run_arguments": { Type: schema.TypeList, Computed: true, Description: "Set arguments for the job that are passed to start job run containers. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container.", @@ -74,12 +89,12 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { Type: schema.TypeString, }, }, - "run_as_user": &schema.Schema{ + "run_as_user": { Type: schema.TypeInt, Computed: true, - Description: "The user ID (UID) to run the job (e.g., 1001).", + Description: "The user ID (UID) to run the job.", }, - "run_commands": &schema.Schema{ + "run_commands": { Type: schema.TypeList, Computed: true, Description: "Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container.", @@ -87,38 +102,38 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { Type: schema.TypeString, }, }, - "run_env_variables": &schema.Schema{ + "run_env_variables": { Type: schema.TypeList, Computed: true, Description: "References to config maps, secrets or literal values, which are exposed as environment variables in the job run.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "key": &schema.Schema{ + "key": { Type: schema.TypeString, Computed: true, Description: "The key to reference as environment variable.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the environment variable.", }, - "prefix": &schema.Schema{ + "prefix": { Type: schema.TypeString, Computed: true, Description: "A prefix that can be added to all keys of a full secret or config map reference.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Computed: true, Description: "The name of the secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Computed: true, Description: "Specify the type of the environment variable.", }, - "value": &schema.Schema{ + "value": { Type: schema.TypeString, Computed: true, Description: "The literal value of the environment variable.", @@ -126,38 +141,38 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { }, }, }, - "run_mode": &schema.Schema{ + "run_mode": { Type: schema.TypeString, Computed: true, - Description: "The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `scale_max_execution_time` and `scale_retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `scale_max_execution_time` and `scale_retry_limit` properties are not allowed.", + Description: "The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed.", }, - "run_service_account": &schema.Schema{ + "run_service_account": { Type: schema.TypeString, Computed: true, Description: "The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, `reader`, and `writer`. This property must not be set on a job run, which references a job template.", }, - "run_volume_mounts": &schema.Schema{ + "run_volume_mounts": { Type: schema.TypeList, Computed: true, - Description: "Optional mounts of config maps or a secrets.", + Description: "Optional mounts of config maps or secrets.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "mount_path": &schema.Schema{ + "mount_path": { Type: schema.TypeString, Computed: true, Description: "The path that should be mounted.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the mount.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Computed: true, Description: "The name of the referenced secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Computed: true, Description: "Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'.", @@ -165,32 +180,32 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { }, }, }, - "scale_array_spec": &schema.Schema{ + "scale_array_spec": { Type: schema.TypeString, Computed: true, - Description: "Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of unique array indices specified here determines the number of job instances to run.", + Description: "Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number of unique array indices that you specify with this parameter determines the number of job instances to run.", }, - "scale_cpu_limit": &schema.Schema{ + "scale_cpu_limit": { Type: schema.TypeString, Computed: true, Description: "Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo).", }, - "scale_ephemeral_storage_limit": &schema.Schema{ + "scale_ephemeral_storage_limit": { Type: schema.TypeString, Computed: true, Description: "Optional amount of ephemeral storage to set for the instance of the job. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_max_execution_time": &schema.Schema{ + "scale_max_execution_time": { Type: schema.TypeInt, Computed: true, Description: "The maximum execution time in seconds for runs of the job. This property can only be specified if `run_mode` is `task`.", }, - "scale_memory_limit": &schema.Schema{ + "scale_memory_limit": { Type: schema.TypeString, Computed: true, Description: "Optional amount of memory set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_retry_limit": &schema.Schema{ + "scale_retry_limit": { Type: schema.TypeInt, Computed: true, Description: "The number of times to rerun an instance of the job before the job is marked as failed. This property can only be specified if `run_mode` is `task`.", @@ -202,7 +217,9 @@ func DataSourceIbmCodeEngineJob() *schema.Resource { func dataSourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_job", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getJobOptions := &codeenginev2.GetJobOptions{} @@ -210,104 +227,140 @@ func dataSourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceD getJobOptions.SetProjectID(d.Get("project_id").(string)) getJobOptions.SetName(d.Get("name").(string)) - job, response, err := codeEngineClient.GetJobWithContext(context, getJobOptions) + job, _, err := codeEngineClient.GetJobWithContext(context, getJobOptions) if err != nil { - log.Printf("[DEBUG] GetJobWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetJobWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_job", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getJobOptions.ProjectID, *getJobOptions.Name)) + if err = d.Set("build", job.Build); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting build: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() + } + + if err = d.Set("build_run", job.BuildRun); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting build_run: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() + } + if err = d.Set("created_at", job.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("entity_tag", job.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting entity_tag: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("href", job.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("job_id", job.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting job_id: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("image_reference", job.ImageReference); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_reference: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting image_reference: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("image_secret", job.ImageSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_secret: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting image_secret: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", job.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", job.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("run_as_user", flex.IntValue(job.RunAsUser)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_as_user: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_as_user: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } runEnvVariables := []map[string]interface{}{} if job.RunEnvVariables != nil { for _, modelItem := range job.RunEnvVariables { - modelMap, err := dataSourceIbmCodeEngineJobEnvVarToMap(&modelItem) + modelMap, err := dataSourceIbmCodeEngineJobEnvVarToMap(&modelItem) /* #nosec G601 */ if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } runEnvVariables = append(runEnvVariables, modelMap) } } if err = d.Set("run_env_variables", runEnvVariables); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_env_variables %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_env_variables: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("run_mode", job.RunMode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_mode: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_mode: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("run_service_account", job.RunServiceAccount); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_service_account: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_service_account: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } runVolumeMounts := []map[string]interface{}{} if job.RunVolumeMounts != nil { for _, modelItem := range job.RunVolumeMounts { - modelMap, err := dataSourceIbmCodeEngineJobVolumeMountToMap(&modelItem) + modelMap, err := dataSourceIbmCodeEngineJobVolumeMountToMap(&modelItem) /* #nosec G601 */ if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } runVolumeMounts = append(runVolumeMounts, modelMap) } } if err = d.Set("run_volume_mounts", runVolumeMounts); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_volume_mounts %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting run_volume_mounts: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_array_spec", job.ScaleArraySpec); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_array_spec: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_array_spec: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_cpu_limit", job.ScaleCpuLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_cpu_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_cpu_limit: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_ephemeral_storage_limit", job.ScaleEphemeralStorageLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_ephemeral_storage_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_ephemeral_storage_limit: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_max_execution_time", flex.IntValue(job.ScaleMaxExecutionTime)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_max_execution_time: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_max_execution_time: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_memory_limit", job.ScaleMemoryLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_memory_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_memory_limit: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } if err = d.Set("scale_retry_limit", flex.IntValue(job.ScaleRetryLimit)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_retry_limit: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting scale_retry_limit: %s", err), "(Data) ibm_code_engine_job", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go index 779f90690d..9f518b453e 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_job_test.go @@ -90,6 +90,13 @@ func testAccCheckIbmCodeEngineJobDataSourceConfigBasic(projectID string, jobImag project_id = data.ibm_code_engine_project.code_engine_project_instance.project_id image_reference = "%s" name = "%s" + + lifecycle { + ignore_changes = [ + run_env_variables, + scale_array_spec + ] + } } data "ibm_code_engine_job" "code_engine_job_instance" { @@ -116,6 +123,13 @@ func testAccCheckIbmCodeEngineJobDataSourceConfig(projectID string, jobImageRefe scale_max_execution_time = %s scale_memory_limit = "%s" scale_retry_limit = %s + + lifecycle { + ignore_changes = [ + run_env_variables, + scale_array_spec + ] + } } data "ibm_code_engine_job" "code_engine_job_instance" { diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_project.go b/ibm/service/codeengine/data_source_ibm_code_engine_project.go index 59e1734ada..d250130421 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_project.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_project.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/code-engine-go-sdk/codeenginev2" ) @@ -20,55 +21,55 @@ func DataSourceIbmCodeEngineProject() *schema.Resource { ReadContext: dataSourceIbmCodeEngineProjectRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "account_id": &schema.Schema{ + "account_id": { Type: schema.TypeString, Computed: true, Description: "An alphanumeric value identifying the account ID.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the project was created.", }, - "crn": &schema.Schema{ + "crn": { Type: schema.TypeString, Computed: true, Description: "The CRN of the project.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new resource, a URL is created identifying the location of the instance.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "The name of the project.", }, - "region": &schema.Schema{ + "region": { Type: schema.TypeString, Computed: true, Description: "The region for your project deployment. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", }, - "resource_group_id": &schema.Schema{ + "resource_group_id": { Type: schema.TypeString, Computed: true, Description: "The ID of the resource group.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the project.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, - Description: "The current state of the project. For example, if the project is created and ready to get used, it will return active.", + Description: "The current state of the project. For example, when the project is created and is ready for use, the status of the project is active.", }, }, } @@ -77,55 +78,69 @@ func DataSourceIbmCodeEngineProject() *schema.Resource { func dataSourceIbmCodeEngineProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_project", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getProjectOptions := &codeenginev2.GetProjectOptions{} getProjectOptions.SetID(d.Get("project_id").(string)) + log.Printf("[DEBUG]\n%+v", getProjectOptions) - project, response, err := codeEngineClient.GetProjectWithContext(context, getProjectOptions) + project, _, err := codeEngineClient.GetProjectWithContext(context, getProjectOptions) if err != nil { - log.Printf("[DEBUG] GetProjectWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetProjectWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_project", "read") + + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } - d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) + d.SetId(*getProjectOptions.ID) if err = d.Set("account_id", project.AccountID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting account_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting account_id: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("created_at", project.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("crn", project.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting crn: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("href", project.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting name: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("region", project.Region); err != nil { - return diag.FromErr(fmt.Errorf("Error setting region: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("resource_group_id", project.ResourceGroupID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_group_id: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", project.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } if err = d.Set("status", project.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting status: %s", err), "(Data) ibm_code_engine_project", "read") + return tfErr.GetDiag() } return nil diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_secret.go b/ibm/service/codeengine/data_source_ibm_code_engine_secret.go index 375e87c1d3..5eb2f1e03e 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_secret.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_secret.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/code-engine-go-sdk/codeenginev2" ) @@ -20,72 +21,77 @@ func DataSourceIbmCodeEngineSecret() *schema.Resource { ReadContext: dataSourceIbmCodeEngineSecretRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of your secret.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "data": &schema.Schema{ + "data": { Type: schema.TypeMap, Computed: true, - Description: "Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each value field can consists of any character and must not be exceed a max length of 1048576 characters.", + Description: "Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a max length of 253 characters. Each value field can consists of any character and must not exceed a max length of 1048576 characters.", Elem: &schema.Schema{ Type: schema.TypeString, }, }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the secret instance, which is used to achieve optimistic locking.", }, - "format": &schema.Schema{ + "format": { Type: schema.TypeString, Computed: true, Description: "Specify the format of the secret.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new secret, a URL is created identifying the location of the instance.", }, - "secret_id": &schema.Schema{ + "secret_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the secret.", }, - "service_access": &schema.Schema{ + "service_access": { Type: schema.TypeList, Computed: true, Description: "Properties for Service Access Secrets.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "resource_key": &schema.Schema{ + "resource_key": { Type: schema.TypeList, Computed: true, Description: "The service credential associated with the secret.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "id": { Type: schema.TypeString, Computed: true, Description: "ID of the service credential associated with the secret.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "Name of the service credential associated with the secret.", @@ -93,18 +99,18 @@ func DataSourceIbmCodeEngineSecret() *schema.Resource { }, }, }, - "role": &schema.Schema{ + "role": { Type: schema.TypeList, Computed: true, Description: "A reference to the Role and Role CRN for service binding.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "crn": &schema.Schema{ + "crn": { Type: schema.TypeString, Computed: true, - Description: "CRN of the IAM Role for thise service access secret.", + Description: "CRN of the IAM Role for this service access secret.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Computed: true, Description: "Role of the service credential.", @@ -112,18 +118,18 @@ func DataSourceIbmCodeEngineSecret() *schema.Resource { }, }, }, - "service_instance": &schema.Schema{ + "service_instance": { Type: schema.TypeList, Computed: true, Description: "The IBM Cloud service instance associated with the secret.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "id": { Type: schema.TypeString, Computed: true, Description: "ID of the IBM Cloud service instance associated with the secret.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Computed: true, Description: "Type of IBM Cloud service associated with the secret.", @@ -131,6 +137,71 @@ func DataSourceIbmCodeEngineSecret() *schema.Resource { }, }, }, + "serviceid": { + Type: schema.TypeList, + Computed: true, + Description: "A reference to a Service ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": { + Type: schema.TypeString, + Computed: true, + Description: "CRN value of a Service ID.", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the Service ID.", + }, + }, + }, + }, + }, + }, + }, + "service_operator": { + Type: schema.TypeList, + Computed: true, + Description: "Properties for the IBM Cloud Operator Secret.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "apikey_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the apikey associated with the operator secret.", + }, + "resource_group_ids": { + Type: schema.TypeList, + Computed: true, + Description: "The list of resource groups (by ID) that the operator secret can bind services in.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "serviceid": { + Type: schema.TypeList, + Computed: true, + Description: "A reference to a Service ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": { + Type: schema.TypeString, + Computed: true, + Description: "CRN value of a Service ID.", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the Service ID.", + }, + }, + }, + }, + "user_managed": { + Type: schema.TypeBool, + Computed: true, + Description: "Specifies whether the operator secret is user managed.", + }, }, }, }, @@ -141,7 +212,9 @@ func DataSourceIbmCodeEngineSecret() *schema.Resource { func dataSourceIbmCodeEngineSecretRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_secret", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getSecretOptions := &codeenginev2.GetSecretOptions{} @@ -149,57 +222,87 @@ func dataSourceIbmCodeEngineSecretRead(context context.Context, d *schema.Resour getSecretOptions.SetProjectID(d.Get("project_id").(string)) getSecretOptions.SetName(d.Get("name").(string)) - secret, response, err := codeEngineClient.GetSecretWithContext(context, getSecretOptions) + secret, _, err := codeEngineClient.GetSecretWithContext(context, getSecretOptions) if err != nil { - log.Printf("[DEBUG] GetSecretWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetSecretWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetSecretWithContext failed: %s", err.Error()), "(Data) ibm_code_engine_secret", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *getSecretOptions.ProjectID, *getSecretOptions.Name)) if err = d.Set("created_at", secret.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if secret.Data != nil { if err = d.Set("data", secret.Data); err != nil { - return diag.FromErr(fmt.Errorf("Error setting data: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting data: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if err != nil { - return diag.FromErr(fmt.Errorf("Error setting data %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting data: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } } if err = d.Set("entity_tag", secret.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting entity_tag: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if err = d.Set("format", secret.Format); err != nil { - return diag.FromErr(fmt.Errorf("Error setting format: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting format: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if err = d.Set("href", secret.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting href: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if err = d.Set("secret_id", secret.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting secret_id: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting secret_id: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() + } + + if err = d.Set("region", secret.Region); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting region: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } if err = d.Set("resource_type", secret.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting resource_type: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } serviceAccess := []map[string]interface{}{} if secret.ServiceAccess != nil { modelMap, err := dataSourceIbmCodeEngineSecretServiceAccessSecretPropsToMap(secret.ServiceAccess) if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } serviceAccess = append(serviceAccess, modelMap) } if err = d.Set("service_access", serviceAccess); err != nil { - return diag.FromErr(fmt.Errorf("Error setting service_access %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting service_access: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() + } + + serviceOperator := []map[string]interface{}{} + if secret.ServiceOperator != nil { + modelMap, err := dataSourceIbmCodeEngineSecretOperatorSecretPropsToMap(secret.ServiceOperator) + if err != nil { + tfErr := flex.TerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() + } + serviceOperator = append(serviceOperator, modelMap) + } + if err = d.Set("service_operator", serviceOperator); err != nil { + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting service_operator: %s", err), "(Data) ibm_code_engine_secret", "read") + return tfErr.GetDiag() } return nil @@ -224,6 +327,13 @@ func dataSourceIbmCodeEngineSecretServiceAccessSecretPropsToMap(model *codeengin return modelMap, err } modelMap["service_instance"] = []map[string]interface{}{serviceInstanceMap} + if model.Serviceid != nil { + serviceidMap, err := dataSourceIbmCodeEngineSecretServiceIDRefToMap(model.Serviceid) + if err != nil { + return modelMap, err + } + modelMap["serviceid"] = []map[string]interface{}{serviceidMap} + } return modelMap, nil } @@ -259,3 +369,27 @@ func dataSourceIbmCodeEngineSecretServiceInstanceRefToMap(model *codeenginev2.Se } return modelMap, nil } + +func dataSourceIbmCodeEngineSecretServiceIDRefToMap(model *codeenginev2.ServiceIDRef) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.ID != nil { + modelMap["id"] = model.ID + } + return modelMap, nil +} + +func dataSourceIbmCodeEngineSecretOperatorSecretPropsToMap(model *codeenginev2.OperatorSecretProps) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["apikey_id"] = model.ApikeyID + modelMap["resource_group_ids"] = model.ResourceGroupIds + serviceidMap, err := dataSourceIbmCodeEngineSecretServiceIDRefToMap(model.Serviceid) + if err != nil { + return modelMap, err + } + modelMap["serviceid"] = []map[string]interface{}{serviceidMap} + modelMap["user_managed"] = model.UserManaged + return modelMap, nil +} diff --git a/ibm/service/codeengine/data_source_ibm_code_engine_secret_test.go b/ibm/service/codeengine/data_source_ibm_code_engine_secret_test.go index 71dbd7cd1b..e62c7a73c9 100644 --- a/ibm/service/codeengine/data_source_ibm_code_engine_secret_test.go +++ b/ibm/service/codeengine/data_source_ibm_code_engine_secret_test.go @@ -5,6 +5,7 @@ package codeengine_test import ( "fmt" + "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -132,8 +133,8 @@ func TestAccIbmCodeEngineSecretDataSourceSSHAuth(t *testing.T) { func TestAccIbmCodeEngineSecretDataSourceTls(t *testing.T) { secretFormat := "tls" secretName := fmt.Sprintf("tf-data-secret-tls-%d", acctest.RandIntRange(10, 1000)) - tlsKey := decodeBase64EnvVar(acc.CeTLSKey, CeTlsKey) - tlsCert := decodeBase64EnvVar(acc.CeTLSCert, CeTlsCert) + tlsKey, _ := os.ReadFile(acc.CeTLSKeyFilePath) + tlsCert, _ := os.ReadFile(acc.CeTLSCertFilePath) projectID := acc.CeProjectId @@ -142,7 +143,7 @@ func TestAccIbmCodeEngineSecretDataSourceTls(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmCodeEngineSecretDataSourceTLSConfigBasic(projectID, tlsKey, tlsCert, secretFormat, secretName), + Config: testAccCheckIbmCodeEngineSecretDataSourceTLSConfigBasic(projectID, string(tlsKey), string(tlsCert), secretFormat, secretName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.ibm_code_engine_secret.code_engine_secret_instance", "project_id", projectID), resource.TestCheckResourceAttr("data.ibm_code_engine_secret.code_engine_secret_instance", "format", secretFormat), diff --git a/ibm/service/codeengine/resource_ibm_code_engine_app.go b/ibm/service/codeengine/resource_ibm_code_engine_app.go index 1c5b286efc..43bc564958 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_app.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_app.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/IBM-Cloud/bluemix-go/bmxerror" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" @@ -34,98 +33,192 @@ func ResourceIbmCodeEngineApp() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "project_id"), Description: "The ID of the project.", }, - "image_reference": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "image_reference"), - Description: "The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "name"), - Description: "The name of the app. Use a name that is unique within the project.", - }, - "image_port": &schema.Schema{ + "image_port": { Type: schema.TypeInt, Optional: true, Default: 8080, Description: "Optional port the app listens on. While the app will always be exposed via port `443` for end users, this port is used to connect to the port that is exposed by the container image.", }, - "image_secret": &schema.Schema{ + "image_reference": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "image_reference"), + Description: "The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`.", + }, + "image_secret": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "image_secret"), Description: "Optional name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the app will be created but cannot reach the ready status, until this property is provided, too.", }, - "managed_domain_mappings": &schema.Schema{ + "managed_domain_mappings": { Type: schema.TypeString, Optional: true, Default: "local_public", ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "managed_domain_mappings"), Description: "Optional value controlling which of the system managed domain mappings will be setup for the application. Valid values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports application private visibility.", }, - "run_arguments": &schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "name"), + Description: "The name of the app.", + }, + "probe_liveness": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Response model for probes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failure_threshold": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "The number of consecutive, unsuccessful checks for the probe to be considered failed.", + }, + "initial_delay": { + Type: schema.TypeInt, + Optional: true, + Description: "The amount of time in seconds to wait before the first probe check is performed.", + }, + "interval": { + Type: schema.TypeInt, + Optional: true, + Default: 10, + Description: "The amount of time in seconds between probe checks.", + }, + "path": { + Type: schema.TypeString, + Optional: true, + Description: "The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`.", + }, + "port": { + Type: schema.TypeInt, + Optional: true, + Description: "The port on which to probe the resource.", + }, + "timeout": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "The amount of time in seconds that the probe waits for a response from the application before it times out and fails.", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Specifies whether to use HTTP or TCP for the probe checks. The default is TCP.", + }, + }, + }, + }, + "probe_readiness": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Response model for probes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failure_threshold": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "The number of consecutive, unsuccessful checks for the probe to be considered failed.", + }, + "initial_delay": { + Type: schema.TypeInt, + Optional: true, + Description: "The amount of time in seconds to wait before the first probe check is performed.", + }, + "interval": { + Type: schema.TypeInt, + Optional: true, + Default: 10, + Description: "The amount of time in seconds between probe checks.", + }, + "path": { + Type: schema.TypeString, + Optional: true, + Description: "The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`.", + }, + "port": { + Type: schema.TypeInt, + Optional: true, + Description: "The port on which to probe the resource.", + }, + "timeout": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + Description: "The amount of time in seconds that the probe waits for a response from the application before it times out and fails.", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Specifies whether to use HTTP or TCP for the probe checks. The default is TCP.", + }, + }, + }, + }, + "run_arguments": { Type: schema.TypeList, Optional: true, - MinItems: 0, Description: "Optional arguments for the app that are passed to start the container. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "run_as_user": &schema.Schema{ + "run_as_user": { Type: schema.TypeInt, Optional: true, - Description: "Optional user ID (UID) to run the app (e.g., `1001`).", + Default: 0, + Description: "Optional user ID (UID) to run the app.", }, - "run_commands": &schema.Schema{ + "run_commands": { Type: schema.TypeList, Optional: true, - MinItems: 0, Description: "Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "run_env_variables": &schema.Schema{ + "run_env_variables": { Type: schema.TypeList, Optional: true, - Description: "Optional references to config maps, secrets or literal values that are exposed as environment variables within the running application.", - MinItems: 0, + Description: "References to config maps, secrets or literal values, which are exposed as environment variables in the application.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "key": &schema.Schema{ + "key": { Type: schema.TypeString, Optional: true, Description: "The key to reference as environment variable.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Optional: true, Description: "The name of the environment variable.", }, - "prefix": &schema.Schema{ + "prefix": { Type: schema.TypeString, Optional: true, Description: "A prefix that can be added to all keys of a full secret or config map reference.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Optional: true, Description: "The name of the secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Optional: true, Default: "literal", Description: "Specify the type of the environment variable.", }, - "value": &schema.Schema{ + "value": { Type: schema.TypeString, Optional: true, Description: "The literal value of the environment variable.", @@ -133,36 +226,35 @@ func ResourceIbmCodeEngineApp() *schema.Resource { }, }, }, - "run_service_account": &schema.Schema{ + "run_service_account": { Type: schema.TypeString, Optional: true, Default: "default", ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "run_service_account"), Description: "Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , `none`, `reader`, and `writer`.", }, - "run_volume_mounts": &schema.Schema{ + "run_volume_mounts": { Type: schema.TypeList, Optional: true, - MinItems: 0, - Description: "Optional mounts of config maps or a secrets.", + Description: "Mounts of config maps or secrets.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "mount_path": &schema.Schema{ + "mount_path": { Type: schema.TypeString, Required: true, Description: "The path that should be mounted.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, - Optional: true, - Description: "Optional name of the mount. If not set, it will be generated based on the `ref` and a random ID. In case the `ref` is longer than 58 characters, it will be cut off.", + Required: true, + Description: "The name of the mount.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Required: true, Description: "The name of the referenced secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Required: true, Description: "Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'.", @@ -170,119 +262,141 @@ func ResourceIbmCodeEngineApp() *schema.Resource { }, }, }, - "scale_concurrency": &schema.Schema{ + "scale_concurrency": { Type: schema.TypeInt, Optional: true, Default: 100, Description: "Optional maximum number of requests that can be processed concurrently per instance.", }, - "scale_concurrency_target": &schema.Schema{ + "scale_concurrency_target": { Type: schema.TypeInt, Optional: true, Description: "Optional threshold of concurrent requests per instance at which one or more additional instances are created. Use this value to scale up instances based on concurrent number of requests. This option defaults to the value of the `scale_concurrency` option, if not specified.", }, - "scale_cpu_limit": &schema.Schema{ + "scale_cpu_limit": { Type: schema.TypeString, Optional: true, Default: "1", ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "scale_cpu_limit"), Description: "Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo).", }, - "scale_ephemeral_storage_limit": &schema.Schema{ + "scale_down_delay": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "scale_down_delay"), + Description: "Optional amount of time in seconds that delays the scale-down behavior for an app instance.", + }, + "scale_ephemeral_storage_limit": { Type: schema.TypeString, Optional: true, Default: "400M", ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "scale_ephemeral_storage_limit"), Description: "Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_initial_instances": &schema.Schema{ + "scale_initial_instances": { Type: schema.TypeInt, Optional: true, Default: 1, Description: "Optional initial number of instances that are created upon app creation or app update.", }, - "scale_max_instances": &schema.Schema{ + "scale_max_instances": { Type: schema.TypeInt, Optional: true, Default: 10, Description: "Optional maximum number of instances for this app. If you set this value to `0`, this property does not set a upper scaling limit. However, the app scaling is still limited by the project quota for instances. See [Limits and quotas for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits).", }, - "scale_memory_limit": &schema.Schema{ + "scale_memory_limit": { Type: schema.TypeString, Optional: true, Default: "4G", ValidateFunc: validate.InvokeValidator("ibm_code_engine_app", "scale_memory_limit"), Description: "Optional amount of memory set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_min_instances": &schema.Schema{ + "scale_min_instances": { Type: schema.TypeInt, Optional: true, Default: 0, Description: "Optional minimum number of instances for this app. If you set this value to `0`, the app will scale down to zero, if not hit by any request for some time.", }, - "scale_request_timeout": &schema.Schema{ + "scale_request_timeout": { Type: schema.TypeInt, Optional: true, Default: 300, Description: "Optional amount of time in seconds that is allowed for a running app to respond to a request.", }, - "created_at": &schema.Schema{ + "build": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build that is associated with the application.", + }, + "build_run": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build run that is associated with the application.", + }, + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "endpoint": &schema.Schema{ + "endpoint": { Type: schema.TypeString, Computed: true, - Description: "Optional URL to invoke app. Depending on visibility this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'.", + Description: "Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'.", }, - "endpoint_internal": &schema.Schema{ + "endpoint_internal": { Type: schema.TypeString, Computed: true, - Description: "URL to app that is only visible within the project.", + Description: "The URL to the app that is only visible within the project.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the app instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new app, a URL is created identifying the location of the instance.", }, - "app_id": &schema.Schema{ + "app_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the app.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the app.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the application.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "latest_created_revision": &schema.Schema{ + "latest_created_revision": { Type: schema.TypeString, Computed: true, Description: "Latest app revision that has been created.", }, - "latest_ready_revision": &schema.Schema{ + "latest_ready_revision": { Type: schema.TypeString, Computed: true, Description: "Latest app revision that reached a ready state.", }, - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -290,7 +404,7 @@ func ResourceIbmCodeEngineApp() *schema.Resource { }, }, }, - "etag": &schema.Schema{ + "etag": { Type: schema.TypeString, Computed: true, }, @@ -319,15 +433,6 @@ func ResourceIbmCodeEngineAppValidator() *validate.ResourceValidator { MinValueLength: 1, MaxValueLength: 256, }, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-z]([-a-z0-9]*[a-z0-9])?$`, - MinValueLength: 1, - MaxValueLength: 63, - }, validate.ValidateSchema{ Identifier: "image_secret", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -344,6 +449,15 @@ func ResourceIbmCodeEngineAppValidator() *validate.ResourceValidator { Optional: true, AllowedValues: "local, local_private, local_public", }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-z]([-a-z0-9]*[a-z0-9])?$`, + MinValueLength: 1, + MaxValueLength: 63, + }, validate.ValidateSchema{ Identifier: "run_service_account", ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, @@ -362,6 +476,14 @@ func ResourceIbmCodeEngineAppValidator() *validate.ResourceValidator { MinValueLength: 0, MaxValueLength: 10, }, + validate.ValidateSchema{ + Identifier: "scale_down_delay", + ValidateFunctionIdentifier: validate.IntBetween, + Type: validate.TypeInt, + Optional: true, + MinValue: "0", + MaxValue: "3600", + }, validate.ValidateSchema{ Identifier: "scale_ephemeral_storage_limit", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -389,7 +511,9 @@ func ResourceIbmCodeEngineAppValidator() *validate.ResourceValidator { func resourceIbmCodeEngineAppCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createAppOptions := &codeenginev2.CreateAppOptions{} @@ -406,6 +530,20 @@ func resourceIbmCodeEngineAppCreate(context context.Context, d *schema.ResourceD if _, ok := d.GetOk("managed_domain_mappings"); ok { createAppOptions.SetManagedDomainMappings(d.Get("managed_domain_mappings").(string)) } + if _, ok := d.GetOk("probe_liveness"); ok { + probeLivenessModel, err := resourceIbmCodeEngineAppMapToProbePrototype(d.Get("probe_liveness.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createAppOptions.SetProbeLiveness(probeLivenessModel) + } + if _, ok := d.GetOk("probe_readiness"); ok { + probeReadinessModel, err := resourceIbmCodeEngineAppMapToProbePrototype(d.Get("probe_readiness.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createAppOptions.SetProbeReadiness(probeReadinessModel) + } if _, ok := d.GetOk("run_arguments"); ok { var runArguments []string for _, v := range d.Get("run_arguments").([]interface{}) { @@ -461,6 +599,9 @@ func resourceIbmCodeEngineAppCreate(context context.Context, d *schema.ResourceD if _, ok := d.GetOk("scale_cpu_limit"); ok { createAppOptions.SetScaleCpuLimit(d.Get("scale_cpu_limit").(string)) } + if _, ok := d.GetOk("scale_down_delay"); ok { + createAppOptions.SetScaleDownDelay(int64(d.Get("scale_down_delay").(int))) + } if _, ok := d.GetOk("scale_ephemeral_storage_limit"); ok { createAppOptions.SetScaleEphemeralStorageLimit(d.Get("scale_ephemeral_storage_limit").(string)) } @@ -480,18 +621,20 @@ func resourceIbmCodeEngineAppCreate(context context.Context, d *schema.ResourceD createAppOptions.SetScaleRequestTimeout(int64(d.Get("scale_request_timeout").(int))) } - app, response, err := codeEngineClient.CreateAppWithContext(context, createAppOptions) + app, _, err := codeEngineClient.CreateAppWithContext(context, createAppOptions) if err != nil { - log.Printf("[DEBUG] CreateAppWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateAppWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateAppWithContext failed: %s", err.Error()), "ibm_code_engine_app", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createAppOptions.ProjectID, *app.Name)) _, err = waitForIbmCodeEngineAppCreate(d, meta) if err != nil { - return diag.FromErr(fmt.Errorf( - "Error waiting for resource IbmCodeEngineApp (%s) to be created: %s", d.Id(), err)) + errMsg := fmt.Sprintf("Error waiting for resource IbmCodeEngineApp (%s) to be created: %s", d.Id(), err) + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_app", "create") + return tfErr.GetDiag() } return resourceIbmCodeEngineAppRead(context, d, meta) @@ -518,14 +661,15 @@ func waitForIbmCodeEngineAppCreate(d *schema.ResourceData, meta interface{}) (in Refresh: func() (interface{}, string, error) { stateObj, response, err := codeEngineClient.GetApp(getAppOptions) if err != nil { - if apiErr, ok := err.(bmxerror.RequestFailure); ok && apiErr.StatusCode() == 404 { - return nil, "", fmt.Errorf("The instance %s does not exist anymore: %s\n%s", "getAppOptions", err, response) + if sdkErr, ok := err.(*core.SDKProblem); ok && response.GetStatusCode() == 404 { + sdkErr.Summary = fmt.Sprintf("The instance %s does not exist anymore: %s", "getAppOptions", err) + return nil, "", sdkErr } return nil, "", err } failStates := map[string]bool{"failure": true, "failed": true} if failStates[*stateObj.Status] { - return stateObj, *stateObj.Status, fmt.Errorf("The instance %s failed: %s\n%s", "getAppOptions", err, response) + return stateObj, *stateObj.Status, fmt.Errorf("the instance %s failed: %s", "getAppOptions", err) } return stateObj, *stateObj.Status, nil }, @@ -540,14 +684,17 @@ func waitForIbmCodeEngineAppCreate(d *schema.ResourceData, meta interface{}) (in func resourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getAppOptions := &codeenginev2.GetAppOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "read") + return tfErr.GetDiag() } getAppOptions.SetProjectID(parts[0]) @@ -559,161 +706,200 @@ func resourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceDat d.SetId("") return nil } - log.Printf("[DEBUG] GetAppWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetAppWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetAppWithContext failed: %s", err.Error()), "ibm_code_engine_app", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", app.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) - } - if err = d.Set("image_reference", app.ImageReference); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_reference: %s", err)) - } - if err = d.Set("name", app.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } if !core.IsNil(app.ImagePort) { if err = d.Set("image_port", flex.IntValue(app.ImagePort)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_port: %s", err)) + return diag.FromErr(fmt.Errorf("error setting image_port: %s", err)) } } + if err = d.Set("image_reference", app.ImageReference); err != nil { + return diag.FromErr(fmt.Errorf("error setting image_reference: %s", err)) + } if !core.IsNil(app.ImageSecret) { if err = d.Set("image_secret", app.ImageSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_secret: %s", err)) + return diag.FromErr(fmt.Errorf("error setting image_secret: %s", err)) } } if !core.IsNil(app.ManagedDomainMappings) { if err = d.Set("managed_domain_mappings", app.ManagedDomainMappings); err != nil { - return diag.FromErr(fmt.Errorf("Error setting managed_domain_mappings: %s", err)) + return diag.FromErr(fmt.Errorf("error setting managed_domain_mappings: %s", err)) + } + } + if err = d.Set("name", app.Name); err != nil { + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) + } + if !core.IsNil(app.ProbeLiveness) { + probeLivenessMap, err := resourceIbmCodeEngineAppProbeToMap(app.ProbeLiveness) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("probe_liveness", []map[string]interface{}{probeLivenessMap}); err != nil { + return diag.FromErr(fmt.Errorf("error setting probe_liveness: %s", err)) + } + } + if !core.IsNil(app.ProbeReadiness) { + probeReadinessMap, err := resourceIbmCodeEngineAppProbeToMap(app.ProbeReadiness) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("probe_readiness", []map[string]interface{}{probeReadinessMap}); err != nil { + return diag.FromErr(fmt.Errorf("error setting probe_readiness: %s", err)) } } if !core.IsNil(app.RunArguments) { if err = d.Set("run_arguments", app.RunArguments); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_arguments: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_arguments: %s", err)) } } if !core.IsNil(app.RunAsUser) { if err = d.Set("run_as_user", flex.IntValue(app.RunAsUser)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_as_user: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_as_user: %s", err)) } } if !core.IsNil(app.RunCommands) { if err = d.Set("run_commands", app.RunCommands); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_commands: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_commands: %s", err)) } } if !core.IsNil(app.RunEnvVariables) { runEnvVariables := []map[string]interface{}{} for _, runEnvVariablesItem := range app.RunEnvVariables { - runEnvVariablesItemMap, err := resourceIbmCodeEngineAppEnvVarToMap(&runEnvVariablesItem) + runEnvVariablesItemMap, err := resourceIbmCodeEngineAppEnvVarToMap(&runEnvVariablesItem) /* #nosec G601 */ if err != nil { return diag.FromErr(err) } runEnvVariables = append(runEnvVariables, runEnvVariablesItemMap) } if err = d.Set("run_env_variables", runEnvVariables); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_env_variables: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_env_variables: %s", err)) } } if !core.IsNil(app.RunServiceAccount) { if err = d.Set("run_service_account", app.RunServiceAccount); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_service_account: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_service_account: %s", err)) } } if !core.IsNil(app.RunVolumeMounts) { runVolumeMounts := []map[string]interface{}{} for _, runVolumeMountsItem := range app.RunVolumeMounts { - runVolumeMountsItemMap, err := resourceIbmCodeEngineAppVolumeMountToMap(&runVolumeMountsItem) + runVolumeMountsItemMap, err := resourceIbmCodeEngineAppVolumeMountToMap(&runVolumeMountsItem) /* #nosec G601 */ if err != nil { return diag.FromErr(err) } runVolumeMounts = append(runVolumeMounts, runVolumeMountsItemMap) } if err = d.Set("run_volume_mounts", runVolumeMounts); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_volume_mounts: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_volume_mounts: %s", err)) } } if !core.IsNil(app.ScaleConcurrency) { if err = d.Set("scale_concurrency", flex.IntValue(app.ScaleConcurrency)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_concurrency: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_concurrency: %s", err)) } } if !core.IsNil(app.ScaleConcurrencyTarget) { if err = d.Set("scale_concurrency_target", flex.IntValue(app.ScaleConcurrencyTarget)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_concurrency_target: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_concurrency_target: %s", err)) } } if !core.IsNil(app.ScaleCpuLimit) { if err = d.Set("scale_cpu_limit", app.ScaleCpuLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_cpu_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_cpu_limit: %s", err)) + } + } + if !core.IsNil(app.ScaleDownDelay) { + if err = d.Set("scale_down_delay", flex.IntValue(app.ScaleDownDelay)); err != nil { + return diag.FromErr(fmt.Errorf("error setting scale_down_delay: %s", err)) } } if !core.IsNil(app.ScaleEphemeralStorageLimit) { if err = d.Set("scale_ephemeral_storage_limit", app.ScaleEphemeralStorageLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_ephemeral_storage_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_ephemeral_storage_limit: %s", err)) } } if !core.IsNil(app.ScaleInitialInstances) { if err = d.Set("scale_initial_instances", flex.IntValue(app.ScaleInitialInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_initial_instances: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_initial_instances: %s", err)) } } if !core.IsNil(app.ScaleMaxInstances) { if err = d.Set("scale_max_instances", flex.IntValue(app.ScaleMaxInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_max_instances: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_max_instances: %s", err)) } } if !core.IsNil(app.ScaleMemoryLimit) { if err = d.Set("scale_memory_limit", app.ScaleMemoryLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_memory_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_memory_limit: %s", err)) } } if !core.IsNil(app.ScaleMinInstances) { if err = d.Set("scale_min_instances", flex.IntValue(app.ScaleMinInstances)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_min_instances: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_min_instances: %s", err)) } } if !core.IsNil(app.ScaleRequestTimeout) { if err = d.Set("scale_request_timeout", flex.IntValue(app.ScaleRequestTimeout)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_request_timeout: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_request_timeout: %s", err)) + } + } + if !core.IsNil(app.Build) { + if err = d.Set("build", app.Build); err != nil { + return diag.FromErr(fmt.Errorf("error setting build: %s", err)) + } + } + if !core.IsNil(app.BuildRun) { + if err = d.Set("build_run", app.BuildRun); err != nil { + return diag.FromErr(fmt.Errorf("error setting build_run: %s", err)) } } if !core.IsNil(app.CreatedAt) { if err = d.Set("created_at", app.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if !core.IsNil(app.Endpoint) { if err = d.Set("endpoint", app.Endpoint); err != nil { - return diag.FromErr(fmt.Errorf("Error setting endpoint: %s", err)) + return diag.FromErr(fmt.Errorf("error setting endpoint: %s", err)) } } if !core.IsNil(app.EndpointInternal) { if err = d.Set("endpoint_internal", app.EndpointInternal); err != nil { - return diag.FromErr(fmt.Errorf("Error setting endpoint_internal: %s", err)) + return diag.FromErr(fmt.Errorf("error setting endpoint_internal: %s", err)) } } if err = d.Set("entity_tag", app.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(app.Href) { if err = d.Set("href", app.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(app.ID) { if err = d.Set("app_id", app.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting app_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting app_id: %s", err)) + } + } + if !core.IsNil(app.Region) { + if err = d.Set("region", app.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(app.ResourceType) { if err = d.Set("resource_type", app.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if !core.IsNil(app.Status) { if err = d.Set("status", app.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status: %s", err)) } } if !core.IsNil(app.StatusDetails) { @@ -722,11 +908,12 @@ func resourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceDat return diag.FromErr(err) } if err = d.Set("status_details", []map[string]interface{}{statusDetailsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status_details: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_app", "read") + return tfErr.GetDiag() } return nil @@ -735,14 +922,17 @@ func resourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceDat func resourceIbmCodeEngineAppUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateAppOptions := &codeenginev2.UpdateAppOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "update") + return tfErr.GetDiag() } updateAppOptions.SetProjectID(parts[0]) @@ -751,17 +941,22 @@ func resourceIbmCodeEngineAppUpdate(context context.Context, d *schema.ResourceD hasChange := false patchVals := &codeenginev2.AppPatch{} - if d.HasChange("image_reference") || d.HasChange("name") { - newImageReference := d.Get("image_reference").(string) - patchVals.ImageReference = &newImageReference - updateAppOptions.SetName(d.Get("name").(string)) - hasChange = true + if d.HasChange("project_id") { + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_app", "update") + return tfErr.GetDiag() } if d.HasChange("image_port") { newImagePort := int64(d.Get("image_port").(int)) patchVals.ImagePort = &newImagePort hasChange = true } + if d.HasChange("image_reference") { + newImageReference := d.Get("image_reference").(string) + patchVals.ImageReference = &newImageReference + hasChange = true + } if d.HasChange("image_secret") { newImageSecret := d.Get("image_secret").(string) patchVals.ImageSecret = &newImageSecret @@ -772,6 +967,22 @@ func resourceIbmCodeEngineAppUpdate(context context.Context, d *schema.ResourceD patchVals.ManagedDomainMappings = &newManagedDomainMappings hasChange = true } + if d.HasChange("probe_liveness") { + probeLiveness, err := resourceIbmCodeEngineAppMapToProbePrototype(d.Get("probe_liveness.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + patchVals.ProbeLiveness = probeLiveness + hasChange = true + } + if d.HasChange("probe_readiness") { + probeReadiness, err := resourceIbmCodeEngineAppMapToProbePrototype(d.Get("probe_readiness.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + patchVals.ProbeReadiness = probeReadiness + hasChange = true + } if d.HasChange("run_arguments") { var runArguments []string for _, v := range d.Get("run_arguments").([]interface{}) { @@ -841,6 +1052,11 @@ func resourceIbmCodeEngineAppUpdate(context context.Context, d *schema.ResourceD patchVals.ScaleCpuLimit = &newScaleCpuLimit hasChange = true } + if d.HasChange("scale_down_delay") { + newScaleDownDelay := int64(d.Get("scale_down_delay").(int)) + patchVals.ScaleDownDelay = &newScaleDownDelay + hasChange = true + } if d.HasChange("scale_ephemeral_storage_limit") { newScaleEphemeralStorageLimit := d.Get("scale_ephemeral_storage_limit").(string) patchVals.ScaleEphemeralStorageLimit = &newScaleEphemeralStorageLimit @@ -875,82 +1091,41 @@ func resourceIbmCodeEngineAppUpdate(context context.Context, d *schema.ResourceD if hasChange { updateAppOptions.App, _ = patchVals.AsPatch() - _, response, err := codeEngineClient.UpdateAppWithContext(context, updateAppOptions) + _, _, err = codeEngineClient.UpdateAppWithContext(context, updateAppOptions) if err != nil { - log.Printf("[DEBUG] UpdateAppWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateAppWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("UpdateAppWithContext failed: %s", err.Error()), "ibm_code_engine_app", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } - _, err = waitForIbmCodeEngineAppUpdate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf( - "Error waiting for resource IbmCodeEngineApp (%s) to be updated: %s", d.Id(), err)) - } - return resourceIbmCodeEngineAppRead(context, d, meta) } -func waitForIbmCodeEngineAppUpdate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() - if err != nil { - return false, err - } - getAppOptions := &codeenginev2.GetAppOptions{} - - parts, err := flex.SepIdParts(d.Id(), "/") - if err != nil { - return false, err - } - - getAppOptions.SetProjectID(parts[0]) - getAppOptions.SetName(parts[1]) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"deploying"}, - Target: []string{"ready"}, - Refresh: func() (interface{}, string, error) { - stateObj, response, err := codeEngineClient.GetApp(getAppOptions) - if err != nil { - if apiErr, ok := err.(bmxerror.RequestFailure); ok && apiErr.StatusCode() == 404 { - return nil, "", fmt.Errorf("The instance %s does not exist anymore: %s\n%s", "getAppOptions", err, response) - } - return nil, "", err - } - failStates := map[string]bool{"failed": true, "warning": true} - if failStates[*stateObj.Status] { - return stateObj, *stateObj.Status, fmt.Errorf("The instance %s failed: %s\n%s", "getAppOptions", err, response) - } - return stateObj, *stateObj.Status, nil - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 20 * time.Second, - MinTimeout: 20 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmCodeEngineAppDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteAppOptions := &codeenginev2.DeleteAppOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_app", "delete") + return tfErr.GetDiag() } deleteAppOptions.SetProjectID(parts[0]) deleteAppOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteAppWithContext(context, deleteAppOptions) + _, err = codeEngineClient.DeleteAppWithContext(context, deleteAppOptions) if err != nil { - log.Printf("[DEBUG] DeleteAppWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteAppWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteAppWithContext failed: %s", err.Error()), "ibm_code_engine_app", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") @@ -958,6 +1133,32 @@ func resourceIbmCodeEngineAppDelete(context context.Context, d *schema.ResourceD return nil } +func resourceIbmCodeEngineAppMapToProbePrototype(modelMap map[string]interface{}) (*codeenginev2.ProbePrototype, error) { + model := &codeenginev2.ProbePrototype{} + if modelMap["failure_threshold"] != nil { + model.FailureThreshold = core.Int64Ptr(int64(modelMap["failure_threshold"].(int))) + } + if modelMap["initial_delay"] != nil { + model.InitialDelay = core.Int64Ptr(int64(modelMap["initial_delay"].(int))) + } + if modelMap["interval"] != nil { + model.Interval = core.Int64Ptr(int64(modelMap["interval"].(int))) + } + if modelMap["path"] != nil && modelMap["path"].(string) != "" { + model.Path = core.StringPtr(modelMap["path"].(string)) + } + if modelMap["port"] != nil { + model.Port = core.Int64Ptr(int64(modelMap["port"].(int))) + } + if modelMap["timeout"] != nil { + model.Timeout = core.Int64Ptr(int64(modelMap["timeout"].(int))) + } + if modelMap["type"] != nil && modelMap["type"].(string) != "" { + model.Type = core.StringPtr(modelMap["type"].(string)) + } + return model, nil +} + func resourceIbmCodeEngineAppMapToEnvVarPrototype(modelMap map[string]interface{}) (*codeenginev2.EnvVarPrototype, error) { model := &codeenginev2.EnvVarPrototype{} if modelMap["key"] != nil && modelMap["key"].(string) != "" { @@ -992,6 +1193,32 @@ func resourceIbmCodeEngineAppMapToVolumeMountPrototype(modelMap map[string]inter return model, nil } +func resourceIbmCodeEngineAppProbeToMap(model *codeenginev2.Probe) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.FailureThreshold != nil { + modelMap["failure_threshold"] = flex.IntValue(model.FailureThreshold) + } + if model.InitialDelay != nil { + modelMap["initial_delay"] = flex.IntValue(model.InitialDelay) + } + if model.Interval != nil { + modelMap["interval"] = flex.IntValue(model.Interval) + } + if model.Path != nil { + modelMap["path"] = model.Path + } + if model.Port != nil { + modelMap["port"] = flex.IntValue(model.Port) + } + if model.Timeout != nil { + modelMap["timeout"] = flex.IntValue(model.Timeout) + } + if model.Type != nil { + modelMap["type"] = model.Type + } + return modelMap, nil +} + func resourceIbmCodeEngineAppEnvVarToMap(model *codeenginev2.EnvVar) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Key != nil { @@ -1006,9 +1233,7 @@ func resourceIbmCodeEngineAppEnvVarToMap(model *codeenginev2.EnvVar) (map[string if model.Reference != nil { modelMap["reference"] = model.Reference } - if model.Type != nil { - modelMap["type"] = model.Type - } + modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } @@ -1018,9 +1243,7 @@ func resourceIbmCodeEngineAppEnvVarToMap(model *codeenginev2.EnvVar) (map[string func resourceIbmCodeEngineAppVolumeMountToMap(model *codeenginev2.VolumeMount) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["mount_path"] = model.MountPath - if model.Name != nil { - modelMap["name"] = model.Name - } + modelMap["name"] = model.Name modelMap["reference"] = model.Reference modelMap["type"] = model.Type return modelMap, nil diff --git a/ibm/service/codeengine/resource_ibm_code_engine_app_test.go b/ibm/service/codeengine/resource_ibm_code_engine_app_test.go index 02d619235c..92e786f94e 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_app_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_app_test.go @@ -43,7 +43,6 @@ func TestAccIbmCodeEngineAppBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "name", name), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "image_port", "8080"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "managed_domain_mappings", "local_public"), - resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "run_as_user", "0"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "run_service_account", "default"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_concurrency", "100"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_cpu_limit", "1"), @@ -65,7 +64,6 @@ func TestAccIbmCodeEngineAppBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "name", nameUpdate), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "image_port", "8080"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "managed_domain_mappings", "local_public"), - resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "run_as_user", "0"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "run_service_account", "default"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_concurrency", "100"), resource.TestCheckResourceAttr("ibm_code_engine_app.code_engine_app_instance", "scale_cpu_limit", "1"), @@ -189,7 +187,9 @@ func testAccCheckIbmCodeEngineAppConfigBasic(projectID string, imageReference st lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } @@ -239,7 +239,9 @@ func testAccCheckIbmCodeEngineAppConfig(projectID string, configMapName string, lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } diff --git a/ibm/service/codeengine/resource_ibm_code_engine_binding.go b/ibm/service/codeengine/resource_ibm_code_engine_binding.go index b97ca47df2..b42b2a01a8 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_binding.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_binding.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -31,14 +31,14 @@ func ResourceIbmCodeEngineBinding() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_binding", "project_id"), Description: "The ID of the project.", }, - "component": &schema.Schema{ + "component": { Type: schema.TypeList, MinItems: 1, MaxItems: 1, @@ -47,12 +47,12 @@ func ResourceIbmCodeEngineBinding() *schema.Resource { Description: "A reference to another component.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of the referenced component.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Required: true, Description: "The type of the referenced resource.", @@ -60,36 +60,36 @@ func ResourceIbmCodeEngineBinding() *schema.Resource { }, }, }, - "prefix": &schema.Schema{ + "prefix": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_binding", "prefix"), - Description: "Optional value that is set as prefix in the component that is bound. Will be generated if not provided.", + Description: "The value that is set as a prefix in the component that is bound.", }, - "secret_name": &schema.Schema{ + "secret_name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_binding", "secret_name"), - Description: "The service access secret that is binding to a component.", + Description: "The service access secret that is bound to a component.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new binding, a URL is created identifying the location of the instance.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the binding.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the binding.", }, - "binding_id": &schema.Schema{ + "binding_id": { Type: schema.TypeString, Computed: true, Description: "The ID of the binding.", @@ -137,7 +137,9 @@ func ResourceIbmCodeEngineBindingValidator() *validate.ResourceValidator { func resourceIbmCodeEngineBindingCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_binding", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createBindingOptions := &codeenginev2.CreateBindingOptions{} @@ -151,10 +153,11 @@ func resourceIbmCodeEngineBindingCreate(context context.Context, d *schema.Resou createBindingOptions.SetPrefix(d.Get("prefix").(string)) createBindingOptions.SetSecretName(d.Get("secret_name").(string)) - binding, response, err := codeEngineClient.CreateBindingWithContext(context, createBindingOptions) + binding, _, err := codeEngineClient.CreateBindingWithContext(context, createBindingOptions) if err != nil { - log.Printf("[DEBUG] CreateBindingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateBindingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateBindingWithContext failed: %s", err.Error()), "ibm_code_engine_binding", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createBindingOptions.ProjectID, *binding.ID)) @@ -165,14 +168,17 @@ func resourceIbmCodeEngineBindingCreate(context context.Context, d *schema.Resou func resourceIbmCodeEngineBindingRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_binding", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getBindingOptions := &codeenginev2.GetBindingOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_binding", "read") + return tfErr.GetDiag() } getBindingOptions.SetProjectID(parts[0]) @@ -184,44 +190,45 @@ func resourceIbmCodeEngineBindingRead(context context.Context, d *schema.Resourc d.SetId("") return nil } - log.Printf("[DEBUG] GetBindingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetBindingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetBindingWithContext failed: %s", err.Error()), "ibm_code_engine_binding", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", binding.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } componentMap, err := resourceIbmCodeEngineBindingComponentRefToMap(binding.Component) if err != nil { return diag.FromErr(err) } if err = d.Set("component", []map[string]interface{}{componentMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting component: %s", err)) + return diag.FromErr(fmt.Errorf("error setting component: %s", err)) } if err = d.Set("prefix", binding.Prefix); err != nil { - return diag.FromErr(fmt.Errorf("Error setting prefix: %s", err)) + return diag.FromErr(fmt.Errorf("error setting prefix: %s", err)) } if err = d.Set("secret_name", binding.SecretName); err != nil { - return diag.FromErr(fmt.Errorf("Error setting secret_name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting secret_name: %s", err)) } if !core.IsNil(binding.Href) { if err = d.Set("href", binding.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(binding.ResourceType) { if err = d.Set("resource_type", binding.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if !core.IsNil(binding.Status) { if err = d.Set("status", binding.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status: %s", err)) } } if !core.IsNil(binding.ID) { if err = d.Set("binding_id", binding.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting binding_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting binding_id: %s", err)) } } @@ -231,23 +238,27 @@ func resourceIbmCodeEngineBindingRead(context context.Context, d *schema.Resourc func resourceIbmCodeEngineBindingDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_binding", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteBindingOptions := &codeenginev2.DeleteBindingOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_binding", "delete") + return tfErr.GetDiag() } deleteBindingOptions.SetProjectID(parts[0]) deleteBindingOptions.SetID(parts[1]) - response, err := codeEngineClient.DeleteBindingWithContext(context, deleteBindingOptions) + _, err = codeEngineClient.DeleteBindingWithContext(context, deleteBindingOptions) if err != nil { - log.Printf("[DEBUG] DeleteBindingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteBindingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteBindingWithContext failed: %s", err.Error()), "ibm_code_engine_binding", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go b/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go index 064e99bfb4..da8f76119f 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_binding_test.go @@ -69,7 +69,9 @@ func testAccCheckIbmCodeEngineBindingConfigBasic(projectID string, appName strin lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } diff --git a/ibm/service/codeengine/resource_ibm_code_engine_build.go b/ibm/service/codeengine/resource_ibm_code_engine_build.go index c223bdc742..fc161fcc66 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_build.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_build.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -27,127 +27,132 @@ func ResourceIbmCodeEngineBuild() *schema.Resource { Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "project_id"), Description: "The ID of the project.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "name"), - Description: "The name of the build. Use a name that is unique within the project.", + Description: "The name of the build.", }, - "output_image": &schema.Schema{ + "output_image": { Type: schema.TypeString, Required: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "output_image"), Description: "The name of the image.", }, - "output_secret": &schema.Schema{ + "output_secret": { Type: schema.TypeString, Required: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "output_secret"), Description: "The secret that is required to access the image registry. Make sure that the secret is granted with push permissions towards the specified container registry namespace.", }, - "strategy_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "strategy_type"), - Description: "The strategy to use for building the image.", - }, - "source_context_dir": &schema.Schema{ + "source_context_dir": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "source_context_dir"), - Description: "Option directory in the repository that contains the buildpacks file or the Dockerfile.", + Description: "Optional directory in the repository that contains the buildpacks file or the Dockerfile.", }, - "source_revision": &schema.Schema{ + "source_revision": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "source_revision"), Description: "Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and uses the HEAD of default branch if not specified. If the `source_type` value is `local`, this field must be omitted.", }, - "source_secret": &schema.Schema{ + "source_secret": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "source_secret"), Description: "Name of the secret that is used access the repository source. This field is optional if the `source_type` is `git`. Additionally, if the `source_url` points to a repository that requires authentication, the build will be created but cannot access any source code, until this property is provided, too. If the `source_type` value is `local`, this field must be omitted.", }, - "source_type": &schema.Schema{ + "source_type": { Type: schema.TypeString, Optional: true, Default: "git", ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "source_type"), Description: "Specifies the type of source to determine if your build source is in a repository or based on local source code.* local - For builds from local source code.* git - For builds from git version controlled source code.", }, - "source_url": &schema.Schema{ + "source_url": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "source_url"), Description: "The URL of the code repository. This field is required if the `source_type` is `git`. If the `source_type` value is `local`, this field must be omitted. If the repository is publicly available you can provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the repository requires authentication, you need to provide a 'ssh' URL like `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to a secret of format `ssh_auth`.", }, - "strategy_size": &schema.Schema{ + "strategy_size": { Type: schema.TypeString, Optional: true, Default: "medium", ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "strategy_size"), - Description: "Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`.", + Description: "Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`.", }, - "strategy_spec_file": &schema.Schema{ + "strategy_spec_file": { Type: schema.TypeString, Optional: true, Default: "Dockerfile", ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "strategy_spec_file"), Description: "Optional path to the specification file that is used for build strategies for building an image.", }, - "timeout": &schema.Schema{ + "strategy_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "strategy_type"), + Description: "The strategy to use for building the image.", + }, + "timeout": { Type: schema.TypeInt, Optional: true, Default: 600, ValidateFunc: validate.InvokeValidator("ibm_code_engine_build", "timeout"), Description: "The maximum amount of time, in seconds, that can pass before the build must succeed or fail.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the build instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new build, a URL is created identifying the location of the instance.", }, - "build_id": &schema.Schema{ + "build_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the build.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the build.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the build.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -155,7 +160,7 @@ func ResourceIbmCodeEngineBuild() *schema.Resource { }, }, }, - "etag": &schema.Schema{ + "etag": { Type: schema.TypeString, Computed: true, }, @@ -202,15 +207,6 @@ func ResourceIbmCodeEngineBuildValidator() *validate.ResourceValidator { MinValueLength: 1, MaxValueLength: 253, }, - validate.ValidateSchema{ - Identifier: "strategy_type", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `[\S]*`, - MinValueLength: 1, - MaxValueLength: 253, - }, validate.ValidateSchema{ Identifier: "source_context_dir", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -272,6 +268,15 @@ func ResourceIbmCodeEngineBuildValidator() *validate.ResourceValidator { MinValueLength: 1, MaxValueLength: 253, }, + validate.ValidateSchema{ + Identifier: "strategy_type", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `[\S]*`, + MinValueLength: 1, + MaxValueLength: 253, + }, validate.ValidateSchema{ Identifier: "timeout", ValidateFunctionIdentifier: validate.IntBetween, @@ -289,7 +294,9 @@ func ResourceIbmCodeEngineBuildValidator() *validate.ResourceValidator { func resourceIbmCodeEngineBuildCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createBuildOptions := &codeenginev2.CreateBuildOptions{} @@ -324,10 +331,11 @@ func resourceIbmCodeEngineBuildCreate(context context.Context, d *schema.Resourc createBuildOptions.SetTimeout(int64(d.Get("timeout").(int))) } - build, response, err := codeEngineClient.CreateBuildWithContext(context, createBuildOptions) + build, _, err := codeEngineClient.CreateBuildWithContext(context, createBuildOptions) if err != nil { - log.Printf("[DEBUG] CreateBuildWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateBuildWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateBuildWithContext failed: %s", err.Error()), "ibm_code_engine_build", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createBuildOptions.ProjectID, *build.Name)) @@ -338,14 +346,17 @@ func resourceIbmCodeEngineBuildCreate(context context.Context, d *schema.Resourc func resourceIbmCodeEngineBuildRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getBuildOptions := &codeenginev2.GetBuildOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "read") + return tfErr.GetDiag() } getBuildOptions.SetProjectID(parts[0]) @@ -357,91 +368,97 @@ func resourceIbmCodeEngineBuildRead(context context.Context, d *schema.ResourceD d.SetId("") return nil } - log.Printf("[DEBUG] GetBuildWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetBuildWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetBuildWithContext failed: %s", err.Error()), "ibm_code_engine_build", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", build.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } if err = d.Set("name", build.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) } if err = d.Set("output_image", build.OutputImage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output_image: %s", err)) + return diag.FromErr(fmt.Errorf("error setting output_image: %s", err)) } if err = d.Set("output_secret", build.OutputSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output_secret: %s", err)) - } - if err = d.Set("strategy_type", build.StrategyType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting output_secret: %s", err)) } if !core.IsNil(build.SourceContextDir) { if err = d.Set("source_context_dir", build.SourceContextDir); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_context_dir: %s", err)) + return diag.FromErr(fmt.Errorf("error setting source_context_dir: %s", err)) } } if !core.IsNil(build.SourceRevision) { if err = d.Set("source_revision", build.SourceRevision); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_revision: %s", err)) + return diag.FromErr(fmt.Errorf("error setting source_revision: %s", err)) } } if !core.IsNil(build.SourceSecret) { if err = d.Set("source_secret", build.SourceSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_secret: %s", err)) + return diag.FromErr(fmt.Errorf("error setting source_secret: %s", err)) } } if !core.IsNil(build.SourceType) { if err = d.Set("source_type", build.SourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting source_type: %s", err)) } } if !core.IsNil(build.SourceURL) { if err = d.Set("source_url", build.SourceURL); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source_url: %s", err)) + return diag.FromErr(fmt.Errorf("error setting source_url: %s", err)) } } if !core.IsNil(build.StrategySize) { if err = d.Set("strategy_size", build.StrategySize); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_size: %s", err)) + return diag.FromErr(fmt.Errorf("error setting strategy_size: %s", err)) } } if !core.IsNil(build.StrategySpecFile) { if err = d.Set("strategy_spec_file", build.StrategySpecFile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting strategy_spec_file: %s", err)) + return diag.FromErr(fmt.Errorf("error setting strategy_spec_file: %s", err)) } } + if err = d.Set("strategy_type", build.StrategyType); err != nil { + return diag.FromErr(fmt.Errorf("error setting strategy_type: %s", err)) + } if !core.IsNil(build.Timeout) { if err = d.Set("timeout", flex.IntValue(build.Timeout)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting timeout: %s", err)) + return diag.FromErr(fmt.Errorf("error setting timeout: %s", err)) } } if !core.IsNil(build.CreatedAt) { if err = d.Set("created_at", build.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if err = d.Set("entity_tag", build.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(build.Href) { if err = d.Set("href", build.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(build.ID) { if err = d.Set("build_id", build.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting build_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting build_id: %s", err)) + } + } + if !core.IsNil(build.Region) { + if err = d.Set("region", build.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(build.ResourceType) { if err = d.Set("resource_type", build.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if !core.IsNil(build.Status) { if err = d.Set("status", build.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status: %s", err)) } } if !core.IsNil(build.StatusDetails) { @@ -450,11 +467,12 @@ func resourceIbmCodeEngineBuildRead(context context.Context, d *schema.ResourceD return diag.FromErr(err) } if err = d.Set("status_details", []map[string]interface{}{statusDetailsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status_details: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_build", "read") + return tfErr.GetDiag() } return nil @@ -463,14 +481,17 @@ func resourceIbmCodeEngineBuildRead(context context.Context, d *schema.ResourceD func resourceIbmCodeEngineBuildUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateBuildOptions := &codeenginev2.UpdateBuildOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "update") + return tfErr.GetDiag() } updateBuildOptions.SetProjectID(parts[0]) @@ -480,20 +501,19 @@ func resourceIbmCodeEngineBuildUpdate(context context.Context, d *schema.Resourc patchVals := &codeenginev2.BuildPatch{} if d.HasChange("project_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "project_id")) - } - if d.HasChange("name") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "name")) + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_build", "update") + return tfErr.GetDiag() } - if d.HasChange("output_image") || d.HasChange("output_secret") || d.HasChange("strategy_type") { + if d.HasChange("output_image") { newOutputImage := d.Get("output_image").(string) patchVals.OutputImage = &newOutputImage + hasChange = true + } + if d.HasChange("output_secret") { newOutputSecret := d.Get("output_secret").(string) patchVals.OutputSecret = &newOutputSecret - newStrategyType := d.Get("strategy_type").(string) - patchVals.StrategyType = &newStrategyType hasChange = true } if d.HasChange("source_context_dir") { @@ -531,6 +551,11 @@ func resourceIbmCodeEngineBuildUpdate(context context.Context, d *schema.Resourc patchVals.StrategySpecFile = &newStrategySpecFile hasChange = true } + if d.HasChange("strategy_type") { + newStrategyType := d.Get("strategy_type").(string) + patchVals.StrategyType = &newStrategyType + hasChange = true + } if d.HasChange("timeout") { newTimeout := int64(d.Get("timeout").(int)) patchVals.Timeout = &newTimeout @@ -540,10 +565,11 @@ func resourceIbmCodeEngineBuildUpdate(context context.Context, d *schema.Resourc if hasChange { updateBuildOptions.Build, _ = patchVals.AsPatch() - _, response, err := codeEngineClient.UpdateBuildWithContext(context, updateBuildOptions) + _, _, err = codeEngineClient.UpdateBuildWithContext(context, updateBuildOptions) if err != nil { - log.Printf("[DEBUG] UpdateBuildWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateBuildWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("UpdateBuildWithContext failed: %s", err.Error()), "ibm_code_engine_build", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -553,23 +579,27 @@ func resourceIbmCodeEngineBuildUpdate(context context.Context, d *schema.Resourc func resourceIbmCodeEngineBuildDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteBuildOptions := &codeenginev2.DeleteBuildOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_build", "delete") + return tfErr.GetDiag() } deleteBuildOptions.SetProjectID(parts[0]) deleteBuildOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteBuildWithContext(context, deleteBuildOptions) + _, err = codeEngineClient.DeleteBuildWithContext(context, deleteBuildOptions) if err != nil { - log.Printf("[DEBUG] DeleteBuildWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteBuildWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteBuildWithContext failed: %s", err.Error()), "ibm_code_engine_build", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/codeengine/resource_ibm_code_engine_config_map.go b/ibm/service/codeengine/resource_ibm_code_engine_config_map.go index cecbd61ca3..3b7131abd3 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_config_map.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_config_map.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -27,52 +27,57 @@ func ResourceIbmCodeEngineConfigMap() *schema.Resource { Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_config_map", "project_id"), Description: "The ID of the project.", }, - "name": &schema.Schema{ + "data": { + Type: schema.TypeMap, + Optional: true, + Description: "The key-value pair for the config map. Values must be specified in `KEY=VALUE` format.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_config_map", "name"), - Description: "The name of the config map. Use a name that is unique within the project.", + Description: "The name of the config map.", }, - "data": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The key-value pair for the config map. Values must be specified in `KEY=VALUE` format. Each `KEY` field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each `VALUE` field can consists of any character and must not be exceed a max length of 1048576 characters.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the config map instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new config map, a URL is created identifying the location of the instance.", }, - "config_map_id": &schema.Schema{ + "config_map_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the config map.", }, - "etag": &schema.Schema{ + "etag": { Type: schema.TypeString, Computed: true, }, @@ -110,7 +115,9 @@ func ResourceIbmCodeEngineConfigMapValidator() *validate.ResourceValidator { func resourceIbmCodeEngineConfigMapCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createConfigMapOptions := &codeenginev2.CreateConfigMapOptions{} @@ -125,10 +132,11 @@ func resourceIbmCodeEngineConfigMapCreate(context context.Context, d *schema.Res createConfigMapOptions.SetData(data) } - configMap, response, err := codeEngineClient.CreateConfigMapWithContext(context, createConfigMapOptions) + configMap, _, err := codeEngineClient.CreateConfigMapWithContext(context, createConfigMapOptions) if err != nil { - log.Printf("[DEBUG] CreateConfigMapWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateConfigMapWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateConfigMapWithContext failed: %s", err.Error()), "ibm_code_engine_config_map", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createConfigMapOptions.ProjectID, *configMap.Name)) @@ -139,14 +147,17 @@ func resourceIbmCodeEngineConfigMapCreate(context context.Context, d *schema.Res func resourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getConfigMapOptions := &codeenginev2.GetConfigMapOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } getConfigMapOptions.SetProjectID(parts[0]) @@ -158,15 +169,13 @@ func resourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.Resou d.SetId("") return nil } - log.Printf("[DEBUG] GetConfigMapWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetConfigMapWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetConfigMapWithContext failed: %s", err.Error()), "ibm_code_engine_config_map", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", configMap.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) - } - if err = d.Set("name", configMap.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } if !core.IsNil(configMap.Data) { data := make(map[string]string) @@ -174,34 +183,43 @@ func resourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.Resou data[k] = string(v) } if err = d.Set("data", data); err != nil { - return diag.FromErr(fmt.Errorf("Error setting data: %s", err)) + return diag.FromErr(fmt.Errorf("error setting data: %s", err)) } } + if err = d.Set("name", configMap.Name); err != nil { + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) + } if !core.IsNil(configMap.CreatedAt) { if err = d.Set("created_at", configMap.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if err = d.Set("entity_tag", configMap.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(configMap.Href) { if err = d.Set("href", configMap.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(configMap.ID) { if err = d.Set("config_map_id", configMap.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting config_map_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting config_map_id: %s", err)) + } + } + if !core.IsNil(configMap.Region) { + if err = d.Set("region", configMap.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(configMap.ResourceType) { if err = d.Set("resource_type", configMap.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_config_map", "read") + return tfErr.GetDiag() } return nil @@ -210,14 +228,17 @@ func resourceIbmCodeEngineConfigMapRead(context context.Context, d *schema.Resou func resourceIbmCodeEngineConfigMapUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } replaceConfigMapOptions := &codeenginev2.ReplaceConfigMapOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "update") + return tfErr.GetDiag() } replaceConfigMapOptions.SetProjectID(parts[0]) @@ -225,9 +246,11 @@ func resourceIbmCodeEngineConfigMapUpdate(context context.Context, d *schema.Res hasChange := false - if d.HasChange("name") { - replaceConfigMapOptions.SetName(d.Get("name").(string)) - hasChange = true + if d.HasChange("project_id") { + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_config_map", "update") + return tfErr.GetDiag() } if d.HasChange("data") { data := make(map[string]string) @@ -240,10 +263,11 @@ func resourceIbmCodeEngineConfigMapUpdate(context context.Context, d *schema.Res replaceConfigMapOptions.SetIfMatch(d.Get("etag").(string)) if hasChange { - _, response, err := codeEngineClient.ReplaceConfigMapWithContext(context, replaceConfigMapOptions) + _, _, err = codeEngineClient.ReplaceConfigMapWithContext(context, replaceConfigMapOptions) if err != nil { - log.Printf("[DEBUG] ReplaceConfigMapWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ReplaceConfigMapWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("ReplaceConfigMapWithContext failed: %s", err.Error()), "ibm_code_engine_config_map", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -253,23 +277,27 @@ func resourceIbmCodeEngineConfigMapUpdate(context context.Context, d *schema.Res func resourceIbmCodeEngineConfigMapDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteConfigMapOptions := &codeenginev2.DeleteConfigMapOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_config_map", "delete") + return tfErr.GetDiag() } deleteConfigMapOptions.SetProjectID(parts[0]) deleteConfigMapOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteConfigMapWithContext(context, deleteConfigMapOptions) + _, err = codeEngineClient.DeleteConfigMapWithContext(context, deleteConfigMapOptions) if err != nil { - log.Printf("[DEBUG] DeleteConfigMapWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteConfigMapWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteConfigMapWithContext failed: %s", err.Error()), "ibm_code_engine_config_map", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping.go b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping.go index 5f1ab5ca72..97ce80a8e6 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/IBM-Cloud/bluemix-go/bmxerror" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" @@ -34,14 +33,14 @@ func ResourceIbmCodeEngineDomainMapping() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_domain_mapping", "project_id"), Description: "The ID of the project.", }, - "component": &schema.Schema{ + "component": { Type: schema.TypeList, MinItems: 1, MaxItems: 1, @@ -49,12 +48,12 @@ func ResourceIbmCodeEngineDomainMapping() *schema.Resource { Description: "A reference to another component.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "The name of the referenced component.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Required: true, Description: "The type of the referenced resource.", @@ -62,61 +61,66 @@ func ResourceIbmCodeEngineDomainMapping() *schema.Resource { }, }, }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_domain_mapping", "name"), Description: "The name of the domain mapping.", }, - "tls_secret": &schema.Schema{ + "tls_secret": { Type: schema.TypeString, Required: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_domain_mapping", "tls_secret"), - Description: "The name of the TLS secret that holds the certificate and private key of this domain mapping.", + Description: "The name of the TLS secret that includes the certificate and private key of this domain mapping.", }, - "cname_target": &schema.Schema{ + "cname_target": { Type: schema.TypeString, Computed: true, - Description: "Exposes the value of the CNAME record that needs to be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region.", + Description: "The value of the CNAME record that must be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "domain_mapping_id": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, - Description: "The identifier of the resource.", + Description: "The version of the domain mapping instance, which is used to achieve optimistic locking.", }, - "entity_tag": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, - Description: "The version of the domain mapping instance, which is used to achieve optimistic locking.", + Description: "When you provision a new domain mapping, a URL is created identifying the location of the instance.", }, - "href": &schema.Schema{ + "domain_mapping_id": { Type: schema.TypeString, Computed: true, - Description: "When you provision a new domain mapping, a URL is created identifying the location of the instance.", + Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { Type: schema.TypeString, Computed: true, - Description: "The type of the CE Resource.", + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", }, - "status": &schema.Schema{ + "resource_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of the Code Engine resource.", + }, + "status": { Type: schema.TypeString, Computed: true, Description: "The current status of the domain mapping.", }, - "status_details": &schema.Schema{ + "status_details": { Type: schema.TypeList, Computed: true, Description: "The detailed status of the domain mapping.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "reason": &schema.Schema{ + "reason": { Type: schema.TypeString, Computed: true, Description: "Optional information to provide more context in case of a 'failed' or 'warning' status.", @@ -124,17 +128,17 @@ func ResourceIbmCodeEngineDomainMapping() *schema.Resource { }, }, }, - "user_managed": &schema.Schema{ + "user_managed": { Type: schema.TypeBool, Computed: true, - Description: "Exposes whether the domain mapping is managed by the user or by Code Engine.", + Description: "Specifies whether the domain mapping is managed by the user or by Code Engine.", }, - "visibility": &schema.Schema{ + "visibility": { Type: schema.TypeString, Computed: true, - Description: "Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project.", + Description: "Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project.", }, - "etag": &schema.Schema{ + "etag": { Type: schema.TypeString, Computed: true, }, @@ -181,7 +185,9 @@ func ResourceIbmCodeEngineDomainMappingValidator() *validate.ResourceValidator { func resourceIbmCodeEngineDomainMappingCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createDomainMappingOptions := &codeenginev2.CreateDomainMappingOptions{} @@ -195,18 +201,20 @@ func resourceIbmCodeEngineDomainMappingCreate(context context.Context, d *schema createDomainMappingOptions.SetName(d.Get("name").(string)) createDomainMappingOptions.SetTlsSecret(d.Get("tls_secret").(string)) - domainMapping, response, err := codeEngineClient.CreateDomainMappingWithContext(context, createDomainMappingOptions) + domainMapping, _, err := codeEngineClient.CreateDomainMappingWithContext(context, createDomainMappingOptions) if err != nil { - log.Printf("[DEBUG] CreateDomainMappingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateDomainMappingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateDomainMappingWithContext failed: %s", err.Error()), "ibm_code_engine_domain_mapping", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createDomainMappingOptions.ProjectID, *domainMapping.Name)) _, err = waitForIbmCodeEngineDomainMappingCreate(d, meta) if err != nil { - return diag.FromErr(fmt.Errorf( - "Error waiting for resource IbmCodeEngineDomainMapping (%s) to be created: %s", d.Id(), err)) + errMsg := fmt.Sprintf("Error waiting for resource IbmCodeEngineDomainMapping (%s) to be created: %s", d.Id(), err) + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_domain_mapping", "create") + return tfErr.GetDiag() } return resourceIbmCodeEngineDomainMappingRead(context, d, meta) @@ -233,14 +241,15 @@ func waitForIbmCodeEngineDomainMappingCreate(d *schema.ResourceData, meta interf Refresh: func() (interface{}, string, error) { stateObj, response, err := codeEngineClient.GetDomainMapping(getDomainMappingOptions) if err != nil { - if apiErr, ok := err.(bmxerror.RequestFailure); ok && apiErr.StatusCode() == 404 { - return nil, "", fmt.Errorf("The instance %s does not exist anymore: %s\n%s", "getDomainMappingOptions", err, response) + if sdkErr, ok := err.(*core.SDKProblem); ok && response.GetStatusCode() == 404 { + sdkErr.Summary = fmt.Sprintf("The instance %s does not exist anymore: %s", "getDomainMappingOptions", err) + return nil, "", sdkErr } return nil, "", err } failStates := map[string]bool{"failure": true, "failed": true} if failStates[*stateObj.Status] { - return stateObj, *stateObj.Status, fmt.Errorf("The instance %s failed: %s\n%s", "getDomainMappingOptions", err, response) + return stateObj, *stateObj.Status, fmt.Errorf("the instance %s failed: %s", "getDomainMappingOptions", err) } return stateObj, *stateObj.Status, nil }, @@ -255,14 +264,17 @@ func waitForIbmCodeEngineDomainMappingCreate(d *schema.ResourceData, meta interf func resourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getDomainMappingOptions := &codeenginev2.GetDomainMappingOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } getDomainMappingOptions.SetProjectID(parts[0]) @@ -274,57 +286,63 @@ func resourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema.R d.SetId("") return nil } - log.Printf("[DEBUG] GetDomainMappingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetDomainMappingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetDomainMappingWithContext failed: %s", err.Error()), "ibm_code_engine_domain_mapping", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", domainMapping.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } componentMap, err := resourceIbmCodeEngineDomainMappingComponentRefToMap(domainMapping.Component) if err != nil { return diag.FromErr(err) } if err = d.Set("component", []map[string]interface{}{componentMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting component: %s", err)) + return diag.FromErr(fmt.Errorf("error setting component: %s", err)) } if err = d.Set("name", domainMapping.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) } if err = d.Set("tls_secret", domainMapping.TlsSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tls_secret: %s", err)) + return diag.FromErr(fmt.Errorf("error setting tls_secret: %s", err)) } if !core.IsNil(domainMapping.CnameTarget) { if err = d.Set("cname_target", domainMapping.CnameTarget); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cname_target: %s", err)) + return diag.FromErr(fmt.Errorf("error setting cname_target: %s", err)) } } if !core.IsNil(domainMapping.CreatedAt) { if err = d.Set("created_at", domainMapping.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if err = d.Set("entity_tag", domainMapping.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(domainMapping.Href) { if err = d.Set("href", domainMapping.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(domainMapping.ID) { if err = d.Set("domain_mapping_id", domainMapping.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting domain_mapping_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting domain_mapping_id: %s", err)) + } + } + if !core.IsNil(domainMapping.Region) { + if err = d.Set("region", domainMapping.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(domainMapping.ResourceType) { if err = d.Set("resource_type", domainMapping.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if !core.IsNil(domainMapping.Status) { if err = d.Set("status", domainMapping.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status: %s", err)) } } if !core.IsNil(domainMapping.StatusDetails) { @@ -333,21 +351,22 @@ func resourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema.R return diag.FromErr(err) } if err = d.Set("status_details", []map[string]interface{}{statusDetailsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_details: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status_details: %s", err)) } } if !core.IsNil(domainMapping.UserManaged) { if err = d.Set("user_managed", domainMapping.UserManaged); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_managed: %s", err)) + return diag.FromErr(fmt.Errorf("error setting user_managed: %s", err)) } } if !core.IsNil(domainMapping.Visibility) { if err = d.Set("visibility", domainMapping.Visibility); err != nil { - return diag.FromErr(fmt.Errorf("Error setting visibility: %s", err)) + return diag.FromErr(fmt.Errorf("error setting visibility: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_domain_mapping", "read") + return tfErr.GetDiag() } return nil @@ -356,14 +375,17 @@ func resourceIbmCodeEngineDomainMappingRead(context context.Context, d *schema.R func resourceIbmCodeEngineDomainMappingUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateDomainMappingOptions := &codeenginev2.UpdateDomainMappingOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "update") + return tfErr.GetDiag() } updateDomainMappingOptions.SetProjectID(parts[0]) @@ -373,12 +395,10 @@ func resourceIbmCodeEngineDomainMappingUpdate(context context.Context, d *schema patchVals := &codeenginev2.DomainMappingPatch{} if d.HasChange("project_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "project_id")) - } - if d.HasChange("name") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "name")) + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_domain_mapping", "update") + return tfErr.GetDiag() } if d.HasChange("component") { component, err := resourceIbmCodeEngineDomainMappingMapToComponentRef(d.Get("component.0").(map[string]interface{})) @@ -397,10 +417,11 @@ func resourceIbmCodeEngineDomainMappingUpdate(context context.Context, d *schema if hasChange { updateDomainMappingOptions.DomainMapping, _ = patchVals.AsPatch() - _, response, err := codeEngineClient.UpdateDomainMappingWithContext(context, updateDomainMappingOptions) + _, _, err = codeEngineClient.UpdateDomainMappingWithContext(context, updateDomainMappingOptions) if err != nil { - log.Printf("[DEBUG] UpdateDomainMappingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateDomainMappingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("UpdateDomainMappingWithContext failed: %s", err.Error()), "ibm_code_engine_domain_mapping", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -410,23 +431,27 @@ func resourceIbmCodeEngineDomainMappingUpdate(context context.Context, d *schema func resourceIbmCodeEngineDomainMappingDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteDomainMappingOptions := &codeenginev2.DeleteDomainMappingOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_domain_mapping", "delete") + return tfErr.GetDiag() } deleteDomainMappingOptions.SetProjectID(parts[0]) deleteDomainMappingOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteDomainMappingWithContext(context, deleteDomainMappingOptions) + _, err = codeEngineClient.DeleteDomainMappingWithContext(context, deleteDomainMappingOptions) if err != nil { - log.Printf("[DEBUG] DeleteDomainMappingWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteDomainMappingWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteDomainMappingWithContext failed: %s", err.Error()), "ibm_code_engine_domain_mapping", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go index 21ae9dfa77..4cd3c3ccf3 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_domain_mapping_test.go @@ -4,12 +4,11 @@ package codeengine_test import ( - "encoding/base64" "fmt" + "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,11 +18,6 @@ import ( "github.com/IBM/code-engine-go-sdk/codeenginev2" ) -const ( - CeTlsCert = "IBM_CODE_ENGINE_TLS_CERT" - CeTlsKey = "IBM_CODE_ENGINE_TLS_KEY" -) - func TestAccIbmCodeEngineDomainMappingBasic(t *testing.T) { var conf codeenginev2.DomainMapping @@ -33,8 +27,8 @@ func TestAccIbmCodeEngineDomainMappingBasic(t *testing.T) { projectID := acc.CeProjectId domainMappingName := acc.CeDomainMappingName - domainMappingTLSKey := decodeBase64EnvVar(acc.CeTLSKey, CeTlsKey) - domainMappingTLSCert := decodeBase64EnvVar(acc.CeTLSCert, CeTlsCert) + domainMappingTLSKey, _ := os.ReadFile(acc.CeTLSKeyFilePath) + domainMappingTLSCert, _ := os.ReadFile(acc.CeTLSCertFilePath) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheckCodeEngine(t) }, @@ -42,7 +36,7 @@ func TestAccIbmCodeEngineDomainMappingBasic(t *testing.T) { CheckDestroy: testAccCheckIbmCodeEngineDomainMappingDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID, app1Name, app2Name, domainMappingTLSKey, domainMappingTLSCert, secretName, app1Name, domainMappingName, "app1_instance"), + Config: testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID, app1Name, app2Name, string(domainMappingTLSKey), string(domainMappingTLSCert), secretName, app1Name, domainMappingName, "app1_instance"), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmCodeEngineDomainMappingExists("ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", conf), resource.TestCheckResourceAttrSet("ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", "id"), @@ -60,7 +54,7 @@ func TestAccIbmCodeEngineDomainMappingBasic(t *testing.T) { ), }, { - Config: testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID, app1Name, app2Name, domainMappingTLSKey, domainMappingTLSCert, secretName, app2Name, domainMappingName, "app2_instance"), + Config: testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID, app1Name, app2Name, string(domainMappingTLSKey), string(domainMappingTLSCert), secretName, app2Name, domainMappingName, "app2_instance"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrSet("ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", "id"), resource.TestCheckResourceAttrSet("ibm_code_engine_domain_mapping.code_engine_domain_mapping_instance", "href"), @@ -80,7 +74,7 @@ func TestAccIbmCodeEngineDomainMappingBasic(t *testing.T) { }) } -func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Name string, app2Name string, tlsKey string, tslCert string, secretName string, componentRefName string, domainMappingName string, dependsOn string) string { +func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Name string, app2Name string, tlsKey string, tlsCert string, secretName string, componentRefName string, domainMappingName string, dependsOn string) string { return fmt.Sprintf(` data "ibm_code_engine_project" "code_engine_project_instance" { project_id = "%s" @@ -93,7 +87,9 @@ func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Nam lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } @@ -105,7 +101,9 @@ func testAccCheckIbmCodeEngineDomainMappingConfigBasic(projectID string, app1Nam lifecycle { ignore_changes = [ - run_env_variables + run_env_variables, + probe_liveness, + probe_readiness ] } } @@ -142,7 +140,7 @@ EOT ibm_code_engine_app.code_engine_%s ] } - `, projectID, app1Name, app2Name, tlsKey, tslCert, secretName, componentRefName, domainMappingName, dependsOn) + `, projectID, app1Name, app2Name, tlsKey, tlsCert, secretName, componentRefName, domainMappingName, dependsOn) } func testAccCheckIbmCodeEngineDomainMappingExists(n string, obj codeenginev2.DomainMapping) resource.TestCheckFunc { @@ -210,12 +208,3 @@ func testAccCheckIbmCodeEngineDomainMappingDestroy(s *terraform.State) error { return nil } - -func decodeBase64EnvVar(base64Text string, envVar string) string { - decodedText, err := base64.StdEncoding.DecodeString(base64Text) - if err != nil { - // fmt.Errorf("Error decoding environment variable %s: %s", envVar, err) - return "" - } - return string(decodedText) -} diff --git a/ibm/service/codeengine/resource_ibm_code_engine_job.go b/ibm/service/codeengine/resource_ibm_code_engine_job.go index fe51077431..6547d1efaa 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_job.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_job.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -27,86 +27,83 @@ func ResourceIbmCodeEngineJob() *schema.Resource { Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "project_id"), Description: "The ID of the project.", }, - "image_reference": &schema.Schema{ + "image_reference": { Type: schema.TypeString, Required: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "image_reference"), Description: "The name of the image that is used for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "name"), - Description: "The name of the job. Use a name that is unique within the project.", - }, - "image_secret": &schema.Schema{ + "image_secret": { Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "image_secret"), Description: "The name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the job / job runs will be created but submitted job runs will fail, until this property is provided, too. This property must not be set on a job run, which references a job template.", }, - "run_arguments": &schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "name"), + Description: "The name of the job.", + }, + "run_arguments": { Type: schema.TypeList, Optional: true, - MinItems: 0, Description: "Set arguments for the job that are passed to start job run containers. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "run_as_user": &schema.Schema{ + "run_as_user": { Type: schema.TypeInt, Optional: true, Default: 0, - Description: "The user ID (UID) to run the application (e.g., 1001).", + Description: "The user ID (UID) to run the job.", }, - "run_commands": &schema.Schema{ + "run_commands": { Type: schema.TypeList, Optional: true, - MinItems: 0, Description: "Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "run_env_variables": &schema.Schema{ + "run_env_variables": { Type: schema.TypeList, Optional: true, - MinItems: 0, - Description: "Optional references to config maps, secrets or a literal values.", + Description: "References to config maps, secrets or literal values, which are exposed as environment variables in the job run.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "key": &schema.Schema{ + "key": { Type: schema.TypeString, Optional: true, Description: "The key to reference as environment variable.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Optional: true, Description: "The name of the environment variable.", }, - "prefix": &schema.Schema{ + "prefix": { Type: schema.TypeString, Optional: true, Description: "A prefix that can be added to all keys of a full secret or config map reference.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Optional: true, Description: "The name of the secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Optional: true, Default: "literal", Description: "Specify the type of the environment variable.", }, - "value": &schema.Schema{ + "value": { Type: schema.TypeString, Optional: true, Description: "The literal value of the environment variable.", @@ -114,43 +111,42 @@ func ResourceIbmCodeEngineJob() *schema.Resource { }, }, }, - "run_mode": &schema.Schema{ + "run_mode": { Type: schema.TypeString, Optional: true, Default: "task", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "run_mode"), - Description: "The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `scale_max_execution_time` and `scale_retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `scale_max_execution_time` and `scale_retry_limit` properties are not allowed.", + Description: "The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed.", }, - "run_service_account": &schema.Schema{ + "run_service_account": { Type: schema.TypeString, Optional: true, Default: "default", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "run_service_account"), Description: "The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, `reader`, and `writer`. This property must not be set on a job run, which references a job template.", }, - "run_volume_mounts": &schema.Schema{ + "run_volume_mounts": { Type: schema.TypeList, Optional: true, - MinItems: 0, - Description: "Optional mounts of config maps or a secrets.", + Description: "Optional mounts of config maps or secrets.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "mount_path": &schema.Schema{ + "mount_path": { Type: schema.TypeString, Required: true, Description: "The path that should be mounted.", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, - Optional: true, - Description: "Optional name of the mount. If not set, it will be generated based on the `ref` and a random ID. In case the `ref` is longer than 58 characters, it will be cut off.", + Required: true, + Description: "The name of the mount.", }, - "reference": &schema.Schema{ + "reference": { Type: schema.TypeString, Required: true, Description: "The name of the referenced secret or config map.", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Required: true, Description: "Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'.", @@ -158,72 +154,86 @@ func ResourceIbmCodeEngineJob() *schema.Resource { }, }, }, - "scale_array_spec": &schema.Schema{ + "scale_array_spec": { Type: schema.TypeString, Optional: true, - Default: "0", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "scale_array_spec"), - Description: "Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of unique array indices specified here determines the number of job instances to run.", + Description: "Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number of unique array indices that you specify with this parameter determines the number of job instances to run.", }, - "scale_cpu_limit": &schema.Schema{ + "scale_cpu_limit": { Type: schema.TypeString, Optional: true, Default: "1", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "scale_cpu_limit"), Description: "Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo).", }, - "scale_ephemeral_storage_limit": &schema.Schema{ + "scale_ephemeral_storage_limit": { Type: schema.TypeString, Optional: true, Default: "400M", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "scale_ephemeral_storage_limit"), Description: "Optional amount of ephemeral storage to set for the instance of the job. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_max_execution_time": &schema.Schema{ + "scale_max_execution_time": { Type: schema.TypeInt, Optional: true, Default: 7200, Description: "The maximum execution time in seconds for runs of the job. This property can only be specified if `run_mode` is `task`.", }, - "scale_memory_limit": &schema.Schema{ + "scale_memory_limit": { Type: schema.TypeString, Optional: true, Default: "4G", ValidateFunc: validate.InvokeValidator("ibm_code_engine_job", "scale_memory_limit"), Description: "Optional amount of memory set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements).", }, - "scale_retry_limit": &schema.Schema{ + "scale_retry_limit": { Type: schema.TypeInt, Optional: true, Default: 3, Description: "The number of times to rerun an instance of the job before the job is marked as failed. This property can only be specified if `run_mode` is `task`.", }, - "created_at": &schema.Schema{ + "build": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build that is associated with the job.", + }, + "build_run": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to a build run that is associated with the job.", + }, + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the resource was created.", }, - "entity_tag": &schema.Schema{ + "entity_tag": { Type: schema.TypeString, Computed: true, Description: "The version of the job instance, which is used to achieve optimistic locking.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new job, a URL is created identifying the location of the instance.", }, - "job_id": &schema.Schema{ + "job_id": { Type: schema.TypeString, Computed: true, Description: "The identifier of the resource.", }, - "resource_type": &schema.Schema{ + "region": { + Type: schema.TypeString, + Computed: true, + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", + }, + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the job.", }, - "etag": &schema.Schema{ + "etag": { Type: schema.TypeString, Computed: true, }, @@ -253,22 +263,22 @@ func ResourceIbmCodeEngineJobValidator() *validate.ResourceValidator { MaxValueLength: 256, }, validate.ValidateSchema{ - Identifier: "name", + Identifier: "image_secret", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, - Regexp: `^[a-z0-9]([\-a-z0-9]*[a-z0-9])?$`, + Optional: true, + Regexp: `^[a-z0-9]([\-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([\-a-z0-9]*[a-z0-9])?)*$`, MinValueLength: 1, - MaxValueLength: 63, + MaxValueLength: 253, }, validate.ValidateSchema{ - Identifier: "image_secret", + Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, - Regexp: `^[a-z0-9]([\-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([\-a-z0-9]*[a-z0-9])?)*$`, + Required: true, + Regexp: `^[a-z0-9]([\-a-z0-9]*[a-z0-9])?$`, MinValueLength: 1, - MaxValueLength: 253, + MaxValueLength: 63, }, validate.ValidateSchema{ Identifier: "run_mode", @@ -333,7 +343,9 @@ func ResourceIbmCodeEngineJobValidator() *validate.ResourceValidator { func resourceIbmCodeEngineJobCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createJobOptions := &codeenginev2.CreateJobOptions{} @@ -412,10 +424,11 @@ func resourceIbmCodeEngineJobCreate(context context.Context, d *schema.ResourceD createJobOptions.SetScaleRetryLimit(int64(d.Get("scale_retry_limit").(int))) } - job, response, err := codeEngineClient.CreateJobWithContext(context, createJobOptions) + job, _, err := codeEngineClient.CreateJobWithContext(context, createJobOptions) if err != nil { - log.Printf("[DEBUG] CreateJobWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateJobWithContext failed: %s", err.Error()), "ibm_code_engine_job", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createJobOptions.ProjectID, *job.Name)) @@ -426,14 +439,17 @@ func resourceIbmCodeEngineJobCreate(context context.Context, d *schema.ResourceD func resourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getJobOptions := &codeenginev2.GetJobOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "read") + return tfErr.GetDiag() } getJobOptions.SetProjectID(parts[0]) @@ -445,130 +461,147 @@ func resourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceDat d.SetId("") return nil } - log.Printf("[DEBUG] GetJobWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetJobWithContext failed: %s", err.Error()), "ibm_code_engine_job", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", job.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } if err = d.Set("image_reference", job.ImageReference); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_reference: %s", err)) - } - if err = d.Set("name", job.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting image_reference: %s", err)) } if !core.IsNil(job.ImageSecret) { if err = d.Set("image_secret", job.ImageSecret); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_secret: %s", err)) + return diag.FromErr(fmt.Errorf("error setting image_secret: %s", err)) } } + if err = d.Set("name", job.Name); err != nil { + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) + } if !core.IsNil(job.RunArguments) { if err = d.Set("run_arguments", job.RunArguments); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_arguments: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_arguments: %s", err)) } } if !core.IsNil(job.RunAsUser) { if err = d.Set("run_as_user", flex.IntValue(job.RunAsUser)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_as_user: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_as_user: %s", err)) } } if !core.IsNil(job.RunCommands) { if err = d.Set("run_commands", job.RunCommands); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_commands: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_commands: %s", err)) } } if !core.IsNil(job.RunEnvVariables) { runEnvVariables := []map[string]interface{}{} for _, runEnvVariablesItem := range job.RunEnvVariables { - runEnvVariablesItemMap, err := resourceIbmCodeEngineJobEnvVarToMap(&runEnvVariablesItem) + runEnvVariablesItemMap, err := resourceIbmCodeEngineJobEnvVarToMap(&runEnvVariablesItem) /* #nosec G601 */ if err != nil { return diag.FromErr(err) } runEnvVariables = append(runEnvVariables, runEnvVariablesItemMap) } if err = d.Set("run_env_variables", runEnvVariables); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_env_variables: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_env_variables: %s", err)) } } if !core.IsNil(job.RunMode) { if err = d.Set("run_mode", job.RunMode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_mode: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_mode: %s", err)) } } if !core.IsNil(job.RunServiceAccount) { if err = d.Set("run_service_account", job.RunServiceAccount); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_service_account: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_service_account: %s", err)) } } if !core.IsNil(job.RunVolumeMounts) { runVolumeMounts := []map[string]interface{}{} for _, runVolumeMountsItem := range job.RunVolumeMounts { - runVolumeMountsItemMap, err := resourceIbmCodeEngineJobVolumeMountToMap(&runVolumeMountsItem) + runVolumeMountsItemMap, err := resourceIbmCodeEngineJobVolumeMountToMap(&runVolumeMountsItem) /* #nosec G601 */ if err != nil { return diag.FromErr(err) } runVolumeMounts = append(runVolumeMounts, runVolumeMountsItemMap) } if err = d.Set("run_volume_mounts", runVolumeMounts); err != nil { - return diag.FromErr(fmt.Errorf("Error setting run_volume_mounts: %s", err)) + return diag.FromErr(fmt.Errorf("error setting run_volume_mounts: %s", err)) } } if !core.IsNil(job.ScaleArraySpec) { if err = d.Set("scale_array_spec", job.ScaleArraySpec); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_array_spec: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_array_spec: %s", err)) } } if !core.IsNil(job.ScaleCpuLimit) { if err = d.Set("scale_cpu_limit", job.ScaleCpuLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_cpu_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_cpu_limit: %s", err)) } } if !core.IsNil(job.ScaleEphemeralStorageLimit) { if err = d.Set("scale_ephemeral_storage_limit", job.ScaleEphemeralStorageLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_ephemeral_storage_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_ephemeral_storage_limit: %s", err)) } } if !core.IsNil(job.ScaleMaxExecutionTime) { if err = d.Set("scale_max_execution_time", flex.IntValue(job.ScaleMaxExecutionTime)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_max_execution_time: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_max_execution_time: %s", err)) } } if !core.IsNil(job.ScaleMemoryLimit) { if err = d.Set("scale_memory_limit", job.ScaleMemoryLimit); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_memory_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_memory_limit: %s", err)) } } if !core.IsNil(job.ScaleRetryLimit) { if err = d.Set("scale_retry_limit", flex.IntValue(job.ScaleRetryLimit)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting scale_retry_limit: %s", err)) + return diag.FromErr(fmt.Errorf("error setting scale_retry_limit: %s", err)) + } + } + if !core.IsNil(job.Build) { + if err = d.Set("build", job.Build); err != nil { + return diag.FromErr(fmt.Errorf("error setting build: %s", err)) + } + } + if !core.IsNil(job.BuildRun) { + if err = d.Set("build_run", job.BuildRun); err != nil { + return diag.FromErr(fmt.Errorf("error setting build_run: %s", err)) } } if !core.IsNil(job.CreatedAt) { if err = d.Set("created_at", job.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if err = d.Set("entity_tag", job.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(job.Href) { if err = d.Set("href", job.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(job.ID) { if err = d.Set("job_id", job.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting job_id: %s", err)) + } + } + if !core.IsNil(job.Region) { + if err = d.Set("region", job.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(job.ResourceType) { if err = d.Set("resource_type", job.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_job", "read") + return tfErr.GetDiag() } return nil @@ -577,14 +610,17 @@ func resourceIbmCodeEngineJobRead(context context.Context, d *schema.ResourceDat func resourceIbmCodeEngineJobUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } updateJobOptions := &codeenginev2.UpdateJobOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "update") + return tfErr.GetDiag() } updateJobOptions.SetProjectID(parts[0]) @@ -593,10 +629,15 @@ func resourceIbmCodeEngineJobUpdate(context context.Context, d *schema.ResourceD hasChange := false patchVals := &codeenginev2.JobPatch{} - if d.HasChange("image_reference") || d.HasChange("name") { + if d.HasChange("project_id") { + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_job", "update") + return tfErr.GetDiag() + } + if d.HasChange("image_reference") { newImageReference := d.Get("image_reference").(string) patchVals.ImageReference = &newImageReference - updateJobOptions.SetName(d.Get("name").(string)) hasChange = true } if d.HasChange("image_secret") { @@ -697,10 +738,11 @@ func resourceIbmCodeEngineJobUpdate(context context.Context, d *schema.ResourceD if hasChange { updateJobOptions.Job, _ = patchVals.AsPatch() - _, response, err := codeEngineClient.UpdateJobWithContext(context, updateJobOptions) + _, _, err = codeEngineClient.UpdateJobWithContext(context, updateJobOptions) if err != nil { - log.Printf("[DEBUG] UpdateJobWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("UpdateJobWithContext failed: %s", err.Error()), "ibm_code_engine_job", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -710,23 +752,27 @@ func resourceIbmCodeEngineJobUpdate(context context.Context, d *schema.ResourceD func resourceIbmCodeEngineJobDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteJobOptions := &codeenginev2.DeleteJobOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_job", "delete") + return tfErr.GetDiag() } deleteJobOptions.SetProjectID(parts[0]) deleteJobOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteJobWithContext(context, deleteJobOptions) + _, err = codeEngineClient.DeleteJobWithContext(context, deleteJobOptions) if err != nil { - log.Printf("[DEBUG] DeleteJobWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteJobWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteJobWithContext failed: %s", err.Error()), "ibm_code_engine_job", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") @@ -782,9 +828,7 @@ func resourceIbmCodeEngineJobEnvVarToMap(model *codeenginev2.EnvVar) (map[string if model.Reference != nil { modelMap["reference"] = model.Reference } - if model.Type != nil { - modelMap["type"] = model.Type - } + modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } @@ -794,9 +838,7 @@ func resourceIbmCodeEngineJobEnvVarToMap(model *codeenginev2.EnvVar) (map[string func resourceIbmCodeEngineJobVolumeMountToMap(model *codeenginev2.VolumeMount) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["mount_path"] = model.MountPath - if model.Name != nil { - modelMap["name"] = model.Name - } + modelMap["name"] = model.Name modelMap["reference"] = model.Reference modelMap["type"] = model.Type return modelMap, nil diff --git a/ibm/service/codeengine/resource_ibm_code_engine_job_test.go b/ibm/service/codeengine/resource_ibm_code_engine_job_test.go index 078e0e758d..a0612b9bf9 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_job_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_job_test.go @@ -155,6 +155,13 @@ func testAccCheckIbmCodeEngineJobConfigBasic(projectID string, name string, imag project_id = data.ibm_code_engine_project.code_engine_project_instance.project_id name = "%s" image_reference = "%s" + + lifecycle { + ignore_changes = [ + run_env_variables, + scale_array_spec + ] + } } `, projectID, name, imageReference) } @@ -177,7 +184,15 @@ func testAccCheckIbmCodeEngineJobConfig(projectID string, name string, imageRefe scale_max_execution_time = %s scale_memory_limit = "%s" scale_retry_limit = %s + + lifecycle { + ignore_changes = [ + run_env_variables, + scale_array_spec + ] + } } + `, projectID, name, imageReference, runAsUser, runMode, runServiceAccount, scaleCpuLimit, scaleEphemeralStorageLimit, scaleMaxExecutionTime, scaleMemoryLimit, scaleRetryLimit) } diff --git a/ibm/service/codeengine/resource_ibm_code_engine_project.go b/ibm/service/codeengine/resource_ibm_code_engine_project.go index 0e3b7a02fa..d6daf67ef9 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_project.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_project.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -13,8 +13,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/IBM-Cloud/bluemix-go/bmxerror" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" "github.com/IBM/code-engine-go-sdk/codeenginev2" "github.com/IBM/go-sdk-core/v5/core" @@ -26,65 +26,64 @@ func ResourceIbmCodeEngineProject() *schema.Resource { ReadContext: resourceIbmCodeEngineProjectRead, DeleteContext: resourceIbmCodeEngineProjectDelete, Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), }, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_project", "name"), Description: "The name of the project.", }, - "project_id": &schema.Schema{ + "project_id": { Type: schema.TypeString, Computed: true, Description: "The ID of the project.", }, - "resource_group_id": &schema.Schema{ + "resource_group_id": { Type: schema.TypeString, Optional: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_code_engine_project", "resource_group_id"), - Description: "Optional ID of the resource group for your project deployment. If this field is not defined, the default resource group of the account will be used.", + Description: "The ID of the resource group.", }, - "account_id": &schema.Schema{ + "account_id": { Type: schema.TypeString, Computed: true, Description: "An alphanumeric value identifying the account ID.", }, - "created_at": &schema.Schema{ + "created_at": { Type: schema.TypeString, Computed: true, Description: "The timestamp when the project was created.", }, - "crn": &schema.Schema{ + "crn": { Type: schema.TypeString, Computed: true, Description: "The CRN of the project.", }, - "href": &schema.Schema{ + "href": { Type: schema.TypeString, Computed: true, Description: "When you provision a new resource, a URL is created identifying the location of the instance.", }, - "region": &schema.Schema{ + "region": { Type: schema.TypeString, Computed: true, Description: "The region for your project deployment. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", }, - "resource_type": &schema.Schema{ + "resource_type": { Type: schema.TypeString, Computed: true, Description: "The type of the project.", }, - "status": &schema.Schema{ + "status": { Type: schema.TypeString, Computed: true, - Description: "The current state of the project. For example, if the project is created and ready to get used, it will return active.", + Description: "The current state of the project. For example, when the project is created and is ready for use, the status of the project is active.", }, }, } @@ -120,7 +119,9 @@ func ResourceIbmCodeEngineProjectValidator() *validate.ResourceValidator { func resourceIbmCodeEngineProjectCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_project", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createProjectOptions := &codeenginev2.CreateProjectOptions{} @@ -129,19 +130,29 @@ func resourceIbmCodeEngineProjectCreate(context context.Context, d *schema.Resou if _, ok := d.GetOk("resource_group_id"); ok { createProjectOptions.SetResourceGroupID(d.Get("resource_group_id").(string)) } + if _, ok := d.GetOk("tags"); ok { + var tags []string + for _, v := range d.Get("tags").([]interface{}) { + tagsItem := v.(string) + tags = append(tags, tagsItem) + } + createProjectOptions.SetTags(tags) + } - project, response, err := codeEngineClient.CreateProjectWithContext(context, createProjectOptions) + project, _, err := codeEngineClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { - log.Printf("[DEBUG] CreateProjectWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateProjectWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateProjectWithContext failed: %s", err.Error()), "ibm_code_engine_project", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(*project.ID) _, err = waitForIbmCodeEngineProjectCreate(d, meta) if err != nil { - return diag.FromErr(fmt.Errorf( - "Error waiting for resource IbmCodeEngineProject (%s) to be created: %s", d.Id(), err)) + errMsg := fmt.Sprintf("Error waiting for resource IbmCodeEngineProject (%s) to be created: %s", d.Id(), err) + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_project", "create") + return tfErr.GetDiag() } return resourceIbmCodeEngineProjectRead(context, d, meta) @@ -162,14 +173,15 @@ func waitForIbmCodeEngineProjectCreate(d *schema.ResourceData, meta interface{}) Refresh: func() (interface{}, string, error) { stateObj, response, err := codeEngineClient.GetProject(getProjectOptions) if err != nil { - if apiErr, ok := err.(bmxerror.RequestFailure); ok && apiErr.StatusCode() == 404 { - return nil, "", fmt.Errorf("The instance %s does not exist anymore: %s\n%s", "getProjectOptions", err, response) + if sdkErr, ok := err.(*core.SDKProblem); ok && response.GetStatusCode() == 404 { + sdkErr.Summary = fmt.Sprintf("The instance %s does not exist anymore: %s", "getProjectOptions", err) + return nil, "", sdkErr } return nil, "", err } failStates := map[string]bool{"creation_failed": true} if failStates[*stateObj.Status] { - return stateObj, *stateObj.Status, fmt.Errorf("The instance %s failed: %s\n%s", "getProjectOptions", err, response) + return stateObj, *stateObj.Status, fmt.Errorf("the instance %s failed: %s", "getProjectOptions", err) } return stateObj, *stateObj.Status, nil }, @@ -184,7 +196,9 @@ func waitForIbmCodeEngineProjectCreate(d *schema.ResourceData, meta interface{}) func resourceIbmCodeEngineProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_project", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getProjectOptions := &codeenginev2.GetProjectOptions{} @@ -197,54 +211,55 @@ func resourceIbmCodeEngineProjectRead(context context.Context, d *schema.Resourc d.SetId("") return nil } - log.Printf("[DEBUG] GetProjectWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetProjectWithContext failed: %s", err.Error()), "ibm_code_engine_project", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) } if err = d.Set("project_id", project.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } if !core.IsNil(project.ResourceGroupID) { if err = d.Set("resource_group_id", project.ResourceGroupID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_group_id: %s", err)) } } if !core.IsNil(project.AccountID) { if err = d.Set("account_id", project.AccountID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting account_id: %s", err)) + return diag.FromErr(fmt.Errorf("error setting account_id: %s", err)) } } if !core.IsNil(project.CreatedAt) { if err = d.Set("created_at", project.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if !core.IsNil(project.Crn) { if err = d.Set("crn", project.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + return diag.FromErr(fmt.Errorf("error setting crn: %s", err)) } } if !core.IsNil(project.Href) { if err = d.Set("href", project.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(project.Region) { if err = d.Set("region", project.Region); err != nil { - return diag.FromErr(fmt.Errorf("Error setting region: %s", err)) + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } if !core.IsNil(project.ResourceType) { if err = d.Set("resource_type", project.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if !core.IsNil(project.Status) { if err = d.Set("status", project.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + return diag.FromErr(fmt.Errorf("error setting status: %s", err)) } } @@ -254,17 +269,20 @@ func resourceIbmCodeEngineProjectRead(context context.Context, d *schema.Resourc func resourceIbmCodeEngineProjectDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_project", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteProjectOptions := &codeenginev2.DeleteProjectOptions{} deleteProjectOptions.SetID(d.Id()) - response, err := codeEngineClient.DeleteProjectWithContext(context, deleteProjectOptions) + _, err = codeEngineClient.DeleteProjectWithContext(context, deleteProjectOptions) if err != nil { - log.Printf("[DEBUG] DeleteProjectWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteProjectWithContext failed: %s", err.Error()), "ibm_code_engine_project", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") diff --git a/ibm/service/codeengine/resource_ibm_code_engine_project_test.go b/ibm/service/codeengine/resource_ibm_code_engine_project_test.go index 196d34fe7e..6492074cdf 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_project_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_project_test.go @@ -5,6 +5,7 @@ package codeengine_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -14,6 +15,7 @@ import ( acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM/code-engine-go-sdk/codeenginev2" + "github.com/IBM/go-sdk-core/v5/core" ) func TestAccIbmCodeEngineProjectBasic(t *testing.T) { @@ -114,3 +116,95 @@ func testAccCheckIbmCodeEngineProjectDestroy(s *terraform.State) error { return nil } + +func RetrieveProjectIdByName(projectName string, apiKey string, apiEndpoint string) (projectId *string, err error) { + iamEndpoint := determineEnvironment(apiEndpoint) + + codeEngineService, err := codeenginev2.NewCodeEngineV2(&codeenginev2.CodeEngineV2Options{ + Authenticator: &core.IamAuthenticator{ + ApiKey: apiKey, + ClientId: "bx", + ClientSecret: "bx", + URL: iamEndpoint, + }, + URL: apiEndpoint, + }) + + if err != nil { + return + } + + limit := int64(100) + listProjectsOptions := &codeenginev2.ListProjectsOptions{ + Limit: &limit, + } + pager, err := codeEngineService.NewProjectsPager(listProjectsOptions) + if err != nil { + panic(err) + } + + var allResults []codeenginev2.Project + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + + for _, project := range allResults { + if project.Name == &projectName { + if *project.Status == "soft_delete" { + err = fmt.Errorf("Error project '%s' is in 'soft_delete' status, please clean it up first", projectName) + break + } + + projectId = project.ID + break + } + } + + // if projectId == nil { + // createProjectOptions := codeenginev2.CreateProjectOptions{ + // Name: &projectName, + // } + + // createdProject, res, err := codeEngineService.CreateProject(&createProjectOptions) + + // if err != nil { + // err = fmt.Errorf("Error created project '%s': '%s'", projectName, err) + // } else if res.StatusCode != 202 { + // err = fmt.Errorf("Error created project '%s'", projectName) + // } else if createdProject == nil { + // err = fmt.Errorf("Error created project '%s'", projectName) + // } + + // createdProjectId := string(*createdProject.ID) + + // println("!!!createdProject.ID: ", createdProjectId) + // attempts := 25 + // getProjectOptions := codeenginev2.GetProjectOptions{ + // ID: createdProject.ID, + // } + // for i := 0; i < attempts; i++ { + // retrievedProject, res, err := codeEngineService.GetProject(&getProjectOptions) + // if err != nil || res.StatusCode != 200 || *retrievedProject.Status != "active" { + // log.Println("Project not ready yet, waiting....", err) + // time.Sleep(5 * time.Second) + // } else { + // projectId = retrievedProject.ID + // break + // } + // } + // } + + return +} + +func determineEnvironment(apiEndpoint string) string { + if strings.Contains(apiEndpoint, "codeengine.test.cloud") || strings.Contains(apiEndpoint, "codeengine.dev.cloud") { + return "https://iam.test.cloud.ibm.com" + } else { + return "https://iam.cloud.ibm.com" + } +} diff --git a/ibm/service/codeengine/resource_ibm_code_engine_secret.go b/ibm/service/codeengine/resource_ibm_code_engine_secret.go index 5b9c7526be..500bf90157 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_secret.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_secret.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package codeengine @@ -34,6 +34,12 @@ func ResourceIbmCodeEngineSecret() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_code_engine_secret", "project_id"), Description: "The ID of the project.", }, + "data": { + Type: schema.TypeMap, + Optional: true, + Description: "Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a max length of 253 characters. Each value field can consists of any character and must not exceed a max length of 1048576 characters.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, "format": { Type: schema.TypeString, Required: true, @@ -48,13 +54,6 @@ func ResourceIbmCodeEngineSecret() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_code_engine_secret", "name"), Description: "The name of the secret.", }, - "data": { - Type: schema.TypeMap, - Optional: true, - Sensitive: true, - Description: "Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each value field can consists of any character and must not be exceed a max length of 1048576 characters.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, "service_access": { Type: schema.TypeList, MaxItems: 1, @@ -94,7 +93,7 @@ func ResourceIbmCodeEngineSecret() *schema.Resource { "crn": { Type: schema.TypeString, Optional: true, - Description: "CRN of the IAM Role for thise service access secret.", + Description: "CRN of the IAM Role for this service access secret.", }, "name": { Type: schema.TypeString, @@ -125,6 +124,73 @@ func ResourceIbmCodeEngineSecret() *schema.Resource { }, }, }, + "serviceid": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A reference to a Service ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": { + Type: schema.TypeString, + Computed: true, + Description: "CRN value of a Service ID.", + }, + "id": { + Type: schema.TypeString, + Optional: true, + Description: "The ID of the Service ID.", + }, + }, + }, + }, + }, + }, + }, + "service_operator": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Properties for the IBM Cloud Operator Secret.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "apikey_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the apikey associated with the operator secret.", + }, + "resource_group_ids": { + Type: schema.TypeList, + Required: true, + Description: "The list of resource groups (by ID) that the operator secret can bind services in.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "serviceid": { + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "A reference to a Service ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": { + Type: schema.TypeString, + Computed: true, + Description: "CRN value of a Service ID.", + }, + "id": { + Type: schema.TypeString, + Optional: true, + Description: "The ID of the Service ID.", + }, + }, + }, + }, + "user_managed": { + Type: schema.TypeBool, + Computed: true, + Description: "Specifies whether the operator secret is user managed.", + }, }, }, }, @@ -143,10 +209,10 @@ func ResourceIbmCodeEngineSecret() *schema.Resource { Computed: true, Description: "When you provision a new secret, a URL is created identifying the location of the instance.", }, - "id": { + "region": { Type: schema.TypeString, Computed: true, - Description: "The identifier of the resource.", + Description: "The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'.", }, "resource_type": { Type: schema.TypeString, @@ -183,8 +249,8 @@ func ResourceIbmCodeEngineSecretValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, Required: true, - AllowedValues: "basic_auth, generic, registry, service_access, ssh_auth, tls", - Regexp: `^(generic|ssh_auth|basic_auth|tls|service_access|registry)$`, + AllowedValues: "basic_auth, generic, other, registry, service_access, service_operator, ssh_auth, tls", + Regexp: `^(generic|ssh_auth|basic_auth|tls|service_access|registry|service_operator|other)$`, }, validate.ValidateSchema{ Identifier: "name", @@ -204,7 +270,9 @@ func ResourceIbmCodeEngineSecretValidator() *validate.ResourceValidator { func resourceIbmCodeEngineSecretCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } createSecretOptions := &codeenginev2.CreateSecretOptions{} @@ -226,11 +294,19 @@ func resourceIbmCodeEngineSecretCreate(context context.Context, d *schema.Resour } createSecretOptions.SetServiceAccess(serviceAccessModel) } + if _, ok := d.GetOk("service_operator"); ok { + serviceOperatorModel, err := resourceIbmCodeEngineSecretMapToOperatorSecretPrototypeProps(d.Get("service_operator.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createSecretOptions.SetServiceOperator(serviceOperatorModel) + } - secret, response, err := codeEngineClient.CreateSecretWithContext(context, createSecretOptions) + secret, _, err := codeEngineClient.CreateSecretWithContext(context, createSecretOptions) if err != nil { - log.Printf("[DEBUG] CreateSecretWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateSecretWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("CreateSecretWithContext failed: %s", err.Error()), "ibm_code_engine_secret", "create") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId(fmt.Sprintf("%s/%s", *createSecretOptions.ProjectID, *secret.Name)) @@ -241,14 +317,17 @@ func resourceIbmCodeEngineSecretCreate(context context.Context, d *schema.Resour func resourceIbmCodeEngineSecretRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } getSecretOptions := &codeenginev2.GetSecretOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "read") + return tfErr.GetDiag() } getSecretOptions.SetProjectID(parts[0]) @@ -260,68 +339,78 @@ func resourceIbmCodeEngineSecretRead(context context.Context, d *schema.Resource d.SetId("") return nil } - log.Printf("[DEBUG] GetSecretWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetSecretWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetSecretWithContext failed: %s", err.Error()), "ibm_code_engine_secret", "read") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } if err = d.Set("project_id", secret.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("error setting project_id: %s", err)) } - if err = d.Set("format", secret.Format); err != nil { - return diag.FromErr(fmt.Errorf("error setting format: %s", err)) - } - if err = d.Set("name", secret.Name); err != nil { - return diag.FromErr(fmt.Errorf("error setting name: %s", err)) - } - if !core.IsNil(secret.Data) { data := make(map[string]string) for k, v := range secret.Data { data[k] = string(v) } if err = d.Set("data", data); err != nil { - return diag.FromErr(fmt.Errorf("Error setting data: %s", err)) + return diag.FromErr(fmt.Errorf("error setting data: %s", err)) } } + if err = d.Set("format", secret.Format); err != nil { + return diag.FromErr(fmt.Errorf("error setting format: %s", err)) + } + if err = d.Set("name", secret.Name); err != nil { + return diag.FromErr(fmt.Errorf("error setting name: %s", err)) + } if !core.IsNil(secret.ServiceAccess) { serviceAccessMap, err := resourceIbmCodeEngineSecretServiceAccessSecretPropsToMap(secret.ServiceAccess) if err != nil { return diag.FromErr(err) } if err = d.Set("service_access", []map[string]interface{}{serviceAccessMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting service_access: %s", err)) + return diag.FromErr(fmt.Errorf("error setting service_access: %s", err)) + } + } + if !core.IsNil(secret.ServiceOperator) { + serviceOperatorMap, err := resourceIbmCodeEngineSecretOperatorSecretPropsToMap(secret.ServiceOperator) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("service_operator", []map[string]interface{}{serviceOperatorMap}); err != nil { + return diag.FromErr(fmt.Errorf("error setting service_operator: %s", err)) } } if !core.IsNil(secret.CreatedAt) { if err = d.Set("created_at", secret.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) } } if err = d.Set("entity_tag", secret.EntityTag); err != nil { - return diag.FromErr(fmt.Errorf("Error setting entity_tag: %s", err)) + return diag.FromErr(fmt.Errorf("error setting entity_tag: %s", err)) } if !core.IsNil(secret.Href) { if err = d.Set("href", secret.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + return diag.FromErr(fmt.Errorf("error setting href: %s", err)) } } if !core.IsNil(secret.ID) { - if err = d.Set("id", secret.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting id: %s", err)) + if err = d.Set("secret_id", secret.ID); err != nil { + return diag.FromErr(fmt.Errorf("error setting id: %s", err)) } } - if !core.IsNil(secret.ResourceType) { - if err = d.Set("resource_type", secret.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_type: %s", err)) + if !core.IsNil(secret.Region) { + if err = d.Set("region", secret.Region); err != nil { + return diag.FromErr(fmt.Errorf("error setting region: %s", err)) } } - if !core.IsNil(secret.ID) { - if err = d.Set("secret_id", secret.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting secret_id: %s", err)) + if !core.IsNil(secret.ResourceType) { + if err = d.Set("resource_type", secret.ResourceType); err != nil { + return diag.FromErr(fmt.Errorf("error setting resource_type: %s", err)) } } if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { - return diag.FromErr(fmt.Errorf("Error setting etag: %s", err)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error setting etag: %s", err), "ibm_code_engine_secret", "read") + return tfErr.GetDiag() } return nil @@ -330,40 +419,38 @@ func resourceIbmCodeEngineSecretRead(context context.Context, d *schema.Resource func resourceIbmCodeEngineSecretUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } replaceSecretOptions := &codeenginev2.ReplaceSecretOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "update") + return tfErr.GetDiag() } replaceSecretOptions.SetProjectID(parts[0]) replaceSecretOptions.SetName(parts[1]) - replaceSecretOptions.SetFormat(d.Get("format").(string)) hasChange := false - if d.HasChange("format") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "format")) - } if d.HasChange("project_id") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "project_id")) + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_secret", "update") + return tfErr.GetDiag() } - if d.HasChange("name") { - return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ - " The resource must be re-created to update this property.", "name")) - } - if d.HasChange("if_match") { - replaceSecretOptions.SetIfMatch(d.Get("if_match").(string)) - hasChange = true + if d.HasChange("format") { + errMsg := fmt.Sprintf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "format") + tfErr := flex.TerraformErrorf(err, errMsg, "ibm_code_engine_secret", "update") + return tfErr.GetDiag() } if d.HasChange("data") { - data, err := resourceIbmCodeEngineSecretMapToSecretData(d.Get("data").(map[string]interface{})) + data, err := resourceIbmCodeEngineSecretMapToSecretData(d.Get("data.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } @@ -373,10 +460,11 @@ func resourceIbmCodeEngineSecretUpdate(context context.Context, d *schema.Resour replaceSecretOptions.SetIfMatch(d.Get("etag").(string)) if hasChange { - _, response, err := codeEngineClient.ReplaceSecretWithContext(context, replaceSecretOptions) + _, _, err = codeEngineClient.ReplaceSecretWithContext(context, replaceSecretOptions) if err != nil { - log.Printf("[DEBUG] ReplaceSecretWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ReplaceSecretWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("ReplaceSecretWithContext failed: %s", err.Error()), "ibm_code_engine_secret", "update") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } } @@ -386,23 +474,27 @@ func resourceIbmCodeEngineSecretUpdate(context context.Context, d *schema.Resour func resourceIbmCodeEngineSecretDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { codeEngineClient, err := meta.(conns.ClientSession).CodeEngineV2() if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } deleteSecretOptions := &codeenginev2.DeleteSecretOptions{} parts, err := flex.SepIdParts(d.Id(), "/") if err != nil { - return diag.FromErr(err) + tfErr := flex.TerraformErrorf(err, err.Error(), "ibm_code_engine_secret", "delete") + return tfErr.GetDiag() } deleteSecretOptions.SetProjectID(parts[0]) deleteSecretOptions.SetName(parts[1]) - response, err := codeEngineClient.DeleteSecretWithContext(context, deleteSecretOptions) + _, err = codeEngineClient.DeleteSecretWithContext(context, deleteSecretOptions) if err != nil { - log.Printf("[DEBUG] DeleteSecretWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteSecretWithContext failed %s\n%s", err, response)) + tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteSecretWithContext failed: %s", err.Error()), "ibm_code_engine_secret", "delete") + log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) + return tfErr.GetDiag() } d.SetId("") @@ -441,6 +533,13 @@ func resourceIbmCodeEngineSecretMapToServiceAccessSecretPrototypeProps(modelMap return model, err } model.ServiceInstance = ServiceInstanceModel + if modelMap["serviceid"] != nil && len(modelMap["serviceid"].([]interface{})) > 0 { + ServiceidModel, err := resourceIbmCodeEngineSecretMapToServiceIDRef(modelMap["serviceid"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Serviceid = ServiceidModel + } return model, nil } @@ -468,6 +567,44 @@ func resourceIbmCodeEngineSecretMapToServiceInstanceRefPrototype(modelMap map[st return model, nil } +func resourceIbmCodeEngineSecretMapToServiceIDRef(modelMap map[string]interface{}) (*codeenginev2.ServiceIDRef, error) { + model := &codeenginev2.ServiceIDRef{} + if modelMap["crn"] != nil && modelMap["crn"].(string) != "" { + model.Crn = core.StringPtr(modelMap["crn"].(string)) + } + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + return model, nil +} + +func resourceIbmCodeEngineSecretMapToOperatorSecretPrototypeProps(modelMap map[string]interface{}) (*codeenginev2.OperatorSecretPrototypeProps, error) { + model := &codeenginev2.OperatorSecretPrototypeProps{} + if modelMap["resource_group_ids"] != nil { + resourceGroupIds := []string{} + for _, resourceGroupIdsItem := range modelMap["resource_group_ids"].([]interface{}) { + resourceGroupIds = append(resourceGroupIds, resourceGroupIdsItem.(string)) + } + model.ResourceGroupIds = resourceGroupIds + } + if modelMap["serviceid"] != nil && len(modelMap["serviceid"].([]interface{})) > 0 { + ServiceidModel, err := resourceIbmCodeEngineSecretMapToServiceIDRefPrototype(modelMap["serviceid"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Serviceid = ServiceidModel + } + return model, nil +} + +func resourceIbmCodeEngineSecretMapToServiceIDRefPrototype(modelMap map[string]interface{}) (*codeenginev2.ServiceIDRefPrototype, error) { + model := &codeenginev2.ServiceIDRefPrototype{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + return model, nil +} + func resourceIbmCodeEngineSecretServiceAccessSecretPropsToMap(model *codeenginev2.ServiceAccessSecretProps) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) resourceKeyMap, err := resourceIbmCodeEngineSecretResourceKeyRefToMap(model.ResourceKey) @@ -487,6 +624,13 @@ func resourceIbmCodeEngineSecretServiceAccessSecretPropsToMap(model *codeenginev return modelMap, err } modelMap["service_instance"] = []map[string]interface{}{serviceInstanceMap} + if model.Serviceid != nil { + serviceidMap, err := resourceIbmCodeEngineSecretServiceIDRefToMap(model.Serviceid) + if err != nil { + return modelMap, err + } + modelMap["serviceid"] = []map[string]interface{}{serviceidMap} + } return modelMap, nil } @@ -522,3 +666,27 @@ func resourceIbmCodeEngineSecretServiceInstanceRefToMap(model *codeenginev2.Serv } return modelMap, nil } + +func resourceIbmCodeEngineSecretServiceIDRefToMap(model *codeenginev2.ServiceIDRef) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.ID != nil { + modelMap["id"] = model.ID + } + return modelMap, nil +} + +func resourceIbmCodeEngineSecretOperatorSecretPropsToMap(model *codeenginev2.OperatorSecretProps) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["apikey_id"] = model.ApikeyID + modelMap["resource_group_ids"] = model.ResourceGroupIds + serviceidMap, err := resourceIbmCodeEngineSecretServiceIDRefToMap(model.Serviceid) + if err != nil { + return modelMap, err + } + modelMap["serviceid"] = []map[string]interface{}{serviceidMap} + modelMap["user_managed"] = model.UserManaged + return modelMap, nil +} diff --git a/ibm/service/codeengine/resource_ibm_code_engine_secret_test.go b/ibm/service/codeengine/resource_ibm_code_engine_secret_test.go index 364ea1e1d4..5bcfa7bc14 100644 --- a/ibm/service/codeengine/resource_ibm_code_engine_secret_test.go +++ b/ibm/service/codeengine/resource_ibm_code_engine_secret_test.go @@ -5,6 +5,7 @@ package codeengine_test import ( "fmt" + "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -238,8 +239,8 @@ func TestAccIbmCodeEngineSecretTls(t *testing.T) { format := "tls" name := fmt.Sprintf("tf-secret-tls-%d", acctest.RandIntRange(10, 1000)) nameUpdate := fmt.Sprintf("tf-secret-tls-update-%d", acctest.RandIntRange(10, 1000)) - tlsKey := decodeBase64EnvVar(acc.CeTLSKey, CeTlsKey) - tlsCert := decodeBase64EnvVar(acc.CeTLSCert, CeTlsCert) + tlsKey, _ := os.ReadFile(acc.CeTLSKeyFilePath) + tlsCert, _ := os.ReadFile(acc.CeTLSCertFilePath) projectID := acc.CeProjectId @@ -249,7 +250,7 @@ func TestAccIbmCodeEngineSecretTls(t *testing.T) { CheckDestroy: testAccCheckIbmCodeEngineSecretDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmCodeEngineSecretTLSConfig(projectID, tlsKey, tlsCert, format, name), + Config: testAccCheckIbmCodeEngineSecretTLSConfig(projectID, string(tlsKey), string(tlsCert), format, name), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmCodeEngineSecretExists("ibm_code_engine_secret.code_engine_secret_instance", conf), resource.TestCheckResourceAttr("ibm_code_engine_secret.code_engine_secret_instance", "project_id", projectID), @@ -261,7 +262,7 @@ func TestAccIbmCodeEngineSecretTls(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmCodeEngineSecretTLSConfig(projectID, tlsKey, tlsCert, format, nameUpdate), + Config: testAccCheckIbmCodeEngineSecretTLSConfig(projectID, string(tlsKey), string(tlsCert), format, nameUpdate), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_code_engine_secret.code_engine_secret_instance", "project_id", projectID), resource.TestCheckResourceAttr("ibm_code_engine_secret.code_engine_secret_instance", "format", format), diff --git a/website/docs/d/code_engine_app.html.markdown b/website/docs/d/code_engine_app.html.markdown index 2e4cf97bde..9cc6639eb8 100644 --- a/website/docs/d/code_engine_app.html.markdown +++ b/website/docs/d/code_engine_app.html.markdown @@ -8,39 +8,44 @@ subcategory: "Code Engine" # ibm_code_engine_app -Provides a read-only data source for code_engine_app. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. +Provides a read-only data source to retrieve information about a code_engine_app. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. ## Example Usage ```hcl data "ibm_code_engine_app" "code_engine_app" { - project_id = data.ibm_code_engine_project.code_engine_project.project_id - name = "my-app" + name = ibm_code_engine_app.code_engine_app_instance.name + project_id = ibm_code_engine_app.code_engine_app_instance.project_id } ``` ## Argument Reference -Review the argument reference that you can specify for your data source. +You can specify the following arguments for this data source. * `name` - (Required, Forces new resource, String) The name of your application. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z]([-a-z0-9]*[a-z0-9])?$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your data source is created. +After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_app. + * `app_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `build` - (String) Reference to a build that is associated with the application. + +* `build_run` - (String) Reference to a build run that is associated with the application. + * `created_at` - (String) The timestamp when the resource was created. -* `endpoint` - (String) Optional URL to invoke app. Depending on visibility this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. +* `endpoint` - (String) Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. -* `endpoint_internal` - (String) URL to app that is only visible within the project. +* `endpoint_internal` - (String) The URL to the app that is only visible within the project. * `entity_tag` - (String) The version of the app instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. @@ -49,6 +54,7 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `image_port` - (Integer) Optional port the app listens on. While the app will always be exposed via port `443` for end users, this port is used to connect to the port that is exposed by the container image. + * Constraints: The default value is `8080`. * `image_reference` - (String) The name of the image that is used for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make sure to also specify the property `image_secret`. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^([a-z0-9][a-z0-9\\-_.]+[a-z0-9][\/])?([a-z0-9][a-z0-9\\-_]+[a-z0-9][\/])?[a-z0-9][a-z0-9\\-_.\/]+[a-z0-9](:[\\w][\\w.\\-]{0,127})?(@sha256:[a-fA-F0-9]{64})?$/`. @@ -59,20 +65,57 @@ In addition to all argument references listed, you can access the following attr * `managed_domain_mappings` - (String) Optional value controlling which of the system managed domain mappings will be setup for the application. Valid values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports application private visibility. * Constraints: The default value is `local_public`. Allowable values are: `local`, `local_private`, `local_public`. +* `probe_liveness` - (List) Response model for probes. +Nested schema for **probe_liveness**: + * `failure_threshold` - (Integer) The number of consecutive, unsuccessful checks for the probe to be considered failed. + * Constraints: The default value is `1`. The maximum value is `10`. The minimum value is `1`. + * `initial_delay` - (Integer) The amount of time in seconds to wait before the first probe check is performed. + * Constraints: The maximum value is `10`. The minimum value is `1`. + * `interval` - (Integer) The amount of time in seconds between probe checks. + * Constraints: The default value is `10`. The maximum value is `60`. The minimum value is `1`. + * `path` - (String) The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`. + * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/^\/(([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})+(\/([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})*)*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:@\/?]|%[a-fA-F0-9]{2})*)?$/`. + * `port` - (Integer) The port on which to probe the resource. + * Constraints: The maximum value is `65535`. The minimum value is `1`. + * `timeout` - (Integer) The amount of time in seconds that the probe waits for a response from the application before it times out and fails. + * Constraints: The default value is `1`. The maximum value is `3600`. The minimum value is `1`. + * `type` - (String) Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. + * Constraints: Allowable values are: `tcp`, `http`. + +* `probe_readiness` - (List) Response model for probes. +Nested schema for **probe_readiness**: + * `failure_threshold` - (Integer) The number of consecutive, unsuccessful checks for the probe to be considered failed. + * Constraints: The default value is `1`. The maximum value is `10`. The minimum value is `1`. + * `initial_delay` - (Integer) The amount of time in seconds to wait before the first probe check is performed. + * Constraints: The maximum value is `10`. The minimum value is `1`. + * `interval` - (Integer) The amount of time in seconds between probe checks. + * Constraints: The default value is `10`. The maximum value is `60`. The minimum value is `1`. + * `path` - (String) The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`. + * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/^\/(([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})+(\/([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})*)*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:@\/?]|%[a-fA-F0-9]{2})*)?$/`. + * `port` - (Integer) The port on which to probe the resource. + * Constraints: The maximum value is `65535`. The minimum value is `1`. + * `timeout` - (Integer) The amount of time in seconds that the probe waits for a response from the application before it times out and fails. + * Constraints: The default value is `1`. The maximum value is `3600`. The minimum value is `1`. + * `type` - (String) Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. + * Constraints: Allowable values are: `tcp`, `http`. + +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + * `resource_type` - (String) The type of the app. * Constraints: Allowable values are: `app_v2`. * `run_arguments` - (List) Optional arguments for the app that are passed to start the container. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. -* `run_as_user` - (Integer) Optional user ID (UID) to run the app (e.g., `1001`). +* `run_as_user` - (Integer) Optional user ID (UID) to run the app. + * Constraints: The default value is `0`. * `run_commands` - (List) Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. * `run_env_variables` - (List) References to config maps, secrets or literal values, which are exposed as environment variables in the application. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_env_variables**: +Nested schema for **run_env_variables**: * `key` - (String) The key to reference as environment variable. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `name` - (String) The name of the environment variable. @@ -91,7 +134,7 @@ Nested scheme for **run_env_variables**: * `run_volume_mounts` - (List) Mounts of config maps or secrets. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_volume_mounts**: +Nested schema for **run_volume_mounts**: * `mount_path` - (String) The path that should be mounted. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^\/([^\/\\0]+\/?)+$/`. * `name` - (String) The name of the mount. @@ -102,34 +145,39 @@ Nested scheme for **run_volume_mounts**: * Constraints: The default value is `secret`. Allowable values are: `config_map`, `secret`. The value must match regular expression `/^(config_map|secret)$/`. * `scale_concurrency` - (Integer) Optional maximum number of requests that can be processed concurrently per instance. + * Constraints: The default value is `100`. * `scale_concurrency_target` - (Integer) Optional threshold of concurrent requests per instance at which one or more additional instances are created. Use this value to scale up instances based on concurrent number of requests. This option defaults to the value of the `scale_concurrency` option, if not specified. * `scale_cpu_limit` - (String) Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). * Constraints: The default value is `1`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. -* `scale_down_delay` - (Integer) Optional amount of time in seconds that delays the scale down behavior for an app instance. - * Constraints: The maximum value is `3600`. The minimum value is `0`. +* `scale_down_delay` - (Integer) Optional amount of time in seconds that delays the scale-down behavior for an app instance. + * Constraints: The default value is `0`. The maximum value is `3600`. The minimum value is `0`. * `scale_ephemeral_storage_limit` - (String) Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). * Constraints: The default value is `400M`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. * `scale_initial_instances` - (Integer) Optional initial number of instances that are created upon app creation or app update. + * Constraints: The default value is `1`. * `scale_max_instances` - (Integer) Optional maximum number of instances for this app. If you set this value to `0`, this property does not set a upper scaling limit. However, the app scaling is still limited by the project quota for instances. See [Limits and quotas for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + * Constraints: The default value is `10`. * `scale_memory_limit` - (String) Optional amount of memory set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). * Constraints: The default value is `4G`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. * `scale_min_instances` - (Integer) Optional minimum number of instances for this app. If you set this value to `0`, the app will scale down to zero, if not hit by any request for some time. + * Constraints: The default value is `0`. * `scale_request_timeout` - (Integer) Optional amount of time in seconds that is allowed for a running app to respond to a request. + * Constraints: The default value is `300`. * `status` - (String) The current status of the app. * Constraints: Allowable values are: `ready`, `deploying`, `failed`, `warning`. * `status_details` - (List) The detailed status of the application. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `latest_created_revision` - (String) Latest app revision that has been created. * `latest_ready_revision` - (String) Latest app revision that reached a ready state. * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. diff --git a/website/docs/d/code_engine_binding.html.markdown b/website/docs/d/code_engine_binding.html.markdown index 8be9288ae5..9b92771429 100644 --- a/website/docs/d/code_engine_binding.html.markdown +++ b/website/docs/d/code_engine_binding.html.markdown @@ -14,8 +14,8 @@ Provides a read-only data source to retrieve information about a code_engine_bin ```hcl data "ibm_code_engine_binding" "code_engine_binding" { - id = "a172ced-b5f21bc-71ba50c-1638604" - project_id = ibm_code_engine_binding.code_engine_binding.project_id + binding_id = "a172ced-b5f21bc-71ba50c-1638604" + project_id = ibm_code_engine_binding.code_engine_binding_instance.project_id } ``` @@ -23,7 +23,7 @@ data "ibm_code_engine_binding" "code_engine_binding" { You can specify the following arguments for this data source. -* `binding_id` - (Required, Forces new resource, String) The ID of the binding. +* `binding_id` - (Required, Forces new resource, String) The id of your binding. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/.+/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. @@ -35,7 +35,7 @@ After your data source is created, you can read values from the following attrib * `id` - The unique identifier of the code_engine_binding. * `component` - (List) A reference to another component. -Nested scheme for **component**: +Nested schema for **component**: * `name` - (String) The name of the referenced component. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `resource_type` - (String) The type of the referenced resource. @@ -44,7 +44,7 @@ Nested scheme for **component**: * `href` - (String) When you provision a new binding, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `prefix` - (String) The value that is set as prefix in the component that is bound. +* `prefix` - (String) The value that is set as a prefix in the component that is bound. * Constraints: The maximum length is `31` characters. The minimum length is `0` characters. The value must match regular expression `/^[A-Z]([_A-Z0-9]*[A-Z0-9])*$/`. * `resource_type` - (String) The type of the binding. diff --git a/website/docs/d/code_engine_build.html.markdown b/website/docs/d/code_engine_build.html.markdown index 97c3421af7..d902658297 100644 --- a/website/docs/d/code_engine_build.html.markdown +++ b/website/docs/d/code_engine_build.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_build -Provides a read-only data source for code_engine_build. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. +Provides a read-only data source to retrieve information about a code_engine_build. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. ## Example Usage @@ -21,18 +21,19 @@ data "ibm_code_engine_build" "code_engine_build" { ## Argument Reference -Review the argument reference that you can specify for your data source. +You can specify the following arguments for this data source. * `name` - (Required, Forces new resource, String) The name of your build. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your data source is created. +After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_build. + * `build_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. @@ -50,10 +51,12 @@ In addition to all argument references listed, you can access the following attr * `output_secret` - (String) The secret that is required to access the image registry. Make sure that the secret is granted with push permissions towards the specified container registry namespace. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + * `resource_type` - (String) The type of the build. * Constraints: Allowable values are: `build_v2`. -* `source_context_dir` - (String) Option directory in the repository that contains the buildpacks file or the Dockerfile. +* `source_context_dir` - (String) Optional directory in the repository that contains the buildpacks file or the Dockerfile. * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^(.*)+$/`. * `source_revision` - (String) Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and uses the HEAD of default branch if not specified. If the `source_type` value is `local`, this field must be omitted. @@ -72,11 +75,11 @@ In addition to all argument references listed, you can access the following attr * Constraints: Allowable values are: `ready`, `failed`. * `status_details` - (List) The detailed status of the build. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. * Constraints: Allowable values are: `registered`, `strategy_not_found`, `cluster_build_strategy_not_found`, `set_owner_reference_failed`, `spec_source_secret_not_found`, `spec_output_secret_ref_not_found`, `spec_runtime_secret_ref_not_found`, `multiple_secret_ref_not_found`, `runtime_paths_can_not_be_empty`, `remote_repository_unreachable`, `failed`. -* `strategy_size` - (String) Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`. +* `strategy_size` - (String) Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`. * Constraints: The default value is `medium`. The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/[\\S]*/`. * `strategy_spec_file` - (String) Optional path to the specification file that is used for build strategies for building an image. @@ -86,5 +89,5 @@ Nested scheme for **status_details**: * Constraints: The default value is `dockerfile`. The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/[\\S]*/`. * `timeout` - (Integer) The maximum amount of time, in seconds, that can pass before the build must succeed or fail. - * Constraints: The maximum value is `3600`. The minimum value is `1`. + * Constraints: The default value is `600`. The maximum value is `3600`. The minimum value is `1`. diff --git a/website/docs/d/code_engine_config_map.html.markdown b/website/docs/d/code_engine_config_map.html.markdown index b493c659cd..89358312dd 100644 --- a/website/docs/d/code_engine_config_map.html.markdown +++ b/website/docs/d/code_engine_config_map.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_config_map -Provides a read-only data source for code_engine_config_map. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. +Provides a read-only data source to retrieve information about a code_engine_config_map. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. ## Example Usage @@ -21,7 +21,7 @@ data "ibm_code_engine_config_map" "code_engine_config_map" { ## Argument Reference -Review the argument reference that you can specify for your data source. +You can specify the following arguments for this data source. * `name` - (Required, Forces new resource, String) The name of your configmap. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. @@ -30,9 +30,10 @@ Review the argument reference that you can specify for your data source. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your data source is created. +After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_config_map. + * `config_map_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. @@ -45,6 +46,8 @@ In addition to all argument references listed, you can access the following attr * `href` - (String) When you provision a new config map, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + * `resource_type` - (String) The type of the config map. * Constraints: Allowable values are: `config_map_v2`. diff --git a/website/docs/d/code_engine_domain_mapping.html.markdown b/website/docs/d/code_engine_domain_mapping.html.markdown index 8b3120382a..89a572f0b8 100644 --- a/website/docs/d/code_engine_domain_mapping.html.markdown +++ b/website/docs/d/code_engine_domain_mapping.html.markdown @@ -33,14 +33,15 @@ You can specify the following arguments for this data source. After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_domain_mapping. + * `domain_mapping_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. -* `cname_target` - (String) Exposes the value of the CNAME record that needs to be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region. +* `cname_target` - (String) The value of the CNAME record that must be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `component` - (List) A reference to another component. -Nested scheme for **component**: +Nested schema for **component**: * `name` - (String) The name of the referenced component. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `resource_type` - (String) The type of the referenced resource. @@ -54,22 +55,24 @@ Nested scheme for **component**: * `href` - (String) When you provision a new domain mapping, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `resource_type` - (String) The type of the CE Resource. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. + +* `resource_type` - (String) The type of the Code Engine resource. * Constraints: Allowable values are: `domain_mapping_v2`. * `status` - (String) The current status of the domain mapping. - * Constraints: Possible values are: `ready`, `failed`, `deploying`. + * Constraints: Allowable values are: `ready`, `failed`, `deploying`. * `status_details` - (List) The detailed status of the domain mapping. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. - * Constraints: Possible values are: `ready`, `domain_already_claimed`, `app_ref_failed`, `failed_reconcile_ingress`, `deploying`, `failed`. + * Constraints: Allowable values are: `ready`, `domain_already_claimed`, `app_ref_failed`, `failed_reconcile_ingress`, `deploying`, `failed`. -* `tls_secret` - (String) The name of the TLS secret that holds the certificate and private key of this domain mapping. +* `tls_secret` - (String) The name of the TLS secret that includes the certificate and private key of this domain mapping. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. -* `user_managed` - (Boolean) Exposes whether the domain mapping is managed by the user or by Code Engine. +* `user_managed` - (Boolean) Specifies whether the domain mapping is managed by the user or by Code Engine. -* `visibility` - (String) Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project. - * Constraints: Possible values are: `custom`, `private`, `project`, `public`. +* `visibility` - (String) Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project. + * Constraints: Allowable values are: `custom`, `private`, `project`, `public`. diff --git a/website/docs/d/code_engine_job.html.markdown b/website/docs/d/code_engine_job.html.markdown index 189092fe7c..af3e969263 100644 --- a/website/docs/d/code_engine_job.html.markdown +++ b/website/docs/d/code_engine_job.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_job -Provides a read-only data source for code_engine_job. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. +Provides a read-only data source to retrieve information about a code_engine_job. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. ## Example Usage @@ -21,18 +21,26 @@ data "ibm_code_engine_job" "code_engine_job" { ## Argument Reference -Review the argument reference that you can specify for your data source. +You can specify the following arguments for this data source. * `name` - (Required, Forces new resource, String) The name of your job. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. + * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your data source is created. +After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_job. + +* `job_id` - (String) The identifier of the resource. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + +* `build` - (String) Reference to a build that is associated with the job. + +* `build_run` - (String) Reference to a build run that is associated with the job. + * `created_at` - (String) The timestamp when the resource was created. * `entity_tag` - (String) The version of the job instance, which is used to achieve optimistic locking. @@ -47,8 +55,7 @@ In addition to all argument references listed, you can access the following attr * `image_secret` - (String) The name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the job / job runs will be created but submitted job runs will fail, until this property is provided, too. This property must not be set on a job run, which references a job template. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. -* `job_id` - (String) The identifier of the resource. - * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the job. * Constraints: Allowable values are: `job_v2`. @@ -56,14 +63,15 @@ In addition to all argument references listed, you can access the following attr * `run_arguments` - (List) Set arguments for the job that are passed to start job run containers. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. -* `run_as_user` - (Integer) The user ID (UID) to run the job (e.g., 1001). +* `run_as_user` - (Integer) The user ID (UID) to run the job. + * Constraints: The default value is `0`. * `run_commands` - (List) Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. * `run_env_variables` - (List) References to config maps, secrets or literal values, which are exposed as environment variables in the job run. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_env_variables**: +Nested schema for **run_env_variables**: * `key` - (String) The key to reference as environment variable. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `name` - (String) The name of the environment variable. @@ -77,15 +85,15 @@ Nested scheme for **run_env_variables**: * `value` - (String) The literal value of the environment variable. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. -* `run_mode` - (String) The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `scale_max_execution_time` and `scale_retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `scale_max_execution_time` and `scale_retry_limit` properties are not allowed. +* `run_mode` - (String) The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` mode, since there is no timeout and failed instances are restarted indefinitely, the `max_execution_time` and `retry_limit` properties are not allowed. * Constraints: The default value is `task`. Allowable values are: `task`, `daemon`. The minimum length is `0` characters. The value must match regular expression `/^(task|daemon)$/`. * `run_service_account` - (String) The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, `reader`, and `writer`. This property must not be set on a job run, which references a job template. * Constraints: The default value is `default`. Allowable values are: `default`, `manager`, `reader`, `writer`, `none`. The minimum length is `0` characters. The value must match regular expression `/^(manager|reader|writer|none|default)$/`. -* `run_volume_mounts` - (List) Optional mounts of config maps or a secrets. +* `run_volume_mounts` - (List) Optional mounts of config maps or secrets. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_volume_mounts**: +Nested schema for **run_volume_mounts**: * `mount_path` - (String) The path that should be mounted. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^\/([^\/\\0]+\/?)+$/`. * `name` - (String) The name of the mount. @@ -95,7 +103,7 @@ Nested scheme for **run_volume_mounts**: * `type` - (String) Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'. * Constraints: The default value is `secret`. Allowable values are: `config_map`, `secret`. The value must match regular expression `/^(config_map|secret)$/`. -* `scale_array_spec` - (String) Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of unique array indices specified here determines the number of job instances to run. +* `scale_array_spec` - (String) Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number of unique array indices that you specify with this parameter determines the number of job instances to run. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?(?:,(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?)*$/`. * `scale_cpu_limit` - (String) Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). @@ -105,9 +113,11 @@ Nested scheme for **run_volume_mounts**: * Constraints: The default value is `400M`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. * `scale_max_execution_time` - (Integer) The maximum execution time in seconds for runs of the job. This property can only be specified if `run_mode` is `task`. + * Constraints: The default value is `7200`. * `scale_memory_limit` - (String) Optional amount of memory set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). * Constraints: The default value is `4G`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. * `scale_retry_limit` - (Integer) The number of times to rerun an instance of the job before the job is marked as failed. This property can only be specified if `run_mode` is `task`. + * Constraints: The default value is `3`. diff --git a/website/docs/d/code_engine_project.html.markdown b/website/docs/d/code_engine_project.html.markdown index 28c0367dda..39cd63ab13 100644 --- a/website/docs/d/code_engine_project.html.markdown +++ b/website/docs/d/code_engine_project.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_project -Provides a read-only data source for code_engine_project. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. +Provides a read-only data source to retrieve information about a code_engine_project. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. ## Example Usage @@ -20,16 +20,17 @@ data "ibm_code_engine_project" "code_engine_project" { ## Argument Reference -Review the argument reference that you can specify for your data source. +You can specify the following arguments for this data source. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your data source is created. +After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_project. + * `account_id` - (String) An alphanumeric value identifying the account ID. * `created_at` - (String) The timestamp when the project was created. @@ -39,11 +40,10 @@ In addition to all argument references listed, you can access the following attr * `href` - (String) When you provision a new resource, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `name` - (String) The name of the project. +* `name` - (Forces new resource, String) The name of the project. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^([^\\x00-\\x7F]|[a-zA-Z0-9\\-._: ])+$/`. -* `region` - (String) The region for your project deployment. - * Constraints: Possible values are: `au-syd`, `br-sao`, `ca-tor`, `eu-de`, `eu-gb`, `jp-osa`, `jp-tok`, `us-east`, `us-south`. +* `region` - (String) The region for your project deployment. Possible values: `au-syd`, `br-sao`, `ca-tor`, `eu-de`, `eu-es`, `eu-gb`, `jp-osa`, `jp-tok`, `us-east`, `us-south`. * `resource_group_id` - (String) The ID of the resource group. * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[a-z0-9]*$/`. @@ -51,6 +51,6 @@ In addition to all argument references listed, you can access the following attr * `resource_type` - (String) The type of the project. * Constraints: Allowable values are: `project_v2`. -* `status` - (String) The current state of the project. For example, if the project is created and ready to get used, it will return `active`. After deleting a project it will remain in `status` `soft_deleted` for a seven day period, during which it will still be retrievable. - * Constraints: Possible values are: `active`, `inactive`, `pending_removal`, `hard_deleting`, `hard_deletion_failed`, `hard_deleted`, `deleting`, `deletion_failed`, `soft_deleted`, `preparing`, `creating`, `creation_failed`. +* `status` - (String) The current state of the project. For example, when the project is created and is ready for use, the status of the project is active. After deleting a project it will remain in `status` `soft_deleted` for a seven day period, during which it will still be retrievable. + * Constraints: Allowable values are: `active`, `inactive`, `pending_removal`, `hard_deleting`, `hard_deletion_failed`, `hard_deleted`, `deleting`, `deletion_failed`, `soft_deleted`, `preparing`, `creating`, `creation_failed`. diff --git a/website/docs/d/code_engine_secret.html.markdown b/website/docs/d/code_engine_secret.html.markdown index 5d86fcc6eb..47a33d9e96 100644 --- a/website/docs/d/code_engine_secret.html.markdown +++ b/website/docs/d/code_engine_secret.html.markdown @@ -33,41 +33,64 @@ You can specify the following arguments for this data source. After your data source is created, you can read values from the following attributes. * `id` - The unique identifier of the code_engine_secret. + +* `secret_id` - (String) The identifier of the resource. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + * `created_at` - (String) The timestamp when the resource was created. -* `data` - (Map) Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each value field can consists of any character and must not be exceed a max length of 1048576 characters. +* `data` - (Map) Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a max length of 253 characters. Each value field can consists of any character and must not exceed a max length of 1048576 characters. * `entity_tag` - (String) The version of the secret instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `format` - (Forces new resource, String) Specify the format of the secret. - * Constraints: Allowable values are: `generic`, `ssh_auth`, `basic_auth`, `tls`, `service_access`, `registry`. The value must match regular expression `/^(generic|ssh_auth|basic_auth|tls|service_access|registry)$/`. + * Constraints: Allowable values are: `generic`, `ssh_auth`, `basic_auth`, `tls`, `service_access`, `registry`, `service_operator`, `other`. The value must match regular expression `/^(generic|ssh_auth|basic_auth|tls|service_access|registry|service_operator|other)$/`. * `href` - (String) When you provision a new secret, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `resource_type` - (String) The type of the secret. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. -* `secret_id` - (String) The identifier of the resource. - * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `resource_type` - (String) The type of the secret. * `service_access` - (Forces new resource, List) Properties for Service Access Secrets. -Nested scheme for **service_access**: +Nested schema for **service_access**: * `resource_key` - (List) The service credential associated with the secret. - Nested scheme for **resource_key**: + Nested schema for **resource_key**: * `id` - (String) ID of the service credential associated with the secret. * Constraints: The maximum length is `36` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-z0-9][\\-a-z0-9]*[a-z0-9]$/`. * `name` - (String) Name of the service credential associated with the secret. * `role` - (List) A reference to the Role and Role CRN for service binding. - Nested scheme for **role**: - * `crn` - (String) CRN of the IAM Role for thise service access secret. + Nested schema for **role**: + * `crn` - (String) CRN of the IAM Role for this service access secret. * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[A-Z][a-zA-Z() ]*[a-z)]$|^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. * `name` - (String) Role of the service credential. * Constraints: The default value is `Writer`. * `service_instance` - (List) The IBM Cloud service instance associated with the secret. - Nested scheme for **service_instance**: + Nested schema for **service_instance**: * `id` - (String) ID of the IBM Cloud service instance associated with the secret. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[a-z0-9][\\-a-z0-9]*[a-z0-9]$/`. * `type` - (String) Type of IBM Cloud service associated with the secret. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^.*$/`. + * `serviceid` - (List) A reference to a Service ID. + Nested schema for **serviceid**: + * `crn` - (String) CRN value of a Service ID. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. + * `id` - (String) The ID of the Service ID. + * Constraints: The maximum length is `46` characters. The minimum length is `46` characters. The value must match regular expression `/^ServiceId-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + +* `service_operator` - (List) Properties for the IBM Cloud Operator Secret. +Nested schema for **service_operator**: + * `apikey_id` - (String) The ID of the apikey associated with the operator secret. + * Constraints: The maximum length is `43` characters. The minimum length is `43` characters. The value must match regular expression `/^ApiKey-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + * `resource_group_ids` - (List) The list of resource groups (by ID) that the operator secret can bind services in. + * Constraints: The list items must match regular expression `/^[a-z0-9]*$/`. The maximum length is `100` items. The minimum length is `0` items. + * `serviceid` - (List) A reference to a Service ID. + Nested schema for **serviceid**: + * `crn` - (String) CRN value of a Service ID. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. + * `id` - (String) The ID of the Service ID. + * Constraints: The maximum length is `46` characters. The minimum length is `46` characters. The value must match regular expression `/^ServiceId-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + * `user_managed` - (Boolean) Specifies whether the operator secret is user managed. diff --git a/website/docs/r/code_engine_app.html.markdown b/website/docs/r/code_engine_app.html.markdown index d1f783fb74..c39b27c3f0 100644 --- a/website/docs/r/code_engine_app.html.markdown +++ b/website/docs/r/code_engine_app.html.markdown @@ -51,19 +51,51 @@ You can specify the following arguments for this resource. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `managed_domain_mappings` - (Optional, String) Optional value controlling which of the system managed domain mappings will be setup for the application. Valid values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports application private visibility. * Constraints: The default value is `local_public`. Allowable values are: `local`, `local_private`, `local_public`. -* `name` - (Required, Forces new resource, String) The name of the app. Use a name that is unique within the project. +* `name` - (Required, Forces new resource, String) The name of the app. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z]([-a-z0-9]*[a-z0-9])?$/`. +* `probe_liveness` - (Optional, List) Response model for probes. +Nested schema for **probe_liveness**: + * `failure_threshold` - (Optional, Integer) The number of consecutive, unsuccessful checks for the probe to be considered failed. + * Constraints: The default value is `1`. The maximum value is `10`. The minimum value is `1`. + * `initial_delay` - (Optional, Integer) The amount of time in seconds to wait before the first probe check is performed. + * Constraints: The maximum value is `10`. The minimum value is `1`. + * `interval` - (Optional, Integer) The amount of time in seconds between probe checks. + * Constraints: The default value is `10`. The maximum value is `60`. The minimum value is `1`. + * `path` - (Optional, String) The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`. + * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/^\/(([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})+(\/([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})*)*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:@\/?]|%[a-fA-F0-9]{2})*)?$/`. + * `port` - (Optional, Integer) The port on which to probe the resource. + * Constraints: The maximum value is `65535`. The minimum value is `1`. + * `timeout` - (Optional, Integer) The amount of time in seconds that the probe waits for a response from the application before it times out and fails. + * Constraints: The default value is `1`. The maximum value is `3600`. The minimum value is `1`. + * `type` - (Optional, String) Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. + * Constraints: Allowable values are: `tcp`, `http`. +* `probe_readiness` - (Optional, List) Response model for probes. +Nested schema for **probe_readiness**: + * `failure_threshold` - (Optional, Integer) The number of consecutive, unsuccessful checks for the probe to be considered failed. + * Constraints: The default value is `1`. The maximum value is `10`. The minimum value is `1`. + * `initial_delay` - (Optional, Integer) The amount of time in seconds to wait before the first probe check is performed. + * Constraints: The maximum value is `10`. The minimum value is `1`. + * `interval` - (Optional, Integer) The amount of time in seconds between probe checks. + * Constraints: The default value is `10`. The maximum value is `60`. The minimum value is `1`. + * `path` - (Optional, String) The path of the HTTP request to the resource. A path is only supported for a probe with a `type` of `http`. + * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/^\/(([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})+(\/([a-zA-Z0-9-._~!$&'()*+,;=:@]|%[a-fA-F0-9]{2})*)*)?(\\?([a-zA-Z0-9-._~!$&'()*+,;=:@\/?]|%[a-fA-F0-9]{2})*)?$/`. + * `port` - (Optional, Integer) The port on which to probe the resource. + * Constraints: The maximum value is `65535`. The minimum value is `1`. + * `timeout` - (Optional, Integer) The amount of time in seconds that the probe waits for a response from the application before it times out and fails. + * Constraints: The default value is `1`. The maximum value is `3600`. The minimum value is `1`. + * `type` - (Optional, String) Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. + * Constraints: Allowable values are: `tcp`, `http`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. * `run_arguments` - (Optional, List) Optional arguments for the app that are passed to start the container. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. -* `run_as_user` - (Optional, Integer) Optional user ID (UID) to run the app (e.g., `1001`). +* `run_as_user` - (Optional, Integer) Optional user ID (UID) to run the app. * Constraints: The default value is `0`. * `run_commands` - (Optional, List) Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. -* `run_env_variables` - (Optional, List) Optional references to config maps, secrets or literal values that are exposed as environment variables within the running application. +* `run_env_variables` - (Optional, List) References to config maps, secrets or literal values, which are exposed as environment variables in the application. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_env_variables**: +Nested schema for **run_env_variables**: * `key` - (Optional, String) The key to reference as environment variable. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `name` - (Optional, String) The name of the environment variable. @@ -78,12 +110,12 @@ Nested scheme for **run_env_variables**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `run_service_account` - (Optional, String) Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , `none`, `reader`, and `writer`. * Constraints: The default value is `default`. Allowable values are: `default`, `manager`, `reader`, `writer`, `none`. The minimum length is `0` characters. The value must match regular expression `/^(manager|reader|writer|none|default)$/`. -* `run_volume_mounts` - (Optional, List) Optional mounts of config maps or a secrets. +* `run_volume_mounts` - (Optional, List) Mounts of config maps or secrets. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_volume_mounts**: +Nested schema for **run_volume_mounts**: * `mount_path` - (Required, String) The path that should be mounted. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^\/([^\/\\0]+\/?)+$/`. - * `name` - (Optional, String) Optional name of the mount. If not set, it will be generated based on the `ref` and a random ID. In case the `ref` is longer than 58 characters, it will be cut off. + * `name` - (Required, String) The name of the mount. * Constraints: The maximum length is `63` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-z]([-a-z0-9]*[a-z0-9])?$/`. * `reference` - (Required, String) The name of the referenced secret or config map. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. @@ -94,7 +126,7 @@ Nested scheme for **run_volume_mounts**: * `scale_concurrency_target` - (Optional, Integer) Optional threshold of concurrent requests per instance at which one or more additional instances are created. Use this value to scale up instances based on concurrent number of requests. This option defaults to the value of the `scale_concurrency` option, if not specified. * `scale_cpu_limit` - (Optional, String) Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). * Constraints: The default value is `1`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. -* `scale_down_delay` - (Optional, Integer) Optional amount of time in seconds that delays the scale down behavior for an app instance. +* `scale_down_delay` - (Optional, Integer) Optional amount of time in seconds that delays the scale-down behavior for an app instance. * Constraints: The default value is `0`. The maximum value is `3600`. The minimum value is `0`. * `scale_ephemeral_storage_limit` - (Optional, String) Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). * Constraints: The default value is `400M`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. @@ -116,19 +148,22 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the code_engine_app. * `app_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `build` - (String) Reference to a build that is associated with the application. +* `build_run` - (String) Reference to a build run that is associated with the application. * `created_at` - (String) The timestamp when the resource was created. -* `endpoint` - (String) Optional URL to invoke app. Depending on visibility this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. -* `endpoint_internal` - (String) URL to app that is only visible within the project. +* `endpoint` - (String) Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. +* `endpoint_internal` - (String) The URL to the app that is only visible within the project. * `entity_tag` - (String) The version of the app instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `href` - (String) When you provision a new app, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the app. * Constraints: Allowable values are: `app_v2`. * `status` - (String) The current status of the app. * Constraints: Allowable values are: `ready`, `deploying`, `failed`, `warning`. * `status_details` - (List) The detailed status of the application. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `latest_created_revision` - (String) Latest app revision that has been created. * `latest_ready_revision` - (String) Latest app revision that reached a ready state. * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. @@ -140,13 +175,13 @@ Nested scheme for **status_details**: You can import the `ibm_code_engine_app` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `name`: A string in the format `my-app`. The name of your application. +* `name`: A string in the format `my-app`. The name of the app. # Syntax -``` -$ terraform import ibm_code_engine_app.code_engine_app / -``` +
+$ terraform import ibm_code_engine_app.code_engine_app <project_id>/<name>
+
diff --git a/website/docs/r/code_engine_binding.html.markdown b/website/docs/r/code_engine_binding.html.markdown index 2cfe796138..d3b142b8b1 100644 --- a/website/docs/r/code_engine_binding.html.markdown +++ b/website/docs/r/code_engine_binding.html.markdown @@ -36,16 +36,16 @@ code_engine_binding provides the following [Timeouts](https://www.terraform.io/d You can specify the following arguments for this resource. * `component` - (Required, Forces new resource, List) A reference to another component. -Nested scheme for **component**: +Nested schema for **component**: * `name` - (Required, String) The name of the referenced component. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `resource_type` - (Required, String) The type of the referenced resource. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/.+/`. -* `prefix` - (Required, Forces new resource, String) Optional value that is set as prefix in the component that is bound. Will be generated if not provided. +* `prefix` - (Required, Forces new resource, String) The value that is set as a prefix in the component that is bound. * Constraints: The maximum length is `31` characters. The minimum length is `0` characters. The value must match regular expression `/^[A-Z]([_A-Z0-9]*[A-Z0-9])*$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. -* `secret_name` - (Required, Forces new resource, String) The service access secret that is binding to a component. +* `secret_name` - (Required, Forces new resource, String) The service access secret that is bound to a component. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. ## Attribute Reference @@ -53,7 +53,7 @@ Nested scheme for **component**: After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the code_engine_binding. -* `binding_id` - (String) The ID of the binding. +* `code_engine_binding_id` - (String) The ID of the binding. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/.+/`. * `href` - (String) When you provision a new binding, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. @@ -64,16 +64,16 @@ After your resource is created, you can read values from the listed arguments an ## Import -You can import the `ibm_code_engine_binding` resource by using `binding_id`. -The `id` property can be formed from `project_id`, and `binding_id` in the following format: +You can import the `ibm_code_engine_binding` resource by using `id`. +The `id` property can be formed from `project_id`, and `code_engine_binding_id` in the following format: -``` -/ -``` +
+<project_id>/<code_engine_binding_id>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `binding_id`: A string in the format `a172ced-b5f21bc-71ba50c-1638604`. The ID of your binding. +* `code_engine_binding_id`: A string in the format `a172ced-b5f21bc-71ba50c-1638604`. The ID of the binding. # Syntax -``` -$ terraform import ibm_code_engine_binding.code_engine_binding / -``` +
+$ terraform import ibm_code_engine_binding.code_engine_binding <project_id>/<code_engine_binding_id>
+
diff --git a/website/docs/r/code_engine_build.html.markdown b/website/docs/r/code_engine_build.html.markdown index 0f8aaacbf8..18a972bce3 100644 --- a/website/docs/r/code_engine_build.html.markdown +++ b/website/docs/r/code_engine_build.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_build -Provides a resource for code_engine_build. This allows code_engine_build to be created, updated and deleted. +Create, update, and delete code_engine_builds with this resource. ## Example Usage @@ -25,9 +25,9 @@ resource "ibm_code_engine_build" "code_engine_build_instance" { ## Argument Reference -Review the argument reference that you can specify for your resource. +You can specify the following arguments for this resource. -* `name` - (Required, String) The name of the build. Use a name that is unique within the project. +* `name` - (Required, Forces new resource, String) The name of the build. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `output_image` - (Required, String) The name of the image. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^([a-z0-9][a-z0-9\\-_.]+[a-z0-9][\/])?([a-z0-9][a-z0-9\\-_]+[a-z0-9][\/])?[a-z0-9][a-z0-9\\-_.\/]+[a-z0-9](:[\\w][\\w.\\-]{0,127})?(@sha256:[a-fA-F0-9]{64})?$/`. @@ -35,7 +35,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. -* `source_context_dir` - (Optional, String) Option directory in the repository that contains the buildpacks file or the Dockerfile. +* `source_context_dir` - (Optional, String) Optional directory in the repository that contains the buildpacks file or the Dockerfile. * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^(.*)+$/`. * `source_revision` - (Optional, String) Commit, tag, or branch in the source repository to pull. This field is optional if the `source_type` is `git` and uses the HEAD of default branch if not specified. If the `source_type` value is `local`, this field must be omitted. * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[\\S]*$/`. @@ -43,9 +43,9 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `source_type` - (Optional, String) Specifies the type of source to determine if your build source is in a repository or based on local source code.* local - For builds from local source code.* git - For builds from git version controlled source code. * Constraints: The default value is `git`. Allowable values are: `local`, `git`. -* `source_url` - (Required, String) The URL of the code repository. This field is required if the `source_type` is `git`. If the `source_type` value is `local`, this field must be omitted. If the repository is publicly available you can provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the repository requires authentication, you need to provide a 'ssh' URL like `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to a secret of format `ssh_auth`. +* `source_url` - (Optional, String) The URL of the code repository. This field is required if the `source_type` is `git`. If the `source_type` value is `local`, this field must be omitted. If the repository is publicly available you can provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the repository requires authentication, you need to provide a 'ssh' URL like `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to a secret of format `ssh_auth`. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^((https:\/\/[a-z0-9]([\\-.]?[a-z0-9])+(:\\d{1,5})?)|((ssh:\/\/)?git@[a-z0-9]([\\-.]{0,1}[a-z0-9])+(:[a-zA-Z0-9\/][\\w\\-.]*)?))(\/([\\w\\-.]|%20)+)*$/`. -* `strategy_size` - (Optional, String) Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`. +* `strategy_size` - (Optional, String) Optional size for the build, which determines the amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`. * Constraints: The default value is `medium`. The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/[\\S]*/`. * `strategy_spec_file` - (Optional, String) Optional path to the specification file that is used for build strategies for building an image. * Constraints: The default value is `Dockerfile`. The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\S]*$/`. @@ -56,7 +56,7 @@ Review the argument reference that you can specify for your resource. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your resource is created. +After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the code_engine_build. * `build_id` - (String) The identifier of the resource. @@ -66,14 +66,16 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `href` - (String) When you provision a new build, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the build. * Constraints: Allowable values are: `build_v2`. * `status` - (String) The current status of the build. - * Constraints: Possible values are: `ready`, `failed`. + * Constraints: Allowable values are: `ready`, `failed`. * `status_details` - (List) The detailed status of the build. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. * Constraints: Allowable values are: `registered`, `strategy_not_found`, `cluster_build_strategy_not_found`, `set_owner_reference_failed`, `spec_source_secret_not_found`, `spec_output_secret_ref_not_found`, `spec_runtime_secret_ref_not_found`, `multiple_secret_ref_not_found`, `runtime_paths_can_not_be_empty`, `remote_repository_unreachable`, `failed`. + * `etag` - ETag identifier for code_engine_build. ## Import @@ -81,18 +83,13 @@ Nested scheme for **status_details**: You can import the `ibm_code_engine_build` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `name`: A string in the format `my-build`. The name of your build. +* `name`: A string in the format `my-build`. The name of the build. # Syntax -``` -$ terraform import ibm_code_engine_build.code_engine_build / -``` - -# Example -``` -$ terraform import ibm_code_engine_build.code_engine_build "15314cc3-85b4-4338-903f-c28cdee6d005/my-build" -``` +
+$ terraform import ibm_code_engine_build.code_engine_build <project_id>/<name>
+
diff --git a/website/docs/r/code_engine_config_map.html.markdown b/website/docs/r/code_engine_config_map.html.markdown index 7f0ddee4d9..29010421bc 100644 --- a/website/docs/r/code_engine_config_map.html.markdown +++ b/website/docs/r/code_engine_config_map.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_config_map -Provides a resource for code_engine_config_map. This allows code_engine_config_map to be created, updated and deleted. +Create, update, and delete code_engine_config_maps with this resource. ## Example Usage @@ -21,17 +21,17 @@ resource "ibm_code_engine_config_map" "code_engine_config_map_instance" { ## Argument Reference -Review the argument reference that you can specify for your resource. +You can specify the following arguments for this resource. * `data` - (Optional, Map) The key-value pair for the config map. Values must be specified in `KEY=VALUE` format. Each `KEY` field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each `VALUE` field can consists of any character and must not be exceed a max length of 1048576 characters. -* `name` - (Required, String) The name of the config map. Use a name that is unique within the project. +* `name` - (Required, Forces new resource, String) The name of the config map. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your resource is created. +After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the code_engine_config_map. * `config_map_id` - (String) The identifier of the resource. @@ -40,6 +40,7 @@ In addition to all argument references listed, you can access the following attr * `entity_tag` - (String) The version of the config map instance, which is used to achieve optimistic locking. * `href` - (String) When you provision a new config map, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the config map. * Constraints: Allowable values are: `config_map_v2`. * `etag` - ETag identifier for code_engine_config_map. @@ -49,18 +50,13 @@ In addition to all argument references listed, you can access the following attr You can import the `ibm_code_engine_config_map` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `name`: A string in the format `my-config-map`. The name of your configmap. +* `name`: A string in the format `my-config-map`. The name of the config map. # Syntax -``` -$ terraform import ibm_code_engine_config_map.code_engine_config_map / -``` - -# Example -``` -$ terraform import ibm_code_engine_config_map.code_engine_config_map "15314cc3-85b4-4338-903f-c28cdee6d005/my-config-map" -``` +
+$ terraform import ibm_code_engine_config_map.code_engine_config_map <project_id>/<name>
+
diff --git a/website/docs/r/code_engine_domain_mapping.html.markdown b/website/docs/r/code_engine_domain_mapping.html.markdown index 005a3cf5db..d8deaaa3c6 100644 --- a/website/docs/r/code_engine_domain_mapping.html.markdown +++ b/website/docs/r/code_engine_domain_mapping.html.markdown @@ -14,13 +14,13 @@ Create, update, and delete code_engine_domain_mappings with this resource. ```hcl resource "ibm_code_engine_domain_mapping" "code_engine_domain_mapping_instance" { + project_id = ibm_code_engine_project.code_engine_project_instance.project_id + name = "www.example.com" + tls_secret = "my-tls-secret" component { - name = "my-app-1" + name = "my-app-1" resource_type = "app_v2" } - name = "www.example.com" - project_id = ibm_code_engine_project.code_engine_project_instance.project_id - tls_secret = "my-tls-secret" } ``` @@ -36,7 +36,7 @@ code_engine_domain_mapping provides the following [Timeouts](https://www.terrafo You can specify the following arguments for this resource. * `component` - (Required, List) A reference to another component. -Nested scheme for **component**: +Nested schema for **component**: * `name` - (Required, String) The name of the referenced component. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `resource_type` - (Required, String) The type of the referenced resource. @@ -45,7 +45,7 @@ Nested scheme for **component**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)+$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. -* `tls_secret` - (Required, String) The name of the TLS secret that holds the certificate and private key of this domain mapping. +* `tls_secret` - (Required, String) The name of the TLS secret that includes the certificate and private key of this domain mapping. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. ## Attribute Reference @@ -55,24 +55,26 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the code_engine_domain_mapping. * `domain_mapping_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. -* `cname_target` - (String) Exposes the value of the CNAME record that needs to be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region. +* `cname_target` - (String) The value of the CNAME record that must be configured in the DNS settings of the domain, to route traffic properly to the target Code Engine region. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `created_at` - (String) The timestamp when the resource was created. * `entity_tag` - (String) The version of the domain mapping instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `href` - (String) When you provision a new domain mapping, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `resource_type` - (String) The type of the CE Resource. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. +* `resource_type` - (String) The type of the Code Engine resource. * Constraints: Allowable values are: `domain_mapping_v2`. * `status` - (String) The current status of the domain mapping. - * Constraints: Possible values are: `ready`, `failed`, `deploying`. + * Constraints: Allowable values are: `ready`, `failed`, `deploying`. * `status_details` - (List) The detailed status of the domain mapping. -Nested scheme for **status_details**: +Nested schema for **status_details**: * `reason` - (String) Optional information to provide more context in case of a 'failed' or 'warning' status. - * Constraints: Possible values are: `ready`, `domain_already_claimed`, `app_ref_failed`, `failed_reconcile_ingress`, `deploying`, `failed`. -* `user_managed` - (Boolean) Exposes whether the domain mapping is managed by the user or by Code Engine. -* `visibility` - (String) Exposes whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project. - * Constraints: Possible values are: `custom`, `private`, `project`, `public`. + * Constraints: Allowable values are: `ready`, `domain_already_claimed`, `app_ref_failed`, `failed_reconcile_ingress`, `deploying`, `failed`. +* `user_managed` - (Boolean) Specifies whether the domain mapping is managed by the user or by Code Engine. +* `visibility` - (String) Specifies whether the domain mapping is reachable through the public internet, or private IBM network, or only through other components within the same Code Engine project. + * Constraints: Allowable values are: `custom`, `private`, `project`, `public`. + * `etag` - ETag identifier for code_engine_domain_mapping. ## Import @@ -80,13 +82,13 @@ Nested scheme for **status_details**: You can import the `ibm_code_engine_domain_mapping` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. * `name`: A string in the format `www.example.com`. The name of the domain mapping. # Syntax -``` -$ terraform import ibm_code_engine_domain_mapping.code_engine_domain_mapping / -``` +
+$ terraform import ibm_code_engine_domain_mapping.code_engine_domain_mapping <project_id>/<name>
+
diff --git a/website/docs/r/code_engine_job.html.markdown b/website/docs/r/code_engine_job.html.markdown index 2a96fd0375..8c168fe3cc 100644 --- a/website/docs/r/code_engine_job.html.markdown +++ b/website/docs/r/code_engine_job.html.markdown @@ -40,7 +40,7 @@ You can specify the following arguments for this resource. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^([a-z0-9][a-z0-9\\-_.]+[a-z0-9][\/])?([a-z0-9][a-z0-9\\-_]+[a-z0-9][\/])?[a-z0-9][a-z0-9\\-_.\/]+[a-z0-9](:[\\w][\\w.\\-]{0,127})?(@sha256:[a-fA-F0-9]{64})?$/`. * `image_secret` - (Optional, String) The name of the image registry access secret. The image registry access secret is used to authenticate with a private registry when you download the container image. If the image reference points to a registry that requires authentication, the job / job runs will be created but submitted job runs will fail, until this property is provided, too. This property must not be set on a job run, which references a job template. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. -* `name` - (Required, Forces new resource, String) The name of the job. Use a name that is unique within the project. +* `name` - (Required, Forces new resource, String) The name of the job. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. @@ -50,9 +50,9 @@ You can specify the following arguments for this resource. * Constraints: The default value is `0`. * `run_commands` - (Optional, List) Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. * Constraints: The list items must match regular expression `/^.*$/`. The maximum length is `100` items. The minimum length is `0` items. -* `run_env_variables` - (Optional, List) Optional references to config maps, secrets or literal values. +* `run_env_variables` - (Optional, List) References to config maps, secrets or literal values, which are exposed as environment variables in the job run. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_env_variables**: +Nested schema for **run_env_variables**: * `key` - (Optional, String) The key to reference as environment variable. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[\\-._a-zA-Z0-9]+$/`. * `name` - (Optional, String) The name of the environment variable. @@ -69,19 +69,19 @@ Nested scheme for **run_env_variables**: * Constraints: The default value is `task`. Allowable values are: `task`, `daemon`. The minimum length is `0` characters. The value must match regular expression `/^(task|daemon)$/`. * `run_service_account` - (Optional, String) The name of the service account. For built-in service accounts, you can use the shortened names `manager`, `none`, `reader`, and `writer`. This property must not be set on a job run, which references a job template. * Constraints: The default value is `default`. Allowable values are: `default`, `manager`, `reader`, `writer`, `none`. The minimum length is `0` characters. The value must match regular expression `/^(manager|reader|writer|none|default)$/`. -* `run_volume_mounts` - (Optional, List) Optional mounts of config maps or a secrets. +* `run_volume_mounts` - (Optional, List) Optional mounts of config maps or secrets. * Constraints: The maximum length is `100` items. The minimum length is `0` items. -Nested scheme for **run_volume_mounts**: +Nested schema for **run_volume_mounts**: * `mount_path` - (Required, String) The path that should be mounted. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^\/([^\/\\0]+\/?)+$/`. - * `name` - (Optional, String) Optional name of the mount. If not set, it will be generated based on the `ref` and a random ID. In case the `ref` is longer than 58 characters, it will be cut off. + * `name` - (Required, String) The name of the mount. * Constraints: The maximum length is `63` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-z]([-a-z0-9]*[a-z0-9])?$/`. * `reference` - (Required, String) The name of the referenced secret or config map. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `type` - (Required, String) Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'. * Constraints: The default value is `secret`. Allowable values are: `config_map`, `secret`. The value must match regular expression `/^(config_map|secret)$/`. -* `scale_array_spec` - (Optional, String) Define a custom set of array indices as comma-separated list containing single values and hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its array index via environment variable `JOB_INDEX`. The number of unique array indices specified here determines the number of job instances to run. - * Constraints: The default value is `0`. The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?(?:,(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?)*$/`. +* `scale_array_spec` - (Optional, String) Define a custom set of array indices as a comma-separated list containing single values and hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its array index value from the environment variable JOB_INDEX. The number of unique array indices that you specify with this parameter determines the number of job instances to run. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?(?:,(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d)(?:-(?:[1-9]\\d\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d\\d|[1-9]\\d\\d\\d\\d|[1-9]\\d\\d\\d|[1-9]\\d\\d|[1-9]?\\d))?)*$/`. * `scale_cpu_limit` - (Optional, String) Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). * Constraints: The default value is `1`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^([0-9.]+)([eEinumkKMGTPB]*)$/`. * `scale_ephemeral_storage_limit` - (Optional, String) Optional amount of ephemeral storage to set for the instance of the job. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). @@ -100,13 +100,17 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the code_engine_job. * `job_id` - (String) The identifier of the resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `build` - (String) Reference to a build that is associated with the job. +* `build_run` - (String) Reference to a build run that is associated with the job. * `created_at` - (String) The timestamp when the resource was created. * `entity_tag` - (String) The version of the job instance, which is used to achieve optimistic locking. * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `href` - (String) When you provision a new job, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the job. * Constraints: Allowable values are: `job_v2`. + * `etag` - ETag identifier for code_engine_job. ## Import @@ -114,13 +118,13 @@ After your resource is created, you can read values from the listed arguments an You can import the `ibm_code_engine_job` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `name`: A string in the format `my-job`. The name of your job. +* `name`: A string in the format `my-job`. The name of the job. # Syntax -``` -$ terraform import ibm_code_engine_job.code_engine_job / -``` +
+$ terraform import ibm_code_engine_job.code_engine_job <project_id>/<name>
+
diff --git a/website/docs/r/code_engine_project.html.markdown b/website/docs/r/code_engine_project.html.markdown index 8061772a00..e7065151c3 100644 --- a/website/docs/r/code_engine_project.html.markdown +++ b/website/docs/r/code_engine_project.html.markdown @@ -8,7 +8,7 @@ subcategory: "Code Engine" # ibm_code_engine_project -Provides a resource for ibm_code_engine_project. This allows ibm_code_engine_project to be created and deleted. +Create and delete code_engine_projects with this resource. ## Example Usage @@ -25,21 +25,23 @@ resource "ibm_code_engine_project" "code_engine_project_instance" { ## Timeouts -* `Create` The creation of an instance is considered failed when no response is received for 2 minutes. -* `Delete` The deletion of an instance is considered failed when no response is received for 2 minutes. +code_engine_project provides the following [Timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) configuration options: + +* `create` - (Default 10 minutes) Used for creating a code_engine_project. +* `delete` - (Default Projects(/projects/{id}) minutes) Used for deleting a code_engine_project. ## Argument Reference -Review the argument reference that you can specify for your resource. +You can specify the following arguments for this resource. * `name` - (Required, Forces new resource, String) The name of the project. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^([^\\x00-\\x7F]|[a-zA-Z0-9\\-._: ])+$/`. -* `resource_group_id` - (Optional, Forces new resource, String) Optional ID of the resource group for your project deployment. If this field is not defined, the default resource group of the account will be used. +* `resource_group_id` - (Optional, Forces new resource, String) The ID of the resource group. If this field is not defined, the default resource group of the account will be used. * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[a-z0-9]*$/`. ## Attribute Reference -In addition to all argument references listed, you can access the following attribute references after your resource is created. +After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the code_engine_project. * `project_id` - (String) The ID of the project. @@ -49,21 +51,20 @@ In addition to all argument references listed, you can access the following attr * `crn` - (String) The CRN of the project. * `href` - (String) When you provision a new resource, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. -* `region` - (String) The region for your project deployment. Possible values: `au-syd`, `br-sao`, `ca-tor`, `eu-de`, `eu-gb`, `jp-osa`, `jp-tok`, `us-east`, `us-south`. - * Constraints: The maximum length is `48` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-z0-9-]+$/`. +* `region` - (String) The region for your project deployment. Possible values: `au-syd`, `br-sao`, `ca-tor`, `eu-de`, `eu-es`, `eu-gb`, `jp-osa`, `jp-tok`, `us-east`, `us-south`. * `resource_type` - (String) The type of the project. * Constraints: Allowable values are: `project_v2`. -* `status` - (String) The current state of the project. For example, if the project is created and ready to get used, it will return active. +* `status` - (String) The current state of the project. For example, when the project is created and is ready for use, the status of the project is active. * Constraints: Allowable values are: `active`, `inactive`, `pending_removal`, `hard_deleting`, `hard_deletion_failed`, `hard_deleted`, `deleting`, `deletion_failed`, `soft_deleted`, `preparing`, `creating`, `creation_failed`. ## Import -You can import the `ibm_code_engine_project` resource by using `project_id`. The ID of the project. +You can import the `ibm_code_engine_project` resource by using `id`. The ID of the project. # Syntax -``` -$ terraform import ibm_code_engine_project.code_engine_project -``` +
+$ terraform import ibm_code_engine_project.code_engine_project <id>
+
# Example ``` diff --git a/website/docs/r/code_engine_secret.html.markdown b/website/docs/r/code_engine_secret.html.markdown index 22385ee4e8..9b676c99db 100644 --- a/website/docs/r/code_engine_secret.html.markdown +++ b/website/docs/r/code_engine_secret.html.markdown @@ -29,32 +29,51 @@ resource "ibm_code_engine_secret" "code_engine_secret_instance" { You can specify the following arguments for this resource. -* `data` - (Optional, Map) Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of 253 characters. Each value field can consists of any character and must not be exceed a max length of 1048576 characters. +* `data` - (Optional, Map) Data container that allows to specify config parameters and their values as a key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a max length of 253 characters. Each value field can consists of any character and must not exceed a max length of 1048576 characters. * `format` - (Required, Forces new resource, String) Specify the format of the secret. - * Constraints: Allowable values are: `generic`, `ssh_auth`, `basic_auth`, `tls`, `service_access`, `registry`. The value must match regular expression `/^(generic|ssh_auth|basic_auth|tls|service_access|registry)$/`. + * Constraints: Allowable values are: `generic`, `ssh_auth`, `basic_auth`, `tls`, `service_access`, `registry`, `service_operator`, `other`. The value must match regular expression `/^(generic|ssh_auth|basic_auth|tls|service_access|registry|service_operator|other)$/`. * `name` - (Required, Forces new resource, String) The name of the secret. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z0-9]([\\-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([\\-a-z0-9]*[a-z0-9])?)*$/`. * `project_id` - (Required, Forces new resource, String) The ID of the project. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. * `service_access` - (Optional, Forces new resource, List) Properties for Service Access Secrets. -Nested scheme for **service_access**: +Nested schema for **service_access**: * `resource_key` - (Required, List) The service credential associated with the secret. - Nested scheme for **resource_key**: + Nested schema for **resource_key**: * `id` - (Optional, String) ID of the service credential associated with the secret. * Constraints: The maximum length is `36` characters. The minimum length is `0` characters. The value must match regular expression `/^[a-z0-9][\\-a-z0-9]*[a-z0-9]$/`. * `name` - (Computed, String) Name of the service credential associated with the secret. * `role` - (Optional, List) A reference to the Role and Role CRN for service binding. - Nested scheme for **role**: - * `crn` - (Optional, String) CRN of the IAM Role for thise service access secret. + Nested schema for **role**: + * `crn` - (Optional, String) CRN of the IAM Role for this service access secret. * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^[A-Z][a-zA-Z() ]*[a-z)]$|^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. * `name` - (Computed, String) Role of the service credential. * Constraints: The default value is `Writer`. * `service_instance` - (Required, List) The IBM Cloud service instance associated with the secret. - Nested scheme for **service_instance**: + Nested schema for **service_instance**: * `id` - (Optional, String) ID of the IBM Cloud service instance associated with the secret. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[a-z0-9][\\-a-z0-9]*[a-z0-9]$/`. * `type` - (Computed, String) Type of IBM Cloud service associated with the secret. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^.*$/`. + * `serviceid` - (Optional, List) A reference to a Service ID. + Nested schema for **serviceid**: + * `crn` - (Computed, String) CRN value of a Service ID. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. + * `id` - (Optional, String) The ID of the Service ID. + * Constraints: The maximum length is `46` characters. The minimum length is `46` characters. The value must match regular expression `/^ServiceId-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. +* `service_operator` - (Optional, List) Properties for the IBM Cloud Operator Secret. +Nested schema for **service_operator**: + * `apikey_id` - (Computed, String) The ID of the apikey associated with the operator secret. + * Constraints: The maximum length is `43` characters. The minimum length is `43` characters. The value must match regular expression `/^ApiKey-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + * `resource_group_ids` - (Required, List) The list of resource groups (by ID) that the operator secret can bind services in. + * Constraints: The list items must match regular expression `/^[a-z0-9]*$/`. The maximum length is `100` items. The minimum length is `0` items. + * `serviceid` - (Required, List) A reference to a Service ID. + Nested schema for **serviceid**: + * `crn` - (Computed, String) CRN value of a Service ID. + * Constraints: The maximum length is `253` characters. The minimum length is `0` characters. The value must match regular expression `/^crn\\:v1\\:[a-zA-Z0-9]*\\:(public|dedicated|local)\\:[\\-a-z0-9]*\\:([a-z][\\-a-z0-9_]*[a-z0-9])?\\:((a|o|s)\/[\\-a-z0-9]+)?\\:[\\-a-z0-9\/]*\\:[\\-a-zA-Z0-9]*(\\:[\\-a-zA-Z0-9\/.]*)?$/`. + * `id` - (Optional, String) The ID of the Service ID. + * Constraints: The maximum length is `46` characters. The minimum length is `46` characters. The value must match regular expression `/^ServiceId-[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/`. + * `user_managed` - (Computed, Boolean) Specifies whether the operator secret is user managed. ## Attribute Reference @@ -68,6 +87,7 @@ After your resource is created, you can read values from the listed arguments an * Constraints: The maximum length is `63` characters. The minimum length is `1` character. The value must match regular expression `/^[\\*\\-a-z0-9]+$/`. * `href` - (String) When you provision a new secret, a URL is created identifying the location of the instance. * Constraints: The maximum length is `2048` characters. The minimum length is `0` characters. The value must match regular expression `/(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `region` - (String) The region of the project the resource is located in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', 'us-east', 'us-south'. * `resource_type` - (String) The type of the secret. * `etag` - ETag identifier for code_engine_secret. @@ -76,18 +96,13 @@ After your resource is created, you can read values from the listed arguments an You can import the `ibm_code_engine_secret` resource by using `name`. The `name` property can be formed from `project_id`, and `name` in the following format: -``` -/ -``` +
+<project_id>/<name>
+
* `project_id`: A string in the format `15314cc3-85b4-4338-903f-c28cdee6d005`. The ID of the project. -* `name`: A string in the format `my-secret`. The name of your secret. +* `name`: A string in the format `my-secret`. The name of the secret. # Syntax -``` -$ terraform import ibm_code_engine_secret.code_engine_secret / -``` - -# Example -``` -$ terraform import ibm_code_engine_secret.code_engine_secret "15314cc3-85b4-4338-903f-c28cdee6d005/my-secret" -``` +
+$ terraform import ibm_code_engine_secret.code_engine_secret <project_id>/<name>
+
From 66a345fff5ba0a8823023d04a555846520e70e3a Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 15 Jul 2024 08:22:51 -0500 Subject: [PATCH 24/25] Fix linting issue --- ibm/service/power/ibm_pi_constants.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 5b4b6c933c..61c6b77b6e 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -82,13 +82,13 @@ const ( Arg_StoragePool = "pi_storage_pool" Arg_StoragePoolAffinity = "pi_storage_pool_affinity" Arg_StorageType = "pi_storage_type" - Arg_TargetStorageTier = "pi_target_storage_tier" - Arg_VolumeCloneName = "pi_volume_clone_name" - Arg_VolumeCloneTaskID = "pi_volume_clone_task_id" Arg_SysType = "pi_sys_type" + Arg_TargetStorageTier = "pi_target_storage_tier" Arg_UserData = "pi_user_data" Arg_VirtualCoresAssigned = "pi_virtual_cores_assigned" Arg_VirtualOpticalDevice = "pi_virtual_optical_device" + Arg_VolumeCloneName = "pi_volume_clone_name" + Arg_VolumeCloneTaskID = "pi_volume_clone_task_id" Arg_VolumeGroupID = "pi_volume_group_id" Arg_VolumeID = "pi_volume_id" Arg_VolumeIDs = "pi_volume_ids" @@ -451,22 +451,22 @@ const ( State_Deleting = "deleting" State_DELETING = "DELETING" State_Down = "down" - State_ERROR = "ERROR" State_Error = "error" + State_ERROR = "ERROR" State_Failed = "failed" State_Inactive = "inactive" State_InProgress = "in progress" State_InUse = "in-use" State_NotFound = "Not Found" - State_PENDING = "PENDING" State_Pending = "pending" + State_PENDING = "PENDING" State_PendingReclamation = "pending_reclamation" State_Provisioning = "provisioning" State_Removed = "removed" State_RESIZE = "RESIZE" State_Retry = "retry" - State_SHUTOFF = "SHUTOFF" State_Shutoff = "shutoff" + State_SHUTOFF = "SHUTOFF" State_Up = "up" Status_Active = "ACTIVE" Status_Deleting = "deleting" From 3cceaf636d795848916345b33acd739dcd8201c2 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 15 Jul 2024 08:39:24 -0500 Subject: [PATCH 25/25] Fix linting issue --- ibm/service/power/ibm_pi_constants.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 979e655777..24c8e0cacc 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -404,7 +404,7 @@ const ( Dedicated = "dedicated" DeploymentTypeEpic = "EPIC" DeploymentTypeVMNoStorage = "VMNoStorage" - DHCPVlan = "dhcp-vlan" + DHCPVlan = "dhcp-vlan" Hana = "Hana" Hard = "hard" Host = "host" @@ -415,12 +415,12 @@ const ( Prefix = "prefix" Private = "private" Public = "public" - PubVlan = "pub-vlan" + PubVlan = "pub-vlan" SAP = "SAP" Shared = "shared" Soft = "soft" Suffix = "suffix" - Vlan = "vlan" + Vlan = "vlan" vSCSI = "vSCSI" Warning = "WARNING"