From b106d00a7d2d3cac40af44ca8c006a66b0f64ab2 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 6 Apr 2023 12:24:40 +0200 Subject: [PATCH 001/125] fix: generate project code Signed-off-by: dvesperini --- ibm/conns/config.go | 29 + ibm/provider/provider.go | 13 +- ibm/service/project/README.md | 11 + ...a_source_ibm_project_event_notification.go | 457 +++++++++++++++ ...rce_ibm_project_event_notification_test.go | 111 ++++ .../project/resource_ibm_project_instance.go | 533 ++++++++++++++++++ .../resource_ibm_project_instance_test.go | 177 ++++++ website/allowed-subcategories.txt | 1 + 8 files changed, 1330 insertions(+), 2 deletions(-) create mode 100644 ibm/service/project/README.md create mode 100644 ibm/service/project/data_source_ibm_project_event_notification.go create mode 100644 ibm/service/project/data_source_ibm_project_event_notification_test.go create mode 100644 ibm/service/project/resource_ibm_project_instance.go create mode 100644 ibm/service/project/resource_ibm_project_instance_test.go diff --git a/ibm/conns/config.go b/ibm/conns/config.go index d4328d7e06..26d9f3bc81 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -75,6 +75,7 @@ import ( ibmcloudshellv1 "github.com/IBM/platform-services-go-sdk/ibmcloudshellv1" resourcecontroller "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" resourcemanager "github.com/IBM/platform-services-go-sdk/resourcemanagerv2" + "github.com/IBM/project-go-sdk/projectv1" "github.com/IBM/push-notifications-go-sdk/pushservicev1" "github.com/IBM/scc-go-sdk/v3/adminserviceapiv1" "github.com/IBM/scc-go-sdk/v3/configurationgovernancev1" @@ -301,6 +302,7 @@ type ClientSession interface { CdToolchainV2() (*cdtoolchainv2.CdToolchainV2, error) CdTektonPipelineV2() (*cdtektonpipelinev2.CdTektonPipelineV2, error) CodeEngineV2() (*codeengine.CodeEngineV2, error) + ProjectV1() (*projectv1.ProjectV1, error) } type clientSession struct { @@ -624,6 +626,10 @@ type clientSession struct { // Code Engine options codeEngineClient *codeengine.CodeEngineV2 codeEngineClientErr error + + // Project options + projectClient *projectv1.ProjectV1 + projectClientErr error } // AppIDAPI provides AppID Service APIs ... @@ -1199,6 +1205,11 @@ func (session clientSession) CodeEngineV2() (*codeengine.CodeEngineV2, error) { return session.codeEngineClient, session.codeEngineClientErr } +// Projects API Specification +func (session clientSession) ProjectV1() (*projectv1.ProjectV1, error) { + return session.projectClient, session.projectClientErr +} + // ClientSession configures and returns a fully initialized ClientSession func (c *Config) ClientSession() (interface{}, error) { sess, err := newSession(c) @@ -1516,6 +1527,24 @@ func (c *Config) ClientSession() (interface{}, error) { } } + // Construct an "options" struct for creating the service client. + projectClientOptions := &projectv1.ProjectV1Options{ + Authenticator: authenticator, + } + + // Construct the service client. + session.projectClient, err = projectv1.NewProjectV1(projectClientOptions) + if err == nil { + // Enable retries for API calls + session.projectClient.Service.EnableRetries(c.RetryCount, c.RetryDelay) + // Add custom header for analytics + session.projectClient.SetDefaultHeaders(gohttp.Header{ + "X-Original-User-Agent": {fmt.Sprintf("terraform-provider-ibm/%s", version.Version)}, + }) + } else { + session.projectClientErr = fmt.Errorf("Error occurred while configuring Projects API Specification service: %q", err) + } + // Construct an "options" struct for creating the service client. ukoClientOptions := &ukov4.UkoV4Options{ Authenticator: authenticator, diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index f189341b2c..2594245075 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -8,8 +8,6 @@ import ( "sync" "time" - "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/service/apigateway" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/appconfiguration" @@ -42,6 +40,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kms" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kubernetes" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/power" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/pushnotification" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/registry" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/resourcecontroller" @@ -53,6 +52,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/transitgateway" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // Provider returns a *schema.Provider. @@ -785,6 +785,9 @@ func Provider() *schema.Provider { // Added for Code Engine "ibm_code_engine_project": codeengine.DataSourceIbmCodeEngineProject(), + + // Added for Project + "ibm_project_event_notification": project.DataSourceIbmProjectEventNotification(), }, ResourcesMap: map[string]*schema.Resource{ @@ -1245,6 +1248,9 @@ func Provider() *schema.Provider { "ibm_code_engine_config_map": codeengine.ResourceIbmCodeEngineConfigMap(), "ibm_code_engine_job": codeengine.ResourceIbmCodeEngineJob(), "ibm_code_engine_project": codeengine.ResourceIbmCodeEngineProject(), + + // Added for Project + "ibm_project_instance": project.ResourceIbmProjectInstance(), }, ConfigureFunc: providerConfigure, @@ -1476,6 +1482,9 @@ func Validator() validate.ValidatorDict { "ibm_code_engine_config_map": codeengine.ResourceIbmCodeEngineConfigMapValidator(), "ibm_code_engine_job": codeengine.ResourceIbmCodeEngineJobValidator(), "ibm_code_engine_project": codeengine.ResourceIbmCodeEngineProjectValidator(), + + // Added for Project + "ibm_project_instance": project.ResourceIbmProjectInstanceValidator(), }, DataSourceValidatorDictionary: map[string]*validate.ResourceValidator{ "ibm_is_subnet": vpc.DataSourceIBMISSubnetValidator(), diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md new file mode 100644 index 0000000000..b0c70bd356 --- /dev/null +++ b/ibm/service/project/README.md @@ -0,0 +1,11 @@ +# Terraform IBM Provider + +This area is primarily for IBM provider contributors and maintainers. For information on _using_ Terraform and the IBM provider, see the links below. + + +## Handy Links +* [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! +* 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/project_instance) +* IBM API Docs: [IBM API Docs for ]() +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go new file mode 100644 index 0000000000..940cd18234 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project_event_notification.go @@ -0,0 +1,457 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "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/project-go-sdk/projectv1" +) + +func DataSourceIbmProjectEventNotification() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmProjectEventNotificationRead, + + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The ID of the project, which uniquely identifies it.", + }, + "exclude_configs": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Only return with the active configuration, no drafts.", + }, + "complete": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "The flag to determine if full metadata should be returned.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A project descriptive text.", + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project configuration description.", + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location ID of a project configuration manual property.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable type.", + }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Whether the variable is required or not.", + }, + }, + }, + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The output value.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "An optional setting object that's passed to the cart API.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of a the configuration setting.", + }, + }, + }, + }, + }, + }, + }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The metadata of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339.", + }, + "cumulative_needs_attention_view": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cumulative list of needs attention items for a project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The event name.", + }, + "event_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "config_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "config_version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version number of the configuration.", + }, + }, + }, + }, + "cumulative_needs_attention_view_err": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "True indicates that the fetch of the needs attention items failed.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location where the project was created.", + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The resource group where the project was created.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(d.Get("id").(string)) + if _, ok := d.GetOk("exclude_configs"); ok { + getProjectOptions.SetExcludeConfigs(d.Get("exclude_configs").(bool)) + } + if _, ok := d.GetOk("complete"); ok { + getProjectOptions.SetComplete(d.Get("complete").(bool)) + } + + project, response, err := projectClient.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)) + } + + d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) + + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", project.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } + + configs := []map[string]interface{}{} + if project.Configs != nil { + for _, modelItem := range project.Configs { + modelMap, err := dataSourceIbmProjectEventNotificationProjectConfigToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, modelMap) + } + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) + } + + metadata := []map[string]interface{}{} + if project.Metadata != nil { + modelMap, err := dataSourceIbmProjectEventNotificationProjectMetadataToMap(project.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) + } + if err = d.Set("metadata", metadata); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + } + + return nil +} + +func dataSourceIbmProjectEventNotificationProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectEventNotificationInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectEventNotificationOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectEventNotificationProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + return modelMap, nil +} + +func dataSourceIbmProjectEventNotificationInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Required != nil { + modelMap["required"] = model.Required + } + return modelMap, nil +} + +func dataSourceIbmProjectEventNotificationOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectEventNotificationProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectEventNotificationProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.CumulativeNeedsAttentionView != nil { + cumulativeNeedsAttentionView := []map[string]interface{}{} + for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { + cumulativeNeedsAttentionViewItemMap, err := dataSourceIbmProjectEventNotificationCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) + if err != nil { + return modelMap, err + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) + } + modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView + } + if model.CumulativeNeedsAttentionViewErr != nil { + modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr + } + if model.Location != nil { + modelMap["location"] = model.Location + } + if model.ResourceGroup != nil { + modelMap["resource_group"] = model.ResourceGroup + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.EventNotificationsCrn != nil { + modelMap["event_notifications_crn"] = model.EventNotificationsCrn + } + return modelMap, nil +} + +func dataSourceIbmProjectEventNotificationCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Event != nil { + modelMap["event"] = model.Event + } + if model.EventID != nil { + modelMap["event_id"] = model.EventID + } + if model.ConfigID != nil { + modelMap["config_id"] = model.ConfigID + } + if model.ConfigVersion != nil { + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go new file mode 100644 index 0000000000..a55fca9fc1 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -0,0 +1,111 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" +) + +func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), + ), + }, + }, + }) +} + +func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "exclude_configs"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "complete"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.id"), + resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.name", projectName), + resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.description", projectDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), + ), + }, + }, + }) +} + +func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName string) string { + return fmt.Sprintf(` + resource "ibm_project_instance" "project_instance_instance" { + name = "%s" + } + + data "ibm_project_event_notification" "project_event_notification_instance" { + id = projectIdLink + exclude_configs = true + complete = true + } + `, projectName) +} + +func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, projectDescription string, projectResourceGroup string, projectLocation string) string { + return fmt.Sprintf(` + resource "ibm_project_instance" "project_instance_instance" { + name = "%s" + description = "%s" + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } + resource_group = "%s" + location = "%s" + } + + data "ibm_project_event_notification" "project_event_notification_instance" { + id = projectIdLink + exclude_configs = true + complete = true + } + `, projectName, projectDescription, projectResourceGroup, projectLocation) +} diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go new file mode 100644 index 0000000000..e36baf5670 --- /dev/null +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -0,0 +1,533 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "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-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/project-go-sdk/projectv1" +) + +func ResourceIbmProjectInstance() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmProjectInstanceCreate, + ReadContext: resourceIbmProjectInstanceRead, + UpdateContext: resourceIbmProjectInstanceUpdate, + DeleteContext: resourceIbmProjectInstanceDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "name"), + Description: "The project name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "description"), + Description: "A project's descriptive text.", + }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The project configuration description.", + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The location ID of a project configuration manual property.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "An optional setting object that's passed to the cart API.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of a the configuration setting.", + }, + }, + }, + }, + }, + }, + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "Default", + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "resource_group"), + Description: "Group name of the customized collection of resources.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "us-south", + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "location"), + Description: "Data center locations for resource deployment.", + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The metadata of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339.", + }, + "cumulative_needs_attention_view": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The cumulative list of needs attention items for a project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The event name.", + }, + "event_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "config_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "config_version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version number of the configuration.", + }, + }, + }, + }, + "cumulative_needs_attention_view_err": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "True indicates that the fetch of the needs attention items failed.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location where the project was created.", + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The resource group where the project was created.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, + }, + }, + }, + }, + } +} + +func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s).+\S$`, + MinValueLength: 1, + MaxValueLength: 64, + }, + validate.ValidateSchema{ + Identifier: "description", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, + }, + validate.ValidateSchema{ + Identifier: "resource_group", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 40, + }, + validate.ValidateSchema{ + Identifier: "location", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + MinValueLength: 0, + MaxValueLength: 12, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project_instance", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmProjectInstanceCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + createProjectOptions := &projectv1.CreateProjectOptions{} + + createProjectOptions.SetName(d.Get("name").(string)) + if _, ok := d.GetOk("description"); ok { + createProjectOptions.SetDescription(d.Get("description").(string)) + } + if _, ok := d.GetOk("configs"); ok { + var configs []projectv1.ProjectConfigPrototype + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectInstanceMapToProjectConfigPrototype(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + createProjectOptions.SetConfigs(configs) + } + if _, ok := d.GetOk("resource_group"); ok { + createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + } + if _, ok := d.GetOk("location"); ok { + createProjectOptions.SetLocation(d.Get("location").(string)) + } + + project, response, err := projectClient.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)) + } + + d.SetId(*project.ID) + + return resourceIbmProjectInstanceRead(context, d, meta) +} + +func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(d.Id()) + + project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + 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)) + } + + if !core.IsNil(project.Crn) { + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } + } + if !core.IsNil(project.Metadata) { + metadataMap, err := resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } + } + + return nil +} + +func resourceIbmProjectInstanceUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + updateProjectOptions := &projectv1.UpdateProjectOptions{} + + updateProjectOptions.SetID(d.Id()) + + hasChange := false + + if hasChange { + _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) + if err != nil { + log.Printf("[DEBUG] UpdateProjectWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateProjectWithContext failed %s\n%s", err, response)) + } + } + + return resourceIbmProjectInstanceRead(context, d, meta) +} + +func resourceIbmProjectInstanceDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + deleteProjectOptions := &projectv1.DeleteProjectOptions{} + + deleteProjectOptions.SetID(d.Id()) + + response, err := projectClient.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)) + } + + d.SetId("") + + return nil +} + +func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { + model := &projectv1.ProjectConfigPrototype{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["labels"] != nil { + labels := []string{} + for _, labelsItem := range modelMap["labels"].([]interface{}) { + labels = append(labels, labelsItem.(string)) + } + model.Labels = labels + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["input"] != nil { + input := []projectv1.ProjectConfigInputVariable{} + for _, inputItem := range modelMap["input"].([]interface{}) { + inputItemModel, err := resourceIbmProjectInstanceMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) + if err != nil { + return model, err + } + input = append(input, *inputItemModel) + } + model.Input = input + } + if modelMap["setting"] != nil { + setting := []projectv1.ProjectConfigSettingCollection{} + for _, settingItem := range modelMap["setting"].([]interface{}) { + settingItemModel, err := resourceIbmProjectInstanceMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) + if err != nil { + return model, err + } + setting = append(setting, *settingItemModel) + } + model.Setting = setting + } + return model, nil +} + +func resourceIbmProjectInstanceMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { + model := &projectv1.ProjectConfigInputVariable{} + model.Name = core.StringPtr(modelMap["name"].(string)) + return model, nil +} + +func resourceIbmProjectInstanceMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { + model := &projectv1.ProjectConfigSettingCollection{} + model.Name = core.StringPtr(modelMap["name"].(string)) + model.Value = core.StringPtr(modelMap["value"].(string)) + return model, nil +} + +func resourceIbmProjectInstanceProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectInstanceProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectInstanceProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + return modelMap, nil +} + +func resourceIbmProjectInstanceProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + return modelMap, nil +} + +func resourceIbmProjectInstanceProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func resourceIbmProjectInstanceProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.CumulativeNeedsAttentionView != nil { + cumulativeNeedsAttentionView := []map[string]interface{}{} + for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { + cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectInstanceCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) + if err != nil { + return modelMap, err + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) + } + modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView + } + if model.CumulativeNeedsAttentionViewErr != nil { + modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr + } + if model.Location != nil { + modelMap["location"] = model.Location + } + if model.ResourceGroup != nil { + modelMap["resource_group"] = model.ResourceGroup + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.EventNotificationsCrn != nil { + modelMap["event_notifications_crn"] = model.EventNotificationsCrn + } + return modelMap, nil +} + +func resourceIbmProjectInstanceCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Event != nil { + modelMap["event"] = model.Event + } + if model.EventID != nil { + modelMap["event_id"] = model.EventID + } + if model.ConfigID != nil { + modelMap["config_id"] = model.ConfigID + } + if model.ConfigVersion != nil { + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go new file mode 100644 index 0000000000..faf71d0603 --- /dev/null +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -0,0 +1,177 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/project-go-sdk/projectv1" + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmProjectInstanceBasic(t *testing.T) { + var conf projectv1.Project + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectInstanceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectInstanceConfigBasic(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), + ), + }, + resource.TestStep{ + Config: testAccCheckIbmProjectInstanceConfigBasic(nameUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), + ), + }, + }, + }) +} + +func TestAccIbmProjectInstanceAllArgs(t *testing.T) { + var conf projectv1.Project + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectInstanceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectInstanceConfig(name, description, resourceGroup, location), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", description), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), + ), + }, + resource.TestStep{ + Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroupUpdate, locationUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), + ), + }, + resource.TestStep{ + ResourceName: "ibm_project_instance.project_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmProjectInstanceConfigBasic(name string) string { + return fmt.Sprintf(` + + resource "ibm_project_instance" "project_instance_instance" { + name = "%s" + } + `, name) +} + +func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { + return fmt.Sprintf(` + + resource "ibm_project_instance" "project_instance_instance" { + name = "%s" + description = "%s" + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } + resource_group = "%s" + location = "%s" + } + `, name, description, resourceGroup, location) +} + +func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { + + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(rs.Primary.ID) + + project, _, err := projectClient.GetProject(getProjectOptions) + if err != nil { + return err + } + + obj = *project + return nil + } +} + +func testAccCheckIbmProjectInstanceDestroy(s *terraform.State) error { + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_project_instance" { + continue + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(rs.Primary.ID) + + // Try to find the key + _, response, err := projectClient.GetProject(getProjectOptions) + + if err == nil { + return fmt.Errorf("Project definition still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for Project definition (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index 1ec993dea2..4e8d757fa8 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -28,6 +28,7 @@ Key Management Service Kubernetes Service Object Storage Power Systems +Projects API Specification Push Notifications Resource management Satellite From a1229cdc5bc92c09dc4c2ac2ccf3afdb409d7ff4 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 6 Apr 2023 12:36:10 +0200 Subject: [PATCH 002/125] fix: fix build Signed-off-by: dvesperini --- go.mod | 3 ++- go.sum | 4 ++++ ibm/service/project/resource_ibm_project_instance_test.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index b35261b017..c96ec44ffb 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/minsikl/netscaler-nitro-go v0.0.0-20170827154432-5b14ce3643e3 github.com/mitchellh/go-homedir v1.1.0 github.com/softlayer/softlayer-go v1.0.3 - go.mongodb.org/mongo-driver v1.11.2 // indirect + go.mongodb.org/mongo-driver v1.11.3 // indirect golang.org/x/crypto v0.5.0 gotest.tools v2.2.0+incompatible k8s.io/api v0.25.0 @@ -62,6 +62,7 @@ require ( ) require ( + github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect diff --git a/go.sum b/go.sum index d3cd8861ca..630aeabcb6 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/IBM/networking-go-sdk v0.36.0 h1:ADntTsRM8DMZOxS9TYGTAL6i0zw9V2L7OeLF github.com/IBM/networking-go-sdk v0.36.0/go.mod h1:tDJtlySQC/txyejU9KeQ27Amc6xKH0MwHFE/B2+Sn5w= github.com/IBM/platform-services-go-sdk v0.34.0 h1:ozGdyWdBByNS8sw07FP4qx2r1qUc59D0BoN3rMTgtIk= github.com/IBM/platform-services-go-sdk v0.34.0/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= +github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03 h1:mpz4CSzFeqfWSx+rP55n1afeZeACDcZGvtud2fY1KKA= +github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03/go.mod h1:yO1Pqm7Y9hWrn6eUlfPKwipqFAbvp9QeuLRb07H3/Ks= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= @@ -793,6 +795,8 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.11.2 h1:+1v2rDQUWNcGW7/7E0Jvdz51V38XXxJfhzbV17aNHCw= go.mongodb.org/mongo-driver v1.11.2/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= +go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y= +go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index faf71d0603..e6ec02576d 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM/project-go-sdk/projectv1" - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" ) func TestAccIbmProjectInstanceBasic(t *testing.T) { From ff4c819e606c012c821ddf19c98484998b70a5e8 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 6 Apr 2023 12:49:15 +0200 Subject: [PATCH 003/125] fix: add examples and markdown files Signed-off-by: dvesperini --- examples/ibm-project/README.md | 87 ++++++++++ examples/ibm-project/main.tf | 36 ++++ examples/ibm-project/outputs.tf | 6 + examples/ibm-project/variables.tf | 43 +++++ examples/ibm-project/versions.tf | 3 + ibm/conns/config.go | 4 + .../project_event_notification.html.markdown | 105 ++++++++++++ website/docs/r/project_instance.html.markdown | 159 ++++++++++++++++++ 8 files changed, 443 insertions(+) create mode 100644 examples/ibm-project/README.md create mode 100644 examples/ibm-project/main.tf create mode 100644 examples/ibm-project/outputs.tf create mode 100644 examples/ibm-project/variables.tf create mode 100644 examples/ibm-project/versions.tf create mode 100644 website/docs/d/project_event_notification.html.markdown create mode 100644 website/docs/r/project_instance.html.markdown diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md new file mode 100644 index 0000000000..ecbb9fffc2 --- /dev/null +++ b/examples/ibm-project/README.md @@ -0,0 +1,87 @@ +# Example for ProjectV1 + +This example illustrates how to use the ProjectV1 + +These types of resources are supported: + +* Project definition + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Run `terraform destroy` when you don't need these resources. + + +## ProjectV1 resources + +project_instance resource: + +```hcl +resource "project_instance" "project_instance_instance" { + name = var.project_instance_name + description = var.project_instance_description + configs = var.project_instance_configs + resource_group = var.project_instance_resource_group + location = var.project_instance_location +} +``` + +## ProjectV1 Data sources + +project_event_notification data source: + +```hcl +data "project_event_notification" "project_event_notification_instance" { + id = var.project_event_notification_id + exclude_configs = var.project_event_notification_exclude_configs + complete = var.project_event_notification_complete +} +``` + +## Assumptions + +1. TODO + +## Notes + +1. TODO + +## Requirements + +| Name | Version | +|------|---------| +| terraform | ~> 0.12 | + +## Providers + +| Name | Version | +|------|---------| +| ibm | 1.13.1 | + +## Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| name | The project name. | `string` | true | +| description | A project's descriptive text. | `string` | false | +| configs | The project configurations. | `list()` | false | +| resource_group | Group name of the customized collection of resources. | `string` | false | +| location | Data center locations for resource deployment. | `string` | false | +| id | The ID of the project, which uniquely identifies it. | `string` | true | +| exclude_configs | Only return with the active configuration, no drafts. | `bool` | false | +| complete | The flag to determine if full metadata should be returned. | `bool` | false | + +## Outputs + +| Name | Description | +|------|-------------| +| project_instance | project_instance object | +| project_event_notification | project_event_notification object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf new file mode 100644 index 0000000000..97372aa833 --- /dev/null +++ b/examples/ibm-project/main.tf @@ -0,0 +1,36 @@ +provider "ibm" { + ibmcloud_api_key = var.ibmcloud_api_key +} + +// Provision project_instance resource instance +resource "ibm_project_instance" "project_instance_instance" { + name = var.project_instance_name + description = var.project_instance_description + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } + resource_group = var.project_instance_resource_group + location = var.project_instance_location +} + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create project_event_notification data source +data "ibm_project_event_notification" "project_event_notification_instance" { + id = var.project_event_notification_id + exclude_configs = var.project_event_notification_exclude_configs + complete = var.project_event_notification_complete +} +*/ diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf new file mode 100644 index 0000000000..45d917b875 --- /dev/null +++ b/examples/ibm-project/outputs.tf @@ -0,0 +1,6 @@ +// This allows project_instance data to be referenced by other resources and the terraform CLI +// Modify this if only certain data should be exposed +output "ibm_project_instance" { + value = ibm_project_instance.project_instance_instance + description = "project_instance resource instance" +} diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf new file mode 100644 index 0000000000..e6ac2ae7e5 --- /dev/null +++ b/examples/ibm-project/variables.tf @@ -0,0 +1,43 @@ +variable "ibmcloud_api_key" { + description = "IBM Cloud API key" + type = string +} + +// Resource arguments for project_instance +variable "project_instance_name" { + description = "The project name." + type = string + default = "acme-microservice" +} +variable "project_instance_description" { + description = "A project's descriptive text." + type = string + default = "A microservice to deploy on top of ACME infrastructure." +} +variable "project_instance_resource_group" { + description = "Group name of the customized collection of resources." + type = string + default = "resource_group" +} +variable "project_instance_location" { + description = "Data center locations for resource deployment." + type = string + default = "location" +} + +// Data source arguments for project_event_notification +variable "project_event_notification_id" { + description = "The ID of the project, which uniquely identifies it." + type = string + default = "id" +} +variable "project_event_notification_exclude_configs" { + description = "Only return with the active configuration, no drafts." + type = bool + default = false +} +variable "project_event_notification_complete" { + description = "The flag to determine if full metadata should be returned." + type = bool + default = false +} diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf new file mode 100644 index 0000000000..ee0f9705a2 --- /dev/null +++ b/examples/ibm-project/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} \ No newline at end of file diff --git a/ibm/conns/config.go b/ibm/conns/config.go index 26d9f3bc81..edb11b17ee 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -1545,6 +1545,10 @@ func (c *Config) ClientSession() (interface{}, error) { session.projectClientErr = fmt.Errorf("Error occurred while configuring Projects API Specification service: %q", err) } + if c.Visibility == "private" || c.Visibility == "public-and-private" { + session.pushServiceClientErr = fmt.Errorf("Projects Service API does not support private endpoints") + } + // Construct an "options" struct for creating the service client. ukoClientOptions := &ukov4.UkoV4Options{ Authenticator: authenticator, diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown new file mode 100644 index 0000000000..99cf81e003 --- /dev/null +++ b/website/docs/d/project_event_notification.html.markdown @@ -0,0 +1,105 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_project_event_notification" +description: |- + Get information about Project definition +subcategory: "Projects API Specification" +--- + +# ibm_project_event_notification + +Provides a read-only data source for Project definition. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_project_event_notification" "project_event_notification" { + id = "id" +} +``` + +## Argument Reference + +Review the argument reference that you can specify for your data source. + +* `complete` - (Optional, Boolean) The flag to determine if full metadata should be returned. + * Constraints: The default value is `false`. +* `exclude_configs` - (Optional, Boolean) Only return with the active configuration, no drafts. + * Constraints: The default value is `false`. +* `id` - (Required, Forces new resource, String) The ID of the project, which uniquely identifies it. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +## Attribute Reference + +In addition to all argument references listed, you can access the following attribute references after your data source is created. + +* `id` - The unique identifier of the Project definition. +* `configs` - (List) The project configurations. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **configs**: + * `description` - (String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s).*\\S$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `input` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `required` - (Boolean) Whether the variable is required or not. + * `type` - (String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) The location ID of a project configuration manual property. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `name` - (String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `value` - (List) The output value. + * Constraints: The list items must match regular expression `/^(?!\\s).+\\S$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `setting` - (List) An optional setting object that's passed to the cart API. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `value` - (String) The value of a the configuration setting. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + +* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + +* `description` - (String) A project descriptive text. + +* `metadata` - (List) The metadata of the project. +Nested scheme for **metadata**: + * `created_at` - (String) A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339. + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **cumulative_needs_attention_view**: + * `config_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `config_version` - (Integer) The version number of the configuration. + * `event` - (String) The event name. + * `event_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. + * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. + * `location` - (String) The location where the project was created. + * `resource_group` - (String) The resource group where the project was created. + * `state` - (String) The project status value. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. + +* `name` - (String) The project name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown new file mode 100644 index 0000000000..9be9b3a30b --- /dev/null +++ b/website/docs/r/project_instance.html.markdown @@ -0,0 +1,159 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_project_instance" +description: |- + Manages Project definition. +subcategory: "Projects API Specification" +--- + +# ibm_project_instance + +Provides a resource for Project definition. This allows Project definition to be created, updated and deleted. + +## Example Usage + +```hcl +resource "ibm_project_instance" "project_instance_instance" { + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } + description = "A microservice to deploy on top of ACME infrastructure." + name = "acme-microservice" +} +``` + +## Argument Reference + +Review the argument reference that you can specify for your resource. + +* `configs` - (Optional, List) The project configurations. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **configs**: + * `description` - (Optional, String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s).*\\S$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (Required, String) The location ID of a project configuration manual property. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^.+$/`. + * `name` - (Required, String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `setting` - (Optional, List) An optional setting object that's passed to the cart API. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `value` - (Required, String) The value of a the configuration setting. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. +* `description` - (Optional, String) A project's descriptive text. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. +* `location` - (Optional, String) Data center locations for resource deployment. + * Constraints: The default value is `us-south`. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. +* `name` - (Required, String) The project name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. +* `resource_group` - (Optional, String) Group name of the customized collection of resources. + * Constraints: The default value is `Default`. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + +## Attribute Reference + +In addition to all argument references listed, you can access the following attribute references after your resource is created. + +* `id` - The unique identifier of the Project definition. +* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. +* `metadata` - (List) The metadata of the project. +Nested scheme for **metadata**: + * `created_at` - (String) A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339. + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **cumulative_needs_attention_view**: + * `config_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `config_version` - (Integer) The version number of the configuration. + * `event` - (String) The event name. + * `event_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. + * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. + * `location` - (String) The location where the project was created. + * `resource_group` - (String) The resource group where the project was created. + * `state` - (String) The project status value. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. + +## Provider Configuration + +The IBM Cloud provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: + +- Static credentials +- Environment variables + +To find which credentials are required for this resource, see the service table [here](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-provider-reference#required-parameters). + +### Static credentials + +You can provide your static credentials by adding the `ibmcloud_api_key`, `iaas_classic_username`, and `iaas_classic_api_key` arguments in the IBM Cloud provider block. + +Usage: +``` +provider "ibm" { + ibmcloud_api_key = "" + iaas_classic_username = "" + iaas_classic_api_key = "" +} +``` + +### Environment variables + +You can provide your credentials by exporting the `IC_API_KEY`, `IAAS_CLASSIC_USERNAME`, and `IAAS_CLASSIC_API_KEY` environment variables, representing your IBM Cloud platform API key, IBM Cloud Classic Infrastructure (SoftLayer) user name, and IBM Cloud infrastructure API key, respectively. + +``` +provider "ibm" {} +``` + +Usage: +``` +export IC_API_KEY="ibmcloud_api_key" +export IAAS_CLASSIC_USERNAME="iaas_classic_username" +export IAAS_CLASSIC_API_KEY="iaas_classic_api_key" +terraform plan +``` + +Note: + +1. Create or find your `ibmcloud_api_key` and `iaas_classic_api_key` [here](https://cloud.ibm.com/iam/apikeys). + - Select `My IBM Cloud API Keys` option from view dropdown for `ibmcloud_api_key` + - Select `Classic Infrastructure API Keys` option from view dropdown for `iaas_classic_api_key` +2. For iaas_classic_username + - Go to [Users](https://cloud.ibm.com/iam/users) + - Click on user. + - Find user name in the `VPN password` section under `User Details` tab + +For more informaton, see [here](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs#authentication). + +## Import + +You can import the `ibm_project_instance` resource by using `id`. The unique ID of a project. + +# Syntax +``` +$ terraform import ibm_project_instance.project_instance +``` From 5ef6411dda437498a9160def04f7bc94190b59b2 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 6 Apr 2023 15:28:30 +0200 Subject: [PATCH 004/125] fix: mark new false positive secrets Signed-off-by: dvesperini --- .secrets.baseline | 56 +++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 7dee1b68ad..b4bd657097 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-03-30T15:45:05Z", + "generated_at": "2023-04-06T13:25:29Z", "plugins_used": [ { "name": "ArtifactoryDetector" @@ -704,7 +704,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 912, + "line_number": 919, "type": "Base64 High Entropy String", "verified_result": null } @@ -714,7 +714,7 @@ "hashed_secret": "9184b0c38101bf24d78b2bb0d044deb1d33696fc", "is_secret": false, "is_verified": false, - "line_number": 132, + "line_number": 133, "type": "Secret Keyword", "verified_result": null }, @@ -722,7 +722,7 @@ "hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790", "is_secret": false, "is_verified": false, - "line_number": 1437, + "line_number": 1448, "type": "Base64 High Entropy String", "verified_result": null }, @@ -730,7 +730,7 @@ "hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018", "is_secret": false, "is_verified": false, - "line_number": 1505, + "line_number": 1516, "type": "Secret Keyword", "verified_result": null }, @@ -738,7 +738,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3335, + "line_number": 3368, "type": "Secret Keyword", "verified_result": null }, @@ -746,7 +746,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3348, + "line_number": 3381, "type": "Secret Keyword", "verified_result": null }, @@ -754,7 +754,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3389, + "line_number": 3422, "type": "Secret Keyword", "verified_result": null } @@ -764,7 +764,7 @@ "hashed_secret": "9982fcad895acdfd083f1f38a5e9b44a084e4747", "is_secret": false, "is_verified": false, - "line_number": 97, + "line_number": 99, "type": "Secret Keyword", "verified_result": null } @@ -784,7 +784,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1628, + "line_number": 1650, "type": "Secret Keyword", "verified_result": null }, @@ -792,7 +792,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1634, + "line_number": 1656, "type": "Secret Keyword", "verified_result": null } @@ -1084,7 +1084,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 441, + "line_number": 442, "type": "Secret Keyword", "verified_result": null } @@ -1094,7 +1094,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 87, + "line_number": 88, "type": "Secret Keyword", "verified_result": null }, @@ -1102,7 +1102,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 447, + "line_number": 450, "type": "Secret Keyword", "verified_result": null } @@ -1848,7 +1848,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 1570, + "line_number": 1575, "type": "Secret Keyword", "verified_result": null }, @@ -1856,7 +1856,7 @@ "hashed_secret": "2c7d1e61c036dc18b2e9b3e6392c8e59c8437f23", "is_secret": false, "is_verified": false, - "line_number": 1923, + "line_number": 1932, "type": "Secret Keyword", "verified_result": null } @@ -3342,7 +3342,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 85021, + "line_number": 84849, "type": "Secret Keyword", "verified_result": null }, @@ -3350,7 +3350,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 104155, + "line_number": 104163, "type": "Secret Keyword", "verified_result": null }, @@ -3358,7 +3358,7 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 131088, + "line_number": 131106, "type": "Secret Keyword", "verified_result": null } @@ -4375,6 +4375,24 @@ "verified_result": null } ], + "website/docs/r/project_instance.html.markdown": [ + { + "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", + "is_secret": false, + "is_verified": false, + "line_number": 134, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", + "is_secret": false, + "is_verified": false, + "line_number": 136, + "type": "Secret Keyword", + "verified_result": null + } + ], "website/docs/r/resource_instance.html.markdown": [ { "hashed_secret": "d62552e3d0606ac398b6ee5cbd49e763ac9c3933", From 6729e088346a014dcae99367e96e6e472a2a3757 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Wed, 12 Apr 2023 15:03:59 +0200 Subject: [PATCH 005/125] fix: fix review Signed-off-by: dvesperini --- ibm/conns/config.go | 22 ++++++++++++++----- .../project_event_notification.html.markdown | 2 +- website/docs/r/project_instance.html.markdown | 22 +++++++++---------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ibm/conns/config.go b/ibm/conns/config.go index edb11b17ee..a12be3f585 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -75,7 +75,7 @@ import ( ibmcloudshellv1 "github.com/IBM/platform-services-go-sdk/ibmcloudshellv1" resourcecontroller "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" resourcemanager "github.com/IBM/platform-services-go-sdk/resourcemanagerv2" - "github.com/IBM/project-go-sdk/projectv1" + project "github.com/IBM/project-go-sdk/projectv1" "github.com/IBM/push-notifications-go-sdk/pushservicev1" "github.com/IBM/scc-go-sdk/v3/adminserviceapiv1" "github.com/IBM/scc-go-sdk/v3/configurationgovernancev1" @@ -302,7 +302,7 @@ type ClientSession interface { CdToolchainV2() (*cdtoolchainv2.CdToolchainV2, error) CdTektonPipelineV2() (*cdtektonpipelinev2.CdTektonPipelineV2, error) CodeEngineV2() (*codeengine.CodeEngineV2, error) - ProjectV1() (*projectv1.ProjectV1, error) + ProjectV1() (*project.ProjectV1, error) } type clientSession struct { @@ -628,7 +628,7 @@ type clientSession struct { codeEngineClientErr error // Project options - projectClient *projectv1.ProjectV1 + projectClient *project.ProjectV1 projectClientErr error } @@ -1206,7 +1206,7 @@ func (session clientSession) CodeEngineV2() (*codeengine.CodeEngineV2, error) { } // Projects API Specification -func (session clientSession) ProjectV1() (*projectv1.ProjectV1, error) { +func (session clientSession) ProjectV1() (*project.ProjectV1, error) { return session.projectClient, session.projectClientErr } @@ -1305,6 +1305,7 @@ func (c *Config) ClientSession() (interface{}, error) { session.cdTektonPipelineClientErr = errEmptyBluemixCredentials session.cdToolchainClientErr = errEmptyBluemixCredentials session.codeEngineClientErr = errEmptyBluemixCredentials + session.projectClientErr = errEmptyBluemixCredentials return session, nil } @@ -1527,13 +1528,22 @@ func (c *Config) ClientSession() (interface{}, error) { } } + projectEndpoint := project.DefaultServiceURL // Construct an "options" struct for creating the service client. - projectClientOptions := &projectv1.ProjectV1Options{ + if fileMap != nil && c.Visibility != "public-and-private" { + projectEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_PROJECT_API_ENDPOINT", c.Region, project.DefaultServiceURL) + } + if c.Visibility == "private" || c.Visibility == "public-and-private" { + session.projectClientErr = fmt.Errorf("Project Service API does not support private endpoints") + } + // Construct an "options" struct for creating the service client. + projectClientOptions := &project.ProjectV1Options{ + URL: EnvFallBack([]string{"IBMCLOUD_PROJECT_API_ENDPOINT"}, projectEndpoint), Authenticator: authenticator, } // Construct the service client. - session.projectClient, err = projectv1.NewProjectV1(projectClientOptions) + session.projectClient, err = project.NewProjectV1(projectClientOptions) if err == nil { // Enable retries for API calls session.projectClient.Service.EnableRetries(c.RetryCount, c.RetryDelay) diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index 99cf81e003..0064fa6f21 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source for Project definition. You can then reference ```hcl data "ibm_project_event_notification" "project_event_notification" { - id = "id" + id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" } ``` diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index 9be9b3a30b..677d4c1d83 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -13,23 +13,23 @@ Provides a resource for Project definition. This allows Project definition to be ## Example Usage ```hcl -resource "ibm_project_instance" "project_instance_instance" { +resource "ibm_project" "project_instance" { configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "locator_id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { - name = "name" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } - description = "A microservice to deploy on top of ACME infrastructure." - name = "acme-microservice" + description = "Sample static website test using the IBM catalog deployable architecture" + name = "My static website" } ``` From bc99b6cafc9d1d2ccf9c69b89b5581e41173e610 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 13 Apr 2023 09:16:04 +0200 Subject: [PATCH 006/125] fix: fix links Signed-off-by: dvesperini --- ibm/service/project/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index b0c70bd356..452ed8d034 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -7,5 +7,5 @@ This area is primarily for IBM provider contributors and maintainers. For inform * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project_instance) -* IBM API Docs: [IBM API Docs for ]() -* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) +* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) +* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) From 7d86c6d2448ff30020bb3ddeae041bb915f986b3 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Thu, 13 Apr 2023 16:30:26 +0200 Subject: [PATCH 007/125] fix: fix test Signed-off-by: dvesperini --- ...rce_ibm_project_event_notification_test.go | 16 +++++++-------- .../resource_ibm_project_instance_test.go | 20 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index a55fca9fc1..a932e3448f 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -14,7 +14,7 @@ import ( ) func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -33,10 +33,10 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { } func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + projectDescription := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -67,15 +67,15 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { +resource "ibm_project_instance" "project_instance_instance" { name = "%s" } - data "ibm_project_event_notification" "project_event_notification_instance" { - id = projectIdLink + id = ibm_project_instance.project_instance_instance.id exclude_configs = true complete = true } + `, projectName) } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index e6ec02576d..c503bcf02a 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -18,8 +18,8 @@ import ( func TestAccIbmProjectInstanceBasic(t *testing.T) { var conf projectv1.Project - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -45,14 +45,14 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, From 8fa9ab8e4c398df86854357203302fec2ef6c7fd Mon Sep 17 00:00:00 2001 From: dvesperini Date: Fri, 14 Apr 2023 12:13:02 +0200 Subject: [PATCH 008/125] fix: remove regex check Signed-off-by: dvesperini --- ...rce_ibm_project_event_notification_test.go | 16 ++-- .../project/resource_ibm_project_instance.go | 84 +++++++++---------- .../resource_ibm_project_instance_test.go | 20 ++--- 3 files changed, 56 insertions(+), 64 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index a932e3448f..7b8d675a98 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -14,7 +14,7 @@ import ( ) func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { - projectName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -33,10 +33,10 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { } func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { - projectName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - projectDescription := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -67,15 +67,15 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName string) string { return fmt.Sprintf(` -resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance_instance" { name = "%s" } + data "ibm_project_event_notification" "project_event_notification_instance" { id = ibm_project_instance.project_instance_instance.id exclude_configs = true complete = true } - `, projectName) } @@ -103,7 +103,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, } data "ibm_project_event_notification" "project_event_notification_instance" { - id = projectIdLink + id = ibm_project_instance.project_instance_instance.id exclude_configs = true complete = true } diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index e36baf5670..be03f03ea8 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -28,16 +28,14 @@ func ResourceIbmProjectInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "name"), - Description: "The project name.", + Type: schema.TypeString, + Required: true, + Description: "The project name.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "description"), - Description: "A project's descriptive text.", + Type: schema.TypeString, + Optional: true, + Description: "A project's descriptive text.", }, "configs": &schema.Schema{ Type: schema.TypeList, @@ -108,18 +106,16 @@ func ResourceIbmProjectInstance() *schema.Resource { }, }, "resource_group": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "Default", - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "resource_group"), - Description: "Group name of the customized collection of resources.", + Type: schema.TypeString, + Optional: true, + Default: "Default", + Description: "Group name of the customized collection of resources.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "us-south", - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "location"), - Description: "Data center locations for resource deployment.", + Type: schema.TypeString, + Optional: true, + Default: "us-south", + Description: "Data center locations for resource deployment.", }, "crn": &schema.Schema{ Type: schema.TypeString, @@ -207,40 +203,36 @@ func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { validateSchema := make([]validate.ValidateSchema, 0) validateSchema = append(validateSchema, validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^(?!\s).+\S$`, - MinValueLength: 1, - MaxValueLength: 64, + Identifier: "name", + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s).+\S$`, + MinValueLength: 1, + MaxValueLength: 64, }, validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, + Identifier: "description", + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, }, validate.ValidateSchema{ - Identifier: "resource_group", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 40, + Identifier: "resource_group", + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 40, }, validate.ValidateSchema{ - Identifier: "location", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, - MinValueLength: 0, - MaxValueLength: 12, + Identifier: "location", + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + MinValueLength: 0, + MaxValueLength: 12, }, ) diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index c503bcf02a..e6ec02576d 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -18,8 +18,8 @@ import ( func TestAccIbmProjectInstanceBasic(t *testing.T) { var conf projectv1.Project - name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -45,14 +45,14 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project - name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tfdescription%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tfresourcegroup%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tflocation%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, From a27a0f96e3393cae469337d49014034d3f9bebec Mon Sep 17 00:00:00 2001 From: dvesperini Date: Fri, 14 Apr 2023 13:25:55 +0200 Subject: [PATCH 009/125] fix: fix id to project_id Signed-off-by: dvesperini --- .../data_source_ibm_project_event_notification.go | 4 ++-- .../data_source_ibm_project_event_notification_test.go | 10 ++++------ website/allowed-subcategories.txt | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go index 940cd18234..07e9ce6000 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification.go +++ b/ibm/service/project/data_source_ibm_project_event_notification.go @@ -21,7 +21,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { ReadContext: dataSourceIbmProjectEventNotificationRead, Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "project_id": &schema.Schema{ Type: schema.TypeString, Required: true, Description: "The ID of the project, which uniquely identifies it.", @@ -250,7 +250,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(d.Get("id").(string)) + getProjectOptions.SetID(d.Get("project_id").(string)) if _, ok := d.GetOk("exclude_configs"); ok { getProjectOptions.SetExcludeConfigs(d.Get("exclude_configs").(bool)) } diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 7b8d675a98..e5ad64a404 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -23,8 +23,7 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), ), }, @@ -45,8 +44,7 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "exclude_configs"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "complete"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), @@ -72,7 +70,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName st } data "ibm_project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.id + project_id = ibm_project_instance.project_instance_instance.id exclude_configs = true complete = true } @@ -103,7 +101,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, } data "ibm_project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.id + project_id = ibm_project_instance.project_instance_instance.id exclude_configs = true complete = true } diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index 4e8d757fa8..f087ca7f89 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -28,7 +28,7 @@ Key Management Service Kubernetes Service Object Storage Power Systems -Projects API Specification +Project Push Notifications Resource management Satellite From b4e022ef2f6c40203340649d33019233daf81c93 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Fri, 14 Apr 2023 15:26:57 +0200 Subject: [PATCH 010/125] fix: fix integration test project Signed-off-by: dvesperini --- .../data_source_ibm_project_event_notification_test.go | 2 +- ibm/service/project/resource_ibm_project_instance_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index e5ad64a404..0eae52ffda 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -35,7 +35,7 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index e6ec02576d..a41197e4fe 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -48,11 +48,11 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("us-south%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, From 22463b829cfbb84115570fdfb7866f8d9325b922 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Fri, 14 Apr 2023 16:03:14 +0200 Subject: [PATCH 011/125] fix: fix resource_group values Signed-off-by: dvesperini --- .../project/data_source_ibm_project_event_notification_test.go | 2 +- ibm/service/project/resource_ibm_project_instance_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 0eae52ffda..7cb133c43d 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -34,7 +34,7 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index a41197e4fe..14a1f7deb6 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -47,7 +47,7 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) From fcd552ee2dcd6e760dd5a1af913b6c7322dc88a9 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Sat, 15 Apr 2023 10:02:58 +0200 Subject: [PATCH 012/125] fix: last changes Signed-off-by: dvesperini --- .../project/data_source_ibm_project_event_notification_test.go | 2 +- ibm/service/project/resource_ibm_project_instance_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 7cb133c43d..84cd6768db 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -87,7 +87,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, name = "name" labels = [ "labels" ] description = "description" - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.307060b5-cba0-43ec-b89e-37366051403e-global" input { name = "name" } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index 14a1f7deb6..dfc4d831ae 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -107,7 +107,7 @@ func testAccCheckIbmProjectInstanceConfig(name string, description string, resou name = "name" labels = [ "labels" ] description = "description" - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.307060b5-cba0-43ec-b89e-37366051403e-global" input { name = "name" } From 34fbcfc3afc9acf9234a969a3320044930623672 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 21 Apr 2023 17:19:58 +0200 Subject: [PATCH 013/125] fix integration test --- ibm/provider/provider.go | 12 +-- .../project/resource_ibm_project_instance.go | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+), 6 deletions(-) diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 2c0cea07b7..2bed4a5893 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -1261,9 +1261,9 @@ func Provider() *schema.Provider { "ibm_code_engine_config_map": codeengine.ResourceIbmCodeEngineConfigMap(), "ibm_code_engine_job": codeengine.ResourceIbmCodeEngineJob(), "ibm_code_engine_project": codeengine.ResourceIbmCodeEngineProject(), - "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecret(), - - // Added for Project + "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecret(), + + // Added for Project "ibm_project_instance": project.ResourceIbmProjectInstance(), }, @@ -1498,9 +1498,9 @@ func Validator() validate.ValidatorDict { "ibm_code_engine_config_map": codeengine.ResourceIbmCodeEngineConfigMapValidator(), "ibm_code_engine_job": codeengine.ResourceIbmCodeEngineJobValidator(), "ibm_code_engine_project": codeengine.ResourceIbmCodeEngineProjectValidator(), - "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecretValidator(), - - // Added for Project + "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecretValidator(), + + // Added for Project "ibm_project_instance": project.ResourceIbmProjectInstanceValidator(), }, DataSourceValidatorDictionary: map[string]*validate.ResourceValidator{ diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index be03f03ea8..3777df5293 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -279,9 +281,50 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc d.SetId(*project.ID) + _, err = waitForProjectInstanceCreate(d, meta) + fmt.Printf("dopo la wait della create ") + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectInstanceRead(context, d, meta) } +func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + fmt.Printf("la risorsa esiste ") + return resp, "exists", nil + } else { + fmt.Printf("la risorsa non esiste, proseguo il ciclo ") + return resp, "not_exists", nil + } + } else { + fmt.Printf("c'e' stato un errore ") + return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutUpdate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -359,11 +402,52 @@ func resourceIbmProjectInstanceDelete(context context.Context, d *schema.Resourc return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectInstanceDelete(d, meta) + fmt.Printf("dopo la wait della delete ") + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + fmt.Printf("la risorsa non esiste piu' ") + return resp, "not_exists", nil + } else { + fmt.Printf("la risorsa ancora esiste, proseguo il ciclo ") + return resp, "exists", nil + } + } else { + fmt.Printf("la risorsa ancora esiste, proseguo il ciclo ") + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutUpdate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { From 8c1b01009ba41c2eecad4dce35b7ff6a1adc30d0 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 21 Apr 2023 17:43:55 +0200 Subject: [PATCH 014/125] fix integration test --- ibm/service/project/resource_ibm_project_instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 3777df5293..606ade6324 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -282,7 +282,7 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc d.SetId(*project.ID) _, err = waitForProjectInstanceCreate(d, meta) - fmt.Printf("dopo la wait della create ") + fmt.Println("dopo la wait della create ") if err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) } From 774aafaa149d9fcb65af0d8631e7509895001fe4 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 26 Apr 2023 13:10:24 +0200 Subject: [PATCH 015/125] fix integration test --- ...rce_ibm_project_event_notification_test.go | 17 ++----- .../project/resource_ibm_project_instance.go | 49 +++++++++---------- .../resource_ibm_project_instance_test.go | 8 +-- 3 files changed, 32 insertions(+), 42 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 84cd6768db..db0f74c16a 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -49,13 +49,6 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "complete"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.id"), - resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.name", projectName), - resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.type"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), ), }, @@ -69,9 +62,9 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName st name = "%s" } - data "ibm_project_event_notification" "project_event_notification_instance" { + data "ibm_project_event_notification" "project_event_notification" { project_id = ibm_project_instance.project_instance_instance.id - exclude_configs = true + exclude_configs = false complete = true } `, projectName) @@ -87,7 +80,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, name = "name" labels = [ "labels" ] description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.307060b5-cba0-43ec-b89e-37366051403e-global" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" } @@ -100,9 +93,9 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, location = "%s" } - data "ibm_project_event_notification" "project_event_notification_instance" { + data "ibm_project_event_notification" "project_event_notification" { project_id = ibm_project_instance.project_instance_instance.id - exclude_configs = true + exclude_configs = false complete = true } `, projectName, projectDescription, projectResourceGroup, projectLocation) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 606ade6324..1df1363b60 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -27,6 +27,10 @@ func ResourceIbmProjectInstance() *schema.Resource { UpdateContext: resourceIbmProjectInstanceUpdate, DeleteContext: resourceIbmProjectInstanceDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -132,38 +136,38 @@ func ResourceIbmProjectInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "crn": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, "created_at": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339.", }, "cumulative_needs_attention_view": &schema.Schema{ Type: schema.TypeList, - Optional: true, + Computed: true, Description: "The cumulative list of needs attention items for a project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "event": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The event name.", }, "event_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The unique ID of a project.", }, "config_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The unique ID of a project.", }, "config_version": &schema.Schema{ Type: schema.TypeInt, - Optional: true, + Computed: true, Description: "The version number of the configuration.", }, }, @@ -171,27 +175,27 @@ func ResourceIbmProjectInstance() *schema.Resource { }, "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "True indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The location where the project was created.", }, "resource_group": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The resource group where the project was created.", }, "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The project status value.", }, "event_notifications_crn": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, }, @@ -282,7 +286,6 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc d.SetId(*project.ID) _, err = waitForProjectInstanceCreate(d, meta) - fmt.Println("dopo la wait della create ") if err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) } @@ -306,18 +309,15 @@ func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (int _, resp, err := projectClient.GetProject(getProjectOptions) if err == nil { if resp != nil && resp.StatusCode == 200 { - fmt.Printf("la risorsa esiste ") return resp, "exists", nil } else { - fmt.Printf("la risorsa non esiste, proseguo il ciclo ") return resp, "not_exists", nil } } else { - fmt.Printf("c'e' stato un errore ") return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) } }, - Timeout: d.Timeout(schema.TimeoutUpdate), + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 2 * time.Second, MinTimeout: 10 * time.Second, } @@ -350,14 +350,15 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } } + metadataMap := make(map[string]interface{}) if !core.IsNil(project.Metadata) { - metadataMap, err := resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) + metadataMap, err = resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) if err != nil { return diag.FromErr(err) } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) - } + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) } return nil @@ -403,7 +404,6 @@ func resourceIbmProjectInstanceDelete(context context.Context, d *schema.Resourc } _, err = waitForProjectInstanceDelete(d, meta) - fmt.Printf("dopo la wait della delete ") if err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) } @@ -429,18 +429,15 @@ func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (int _, resp, err := projectClient.GetProject(getProjectOptions) if err != nil { if resp != nil && resp.StatusCode == 404 { - fmt.Printf("la risorsa non esiste piu' ") return resp, "not_exists", nil } else { - fmt.Printf("la risorsa ancora esiste, proseguo il ciclo ") return resp, "exists", nil } } else { - fmt.Printf("la risorsa ancora esiste, proseguo il ciclo ") return resp, "exists", nil } }, - Timeout: d.Timeout(schema.TimeoutUpdate), + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 2 * time.Second, MinTimeout: 10 * time.Second, } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index dfc4d831ae..d2d6562cc2 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -19,7 +19,7 @@ import ( func TestAccIbmProjectInstanceBasic(t *testing.T) { var conf projectv1.Project name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_update_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -90,7 +90,7 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { func testAccCheckIbmProjectInstanceConfigBasic(name string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance" { name = "%s" } `, name) @@ -99,7 +99,7 @@ func testAccCheckIbmProjectInstanceConfigBasic(name string) string { func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance" { name = "%s" description = "%s" configs { @@ -107,7 +107,7 @@ func testAccCheckIbmProjectInstanceConfig(name string, description string, resou name = "name" labels = [ "labels" ] description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.307060b5-cba0-43ec-b89e-37366051403e-global" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" } From ddfb9bc38bdbf09ddd616750ea6514e1211840be Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 27 Apr 2023 13:36:45 +0200 Subject: [PATCH 016/125] fix integration test --- .../project/resource_ibm_project_instance.go | 1 + .../resource_ibm_project_instance_test.go | 53 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 1df1363b60..b692ab65f1 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -36,6 +36,7 @@ func ResourceIbmProjectInstance() *schema.Resource { "name": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, Description: "The project name.", }, "description": &schema.Schema{ diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index d2d6562cc2..b8bf3c2454 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -51,8 +51,6 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { location := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("us-south%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -70,18 +68,21 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroupUpdate, locationUpdate), + Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroup, location), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), ), }, resource.TestStep{ ResourceName: "ibm_project_instance.project_instance", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "configs", + }, }, }, }) @@ -99,27 +100,27 @@ func testAccCheckIbmProjectInstanceConfigBasic(name string) string { func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance" { - name = "%s" - description = "%s" - configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - } - setting { - name = "name" - value = "value" - } - } - resource_group = "%s" - location = "%s" - } - `, name, description, resourceGroup, location) + resource "ibm_project_instance" "project_instance" { + name = "%s" + description = "%s" + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } + resource_group = "%s" + location = "%s" + } + `, name, description, resourceGroup, location) } func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { From 232c27600b23fefb3fa03763bbaa64e53d989277 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 27 Apr 2023 16:50:43 +0200 Subject: [PATCH 017/125] fix integration test --- .../project/resource_ibm_project_instance.go | 5 +++++ .../resource_ibm_project_instance_test.go | 21 ++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index b692ab65f1..4956aaaaa9 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -351,6 +351,11 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } } + if !core.IsNil(project.Name) { + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + } metadataMap := make(map[string]interface{}) if !core.IsNil(project.Metadata) { metadataMap, err = resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index b8bf3c2454..45b9ab8c30 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -46,11 +46,7 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -58,22 +54,16 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { CheckDestroy: testAccCheckIbmProjectInstanceDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(name, description, resourceGroup, location), + Config: testAccCheckIbmProjectInstanceConfig(name), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", description), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroup, location), + Config: testAccCheckIbmProjectInstanceConfig(nameUpdate), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), ), }, resource.TestStep{ @@ -97,12 +87,11 @@ func testAccCheckIbmProjectInstanceConfigBasic(name string) string { `, name) } -func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { +func testAccCheckIbmProjectInstanceConfig(name string) string { return fmt.Sprintf(` resource "ibm_project_instance" "project_instance" { name = "%s" - description = "%s" configs { id = "id" name = "name" @@ -117,10 +106,8 @@ func testAccCheckIbmProjectInstanceConfig(name string, description string, resou value = "value" } } - resource_group = "%s" - location = "%s" } - `, name, description, resourceGroup, location) + `, name) } func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { From d4d39f2afdb7d623219b4ff4ac6da65853e94ba3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 27 Apr 2023 20:30:43 +0200 Subject: [PATCH 018/125] fix integration test --- ibm/service/project/resource_ibm_project_instance_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index 45b9ab8c30..33df503484 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -71,6 +71,8 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ + "location", + "resource_group", "configs", }, }, From 4b6e36f344e5ecb76f441d925329990a08aad075 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 2 May 2023 09:20:03 +0200 Subject: [PATCH 019/125] fix name --- examples/ibm-project/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 97372aa833..54df66c6a9 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -3,7 +3,7 @@ provider "ibm" { } // Provision project_instance resource instance -resource "ibm_project_instance" "project_instance_instance" { +resource "ibm_project_instance" "project_instance" { name = var.project_instance_name description = var.project_instance_description configs { From c4f1a146ba5bb86fe8d925632cbb2e5e1864ceee Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 3 May 2023 11:32:24 +0200 Subject: [PATCH 020/125] pr comments --- examples/ibm-project/main.tf | 26 +++++----- ibm/conns/config.go | 4 -- ...rce_ibm_project_event_notification_test.go | 2 +- website/docs/r/project_instance.html.markdown | 50 ------------------- 4 files changed, 14 insertions(+), 68 deletions(-) diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 54df66c6a9..555d3653f5 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -3,25 +3,25 @@ provider "ibm" { } // Provision project_instance resource instance -resource "ibm_project_instance" "project_instance" { - name = var.project_instance_name - description = var.project_instance_description +resource "ibm_project" "project_instance" { + name = "My static website" + description = "Sample static website test using the IBM catalog deployable architecture" configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "locator_id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { - name = "name" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } - resource_group = var.project_instance_resource_group - location = var.project_instance_location + resource_group = "Default" + location = "us-south" } // Data source is not linked to a resource instance diff --git a/ibm/conns/config.go b/ibm/conns/config.go index 7e7ea5b75f..30c404c3f7 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -1544,10 +1544,6 @@ func (c *Config) ClientSession() (interface{}, error) { session.projectClientErr = fmt.Errorf("Error occurred while configuring Projects API Specification service: %q", err) } - if c.Visibility == "private" || c.Visibility == "public-and-private" { - session.pushServiceClientErr = fmt.Errorf("Projects Service API does not support private endpoints") - } - // Construct an "options" struct for creating the service client. ukoClientOptions := &ukov4.UkoV4Options{ Authenticator: authenticator, diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index db0f74c16a..3abc12706f 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -76,7 +76,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, name = "%s" description = "%s" configs { - id = "id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" name = "name" labels = [ "labels" ] description = "description" diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index 677d4c1d83..1e9af48df9 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -99,56 +99,6 @@ Nested scheme for **metadata**: * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. -## Provider Configuration - -The IBM Cloud provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: - -- Static credentials -- Environment variables - -To find which credentials are required for this resource, see the service table [here](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-provider-reference#required-parameters). - -### Static credentials - -You can provide your static credentials by adding the `ibmcloud_api_key`, `iaas_classic_username`, and `iaas_classic_api_key` arguments in the IBM Cloud provider block. - -Usage: -``` -provider "ibm" { - ibmcloud_api_key = "" - iaas_classic_username = "" - iaas_classic_api_key = "" -} -``` - -### Environment variables - -You can provide your credentials by exporting the `IC_API_KEY`, `IAAS_CLASSIC_USERNAME`, and `IAAS_CLASSIC_API_KEY` environment variables, representing your IBM Cloud platform API key, IBM Cloud Classic Infrastructure (SoftLayer) user name, and IBM Cloud infrastructure API key, respectively. - -``` -provider "ibm" {} -``` - -Usage: -``` -export IC_API_KEY="ibmcloud_api_key" -export IAAS_CLASSIC_USERNAME="iaas_classic_username" -export IAAS_CLASSIC_API_KEY="iaas_classic_api_key" -terraform plan -``` - -Note: - -1. Create or find your `ibmcloud_api_key` and `iaas_classic_api_key` [here](https://cloud.ibm.com/iam/apikeys). - - Select `My IBM Cloud API Keys` option from view dropdown for `ibmcloud_api_key` - - Select `Classic Infrastructure API Keys` option from view dropdown for `iaas_classic_api_key` -2. For iaas_classic_username - - Go to [Users](https://cloud.ibm.com/iam/users) - - Click on user. - - Find user name in the `VPN password` section under `User Details` tab - -For more informaton, see [here](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs#authentication). - ## Import You can import the `ibm_project_instance` resource by using `id`. The unique ID of a project. From 40ef8296566271f21b9082743a738d5e1dfdfed9 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 3 May 2023 11:34:27 +0200 Subject: [PATCH 021/125] pr comments --- examples/ibm-project/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 555d3653f5..7a3d974e9f 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -3,7 +3,7 @@ provider "ibm" { } // Provision project_instance resource instance -resource "ibm_project" "project_instance" { +resource "ibm_project_instance" "project_instance" { name = "My static website" description = "Sample static website test using the IBM catalog deployable architecture" configs { From 33260af95803b4d2fced2c87e1f65c00b6853d46 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 4 May 2023 13:42:22 +0200 Subject: [PATCH 022/125] fix doc --- website/docs/r/project_instance.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index 1e9af48df9..c53f47f14d 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_instance" description: |- Manages Project definition. -subcategory: "Projects API Specification" +subcategory: "Project" --- # ibm_project_instance From 2dbbd8f19d25d47512dfbb3769ed5f88577cb67c Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 4 May 2023 14:01:54 +0200 Subject: [PATCH 023/125] fix doc --- website/docs/d/project_event_notification.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index 0064fa6f21..bc6b73a1d9 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_event_notification" description: |- Get information about Project definition -subcategory: "Projects API Specification" +subcategory: "Project" --- # ibm_project_event_notification From 97abc9e3f067463ff5d9dbcbc7a07bc7428c8299 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Sun, 7 May 2023 23:33:10 +0200 Subject: [PATCH 024/125] new version --- cloud-docs/project-data-sources.md | 89 ++++++ cloud-docs/project-resources.md | 85 +++++ examples/ibm-project/README.md | 16 +- examples/ibm-project/main.tf | 35 +-- examples/ibm-project/variables.tf | 32 +- ibm/service/project/README.md | 4 +- ...a_source_ibm_project_event_notification.go | 57 ++-- ...rce_ibm_project_event_notification_test.go | 56 ++-- .../project/resource_ibm_project_instance.go | 296 ++++++++---------- .../resource_ibm_project_instance_test.go | 87 +++-- .../project_event_notification.html.markdown | 50 +-- website/docs/r/project_instance.html.markdown | 121 +++++-- 12 files changed, 568 insertions(+), 360 deletions(-) create mode 100644 cloud-docs/project-data-sources.md create mode 100644 cloud-docs/project-resources.md diff --git a/cloud-docs/project-data-sources.md b/cloud-docs/project-data-sources.md new file mode 100644 index 0000000000..2b54f9ae2d --- /dev/null +++ b/cloud-docs/project-data-sources.md @@ -0,0 +1,89 @@ +--- + +copyright: + years: 2023 +lastupdated: "2023" + +keywords: terraform + +subcollection: terraform + +--- + +# Projects API data sources +{: #project-data-sources} + +Review the data sources that you can use to retrieve information about your Projects API resources. +All data sources are imported as read-only information. You can reference the output parameters for each data source by using Terraform interpolation syntax. + +Before you start working with your data source, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) +that you need to specify in the `provider` block of your Terraform configuration file. +{: important} + +## `ibm_project_event_notification` +{: #project_event_notification} + +Retrieve information about Project definition. +{: shortdesc} + +### Sample Terraform code +{: #project_event_notification-sample} + +``` +data "ibm_project_event_notification" "project_event_notification" { + id = "id" +} +``` + +### Input parameters +{: #project_event_notification-input} + +Review the input parameters that you can specify for your data source. {: shortdesc} + +|Name|Data type|Required/optional|Description| +|----|-----------|-------|----------| +|`id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| + +### Output parameters +{: #project_event_notification-output} + +Review the output parameters that you can access after you retrieved your data source. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`configs`|List|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| +|`configs.labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`configs.locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| +|`configs.type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| +|`configs.input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| +|`configs.input.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`configs.input.required`|Boolean|Whether the variable is required or not.| +|`configs.output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`configs.output.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`configs.setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`description`|String|A project descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`metadata`|List|The metadata of the project. This list contains only one item.| +|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| +|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| +|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.cumulative_needs_attention_view.event_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| +|`metadata.cumulative_needs_attention_view_err`|String|\"True\" indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| +|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`name`|String|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.| + diff --git a/cloud-docs/project-resources.md b/cloud-docs/project-resources.md new file mode 100644 index 0000000000..186cbcd488 --- /dev/null +++ b/cloud-docs/project-resources.md @@ -0,0 +1,85 @@ +--- + +copyright: + years: 2023 +lastupdated: "2023" + +keywords: terraform + +subcollection: terraform + +--- + +# Projects API resources +{: #project-resources} + +Create, update, or delete Projects API resources. +You can reference the output parameters for each resource in other resources or data sources by using Terraform interpolation syntax. + +Before you start working with your resource, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) +that you need to specify in the `provider` block of your Terraform configuration file. +{: important} + +## `ibm_project_instance` +{: #project_instance} + +Create, update, or delete an Project definition. +{: shortdesc} + +### Sample Terraform code +{: #project_instance-sample} + +``` +resource "ibm_project_instance" "project_instance" { + description = "A microservice to deploy on top of ACME infrastructure." + location = "us-south" + name = "acme-microservice" + resource_group = "Default" +} +``` + +### Input parameters +{: #project_instance-input} + +Review the input parameters that you can specify for your resource. {: shortdesc} + +|Name|Data type|Required/optional|Description|Forces new resource| +|----|-----------|-------|----------|--------------------| +|`configs`|List|Optional|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.|No| +|`description`|String|Optional|A project's descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|No| +|`location`|String|Required|The location where the project's data and tools are created. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.|No| +|`name`|String|Required|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.|No| +|`resource_group`|String|Required|The resource group where the project's data and tools are created. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.|No| + +### Output parameters +{: #project_instance-output} + +Review the output parameters that you can access after your resource is created. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`id`|String|The unique identifier of the Project definition.| +|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata`|List|The metadata of the project. This list contains only one item.| +|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| +|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| +|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.cumulative_needs_attention_view.event_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| +|`metadata.cumulative_needs_attention_view_err`|String|\"True\" indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| +|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| + +### Import +{: #project_instance-import} + +`ibm_project_instance` can be imported by ID + +``` +$ terraform import ibm_project_instance.example sample-id +``` + diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index ecbb9fffc2..167f62ae8a 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -25,11 +25,11 @@ project_instance resource: ```hcl resource "project_instance" "project_instance_instance" { + resource_group = var.project_instance_resource_group + location = var.project_instance_location name = var.project_instance_name description = var.project_instance_description configs = var.project_instance_configs - resource_group = var.project_instance_resource_group - location = var.project_instance_location } ``` @@ -39,9 +39,7 @@ project_event_notification data source: ```hcl data "project_event_notification" "project_event_notification_instance" { - id = var.project_event_notification_id - exclude_configs = var.project_event_notification_exclude_configs - complete = var.project_event_notification_complete + id = ibm_project_instance.project_instance_instance.id } ``` @@ -70,14 +68,12 @@ data "project_event_notification" "project_event_notification_instance" { | Name | Description | Type | Required | |------|-------------|------|---------| | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| resource_group | The resource group where the project's data and tools are created. | `string` | true | +| location | The location where the project's data and tools are created. | `string` | true | | name | The project name. | `string` | true | | description | A project's descriptive text. | `string` | false | | configs | The project configurations. | `list()` | false | -| resource_group | Group name of the customized collection of resources. | `string` | false | -| location | Data center locations for resource deployment. | `string` | false | -| id | The ID of the project, which uniquely identifies it. | `string` | true | -| exclude_configs | Only return with the active configuration, no drafts. | `bool` | false | -| complete | The flag to determine if full metadata should be returned. | `bool` | false | +| id | The unique project ID. | `string` | true | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 7a3d974e9f..b6c2dc6890 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -3,34 +3,29 @@ provider "ibm" { } // Provision project_instance resource instance -resource "ibm_project_instance" "project_instance" { - name = "My static website" - description = "Sample static website test using the IBM catalog deployable architecture" +resource "ibm_project_instance" "project_instance_instance" { + resource_group = var.project_instance_resource_group + location = var.project_instance_location + name = var.project_instance_name + description = var.project_instance_description configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" - name = "static-website-dev" - labels = [ "env:dev", "billing:internal" ] - description = "Website - development" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" input { - name = "app_repo_name" + name = "name" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } - resource_group = "Default" - location = "us-south" } -// Data source is not linked to a resource instance -// Uncomment if an existing data source instance exists -/* // Create project_event_notification data source data "ibm_project_event_notification" "project_event_notification_instance" { - id = var.project_event_notification_id - exclude_configs = var.project_event_notification_exclude_configs - complete = var.project_event_notification_complete + id = ibm_project_instance.project_instance_instance.id } -*/ diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index e6ac2ae7e5..b2ee7f7263 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -4,6 +4,16 @@ variable "ibmcloud_api_key" { } // Resource arguments for project_instance +variable "project_instance_resource_group" { + description = "The resource group where the project's data and tools are created." + type = string + default = "Default" +} +variable "project_instance_location" { + description = "The location where the project's data and tools are created." + type = string + default = "us-south" +} variable "project_instance_name" { description = "The project name." type = string @@ -14,30 +24,10 @@ variable "project_instance_description" { type = string default = "A microservice to deploy on top of ACME infrastructure." } -variable "project_instance_resource_group" { - description = "Group name of the customized collection of resources." - type = string - default = "resource_group" -} -variable "project_instance_location" { - description = "Data center locations for resource deployment." - type = string - default = "location" -} // Data source arguments for project_event_notification variable "project_event_notification_id" { - description = "The ID of the project, which uniquely identifies it." + description = "The unique project ID." type = string default = "id" } -variable "project_event_notification_exclude_configs" { - description = "Only return with the active configuration, no drafts." - type = bool - default = false -} -variable "project_event_notification_complete" { - description = "The flag to determine if full metadata should be returned." - type = bool - default = false -} diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index 452ed8d034..b0c70bd356 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -7,5 +7,5 @@ This area is primarily for IBM provider contributors and maintainers. For inform * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project_instance) -* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) -* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) +* IBM API Docs: [IBM API Docs for ]() +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go index 07e9ce6000..b1273efaf7 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification.go +++ b/ibm/service/project/data_source_ibm_project_event_notification.go @@ -21,22 +21,10 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { ReadContext: dataSourceIbmProjectEventNotificationRead, Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The ID of the project, which uniquely identifies it.", - }, - "exclude_configs": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Only return with the active configuration, no drafts.", - }, - "complete": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "The flag to determine if full metadata should be returned.", + Description: "The unique project ID.", }, "name": &schema.Schema{ Type: schema.TypeString, @@ -62,7 +50,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", }, "name": &schema.Schema{ Type: schema.TypeString, @@ -85,7 +73,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "locator_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The location ID of a project configuration manual property.", + Description: "A dotted value of catalogID.versionID.", }, "type": &schema.Schema{ Type: schema.TypeString, @@ -108,6 +96,11 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { Computed: true, Description: "The variable type.", }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, "required": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -133,12 +126,9 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { Description: "A short explanation of the output value.", }, "value": &schema.Schema{ - Type: schema.TypeList, + Type: schema.TypeString, Computed: true, - Description: "The output value.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, @@ -146,7 +136,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "An optional setting object that's passed to the cart API.", + Description: "Schematics environment variables to use to deploy the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -157,7 +147,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The value of a the configuration setting.", + Description: "The value of the configuration setting.", }, }, }, @@ -179,7 +169,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, "cumulative_needs_attention_view": &schema.Schema{ Type: schema.TypeList, @@ -213,17 +203,17 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "True indicates that the fetch of the needs attention items failed.", + Description: "\\"True\\" indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The location where the project was created.", + Description: "The IBM Cloud location where a resource is deployed.", }, "resource_group": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The resource group where the project was created.", + Description: "The resource group where the project's data and tools are created.", }, "state": &schema.Schema{ Type: schema.TypeString, @@ -250,13 +240,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(d.Get("project_id").(string)) - if _, ok := d.GetOk("exclude_configs"); ok { - getProjectOptions.SetExcludeConfigs(d.Get("exclude_configs").(bool)) - } - if _, ok := d.GetOk("complete"); ok { - getProjectOptions.SetComplete(d.Get("complete").(bool)) - } + getProjectOptions.SetID(d.Get("id").(string)) project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { @@ -280,7 +264,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem configs := []map[string]interface{}{} if project.Configs != nil { - for _, modelItem := range project.Configs { + for _, modelItem := range project.Configs { modelMap, err := dataSourceIbmProjectEventNotificationProjectConfigToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -371,6 +355,9 @@ func dataSourceIbmProjectEventNotificationInputVariableToMap(model *projectv1.In if model.Type != nil { modelMap["type"] = model.Type } + if model.Value != nil { + modelMap["value"] = model.Value + } if model.Required != nil { modelMap["required"] = model.Required } diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 3abc12706f..a32f9513f0 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -14,6 +14,8 @@ import ( ) func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -21,9 +23,10 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName), + Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), ), }, @@ -32,23 +35,29 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { } func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), + Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "exclude_configs"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "complete"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.id"), + resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.name", projectName), + resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.description", projectDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.type"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), ), }, @@ -56,47 +65,46 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { }) } -func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectName string) string { +func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup string, projectLocation string, projectName string) string { return fmt.Sprintf(` resource "ibm_project_instance" "project_instance_instance" { + resource_group = "%s" + location = "%s" name = "%s" } - data "ibm_project_event_notification" "project_event_notification" { - project_id = ibm_project_instance.project_instance_instance.id - exclude_configs = false - complete = true + data "ibm_project_event_notification" "project_event_notification_instance" { + id = ibm_project_instance.project_instance_instance.project_id } - `, projectName) + `, projectResourceGroup, projectLocation, projectName) } -func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, projectDescription string, projectResourceGroup string, projectLocation string) string { +func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectResourceGroup string, projectLocation string, projectName string, projectDescription string) string { return fmt.Sprintf(` resource "ibm_project_instance" "project_instance_instance" { + resource_group = "%s" + location = "%s" name = "%s" description = "%s" configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" + id = "id" name = "name" labels = [ "labels" ] description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + locator_id = "locator_id" input { name = "name" + value = "anything as a string" } setting { name = "name" value = "value" } } - resource_group = "%s" - location = "%s" } - data "ibm_project_event_notification" "project_event_notification" { - project_id = ibm_project_instance.project_instance_instance.id - exclude_configs = false - complete = true + data "ibm_project_event_notification" "project_event_notification_instance" { + id = ibm_project_instance.project_instance_instance.project_id } - `, projectName, projectDescription, projectResourceGroup, projectLocation) + `, projectResourceGroup, projectLocation, projectName, projectDescription) } diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 4956aaaaa9..c2dc74b802 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -7,14 +7,11 @@ import ( "context" "fmt" "log" - "time" "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/schema" "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/go-sdk-core/v5/core" "github.com/IBM/project-go-sdk/projectv1" @@ -22,26 +19,35 @@ import ( func ResourceIbmProjectInstance() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectInstanceCreate, - ReadContext: resourceIbmProjectInstanceRead, - UpdateContext: resourceIbmProjectInstanceUpdate, - DeleteContext: resourceIbmProjectInstanceDelete, - Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, + CreateContext: resourceIbmProjectInstanceCreate, + ReadContext: resourceIbmProjectInstanceRead, + UpdateContext: resourceIbmProjectInstanceUpdate, + DeleteContext: resourceIbmProjectInstanceDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "resource_group"), + Description: "The resource group where the project's data and tools are created.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "location"), + Description: "The location where the project's data and tools are created.", + }, "name": &schema.Schema{ Type: schema.TypeString, Required: true, - ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "name"), Description: "The project name.", }, "description": &schema.Schema{ Type: schema.TypeString, Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_instance", "description"), Description: "A project's descriptive text.", }, "configs": &schema.Schema{ @@ -53,7 +59,7 @@ func ResourceIbmProjectInstance() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", }, "name": &schema.Schema{ Type: schema.TypeString, @@ -74,12 +80,12 @@ func ResourceIbmProjectInstance() *schema.Resource { "locator_id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The location ID of a project configuration manual property.", + Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The input values to use to deploy the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -87,13 +93,18 @@ func ResourceIbmProjectInstance() *schema.Resource { Required: true, Description: "The variable name.", }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "An optional setting object that's passed to the cart API.", + Description: "Schematics environment variables to use to deploy the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -104,7 +115,7 @@ func ResourceIbmProjectInstance() *schema.Resource { "value": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The value of a the configuration setting.", + Description: "The value of the configuration setting.", }, }, }, @@ -112,18 +123,6 @@ func ResourceIbmProjectInstance() *schema.Resource { }, }, }, - "resource_group": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "Default", - Description: "Group name of the customized collection of resources.", - }, - "location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "us-south", - Description: "Data center locations for resource deployment.", - }, "crn": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -137,38 +136,38 @@ func ResourceIbmProjectInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "crn": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, "created_at": &schema.Schema{ Type: schema.TypeString, - Computed: true, - Description: "A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339.", + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, "cumulative_needs_attention_view": &schema.Schema{ Type: schema.TypeList, - Computed: true, + Optional: true, Description: "The cumulative list of needs attention items for a project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "event": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "The event name.", }, "event_id": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "The unique ID of a project.", }, "config_id": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "The unique ID of a project.", }, "config_version": &schema.Schema{ Type: schema.TypeInt, - Computed: true, + Optional: true, Description: "The version number of the configuration.", }, }, @@ -176,27 +175,27 @@ func ResourceIbmProjectInstance() *schema.Resource { }, "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, - Computed: true, - Description: "True indicates that the fetch of the needs attention items failed.", + Optional: true, + Description: "\\"True\\" indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, - Computed: true, - Description: "The location where the project was created.", + Optional: true, + Description: "The IBM Cloud location where a resource is deployed.", }, "resource_group": &schema.Schema{ Type: schema.TypeString, - Computed: true, - Description: "The resource group where the project was created.", + Optional: true, + Description: "The resource group where the project's data and tools are created.", }, "state": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "The project status value.", }, "event_notifications_crn": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, }, @@ -210,36 +209,40 @@ func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { validateSchema := make([]validate.ValidateSchema, 0) validateSchema = append(validateSchema, validate.ValidateSchema{ - Identifier: "name", - Type: validate.TypeString, - Required: true, - Regexp: `^(?!\s).+\S$`, - MinValueLength: 1, - MaxValueLength: 64, + Identifier: "resource_group", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(?!\s)(?!.*\s$)[^'"`<>{}\x00-\x1F]*$`, + MinValueLength: 0, + MaxValueLength: 40, }, validate.ValidateSchema{ - Identifier: "description", - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, + Identifier: "location", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + MinValueLength: 0, + MaxValueLength: 12, }, validate.ValidateSchema{ - Identifier: "resource_group", - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 40, + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s)(?!.*\s$)[^'"`<>{}\x00-\x1F]+$`, + MinValueLength: 1, + MaxValueLength: 64, }, validate.ValidateSchema{ - Identifier: "location", - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, - MinValueLength: 0, - MaxValueLength: 12, + Identifier: "description", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, }, ) @@ -255,6 +258,8 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc createProjectOptions := &projectv1.CreateProjectOptions{} + createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + createProjectOptions.SetLocation(d.Get("location").(string)) createProjectOptions.SetName(d.Get("name").(string)) if _, ok := d.GetOk("description"); ok { createProjectOptions.SetDescription(d.Get("description").(string)) @@ -271,12 +276,6 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc } createProjectOptions.SetConfigs(configs) } - if _, ok := d.GetOk("resource_group"); ok { - createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - } - if _, ok := d.GetOk("location"); ok { - createProjectOptions.SetLocation(d.Get("location").(string)) - } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { @@ -286,46 +285,9 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc d.SetId(*project.ID) - _, err = waitForProjectInstanceCreate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) - } - return resourceIbmProjectInstanceRead(context, d, meta) } -func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -346,25 +308,46 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } + if err = d.Set("resource_group", getProjectOptions.ResourceGroup); err != nil { + return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + } + if err = d.Set("location", getProjectOptions.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + } + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if !core.IsNil(project.Description) { + if err = d.Set("description", project.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + } + if !core.IsNil(project.Configs) { + configs := []map[string]interface{}{} + for _, configsItem := range project.Configs { + configsItemMap, err := resourceIbmProjectInstanceProjectConfigPrototypeToMap(&configsItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, configsItemMap) + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs: %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)) } } - if !core.IsNil(project.Name) { - if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - } - metadataMap := make(map[string]interface{}) if !core.IsNil(project.Metadata) { - metadataMap, err = resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) + metadataMap, err := resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) if err != nil { return diag.FromErr(err) } - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } } return nil @@ -382,6 +365,30 @@ func resourceIbmProjectInstanceUpdate(context context.Context, d *schema.Resourc hasChange := false + if d.HasChange("resource_group") || d.HasChange("location") || d.HasChange("name") { + updateProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + updateProjectOptions.SetLocation(d.Get("location").(string)) + updateProjectOptions.SetName(d.Get("name").(string)) + hasChange = true + } + if d.HasChange("description") { + updateProjectOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } + if d.HasChange("configs") { + var configs []projectv1.ProjectConfigPrototype + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectInstanceMapToProjectConfigPrototype(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + updateProjectOptions.SetConfigs(configs) + hasChange = true + } + if hasChange { _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) if err != nil { @@ -409,48 +416,11 @@ func resourceIbmProjectInstanceDelete(context context.Context, d *schema.Resourc return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } - _, err = waitForProjectInstanceDelete(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) - } - d.SetId("") return nil } -func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { @@ -496,6 +466,9 @@ func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]i func resourceIbmProjectInstanceMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { model := &projectv1.ProjectConfigInputVariable{} model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["value"] != nil { + model.Value = modelMap["value"].(string) + } return model, nil } @@ -547,6 +520,9 @@ func resourceIbmProjectInstanceProjectConfigPrototypeToMap(model *projectv1.Proj func resourceIbmProjectInstanceProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value + } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index 33df503484..e158ec8bd2 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -11,15 +11,19 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM/project-go-sdk/projectv1" + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" ) func TestAccIbmProjectInstanceBasic(t *testing.T) { var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_update_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -27,15 +31,19 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { CheckDestroy: testAccCheckIbmProjectInstanceDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfigBasic(name), + Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroup, location, name), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfigBasic(nameUpdate), + Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroupUpdate, locationUpdate, nameUpdate), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), ), }, @@ -45,8 +53,14 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -54,62 +68,69 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { CheckDestroy: testAccCheckIbmProjectInstanceDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(name), + Config: testAccCheckIbmProjectInstanceConfig(resourceGroup, location, name, description), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", description), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(nameUpdate), + Config: testAccCheckIbmProjectInstanceConfig(resourceGroupUpdate, locationUpdate, nameUpdate, descriptionUpdate), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), ), }, resource.TestStep{ ResourceName: "ibm_project_instance.project_instance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "location", - "resource_group", - "configs", - }, }, }, }) } -func testAccCheckIbmProjectInstanceConfigBasic(name string) string { +func testAccCheckIbmProjectInstanceConfigBasic(resourceGroup string, location string, name string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance" { + resource "ibm_project_instance" "project_instance_instance" { + resource_group = "%s" + location = "%s" name = "%s" } - `, name) + `, resourceGroup, location, name) } -func testAccCheckIbmProjectInstanceConfig(name string) string { +func testAccCheckIbmProjectInstanceConfig(resourceGroup string, location string, name string, description string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance" { - name = "%s" - configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - } - setting { - name = "name" - value = "value" - } - } - } - `, name) + resource "ibm_project_instance" "project_instance_instance" { + resource_group = "%s" + location = "%s" + name = "%s" + description = "%s" + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } + } + `, resourceGroup, location, name, description) } func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index bc6b73a1d9..9a07fb8627 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_event_notification" description: |- Get information about Project definition -subcategory: "Project" +subcategory: "Projects API" --- # ibm_project_event_notification @@ -14,7 +14,7 @@ Provides a read-only data source for Project definition. You can then reference ```hcl data "ibm_project_event_notification" "project_event_notification" { - id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" + id = ibm_project_instance.project_instance_instance.project_id } ``` @@ -22,11 +22,7 @@ data "ibm_project_event_notification" "project_event_notification" { Review the argument reference that you can specify for your data source. -* `complete` - (Optional, Boolean) The flag to determine if full metadata should be returned. - * Constraints: The default value is `false`. -* `exclude_configs` - (Optional, Boolean) Only return with the active configuration, no drafts. - * Constraints: The default value is `false`. -* `id` - (Required, Forces new resource, String) The ID of the project, which uniquely identifies it. +* `id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. ## Attribute Reference @@ -38,39 +34,39 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **configs**: * `description` - (String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s).*\\S$/`. - * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **input**: * `name` - (String) The variable name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `required` - (Boolean) Whether the variable is required or not. * `type` - (String) The variable type. * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) The location ID of a project configuration manual property. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **output**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. - * `value` - (List) The output value. - * Constraints: The list items must match regular expression `/^(?!\\s).+\\S$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `setting` - (List) An optional setting object that's passed to the cart API. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **setting**: * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. - * `value` - (String) The value of a the configuration setting. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. @@ -78,10 +74,11 @@ Nested scheme for **configs**: * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `description` - (String) A project descriptive text. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `metadata` - (List) The metadata of the project. Nested scheme for **metadata**: - * `created_at` - (String) A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. @@ -91,15 +88,20 @@ Nested scheme for **metadata**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * `location` - (String) The location where the project was created. - * `resource_group` - (String) The resource group where the project was created. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `location` - (String) The IBM Cloud location where a resource is deployed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `resource_group` - (String) The resource group where the project's data and tools are created. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. * `name` - (String) The project name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index c53f47f14d..29cae9c6ab 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_instance" description: |- Manages Project definition. -subcategory: "Project" +subcategory: "Projects API" --- # ibm_project_instance @@ -13,23 +13,26 @@ Provides a resource for Project definition. This allows Project definition to be ## Example Usage ```hcl -resource "ibm_project" "project_instance" { +resource "ibm_project_instance" "project_instance_instance" { configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" - name = "static-website-dev" - labels = [ "env:dev", "billing:internal" ] - description = "Website - development" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "locator_id" input { - name = "app_repo_name" + name = "name" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } - description = "Sample static website test using the IBM catalog deployable architecture" - name = "My static website" + description = "A microservice to deploy on top of ACME infrastructure." + location = "us-south" + name = "acme-microservice" + resource_group = "Default" } ``` @@ -41,35 +44,36 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **configs**: * `description` - (Optional, String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s).*\\S$/`. - * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. + * `input` - (Optional, List) The input values to use to deploy the configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **input**: * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (Required, String) The location ID of a project configuration manual property. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^.+$/`. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. - * `setting` - (Optional, List) An optional setting object that's passed to the cart API. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **setting**: * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. - * `value` - (Required, String) The value of a the configuration setting. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `description` - (Optional, String) A project's descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `location` - (Optional, String) Data center locations for resource deployment. - * Constraints: The default value is `us-south`. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. +* `location` - (Required, String) The location where the project's data and tools are created. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `name` - (Required, String) The project name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s).+\\S$/`. -* `resource_group` - (Optional, String) Group name of the customized collection of resources. - * Constraints: The default value is `Default`. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. +* `resource_group` - (Required, String) The resource group where the project's data and tools are created. + * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. ## Attribute Reference @@ -80,7 +84,7 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `metadata` - (List) The metadata of the project. Nested scheme for **metadata**: - * `created_at` - (String) A date/time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date-time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. @@ -90,15 +94,70 @@ Nested scheme for **metadata**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * `location` - (String) The location where the project was created. - * `resource_group` - (String) The resource group where the project was created. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `location` - (String) The IBM Cloud location where a resource is deployed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `resource_group` - (String) The resource group where the project's data and tools are created. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. +## Provider Configuration + +The IBM Cloud provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: + +- Static credentials +- Environment variables + +To find which credentials are required for this resource, see the service table [here](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-provider-reference#required-parameters). + +### Static credentials + +You can provide your static credentials by adding the `ibmcloud_api_key`, `iaas_classic_username`, and `iaas_classic_api_key` arguments in the IBM Cloud provider block. + +Usage: +``` +provider "ibm" { + ibmcloud_api_key = "" + iaas_classic_username = "" + iaas_classic_api_key = "" +} +``` + +### Environment variables + +You can provide your credentials by exporting the `IC_API_KEY`, `IAAS_CLASSIC_USERNAME`, and `IAAS_CLASSIC_API_KEY` environment variables, representing your IBM Cloud platform API key, IBM Cloud Classic Infrastructure (SoftLayer) user name, and IBM Cloud infrastructure API key, respectively. + +``` +provider "ibm" {} +``` + +Usage: +``` +export IC_API_KEY="ibmcloud_api_key" +export IAAS_CLASSIC_USERNAME="iaas_classic_username" +export IAAS_CLASSIC_API_KEY="iaas_classic_api_key" +terraform plan +``` + +Note: + +1. Create or find your `ibmcloud_api_key` and `iaas_classic_api_key` [here](https://cloud.ibm.com/iam/apikeys). + - Select `My IBM Cloud API Keys` option from view dropdown for `ibmcloud_api_key` + - Select `Classic Infrastructure API Keys` option from view dropdown for `iaas_classic_api_key` +2. For iaas_classic_username + - Go to [Users](https://cloud.ibm.com/iam/users) + - Click on user. + - Find user name in the `VPN password` section under `User Details` tab + +For more informaton, see [here](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs#authentication). + ## Import You can import the `ibm_project_instance` resource by using `id`. The unique ID of a project. From 73b78141ef7fa2cffa39bfd239d1b70bdf4b051f Mon Sep 17 00:00:00 2001 From: dvesperini Date: Sun, 7 May 2023 23:34:35 +0200 Subject: [PATCH 025/125] new version --- go.mod | 4 ++-- go.sum | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index e640bebe89..801a51064d 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/IBM/continuous-delivery-go-sdk v1.1.0 github.com/IBM/event-notifications-go-admin-sdk v0.2.1 github.com/IBM/eventstreams-go-sdk v1.2.0 - github.com/IBM/go-sdk-core/v5 v5.13.0 + github.com/IBM/go-sdk-core/v5 v5.13.1 github.com/IBM/ibm-cos-sdk-go v1.10.0 github.com/IBM/ibm-cos-sdk-go-config v1.2.0 github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 @@ -58,12 +58,12 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 + github.com/IBM/project-go-sdk v0.0.10 github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect diff --git a/go.sum b/go.sum index b27582ecd5..12a1e6ba95 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= -github.com/IBM/go-sdk-core/v5 v5.13.0 h1:foXLa2LfTSr3kgldpizaSDXH3gS/HB3YKj1BK8ywrE4= -github.com/IBM/go-sdk-core/v5 v5.13.0/go.mod h1:pVkN7IGmsSdmR1ZCU4E/cLcCclqRKMYgg7ya+O2Mk6g= +github.com/IBM/go-sdk-core/v5 v5.13.1 h1:zD6p3t1whAlRJo/VBmE69c8RcH9LCHL1n0/sO1MWlpw= +github.com/IBM/go-sdk-core/v5 v5.13.1/go.mod h1:pVkN7IGmsSdmR1ZCU4E/cLcCclqRKMYgg7ya+O2Mk6g= github.com/IBM/ibm-cos-sdk-go v1.3.1/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY= github.com/IBM/ibm-cos-sdk-go v1.10.0 h1:/2VIev2/jBei39OqU2+nSZQnoWJ+KtkiSAIDkqsd7uU= github.com/IBM/ibm-cos-sdk-go v1.10.0/go.mod h1:C8KRTRaoD3CWPPBOa6FCOpdh0ZMlUjKAAA4i3F+Q/sc= @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.34.0 h1:ozGdyWdBByNS8sw07FP4qx2r1qUc59D0BoN3rMTgtIk= github.com/IBM/platform-services-go-sdk v0.34.0/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03 h1:mpz4CSzFeqfWSx+rP55n1afeZeACDcZGvtud2fY1KKA= -github.com/IBM/project-go-sdk v0.0.0-20230405195937-52b52b875b03/go.mod h1:yO1Pqm7Y9hWrn6eUlfPKwipqFAbvp9QeuLRb07H3/Ks= +github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8= +github.com/IBM/project-go-sdk v0.0.10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= @@ -101,8 +101,6 @@ github.com/IBM/scc-go-sdk/v4 v4.0.2 h1:8BHMRobCFurZwKaUhxWi8CdAA9+CvyzmlBOmo7KmX github.com/IBM/scc-go-sdk/v4 v4.0.2/go.mod h1:ufqf/kBtRn3Pq/pFXF6zQGHXV2P2EzPsntw1Sw19clE= github.com/IBM/schematics-go-sdk v0.2.1 h1:byATysGD+Z1k/wdtNqQmKALcAPjgSLuSyzcabh1jRAw= github.com/IBM/schematics-go-sdk v0.2.1/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ= -github.com/IBM/secrets-manager-go-sdk v1.2.0 h1:bgFfBF+LjHLtUfV3hTLkfgE8EjFsJaeU2icA2Hg+M50= -github.com/IBM/secrets-manager-go-sdk v1.2.0/go.mod h1:qv+tQg8Z3Vb11DQYxDjEGeROHDtTLQxUWuOIrIdWg6E= github.com/IBM/secrets-manager-go-sdk/v2 v2.0.0 h1:Lx4Bvim/MfoHEYR+n312bty5DirAJypBGGS9YZo3zCw= github.com/IBM/secrets-manager-go-sdk/v2 v2.0.0/go.mod h1:jagqWmjZ0zUEqh5jdGB42ApSQS40fu2LWw6pdg8JJko= github.com/IBM/vpc-beta-go-sdk v0.1.0 h1:+kdF+Y/0KY189HhpkqDrue9o0LluAr7rlOU5Zhu7hck= @@ -794,8 +792,6 @@ go.mongodb.org/mongo-driver v1.7.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8N go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.mongodb.org/mongo-driver v1.11.2 h1:+1v2rDQUWNcGW7/7E0Jvdz51V38XXxJfhzbV17aNHCw= -go.mongodb.org/mongo-driver v1.11.2/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y= go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= From c0469bdd7aeec337eaa75064927a861e2ec6d904 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Mon, 8 May 2023 09:04:23 +0200 Subject: [PATCH 026/125] new version --- ...a_source_ibm_project_event_notification.go | 4 +- .../project/resource_ibm_project_instance.go | 40 +++++++++---------- .../resource_ibm_project_instance_test.go | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go index b1273efaf7..bd664d5142 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification.go +++ b/ibm/service/project/data_source_ibm_project_event_notification.go @@ -203,7 +203,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "\\"True\\" indicates that the fetch of the needs attention items failed.", + Description: "True indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, @@ -264,7 +264,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem configs := []map[string]interface{}{} if project.Configs != nil { - for _, modelItem := range project.Configs { + for _, modelItem := range project.Configs { modelMap, err := dataSourceIbmProjectEventNotificationProjectConfigToMap(&modelItem) if err != nil { return diag.FromErr(err) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index c2dc74b802..7d8b90b6a5 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -19,36 +19,36 @@ import ( func ResourceIbmProjectInstance() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectInstanceCreate, - ReadContext: resourceIbmProjectInstanceRead, - UpdateContext: resourceIbmProjectInstanceUpdate, - DeleteContext: resourceIbmProjectInstanceDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectInstanceCreate, + ReadContext: resourceIbmProjectInstanceRead, + UpdateContext: resourceIbmProjectInstanceUpdate, + DeleteContext: resourceIbmProjectInstanceDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project_instance", "resource_group"), - Description: "The resource group where the project's data and tools are created.", + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project_instance", "location"), - Description: "The location where the project's data and tools are created.", + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project_instance", "name"), - Description: "The project name.", + Description: "The project name.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, ValidateFunc: validate.InvokeValidator("ibm_project_instance", "description"), - Description: "A project's descriptive text.", + Description: "A project's descriptive text.", }, "configs": &schema.Schema{ Type: schema.TypeList, @@ -176,7 +176,7 @@ func ResourceIbmProjectInstance() *schema.Resource { "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "\\"True\\" indicates that the fetch of the needs attention items failed.", + Description: "True indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, @@ -213,7 +213,7 @@ func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^$|^(?!\s)(?!.*\s$)[^'"`<>{}\x00-\x1F]*$`, + Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, MinValueLength: 0, MaxValueLength: 40, }, @@ -231,7 +231,7 @@ func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^(?!\s)(?!.*\s$)[^'"`<>{}\x00-\x1F]+$`, + Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, MinValueLength: 1, MaxValueLength: 64, }, diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index e158ec8bd2..9f49ed58a5 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM/project-go-sdk/projectv1" - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" ) func TestAccIbmProjectInstanceBasic(t *testing.T) { From 075da8dffddd28bd4448e40365488d1497495731 Mon Sep 17 00:00:00 2001 From: dvesperini Date: Mon, 8 May 2023 09:10:46 +0200 Subject: [PATCH 027/125] new version --- .../project/resource_ibm_project_instance.go | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 7d8b90b6a5..1a7430d683 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -308,12 +308,6 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("resource_group", getProjectOptions.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) - } - if err = d.Set("location", getProjectOptions.Location); err != nil { - return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) - } if err = d.Set("name", project.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } @@ -324,13 +318,6 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD } if !core.IsNil(project.Configs) { configs := []map[string]interface{}{} - for _, configsItem := range project.Configs { - configsItemMap, err := resourceIbmProjectInstanceProjectConfigPrototypeToMap(&configsItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, configsItemMap) - } if err = d.Set("configs", configs); err != nil { return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } @@ -365,9 +352,7 @@ func resourceIbmProjectInstanceUpdate(context context.Context, d *schema.Resourc hasChange := false - if d.HasChange("resource_group") || d.HasChange("location") || d.HasChange("name") { - updateProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - updateProjectOptions.SetLocation(d.Get("location").(string)) + if d.HasChange("name") { updateProjectOptions.SetName(d.Get("name").(string)) hasChange = true } @@ -385,7 +370,6 @@ func resourceIbmProjectInstanceUpdate(context context.Context, d *schema.Resourc } configs = append(configs, *configsItem) } - updateProjectOptions.SetConfigs(configs) hasChange = true } @@ -581,8 +565,5 @@ func resourceIbmProjectInstanceCumulativeNeedsAttentionToMap(model *projectv1.Cu if model.ConfigID != nil { modelMap["config_id"] = model.ConfigID } - if model.ConfigVersion != nil { - modelMap["config_version"] = flex.IntValue(model.ConfigVersion) - } return modelMap, nil } From edc3c18c958cd21b04b7eea556f31e8fe8f381d6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 8 May 2023 17:56:33 +0200 Subject: [PATCH 028/125] update code to the latest SDK level --- cloud-docs/project-data-sources.md | 89 --------- cloud-docs/project-resources.md | 85 -------- examples/ibm-project/README.md | 10 +- examples/ibm-project/main.tf | 33 ++-- examples/ibm-project/variables.tf | 20 +- ibm/service/project/README.md | 4 +- ...rce_ibm_project_event_notification_test.go | 31 ++- .../project/resource_ibm_project_instance.go | 187 ++++++++++++------ .../resource_ibm_project_instance_test.go | 70 +++---- .../project_event_notification.html.markdown | 4 +- website/docs/r/project_instance.html.markdown | 75 ++----- 11 files changed, 230 insertions(+), 378 deletions(-) delete mode 100644 cloud-docs/project-data-sources.md delete mode 100644 cloud-docs/project-resources.md diff --git a/cloud-docs/project-data-sources.md b/cloud-docs/project-data-sources.md deleted file mode 100644 index 2b54f9ae2d..0000000000 --- a/cloud-docs/project-data-sources.md +++ /dev/null @@ -1,89 +0,0 @@ ---- - -copyright: - years: 2023 -lastupdated: "2023" - -keywords: terraform - -subcollection: terraform - ---- - -# Projects API data sources -{: #project-data-sources} - -Review the data sources that you can use to retrieve information about your Projects API resources. -All data sources are imported as read-only information. You can reference the output parameters for each data source by using Terraform interpolation syntax. - -Before you start working with your data source, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) -that you need to specify in the `provider` block of your Terraform configuration file. -{: important} - -## `ibm_project_event_notification` -{: #project_event_notification} - -Retrieve information about Project definition. -{: shortdesc} - -### Sample Terraform code -{: #project_event_notification-sample} - -``` -data "ibm_project_event_notification" "project_event_notification" { - id = "id" -} -``` - -### Input parameters -{: #project_event_notification-input} - -Review the input parameters that you can specify for your data source. {: shortdesc} - -|Name|Data type|Required/optional|Description| -|----|-----------|-------|----------| -|`id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| - -### Output parameters -{: #project_event_notification-output} - -Review the output parameters that you can access after you retrieved your data source. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`configs`|List|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| -|`configs.labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`configs.locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| -|`configs.type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| -|`configs.input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| -|`configs.input.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`configs.input.required`|Boolean|Whether the variable is required or not.| -|`configs.output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`configs.output.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`configs.setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`description`|String|A project descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`metadata`|List|The metadata of the project. This list contains only one item.| -|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| -|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| -|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.cumulative_needs_attention_view.event_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| -|`metadata.cumulative_needs_attention_view_err`|String|\"True\" indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| -|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`name`|String|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.| - diff --git a/cloud-docs/project-resources.md b/cloud-docs/project-resources.md deleted file mode 100644 index 186cbcd488..0000000000 --- a/cloud-docs/project-resources.md +++ /dev/null @@ -1,85 +0,0 @@ ---- - -copyright: - years: 2023 -lastupdated: "2023" - -keywords: terraform - -subcollection: terraform - ---- - -# Projects API resources -{: #project-resources} - -Create, update, or delete Projects API resources. -You can reference the output parameters for each resource in other resources or data sources by using Terraform interpolation syntax. - -Before you start working with your resource, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) -that you need to specify in the `provider` block of your Terraform configuration file. -{: important} - -## `ibm_project_instance` -{: #project_instance} - -Create, update, or delete an Project definition. -{: shortdesc} - -### Sample Terraform code -{: #project_instance-sample} - -``` -resource "ibm_project_instance" "project_instance" { - description = "A microservice to deploy on top of ACME infrastructure." - location = "us-south" - name = "acme-microservice" - resource_group = "Default" -} -``` - -### Input parameters -{: #project_instance-input} - -Review the input parameters that you can specify for your resource. {: shortdesc} - -|Name|Data type|Required/optional|Description|Forces new resource| -|----|-----------|-------|----------|--------------------| -|`configs`|List|Optional|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.|No| -|`description`|String|Optional|A project's descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|No| -|`location`|String|Required|The location where the project's data and tools are created. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.|No| -|`name`|String|Required|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.|No| -|`resource_group`|String|Required|The resource group where the project's data and tools are created. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.|No| - -### Output parameters -{: #project_instance-output} - -Review the output parameters that you can access after your resource is created. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`id`|String|The unique identifier of the Project definition.| -|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata`|List|The metadata of the project. This list contains only one item.| -|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| -|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| -|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.cumulative_needs_attention_view.event_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| -|`metadata.cumulative_needs_attention_view_err`|String|\"True\" indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| -|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| - -### Import -{: #project_instance-import} - -`ibm_project_instance` can be imported by ID - -``` -$ terraform import ibm_project_instance.example sample-id -``` - diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 167f62ae8a..57f37ed709 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -25,11 +25,11 @@ project_instance resource: ```hcl resource "project_instance" "project_instance_instance" { - resource_group = var.project_instance_resource_group - location = var.project_instance_location name = var.project_instance_name description = var.project_instance_description configs = var.project_instance_configs + resource_group = var.project_instance_resource_group + location = var.project_instance_location } ``` @@ -39,7 +39,7 @@ project_event_notification data source: ```hcl data "project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.id + id = var.project_event_notification_id } ``` @@ -68,11 +68,11 @@ data "project_event_notification" "project_event_notification_instance" { | Name | Description | Type | Required | |------|-------------|------|---------| | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | -| resource_group | The resource group where the project's data and tools are created. | `string` | true | -| location | The location where the project's data and tools are created. | `string` | true | | name | The project name. | `string` | true | | description | A project's descriptive text. | `string` | false | | configs | The project configurations. | `list()` | false | +| resource_group | The resource group where the project's data and tools are created. | `string` | true | +| location | The location where the project's data and tools are created. | `string` | true | | id | The unique project ID. | `string` | true | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index b6c2dc6890..b626bd089a 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -3,29 +3,32 @@ provider "ibm" { } // Provision project_instance resource instance -resource "ibm_project_instance" "project_instance_instance" { - resource_group = var.project_instance_resource_group - location = var.project_instance_location - name = var.project_instance_name - description = var.project_instance_description +resource "ibm_project_instance" "project_instance" { + name = "My static website" + description = "Sample static website test using the IBM catalog deployable architecture" configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "locator_id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } + resource_group = "Default" + location = "us-south" } +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* // Create project_event_notification data source data "ibm_project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.id + id = var.project_event_notification_id } +*/ diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index b2ee7f7263..240c070647 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -4,16 +4,6 @@ variable "ibmcloud_api_key" { } // Resource arguments for project_instance -variable "project_instance_resource_group" { - description = "The resource group where the project's data and tools are created." - type = string - default = "Default" -} -variable "project_instance_location" { - description = "The location where the project's data and tools are created." - type = string - default = "us-south" -} variable "project_instance_name" { description = "The project name." type = string @@ -24,6 +14,16 @@ variable "project_instance_description" { type = string default = "A microservice to deploy on top of ACME infrastructure." } +variable "project_instance_resource_group" { + description = "Group name of the customized collection of resources." + type = string + default = "resource_group" +} +variable "project_instance_location" { + description = "Data center locations for resource deployment." + type = string + default = "location" +} // Data source arguments for project_event_notification variable "project_event_notification_id" { diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index b0c70bd356..452ed8d034 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -7,5 +7,5 @@ This area is primarily for IBM provider contributors and maintainers. For inform * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project_instance) -* IBM API Docs: [IBM API Docs for ]() -* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) +* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) +* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index a32f9513f0..ec04a6d57c 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -14,9 +14,9 @@ import ( ) func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") + projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -25,7 +25,6 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), ), @@ -35,19 +34,18 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { } func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") + projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription), + Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), @@ -73,38 +71,37 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourc name = "%s" } - data "ibm_project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.project_id + data "ibm_project_event_notification" "project_event_notification" { + id = ibm_project_instance.project_instance_instance.id } `, projectResourceGroup, projectLocation, projectName) } -func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectResourceGroup string, projectLocation string, projectName string, projectDescription string) string { +func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, projectDescription string, projectResourceGroup string, projectLocation string) string { return fmt.Sprintf(` resource "ibm_project_instance" "project_instance_instance" { - resource_group = "%s" - location = "%s" name = "%s" description = "%s" configs { - id = "id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" name = "name" labels = [ "labels" ] description = "description" - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" - value = "anything as a string" } setting { name = "name" value = "value" } } + resource_group = "%s" + location = "%s" } - data "ibm_project_event_notification" "project_event_notification_instance" { - id = ibm_project_instance.project_instance_instance.project_id + data "ibm_project_event_notification" "project_event_notification" { + id = ibm_project_instance.project_instance_instance.id } `, projectResourceGroup, projectLocation, projectName, projectDescription) } diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index 1a7430d683..b38819c871 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -24,31 +26,22 @@ func ResourceIbmProjectInstance() *schema.Resource { UpdateContext: resourceIbmProjectInstanceUpdate, DeleteContext: resourceIbmProjectInstanceDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ - "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "resource_group"), - Description: "The resource group where the project's data and tools are created.", - }, - "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "location"), - Description: "The location where the project's data and tools are created.", - }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "name"), - Description: "The project name.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The project name.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_instance", "description"), - Description: "A project's descriptive text.", + Type: schema.TypeString, + Optional: true, + Description: "A project's descriptive text.", }, "configs": &schema.Schema{ Type: schema.TypeList, @@ -123,6 +116,16 @@ func ResourceIbmProjectInstance() *schema.Resource { }, }, }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The resource group where the project's data and tools are created.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The location where the project's data and tools are created.", + }, "crn": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -209,40 +212,36 @@ func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { validateSchema := make([]validate.ValidateSchema, 0) validateSchema = append(validateSchema, validate.ValidateSchema{ - Identifier: "resource_group", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, - MinValueLength: 0, - MaxValueLength: 40, + Identifier: "name", + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, + MinValueLength: 1, + MaxValueLength: 64, }, validate.ValidateSchema{ - Identifier: "location", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, - MinValueLength: 0, - MaxValueLength: 12, + Identifier: "description", + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, }, validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, - MinValueLength: 1, - MaxValueLength: 64, + Identifier: "resource_group", + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, + MinValueLength: 0, + MaxValueLength: 40, }, validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, + Identifier: "location", + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + MinValueLength: 0, + MaxValueLength: 12, }, ) @@ -258,8 +257,6 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc createProjectOptions := &projectv1.CreateProjectOptions{} - createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - createProjectOptions.SetLocation(d.Get("location").(string)) createProjectOptions.SetName(d.Get("name").(string)) if _, ok := d.GetOk("description"); ok { createProjectOptions.SetDescription(d.Get("description").(string)) @@ -276,6 +273,12 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc } createProjectOptions.SetConfigs(configs) } + if _, ok := d.GetOk("resource_group"); ok { + createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + } + if _, ok := d.GetOk("location"); ok { + createProjectOptions.SetLocation(d.Get("location").(string)) + } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { @@ -285,9 +288,46 @@ func resourceIbmProjectInstanceCreate(context context.Context, d *schema.Resourc d.SetId(*project.ID) + _, err = waitForProjectInstanceCreate(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectInstanceRead(context, d, meta) } +func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + return resp, "exists", nil + } else { + return resp, "not_exists", nil + } + } else { + return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -308,6 +348,11 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } + if !core.IsNil(project.Crn) { + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } + } if err = d.Set("name", project.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } @@ -322,11 +367,6 @@ func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting configs: %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)) - } - } if !core.IsNil(project.Metadata) { metadataMap, err := resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) if err != nil { @@ -400,11 +440,48 @@ func resourceIbmProjectInstanceDelete(context context.Context, d *schema.Resourc return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectInstanceDelete(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return resp, "not_exists", nil + } else { + return resp, "exists", nil + } + } else { + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index 9f49ed58a5..ba691ff7f1 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -18,12 +18,10 @@ import ( func TestAccIbmProjectInstanceBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_update_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -40,10 +38,10 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroupUpdate, locationUpdate, nameUpdate), + Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroup, location, nameUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), ), }, @@ -53,14 +51,12 @@ func TestAccIbmProjectInstanceBasic(t *testing.T) { func TestAccIbmProjectInstanceAllArgs(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -78,10 +74,10 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(resourceGroupUpdate, locationUpdate, nameUpdate, descriptionUpdate), + Config: testAccCheckIbmProjectInstanceConfig(resourceGroup, location, nameUpdate, descriptionUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), ), @@ -90,6 +86,11 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { ResourceName: "ibm_project_instance.project_instance", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "location", + "resource_group", + "configs", + }, }, }, }) @@ -98,7 +99,7 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { func testAccCheckIbmProjectInstanceConfigBasic(resourceGroup string, location string, name string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance" { resource_group = "%s" location = "%s" name = "%s" @@ -109,26 +110,25 @@ func testAccCheckIbmProjectInstanceConfigBasic(resourceGroup string, location st func testAccCheckIbmProjectInstanceConfig(resourceGroup string, location string, name string, description string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { - resource_group = "%s" - location = "%s" + resource "ibm_project_instance" "project_instance" { name = "%s" description = "%s" - configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } + resource_group = "%s" + location = "%s" + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + input { + name = "name" + } + setting { + name = "name" + value = "value" + } + } } `, resourceGroup, location, name, description) } diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index 9a07fb8627..e546b6e542 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_event_notification" description: |- Get information about Project definition -subcategory: "Projects API" +subcategory: "Project" --- # ibm_project_event_notification @@ -14,7 +14,7 @@ Provides a read-only data source for Project definition. You can then reference ```hcl data "ibm_project_event_notification" "project_event_notification" { - id = ibm_project_instance.project_instance_instance.project_id + id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" } ``` diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index 29cae9c6ab..f3fdacd7f2 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_instance" description: |- Manages Project definition. -subcategory: "Projects API" +subcategory: "Project" --- # ibm_project_instance @@ -13,25 +13,24 @@ Provides a resource for Project definition. This allows Project definition to be ## Example Usage ```hcl -resource "ibm_project_instance" "project_instance_instance" { +resource "ibm_project" "project_instance" { configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "locator_id" + id = "0013790d-6cb5-4adc-8927-a725a1261d0c" + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } - description = "A microservice to deploy on top of ACME infrastructure." + description = "Sample static website test using the IBM catalog deployable architecture" + name = "My static website" location = "us-south" - name = "acme-microservice" resource_group = "Default" } ``` @@ -108,56 +107,6 @@ Nested scheme for **metadata**: * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. -## Provider Configuration - -The IBM Cloud provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below: - -- Static credentials -- Environment variables - -To find which credentials are required for this resource, see the service table [here](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-provider-reference#required-parameters). - -### Static credentials - -You can provide your static credentials by adding the `ibmcloud_api_key`, `iaas_classic_username`, and `iaas_classic_api_key` arguments in the IBM Cloud provider block. - -Usage: -``` -provider "ibm" { - ibmcloud_api_key = "" - iaas_classic_username = "" - iaas_classic_api_key = "" -} -``` - -### Environment variables - -You can provide your credentials by exporting the `IC_API_KEY`, `IAAS_CLASSIC_USERNAME`, and `IAAS_CLASSIC_API_KEY` environment variables, representing your IBM Cloud platform API key, IBM Cloud Classic Infrastructure (SoftLayer) user name, and IBM Cloud infrastructure API key, respectively. - -``` -provider "ibm" {} -``` - -Usage: -``` -export IC_API_KEY="ibmcloud_api_key" -export IAAS_CLASSIC_USERNAME="iaas_classic_username" -export IAAS_CLASSIC_API_KEY="iaas_classic_api_key" -terraform plan -``` - -Note: - -1. Create or find your `ibmcloud_api_key` and `iaas_classic_api_key` [here](https://cloud.ibm.com/iam/apikeys). - - Select `My IBM Cloud API Keys` option from view dropdown for `ibmcloud_api_key` - - Select `Classic Infrastructure API Keys` option from view dropdown for `iaas_classic_api_key` -2. For iaas_classic_username - - Go to [Users](https://cloud.ibm.com/iam/users) - - Click on user. - - Find user name in the `VPN password` section under `User Details` tab - -For more informaton, see [here](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs#authentication). - ## Import You can import the `ibm_project_instance` resource by using `id`. The unique ID of a project. From 66eab891a5a1f5066efae78a007ccde80861c3b3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 8 May 2023 20:59:41 +0200 Subject: [PATCH 029/125] fix integration tests --- .../data_source_ibm_project_event_notification_test.go | 10 +--------- .../project/resource_ibm_project_instance_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index ec04a6d57c..fbc9e00eba 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -49,14 +49,6 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.id"), - resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.name", projectName), - resource.TestCheckResourceAttr("data.ibm_project_event_notification.project_event_notification", "configs.0.description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "configs.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), ), }, }, @@ -103,5 +95,5 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, data "ibm_project_event_notification" "project_event_notification" { id = ibm_project_instance.project_instance_instance.id } - `, projectResourceGroup, projectLocation, projectName, projectDescription) + `, projectName, projectDescription, projectResourceGroup, projectLocation) } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index ba691ff7f1..ce5be90ee9 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -64,7 +64,7 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { CheckDestroy: testAccCheckIbmProjectInstanceDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(resourceGroup, location, name, description), + Config: testAccCheckIbmProjectInstanceConfig(name, description, resourceGroup, location), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), @@ -74,7 +74,7 @@ func TestAccIbmProjectInstanceAllArgs(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(resourceGroup, location, nameUpdate, descriptionUpdate), + Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroup, location), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), @@ -107,7 +107,7 @@ func testAccCheckIbmProjectInstanceConfigBasic(resourceGroup string, location st `, resourceGroup, location, name) } -func testAccCheckIbmProjectInstanceConfig(resourceGroup string, location string, name string, description string) string { +func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { return fmt.Sprintf(` resource "ibm_project_instance" "project_instance" { @@ -130,7 +130,7 @@ func testAccCheckIbmProjectInstanceConfig(resourceGroup string, location string, } } } - `, resourceGroup, location, name, description) + `, name, description, resourceGroup, location) } func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { From 074cc3edf73a5d48843e48f6198da7d6c7ebd8fa Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 8 May 2023 21:03:01 +0200 Subject: [PATCH 030/125] fix integration tests --- .../project/data_source_ibm_project_event_notification_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index fbc9e00eba..33d0e3f59d 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -49,6 +49,7 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), ), }, }, From 1f153d4ff8467ec7d9211fcd2959d262008df8ce Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 9 May 2023 08:21:01 +0200 Subject: [PATCH 031/125] fix integration tests --- .../project/resource_ibm_project_instance.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go index b38819c871..2d4c5af5a4 100644 --- a/ibm/service/project/resource_ibm_project_instance.go +++ b/ibm/service/project/resource_ibm_project_instance.go @@ -139,38 +139,38 @@ func ResourceIbmProjectInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "crn": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, "created_at": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, "cumulative_needs_attention_view": &schema.Schema{ Type: schema.TypeList, - Optional: true, + Computed: true, Description: "The cumulative list of needs attention items for a project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "event": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The event name.", }, "event_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The unique ID of a project.", }, "config_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The unique ID of a project.", }, "config_version": &schema.Schema{ Type: schema.TypeInt, - Optional: true, + Computed: true, Description: "The version number of the configuration.", }, }, @@ -178,27 +178,27 @@ func ResourceIbmProjectInstance() *schema.Resource { }, "cumulative_needs_attention_view_err": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "True indicates that the fetch of the needs attention items failed.", }, "location": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The IBM Cloud location where a resource is deployed.", }, "resource_group": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The resource group where the project's data and tools are created.", }, "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The project status value.", }, "event_notifications_crn": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, }, From a81ee33e47cc97682997e83a53ed404a8262e2e6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 9 May 2023 10:29:01 +0200 Subject: [PATCH 032/125] fix integration tests --- examples/ibm-project/README.md | 2 +- examples/ibm-project/main.tf | 1 - examples/ibm-project/outputs.tf | 2 +- .../data_source_ibm_project_event_notification_test.go | 9 ++++----- .../project/resource_ibm_project_instance_test.go | 1 - 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 57f37ed709..2302823c54 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -24,7 +24,7 @@ Run `terraform destroy` when you don't need these resources. project_instance resource: ```hcl -resource "project_instance" "project_instance_instance" { +resource "project_instance" "project_instance" { name = var.project_instance_name description = var.project_instance_description configs = var.project_instance_configs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index b626bd089a..ea9aa93eb3 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -7,7 +7,6 @@ resource "ibm_project_instance" "project_instance" { name = "My static website" description = "Sample static website test using the IBM catalog deployable architecture" configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" name = "static-website-dev" labels = [ "env:dev", "billing:internal" ] description = "Website - development" diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 45d917b875..8a59bbf786 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -1,6 +1,6 @@ // This allows project_instance data to be referenced by other resources and the terraform CLI // Modify this if only certain data should be exposed output "ibm_project_instance" { - value = ibm_project_instance.project_instance_instance + value = ibm_project_instance.project_instance description = "project_instance resource instance" } diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index 33d0e3f59d..c67303ad30 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -58,25 +58,24 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup string, projectLocation string, projectName string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance" { resource_group = "%s" location = "%s" name = "%s" } data "ibm_project_event_notification" "project_event_notification" { - id = ibm_project_instance.project_instance_instance.id + id = ibm_project_instance.project_instance.id } `, projectResourceGroup, projectLocation, projectName) } func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, projectDescription string, projectResourceGroup string, projectLocation string) string { return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance_instance" { + resource "ibm_project_instance" "project_instance" { name = "%s" description = "%s" configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" name = "name" labels = [ "labels" ] description = "description" @@ -94,7 +93,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, } data "ibm_project_event_notification" "project_event_notification" { - id = ibm_project_instance.project_instance_instance.id + id = ibm_project_instance.project_instance.id } `, projectName, projectDescription, projectResourceGroup, projectLocation) } diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go index ce5be90ee9..088784f11b 100644 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ b/ibm/service/project/resource_ibm_project_instance_test.go @@ -116,7 +116,6 @@ func testAccCheckIbmProjectInstanceConfig(name string, description string, resou resource_group = "%s" location = "%s" configs { - id = "id" name = "name" labels = [ "labels" ] description = "description" From e5b7d87cc532a8a7e1adcb101200120f823650dd Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 10 May 2023 12:21:05 +0200 Subject: [PATCH 033/125] address PR comment --- examples/ibm-project/README.md | 2 +- examples/ibm-project/main.tf | 2 +- .../project/data_source_ibm_project_event_notification.go | 6 +++--- .../data_source_ibm_project_event_notification_test.go | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 2302823c54..010899110e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -73,7 +73,7 @@ data "project_event_notification" "project_event_notification_instance" { | configs | The project configurations. | `list()` | false | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| id | The unique project ID. | `string` | true | +| project_id | The unique project ID. | `string` | true | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index ea9aa93eb3..d3348263c7 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -28,6 +28,6 @@ resource "ibm_project_instance" "project_instance" { /* // Create project_event_notification data source data "ibm_project_event_notification" "project_event_notification_instance" { - id = var.project_event_notification_id + project_id = var.project_event_notification_id } */ diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go index bd664d5142..7ffac8fd48 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification.go +++ b/ibm/service/project/data_source_ibm_project_event_notification.go @@ -21,7 +21,7 @@ func DataSourceIbmProjectEventNotification() *schema.Resource { ReadContext: dataSourceIbmProjectEventNotificationRead, Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "project_id": &schema.Schema{ Type: schema.TypeString, Required: true, Description: "The unique project ID.", @@ -240,7 +240,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(d.Get("id").(string)) + getProjectOptions.SetID(d.Get("project_id").(string)) project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { @@ -294,7 +294,7 @@ func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schem func dataSourceIbmProjectEventNotificationProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { - modelMap["id"] = model.ID + modelMap["project_id"] = model.ID } if model.Name != nil { modelMap["name"] = model.Name diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go index c67303ad30..a4bb083448 100644 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ b/ibm/service/project/data_source_ibm_project_event_notification_test.go @@ -25,7 +25,7 @@ func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), ), }, @@ -46,7 +46,7 @@ func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), @@ -65,7 +65,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourc } data "ibm_project_event_notification" "project_event_notification" { - id = ibm_project_instance.project_instance.id + project_id = ibm_project_instance.project_instance.id } `, projectResourceGroup, projectLocation, projectName) } @@ -93,7 +93,7 @@ func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, } data "ibm_project_event_notification" "project_event_notification" { - id = ibm_project_instance.project_instance.id + project_id = ibm_project_instance.project_instance.id } `, projectName, projectDescription, projectResourceGroup, projectLocation) } From 974d5a51af1c184c2c97bad874c5986f132cac1c Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 15 May 2023 09:37:19 +0200 Subject: [PATCH 034/125] typo --- examples/ibm-project/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 010899110e..e68dff870a 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -39,7 +39,7 @@ project_event_notification data source: ```hcl data "project_event_notification" "project_event_notification_instance" { - id = var.project_event_notification_id + project_id = var.project_event_notification_id } ``` From 0581a06cd9408d25271cdba7dd031a04cbd971c6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 15 May 2023 09:41:50 +0200 Subject: [PATCH 035/125] typo --- examples/ibm-project/variables.tf | 2 +- website/docs/d/project_event_notification.html.markdown | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 240c070647..77f31eace5 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -29,5 +29,5 @@ variable "project_instance_location" { variable "project_event_notification_id" { description = "The unique project ID." type = string - default = "id" + default = "project_id" } diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index e546b6e542..689ce78b89 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source for Project definition. You can then reference ```hcl data "ibm_project_event_notification" "project_event_notification" { - id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" + project_id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" } ``` @@ -22,7 +22,7 @@ data "ibm_project_event_notification" "project_event_notification" { Review the argument reference that you can specify for your data source. -* `id` - (Required, Forces new resource, String) The unique project ID. +* `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. ## Attribute Reference From cb87ca61f3b90462ba4355533b36a0e22ef0dc11 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 19 May 2023 21:29:26 +0200 Subject: [PATCH 036/125] terraform --- cloud-docs/project-data-sources.md | 102 +++ cloud-docs/project-resources.md | 146 ++++ examples/ibm-project/README.md | 55 +- examples/ibm-project/main.tf | 81 +- examples/ibm-project/outputs.tf | 14 +- examples/ibm-project/variables.tf | 53 +- examples/ibm-project/versions.tf | 10 +- go.mod | 2 +- go.sum | 4 +- ...a_source_ibm_project_event_notification.go | 444 ---------- ...rce_ibm_project_event_notification_test.go | 99 --- ibm/service/project/resource_ibm_project.go | 761 ++++++++++++++++++ .../project/resource_ibm_project_config.go | 703 ++++++++++++++++ .../resource_ibm_project_config_test.go | 213 +++++ .../project/resource_ibm_project_instance.go | 646 --------------- .../resource_ibm_project_instance_test.go | 187 ----- .../project/resource_ibm_project_test.go | 182 +++++ website/docs/d/project.html.markdown | 134 +++ ...ce.html.markdown => project.html.markdown} | 95 ++- website/docs/r/project_config.html.markdown | 132 +++ 20 files changed, 2600 insertions(+), 1463 deletions(-) create mode 100644 cloud-docs/project-data-sources.md create mode 100644 cloud-docs/project-resources.md delete mode 100644 ibm/service/project/data_source_ibm_project_event_notification.go delete mode 100644 ibm/service/project/data_source_ibm_project_event_notification_test.go create mode 100644 ibm/service/project/resource_ibm_project.go create mode 100644 ibm/service/project/resource_ibm_project_config.go create mode 100644 ibm/service/project/resource_ibm_project_config_test.go delete mode 100644 ibm/service/project/resource_ibm_project_instance.go delete mode 100644 ibm/service/project/resource_ibm_project_instance_test.go create mode 100644 ibm/service/project/resource_ibm_project_test.go create mode 100644 website/docs/d/project.html.markdown rename website/docs/r/{project_instance.html.markdown => project.html.markdown} (60%) create mode 100644 website/docs/r/project_config.html.markdown diff --git a/cloud-docs/project-data-sources.md b/cloud-docs/project-data-sources.md new file mode 100644 index 0000000000..396e5083b7 --- /dev/null +++ b/cloud-docs/project-data-sources.md @@ -0,0 +1,102 @@ +--- + +copyright: + years: 2023 +lastupdated: "2023" + +keywords: terraform + +subcollection: terraform + +--- + +# Projects API data sources +{: #project-data-sources} + +Review the data sources that you can use to retrieve information about your Projects API resources. +All data sources are imported as read-only information. You can reference the output parameters for each data source by using Terraform interpolation syntax. + +Before you start working with your data source, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) +that you need to specify in the `provider` block of your Terraform configuration file. +{: important} + +## `ibm_project` +{: #project} + +Retrieve information about Project definition. +{: shortdesc} + +### Sample Terraform code +{: #project-sample} + +``` +data "ibm_project" "project" { + id = "id" +} +``` + +### Input parameters +{: #project-input} + +Review the input parameters that you can specify for your data source. {: shortdesc} + +|Name|Data type|Required/optional|Description| +|----|-----------|-------|----------| +|`id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| + +### Output parameters +{: #project-output} + +Review the output parameters that you can access after you retrieved your data source. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`configs`|List|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| +|`configs.labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`configs.authorizations`|List|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. This list contains only one item.| +|`configs.authorizations.trusted_profile`|List|The trusted profile for authorizations. This list contains only one item.| +|`configs.authorizations.trusted_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.authorizations.trusted_profile.target_iam_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.authorizations.method`|String|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`configs.authorizations.api_key`|String|The IBM Cloud API Key. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| +|`configs.compliance_profile`|List|The profile required for compliance. This list contains only one item.| +|`configs.compliance_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.compliance_profile.instance_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.compliance_profile.instance_location`|String|The location of the compliance instance. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.| +|`configs.compliance_profile.attachment_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`configs.compliance_profile.profile_name`|String|The name of the compliance profile. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| +|`configs.locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| +|`configs.type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| +|`configs.input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| +|`configs.input.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`configs.input.required`|Boolean|Whether the variable is required or not.| +|`configs.output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`configs.output.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`configs.setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| +|`configs.setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`configs.setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`description`|String|A project descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`destroy_on_delete`|Boolean|The policy that indicates whether the resources are destroyed or not when a project is deleted. The default value is `true`.| +|`metadata`|List|The metadata of the project. This list contains only one item.| +|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| +|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| +|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.cumulative_needs_attention_view.event_id`|String|A unique ID for that individual event. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_id`|String|A unique ID for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| +|`metadata.cumulative_needs_attention_view_err`|String|True indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| +|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`name`|String|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.| + diff --git a/cloud-docs/project-resources.md b/cloud-docs/project-resources.md new file mode 100644 index 0000000000..cb6b5b54d8 --- /dev/null +++ b/cloud-docs/project-resources.md @@ -0,0 +1,146 @@ +--- + +copyright: + years: 2023 +lastupdated: "2023" + +keywords: terraform + +subcollection: terraform + +--- + +# Projects API resources +{: #project-resources} + +Create, update, or delete Projects API resources. +You can reference the output parameters for each resource in other resources or data sources by using Terraform interpolation syntax. + +Before you start working with your resource, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) +that you need to specify in the `provider` block of your Terraform configuration file. +{: important} + +## `ibm_project` +{: #project} + +Create, update, or delete an project. +{: shortdesc} + +### Sample Terraform code +{: #project-sample} + +``` +resource "ibm_project" "project" { + description = "A microservice to deploy on top of ACME infrastructure." + location = "us-south" + name = "acme-microservice" + resource_group = "Default" +} +``` + +### Input parameters +{: #project-input} + +Review the input parameters that you can specify for your resource. {: shortdesc} + +|Name|Data type|Required/optional|Description|Forces new resource| +|----|-----------|-------|----------|--------------------| +|`configs`|List|Optional|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.|Yes| +|`description`|String|Optional|A project's descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|Yes| +|`destroy_on_delete`|Boolean|Optional|The policy that indicates whether the resources are destroyed or not when a project is deleted. The default value is `true`.|Yes| +|`location`|String|Required|The location where the project's data and tools are created. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.|Yes| +|`name`|String|Required|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.|Yes| +|`resource_group`|String|Required|The resource group where the project's data and tools are created. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.|Yes| + +### Output parameters +{: #project-output} + +Review the output parameters that you can access after your resource is created. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`id`|String|The unique identifier of the project.| +|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata`|List|The metadata of the project. This list contains only one item.| +|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| +|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| +|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| +|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.cumulative_needs_attention_view.event_id`|String|A unique ID for that individual event. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_id`|String|A unique ID for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| +|`metadata.cumulative_needs_attention_view_err`|String|True indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| +|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| + +### Import +{: #project-import} + +`ibm_project` can be imported by ID + +``` +$ terraform import ibm_project.example sample-id +``` + +## `ibm_project_config` +{: #project_config} + +Create, update, or delete an project_config. +{: shortdesc} + +### Sample Terraform code +{: #project_config-sample} + +``` +resource "ibm_project_config" "project_config" { + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + labels = ["env:stage","governance:test","build:0"] + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + name = "env-stage" + project_id = ibm_project.project_instance.id +} +``` + +### Input parameters +{: #project_config-input} + +Review the input parameters that you can specify for your resource. {: shortdesc} + +|Name|Data type|Required/optional|Description|Forces new resource| +|----|-----------|-------|----------|--------------------| +|`authorizations`|List|Optional|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. You can specify one item in this list only.|No| +|`compliance_profile`|List|Optional|The profile required for compliance. You can specify one item in this list only.|No| +|`description`|String|Optional|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|No| +|`input`|List|Optional|The input values to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.|No| +|`labels`|List|Optional|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.|No| +|`locator_id`|String|Required|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.|No| +|`name`|String|Required|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.|No| +|`project_id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.|Yes| +|`setting`|List|Optional|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.|No| + +### Output parameters +{: #project_config-output} + +Review the output parameters that you can access after your resource is created. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`id`|String|The unique identifier of the project_config.| +|`output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`output.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`project_config_id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| + +### Import +{: #project_config-import} + +`ibm_project_config` can be imported by ID + +``` +$ terraform import ibm_project_config.example sample-id +``` + diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index e68dff870a..23241e6a37 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -4,7 +4,8 @@ This example illustrates how to use the ProjectV1 These types of resources are supported: -* Project definition +* project +* project_config ## Usage @@ -21,28 +22,37 @@ Run `terraform destroy` when you don't need these resources. ## ProjectV1 resources -project_instance resource: +project resource: ```hcl -resource "project_instance" "project_instance" { - name = var.project_instance_name - description = var.project_instance_description - configs = var.project_instance_configs - resource_group = var.project_instance_resource_group - location = var.project_instance_location +resource "project" "project_instance" { + resource_group = var.project_resource_group + location = var.project_location + name = var.project_name + description = var.project_description + destroy_on_delete = var.project_destroy_on_delete + configs = var.project_configs } ``` - -## ProjectV1 Data sources - -project_event_notification data source: +project_config resource: ```hcl -data "project_event_notification" "project_event_notification_instance" { - project_id = var.project_event_notification_id +resource "project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = var.project_config_name + locator_id = var.project_config_locator_id + labels = var.project_config_labels + description = var.project_config_description + authorizations = var.project_config_authorizations + compliance_profile = var.project_config_compliance_profile + input = var.project_config_input + setting = var.project_config_setting } ``` +## ProjectV1 Data sources + + ## Assumptions 1. TODO @@ -68,16 +78,25 @@ data "project_event_notification" "project_event_notification_instance" { | Name | Description | Type | Required | |------|-------------|------|---------| | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| resource_group | The resource group where the project's data and tools are created. | `string` | true | +| location | The location where the project's data and tools are created. | `string` | true | | name | The project name. | `string` | true | | description | A project's descriptive text. | `string` | false | +| destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | | configs | The project configurations. | `list()` | false | -| resource_group | The resource group where the project's data and tools are created. | `string` | true | -| location | The location where the project's data and tools are created. | `string` | true | | project_id | The unique project ID. | `string` | true | +| name | The configuration name. | `string` | true | +| locator_id | A dotted value of catalogID.versionID. | `string` | true | +| labels | A collection of configuration labels. | `list(string)` | false | +| description | The project configuration description. | `string` | false | +| authorizations | The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | +| compliance_profile | The profile required for compliance. | `` | false | +| input | The input values to use to deploy the configuration. | `list()` | false | +| setting | Schematics environment variables to use to deploy the configuration. | `list()` | false | ## Outputs | Name | Description | |------|-------------| -| project_instance | project_instance object | -| project_event_notification | project_event_notification object | +| project | project object | +| project_config | project_config object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index d3348263c7..bbd9c8ba34 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -2,32 +2,73 @@ provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key } -// Provision project_instance resource instance -resource "ibm_project_instance" "project_instance" { - name = "My static website" - description = "Sample static website test using the IBM catalog deployable architecture" +// Provision project resource instance +resource "ibm_project" "project_instance" { + resource_group = var.project_resource_group + location = var.project_location + name = var.project_name + description = var.project_description + destroy_on_delete = var.project_destroy_on_delete configs { - name = "static-website-dev" - labels = [ "env:dev", "billing:internal" ] - description = "Website - development" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" input { - name = "app_repo_name" + name = "name" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } - resource_group = "Default" - location = "us-south" } -// Data source is not linked to a resource instance -// Uncomment if an existing data source instance exists -/* -// Create project_event_notification data source -data "ibm_project_event_notification" "project_event_notification_instance" { - project_id = var.project_event_notification_id +// Provision project_config resource instance +resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = var.project_config_name + locator_id = var.project_config_locator_id + labels = var.project_config_labels + description = var.project_config_description + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } } -*/ diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 8a59bbf786..4a20a363b6 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -1,6 +1,12 @@ -// This allows project_instance data to be referenced by other resources and the terraform CLI +// This allows project data to be referenced by other resources and the terraform CLI // Modify this if only certain data should be exposed -output "ibm_project_instance" { - value = ibm_project_instance.project_instance - description = "project_instance resource instance" +output "ibm_project" { + value = ibm_project.project_instance + description = "project resource instance" +} +// This allows project_config data to be referenced by other resources and the terraform CLI +// Modify this if only certain data should be exposed +output "ibm_project_config" { + value = ibm_project_config.project_config_instance + description = "project_config resource instance" } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 77f31eace5..1bce0fca37 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -3,31 +3,56 @@ variable "ibmcloud_api_key" { type = string } -// Resource arguments for project_instance -variable "project_instance_name" { +// Resource arguments for project +variable "project_resource_group" { + description = "The resource group where the project's data and tools are created." + type = string + default = "Default" +} +variable "project_location" { + description = "The location where the project's data and tools are created." + type = string + default = "us-south" +} +variable "project_name" { description = "The project name." type = string default = "acme-microservice" } -variable "project_instance_description" { +variable "project_description" { description = "A project's descriptive text." type = string default = "A microservice to deploy on top of ACME infrastructure." } -variable "project_instance_resource_group" { - description = "Group name of the customized collection of resources." - type = string - default = "resource_group" -} -variable "project_instance_location" { - description = "Data center locations for resource deployment." - type = string - default = "location" +variable "project_destroy_on_delete" { + description = "The policy that indicates whether the resources are destroyed or not when a project is deleted." + type = bool + default = true } -// Data source arguments for project_event_notification -variable "project_event_notification_id" { +// Resource arguments for project_config +variable "project_config_project_id" { description = "The unique project ID." type = string default = "project_id" } +variable "project_config_name" { + description = "The configuration name." + type = string + default = "env-stage" +} +variable "project_config_locator_id" { + description = "A dotted value of catalogID.versionID." + type = string + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" +} +variable "project_config_labels" { + description = "A collection of configuration labels." + type = list(string) + default = ["env:stage","governance:test","build:0"] +} +variable "project_config_description" { + description = "The project configuration description." + type = string + default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." +} diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index ee0f9705a2..54c9d03e8d 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,3 +1,9 @@ terraform { - required_version = ">= 0.12" -} \ No newline at end of file + required_version = ">= 1.0" + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + version = "1.52.0-beta0" + } + } +} diff --git a/go.mod b/go.mod index bad7d5d750..77448932a0 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.10 + github.com/IBM/project-go-sdk v0.0.11 github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index f35d6d935b..5fd21772da 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8= -github.com/IBM/project-go-sdk v0.0.10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.11 h1:0R7Z4njvDUwmrZcvKe/om55/N0fqa9VNRNdV2IMDFLE= +github.com/IBM/project-go-sdk v0.0.11/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project_event_notification.go b/ibm/service/project/data_source_ibm_project_event_notification.go deleted file mode 100644 index 7ffac8fd48..0000000000 --- a/ibm/service/project/data_source_ibm_project_event_notification.go +++ /dev/null @@ -1,444 +0,0 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package project - -import ( - "context" - "fmt" - "log" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "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/project-go-sdk/projectv1" -) - -func DataSourceIbmProjectEventNotification() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIbmProjectEventNotificationRead, - - Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique project ID.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A project descriptive text.", - }, - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "configs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The project configurations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The configuration name.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project configuration description.", - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable type.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the variable is required or not.", - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - }, - }, - }, - "metadata": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The metadata of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cumulative_needs_attention_view": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cumulative list of needs attention items for a project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "event": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The event name.", - }, - "event_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - }, - }, - }, - "cumulative_needs_attention_view_err": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "True indicates that the fetch of the needs attention items failed.", - }, - "location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud location where a resource is deployed.", - }, - "resource_group": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The resource group where the project's data and tools are created.", - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project status value.", - }, - "event_notifications_crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The CRN of the event notifications instance if one is connected to this project.", - }, - }, - }, - }, - }, - } -} - -func dataSourceIbmProjectEventNotificationRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - getProjectOptions := &projectv1.GetProjectOptions{} - - getProjectOptions.SetID(d.Get("project_id").(string)) - - project, response, err := projectClient.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)) - } - - d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) - - if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - - if err = d.Set("description", project.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - - if err = d.Set("crn", project.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) - } - - configs := []map[string]interface{}{} - if project.Configs != nil { - for _, modelItem := range project.Configs { - modelMap, err := dataSourceIbmProjectEventNotificationProjectConfigToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, modelMap) - } - } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) - } - - metadata := []map[string]interface{}{} - if project.Metadata != nil { - modelMap, err := dataSourceIbmProjectEventNotificationProjectMetadataToMap(project.Metadata) - if err != nil { - return diag.FromErr(err) - } - metadata = append(metadata, modelMap) - } - if err = d.Set("metadata", metadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) - } - - return nil -} - -func dataSourceIbmProjectEventNotificationProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["project_id"] = model.ID - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectEventNotificationInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectEventNotificationOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectEventNotificationProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - return modelMap, nil -} - -func dataSourceIbmProjectEventNotificationInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Required != nil { - modelMap["required"] = model.Required - } - return modelMap, nil -} - -func dataSourceIbmProjectEventNotificationOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func dataSourceIbmProjectEventNotificationProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func dataSourceIbmProjectEventNotificationProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Crn != nil { - modelMap["crn"] = model.Crn - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.CumulativeNeedsAttentionView != nil { - cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { - cumulativeNeedsAttentionViewItemMap, err := dataSourceIbmProjectEventNotificationCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) - if err != nil { - return modelMap, err - } - cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) - } - modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView - } - if model.CumulativeNeedsAttentionViewErr != nil { - modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr - } - if model.Location != nil { - modelMap["location"] = model.Location - } - if model.ResourceGroup != nil { - modelMap["resource_group"] = model.ResourceGroup - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.EventNotificationsCrn != nil { - modelMap["event_notifications_crn"] = model.EventNotificationsCrn - } - return modelMap, nil -} - -func dataSourceIbmProjectEventNotificationCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Event != nil { - modelMap["event"] = model.Event - } - if model.EventID != nil { - modelMap["event_id"] = model.EventID - } - if model.ConfigID != nil { - modelMap["config_id"] = model.ConfigID - } - if model.ConfigVersion != nil { - modelMap["config_version"] = flex.IntValue(model.ConfigVersion) - } - return modelMap, nil -} diff --git a/ibm/service/project/data_source_ibm_project_event_notification_test.go b/ibm/service/project/data_source_ibm_project_event_notification_test.go deleted file mode 100644 index a4bb083448..0000000000 --- a/ibm/service/project/data_source_ibm_project_event_notification_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package project_test - -import ( - "fmt" - "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" -) - -func TestAccIbmProjectEventNotificationDataSourceBasic(t *testing.T) { - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), - ), - }, - }, - }) -} - -func TestAccIbmProjectEventNotificationDataSourceAllArgs(t *testing.T) { - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName, projectDescription, projectResourceGroup, projectLocation), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_event_notification.project_event_notification", "metadata.#"), - ), - }, - }, - }) -} - -func testAccCheckIbmProjectEventNotificationDataSourceConfigBasic(projectResourceGroup string, projectLocation string, projectName string) string { - return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance" { - resource_group = "%s" - location = "%s" - name = "%s" - } - - data "ibm_project_event_notification" "project_event_notification" { - project_id = ibm_project_instance.project_instance.id - } - `, projectResourceGroup, projectLocation, projectName) -} - -func testAccCheckIbmProjectEventNotificationDataSourceConfig(projectName string, projectDescription string, projectResourceGroup string, projectLocation string) string { - return fmt.Sprintf(` - resource "ibm_project_instance" "project_instance" { - name = "%s" - description = "%s" - configs { - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - } - setting { - name = "name" - value = "value" - } - } - resource_group = "%s" - location = "%s" - } - - data "ibm_project_event_notification" "project_event_notification" { - project_id = ibm_project_instance.project_instance.id - } - `, projectName, projectDescription, projectResourceGroup, projectLocation) -} diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go new file mode 100644 index 0000000000..176f704bad --- /dev/null +++ b/ibm/service/project/resource_ibm_project.go @@ -0,0 +1,761 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "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/validate" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/project-go-sdk/projectv1" +) + +func ResourceIbmProject() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmProjectCreate, + ReadContext: resourceIbmProjectRead, + DeleteContext: resourceIbmProjectDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Description: "The resource group where the project's data and tools are created.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "location"), + Description: "The location where the project's data and tools are created.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Description: "The project name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Description: "A project's descriptive text.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The input values to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The metadata of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "cumulative_needs_attention_view": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The cumulative list of needs attention items for a project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The event name.", + }, + "event_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A unique ID for that individual event.", + }, + "config_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A unique ID for the configuration.", + }, + "config_version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version number of the configuration.", + }, + }, + }, + }, + "cumulative_needs_attention_view_err": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "True indicates that the fetch of the needs attention items failed.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud location where a resource is deployed.", + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The resource group where the project's data and tools are created.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, + }, + }, + }, + }, + } +} + +func ResourceIbmProjectValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "resource_group", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, + MinValueLength: 0, + MaxValueLength: 40, + }, + validate.ValidateSchema{ + Identifier: "location", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + MinValueLength: 0, + MaxValueLength: 12, + }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, + MinValueLength: 1, + MaxValueLength: 64, + }, + validate.ValidateSchema{ + Identifier: "description", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + createProjectOptions := &projectv1.CreateProjectOptions{} + + createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + createProjectOptions.SetLocation(d.Get("location").(string)) + createProjectOptions.SetName(d.Get("name").(string)) + if _, ok := d.GetOk("description"); ok { + createProjectOptions.SetDescription(d.Get("description").(string)) + } + if _, ok := d.GetOk("destroy_on_delete"); ok { + createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) + } + if _, ok := d.GetOk("configs"); ok { + var configs []projectv1.ProjectConfigPrototype + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + createProjectOptions.SetConfigs(configs) + } + + project, response, err := projectClient.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)) + } + + d.SetId(*project.ID) + + return resourceIbmProjectRead(context, d, meta) +} + +func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(d.Id()) + + project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + 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)) + } + + if err = d.Set("resource_group", getProjectOptions.ResourceGroup); err != nil { + return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + } + if err = d.Set("location", getProjectOptions.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + } + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if !core.IsNil(project.Description) { + if err = d.Set("description", project.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + } + if !core.IsNil(project.DestroyOnDelete) { + if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) + } + } + if !core.IsNil(project.Configs) { + configs := []map[string]interface{}{} + for _, configsItem := range project.Configs { + configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, configsItemMap) + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs: %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)) + } + } + if !core.IsNil(project.Metadata) { + metadataMap, err := resourceIbmProjectProjectMetadataToMap(project.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } + } + + return nil +} + +func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + deleteProjectOptions := &projectv1.DeleteProjectOptions{} + + deleteProjectOptions.SetID(d.Id()) + + response, err := projectClient.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)) + } + + d.SetId("") + + return nil +} + +func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { + model := &projectv1.ProjectConfigPrototype{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["labels"] != nil { + labels := []string{} + for _, labelsItem := range modelMap["labels"].([]interface{}) { + labels = append(labels, labelsItem.(string)) + } + model.Labels = labels + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["input"] != nil { + input := []projectv1.ProjectConfigInputVariable{} + for _, inputItem := range modelMap["input"].([]interface{}) { + inputItemModel, err := resourceIbmProjectMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) + if err != nil { + return model, err + } + input = append(input, *inputItemModel) + } + model.Input = input + } + if modelMap["setting"] != nil { + setting := []projectv1.ProjectConfigSettingCollection{} + for _, settingItem := range modelMap["setting"].([]interface{}) { + settingItemModel, err := resourceIbmProjectMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) + if err != nil { + return model, err + } + setting = append(setting, *settingItemModel) + } + model.Setting = setting + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { + model := &projectv1.ProjectConfigAuth{} + if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { + TrustedProfileModel, err := resourceIbmProjectMapToProjectConfigAuthTrustedProfile(modelMap["trusted_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.TrustedProfile = TrustedProfileModel + } + if modelMap["method"] != nil && modelMap["method"].(string) != "" { + model.Method = core.StringPtr(modelMap["method"].(string)) + } + if modelMap["api_key"] != nil && modelMap["api_key"].(string) != "" { + model.ApiKey = core.StringPtr(modelMap["api_key"].(string)) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigAuthTrustedProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuthTrustedProfile, error) { + model := &projectv1.ProjectConfigAuthTrustedProfile{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + if modelMap["target_iam_id"] != nil && modelMap["target_iam_id"].(string) != "" { + model.TargetIamID = core.StringPtr(modelMap["target_iam_id"].(string)) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigComplianceProfile, error) { + model := &projectv1.ProjectConfigComplianceProfile{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + if modelMap["instance_id"] != nil && modelMap["instance_id"].(string) != "" { + model.InstanceID = core.StringPtr(modelMap["instance_id"].(string)) + } + if modelMap["instance_location"] != nil && modelMap["instance_location"].(string) != "" { + model.InstanceLocation = core.StringPtr(modelMap["instance_location"].(string)) + } + if modelMap["attachment_id"] != nil && modelMap["attachment_id"].(string) != "" { + model.AttachmentID = core.StringPtr(modelMap["attachment_id"].(string)) + } + if modelMap["profile_name"] != nil && modelMap["profile_name"].(string) != "" { + model.ProfileName = core.StringPtr(modelMap["profile_name"].(string)) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { + model := &projectv1.ProjectConfigInputVariable{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["value"] != nil { + model.Value = modelMap["value"].(string) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { + model := &projectv1.ProjectConfigSettingCollection{} + model.Name = core.StringPtr(modelMap["name"].(string)) + model.Value = core.StringPtr(modelMap["value"].(string)) + return model, nil +} + +func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func resourceIbmProjectProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.CumulativeNeedsAttentionView != nil { + cumulativeNeedsAttentionView := []map[string]interface{}{} + for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { + cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) + if err != nil { + return modelMap, err + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) + } + modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView + } + if model.CumulativeNeedsAttentionViewErr != nil { + modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr + } + if model.Location != nil { + modelMap["location"] = model.Location + } + if model.ResourceGroup != nil { + modelMap["resource_group"] = model.ResourceGroup + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.EventNotificationsCrn != nil { + modelMap["event_notifications_crn"] = model.EventNotificationsCrn + } + return modelMap, nil +} + +func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Event != nil { + modelMap["event"] = model.Event + } + if model.EventID != nil { + modelMap["event_id"] = model.EventID + } + if model.ConfigID != nil { + modelMap["config_id"] = model.ConfigID + } + if model.ConfigVersion != nil { + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go new file mode 100644 index 0000000000..5a4b54df60 --- /dev/null +++ b/ibm/service/project/resource_ibm_project_config.go @@ -0,0 +1,703 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "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-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/project-go-sdk/projectv1" +) + +func ResourceIbmProjectConfig() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmProjectConfigCreate, + ReadContext: resourceIbmProjectConfigRead, + UpdateContext: resourceIbmProjectConfigUpdate, + DeleteContext: resourceIbmProjectConfigDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "project_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), + Description: "The unique project ID.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), + Description: "The configuration name.", + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Description: "A dotted value of catalogID.versionID.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The input values to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "project_config_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + }, + } +} + +func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "project_id", + ValidateFunctionIdentifier: validate.ValidateRegexp, + Type: validate.TypeString, + Required: true, + Regexp: `^[\.\-0-9a-zA-Z]+$`, + MaxValueLength: 128, + }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$`, + MinValueLength: 1, + MaxValueLength: 64, + }, + validate.ValidateSchema{ + Identifier: "locator_id", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, + MinValueLength: 1, + MaxValueLength: 512, + }, + validate.ValidateSchema{ + Identifier: "description", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^$|^(?!\s).*\S$`, + MinValueLength: 0, + MaxValueLength: 1024, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project_config", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + createConfigOptions := &projectv1.CreateConfigOptions{} + + createConfigOptions.SetProjectID(d.Get("project_id").(string)) + createConfigOptions.SetName(d.Get("name").(string)) + createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + if _, ok := d.GetOk("labels"); ok { + var labels []string + for _, v := range d.Get("labels").([]interface{}) { + labelsItem := v.(string) + labels = append(labels, labelsItem) + } + createConfigOptions.SetLabels(labels) + } + if _, ok := d.GetOk("description"); ok { + createConfigOptions.SetDescription(d.Get("description").(string)) + } + if _, ok := d.GetOk("authorizations"); ok { + authorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createConfigOptions.SetAuthorizations(authorizationsModel) + } + if _, ok := d.GetOk("compliance_profile"); ok { + complianceProfileModel, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createConfigOptions.SetComplianceProfile(complianceProfileModel) + } + if _, ok := d.GetOk("input"); ok { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) + } + createConfigOptions.SetInput(input) + } + if _, ok := d.GetOk("setting"); ok { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) + } + createConfigOptions.SetSetting(setting) + } + + projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) + if err != nil { + log.Printf("[DEBUG] CreateConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateConfigWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) + + return resourceIbmProjectConfigRead(context, d, meta) +} + +func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getConfigOptions := &projectv1.GetConfigOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + + projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) + } + + if err = d.Set("project_id", getConfigOptions.ProjectID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) + } + if err = d.Set("name", projectConfig.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } + if !core.IsNil(projectConfig.Labels) { + if err = d.Set("labels", projectConfig.Labels); err != nil { + return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) + } + } + if !core.IsNil(projectConfig.Description) { + if err = d.Set("description", projectConfig.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + } + if !core.IsNil(projectConfig.Authorizations) { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("authorizations", []map[string]interface{}{authorizationsMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting authorizations: %s", err)) + } + } + if !core.IsNil(projectConfig.ComplianceProfile) { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("compliance_profile", []map[string]interface{}{complianceProfileMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) + } + } + if !core.IsNil(projectConfig.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfig.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, inputItemMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + } + } + if !core.IsNil(projectConfig.Setting) { + setting := []map[string]interface{}{} + for _, settingItem := range projectConfig.Setting { + settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, settingItemMap) + } + if err = d.Set("setting", setting); err != nil { + return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) + } + } + if err = d.Set("type", projectConfig.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + } + if !core.IsNil(projectConfig.Output) { + output := []map[string]interface{}{} + for _, outputItem := range projectConfig.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return diag.FromErr(err) + } + output = append(output, outputItemMap) + } + if err = d.Set("output", output); err != nil { + return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) + } + } + if !core.IsNil(projectConfig.ID) { + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + } + } + + return nil +} + +func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + updateConfigOptions := &projectv1.UpdateConfigOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + updateConfigOptions.SetProjectID(parts[0]) + updateConfigOptions.SetID(parts[1]) + + hasChange := false + + 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") || d.HasChange("locator_id") { + updateConfigOptions.SetName(d.Get("name").(string)) + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + hasChange = true + } + if d.HasChange("labels") { + var labels []string + for _, v := range d.Get("labels").([]interface{}) { + labelsItem := v.(string) + labels = append(labels, labelsItem) + } + updateConfigOptions.SetLabels(labels) + hasChange = true + } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } + if d.HasChange("authorizations") { + authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetAuthorizations(authorizations) + hasChange = true + } + if d.HasChange("compliance_profile") { + complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetComplianceProfile(complianceProfile) + hasChange = true + } + if d.HasChange("input") { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } + + if hasChange { + _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) + if err != nil { + log.Printf("[DEBUG] UpdateConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateConfigWithContext failed %s\n%s", err, response)) + } + } + + return resourceIbmProjectConfigRead(context, d, meta) +} + +func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + deleteConfigOptions := &projectv1.DeleteConfigOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteConfigOptions.SetProjectID(parts[0]) + deleteConfigOptions.SetID(parts[1]) + + _, response, err := projectClient.DeleteConfigWithContext(context, deleteConfigOptions) + if err != nil { + log.Printf("[DEBUG] DeleteConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) + } + + d.SetId("") + + return nil +} + +func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { + model := &projectv1.ProjectConfigAuth{} + if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { + TrustedProfileModel, err := resourceIbmProjectConfigMapToProjectConfigAuthTrustedProfile(modelMap["trusted_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.TrustedProfile = TrustedProfileModel + } + if modelMap["method"] != nil && modelMap["method"].(string) != "" { + model.Method = core.StringPtr(modelMap["method"].(string)) + } + if modelMap["api_key"] != nil && modelMap["api_key"].(string) != "" { + model.ApiKey = core.StringPtr(modelMap["api_key"].(string)) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigAuthTrustedProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuthTrustedProfile, error) { + model := &projectv1.ProjectConfigAuthTrustedProfile{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + if modelMap["target_iam_id"] != nil && modelMap["target_iam_id"].(string) != "" { + model.TargetIamID = core.StringPtr(modelMap["target_iam_id"].(string)) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigComplianceProfile, error) { + model := &projectv1.ProjectConfigComplianceProfile{} + if modelMap["id"] != nil && modelMap["id"].(string) != "" { + model.ID = core.StringPtr(modelMap["id"].(string)) + } + if modelMap["instance_id"] != nil && modelMap["instance_id"].(string) != "" { + model.InstanceID = core.StringPtr(modelMap["instance_id"].(string)) + } + if modelMap["instance_location"] != nil && modelMap["instance_location"].(string) != "" { + model.InstanceLocation = core.StringPtr(modelMap["instance_location"].(string)) + } + if modelMap["attachment_id"] != nil && modelMap["attachment_id"].(string) != "" { + model.AttachmentID = core.StringPtr(modelMap["attachment_id"].(string)) + } + if modelMap["profile_name"] != nil && modelMap["profile_name"].(string) != "" { + model.ProfileName = core.StringPtr(modelMap["profile_name"].(string)) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { + model := &projectv1.ProjectConfigInputVariable{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["value"] != nil { + model.Value = modelMap["value"].(string) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { + model := &projectv1.ProjectConfigSettingCollection{} + model.Name = core.StringPtr(modelMap["name"].(string)) + model.Value = core.StringPtr(modelMap["value"].(string)) + return model, nil +} + +func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := resourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go new file mode 100644 index 0000000000..51d5e9e77e --- /dev/null +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -0,0 +1,213 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/project-go-sdk/projectv1" +) + +func TestAccIbmProjectConfigBasic(t *testing.T) { + var conf projectv1.ProjectConfig + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectConfigDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + ), + }, + resource.TestStep{ + Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + ), + }, + }, + }) +} + +func TestAccIbmProjectConfigAllArgs(t *testing.T) { + var conf projectv1.ProjectConfig + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectConfigDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfigConfig(name, locatorID, description), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), + ), + }, + resource.TestStep{ + Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorIDUpdate, descriptionUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), + ), + }, + resource.TestStep{ + ResourceName: "ibm_project_config.project_config", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) string { + return fmt.Sprintf(` + resource "ibm_project" "project_instance" { + resource_group = "Default" + location = "us-south" + name = "acme-microservice" + } + + resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = "%s" + locator_id = "%s" + } + `, name, locatorID) +} + +func testAccCheckIbmProjectConfigConfig(name string, locatorID string, description string) string { + return fmt.Sprintf(` + + resource "ibm_project" "project_instance" { + resource_group = "Default" + location = "us-south" + name = "acme-microservice" + } + + resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = "%s" + locator_id = "%s" + labels = "FIXME" + description = "%s" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } + `, name, locatorID, description) +} + +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { + + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + + getConfigOptions := &projectv1.GetConfigOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + + projectConfig, _, err := projectClient.GetConfig(getConfigOptions) + if err != nil { + return err + } + + obj = *projectConfig + return nil + } +} + +func testAccCheckIbmProjectConfigDestroy(s *terraform.State) error { + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_project_config" { + continue + } + + getConfigOptions := &projectv1.GetConfigOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + + // Try to find the key + _, response, err := projectClient.GetConfig(getConfigOptions) + + if err == nil { + return fmt.Errorf("project_config still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for project_config (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/project/resource_ibm_project_instance.go b/ibm/service/project/resource_ibm_project_instance.go deleted file mode 100644 index 2d4c5af5a4..0000000000 --- a/ibm/service/project/resource_ibm_project_instance.go +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package project - -import ( - "context" - "fmt" - "log" - "time" - - "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/schema" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/project-go-sdk/projectv1" -) - -func ResourceIbmProjectInstance() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceIbmProjectInstanceCreate, - ReadContext: resourceIbmProjectInstanceRead, - UpdateContext: resourceIbmProjectInstanceUpdate, - DeleteContext: resourceIbmProjectInstanceDelete, - Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The project name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A project's descriptive text.", - }, - "configs": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The project configurations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The configuration name.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The project configuration description.", - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The input values to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - }, - }, - }, - "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The resource group where the project's data and tools are created.", - }, - "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The location where the project's data and tools are created.", - }, - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "metadata": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The metadata of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cumulative_needs_attention_view": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cumulative list of needs attention items for a project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "event": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The event name.", - }, - "event_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - }, - }, - }, - "cumulative_needs_attention_view_err": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "True indicates that the fetch of the needs attention items failed.", - }, - "location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud location where a resource is deployed.", - }, - "resource_group": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The resource group where the project's data and tools are created.", - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project status value.", - }, - "event_notifications_crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The CRN of the event notifications instance if one is connected to this project.", - }, - }, - }, - }, - }, - } -} - -func ResourceIbmProjectInstanceValidator() *validate.ResourceValidator { - validateSchema := make([]validate.ValidateSchema, 0) - validateSchema = append(validateSchema, - validate.ValidateSchema{ - Identifier: "name", - Type: validate.TypeString, - Required: true, - Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, - MinValueLength: 1, - MaxValueLength: 64, - }, - validate.ValidateSchema{ - Identifier: "description", - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, - }, - validate.ValidateSchema{ - Identifier: "resource_group", - Type: validate.TypeString, - Required: true, - Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, - MinValueLength: 0, - MaxValueLength: 40, - }, - validate.ValidateSchema{ - Identifier: "location", - Type: validate.TypeString, - Required: true, - Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, - MinValueLength: 0, - MaxValueLength: 12, - }, - ) - - resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project_instance", Schema: validateSchema} - return &resourceValidator -} - -func resourceIbmProjectInstanceCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - createProjectOptions := &projectv1.CreateProjectOptions{} - - createProjectOptions.SetName(d.Get("name").(string)) - if _, ok := d.GetOk("description"); ok { - createProjectOptions.SetDescription(d.Get("description").(string)) - } - if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigPrototype - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectInstanceMapToProjectConfigPrototype(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) - } - createProjectOptions.SetConfigs(configs) - } - if _, ok := d.GetOk("resource_group"); ok { - createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - } - if _, ok := d.GetOk("location"); ok { - createProjectOptions.SetLocation(d.Get("location").(string)) - } - - project, response, err := projectClient.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)) - } - - d.SetId(*project.ID) - - _, err = waitForProjectInstanceCreate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) - } - - return resourceIbmProjectInstanceRead(context, d, meta) -} - -func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - -func resourceIbmProjectInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - getProjectOptions := &projectv1.GetProjectOptions{} - - getProjectOptions.SetID(d.Id()) - - project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) - if err != nil { - if response != nil && response.StatusCode == 404 { - 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)) - } - - if !core.IsNil(project.Crn) { - if err = d.Set("crn", project.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) - } - } - if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if !core.IsNil(project.Description) { - if err = d.Set("description", project.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - } - if !core.IsNil(project.Configs) { - configs := []map[string]interface{}{} - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) - } - } - if !core.IsNil(project.Metadata) { - metadataMap, err := resourceIbmProjectInstanceProjectMetadataToMap(project.Metadata) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) - } - } - - return nil -} - -func resourceIbmProjectInstanceUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - updateProjectOptions := &projectv1.UpdateProjectOptions{} - - updateProjectOptions.SetID(d.Id()) - - hasChange := false - - if d.HasChange("name") { - updateProjectOptions.SetName(d.Get("name").(string)) - hasChange = true - } - if d.HasChange("description") { - updateProjectOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } - if d.HasChange("configs") { - var configs []projectv1.ProjectConfigPrototype - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectInstanceMapToProjectConfigPrototype(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) - } - hasChange = true - } - - if hasChange { - _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) - if err != nil { - log.Printf("[DEBUG] UpdateProjectWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateProjectWithContext failed %s\n%s", err, response)) - } - } - - return resourceIbmProjectInstanceRead(context, d, meta) -} - -func resourceIbmProjectInstanceDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - deleteProjectOptions := &projectv1.DeleteProjectOptions{} - - deleteProjectOptions.SetID(d.Id()) - - response, err := projectClient.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)) - } - - _, err = waitForProjectInstanceDelete(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) - } - - d.SetId("") - - return nil -} - -func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - -func resourceIbmProjectInstanceMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { - model := &projectv1.ProjectConfigPrototype{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["labels"] != nil { - labels := []string{} - for _, labelsItem := range modelMap["labels"].([]interface{}) { - labels = append(labels, labelsItem.(string)) - } - model.Labels = labels - } - if modelMap["description"] != nil && modelMap["description"].(string) != "" { - model.Description = core.StringPtr(modelMap["description"].(string)) - } - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) - if modelMap["input"] != nil { - input := []projectv1.ProjectConfigInputVariable{} - for _, inputItem := range modelMap["input"].([]interface{}) { - inputItemModel, err := resourceIbmProjectInstanceMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) - if err != nil { - return model, err - } - input = append(input, *inputItemModel) - } - model.Input = input - } - if modelMap["setting"] != nil { - setting := []projectv1.ProjectConfigSettingCollection{} - for _, settingItem := range modelMap["setting"].([]interface{}) { - settingItemModel, err := resourceIbmProjectInstanceMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) - if err != nil { - return model, err - } - setting = append(setting, *settingItemModel) - } - model.Setting = setting - } - return model, nil -} - -func resourceIbmProjectInstanceMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { - model := &projectv1.ProjectConfigInputVariable{} - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["value"] != nil { - model.Value = modelMap["value"].(string) - } - return model, nil -} - -func resourceIbmProjectInstanceMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { - model := &projectv1.ProjectConfigSettingCollection{} - model.Name = core.StringPtr(modelMap["name"].(string)) - model.Value = core.StringPtr(modelMap["value"].(string)) - return model, nil -} - -func resourceIbmProjectInstanceProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectInstanceProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectInstanceProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - return modelMap, nil -} - -func resourceIbmProjectInstanceProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func resourceIbmProjectInstanceProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value - return modelMap, nil -} - -func resourceIbmProjectInstanceProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Crn != nil { - modelMap["crn"] = model.Crn - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.CumulativeNeedsAttentionView != nil { - cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { - cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectInstanceCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) - if err != nil { - return modelMap, err - } - cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) - } - modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView - } - if model.CumulativeNeedsAttentionViewErr != nil { - modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr - } - if model.Location != nil { - modelMap["location"] = model.Location - } - if model.ResourceGroup != nil { - modelMap["resource_group"] = model.ResourceGroup - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.EventNotificationsCrn != nil { - modelMap["event_notifications_crn"] = model.EventNotificationsCrn - } - return modelMap, nil -} - -func resourceIbmProjectInstanceCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Event != nil { - modelMap["event"] = model.Event - } - if model.EventID != nil { - modelMap["event_id"] = model.EventID - } - if model.ConfigID != nil { - modelMap["config_id"] = model.ConfigID - } - return modelMap, nil -} diff --git a/ibm/service/project/resource_ibm_project_instance_test.go b/ibm/service/project/resource_ibm_project_instance_test.go deleted file mode 100644 index 088784f11b..0000000000 --- a/ibm/service/project/resource_ibm_project_instance_test.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright IBM Corp. 2023 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package project_test - -import ( - "fmt" - "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" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM/project-go-sdk/projectv1" -) - -func TestAccIbmProjectInstanceBasic(t *testing.T) { - var conf projectv1.Project - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_update_%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmProjectInstanceDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroup, location, name), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), - ), - }, - resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfigBasic(resourceGroup, location, nameUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), - ), - }, - }, - }) -} - -func TestAccIbmProjectInstanceAllArgs(t *testing.T) { - var conf projectv1.Project - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmProjectInstanceDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(name, description, resourceGroup, location), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectInstanceExists("ibm_project_instance.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", description), - ), - }, - resource.TestStep{ - Config: testAccCheckIbmProjectInstanceConfig(nameUpdate, descriptionUpdate, resourceGroup, location), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_instance.project_instance", "description", descriptionUpdate), - ), - }, - resource.TestStep{ - ResourceName: "ibm_project_instance.project_instance", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "location", - "resource_group", - "configs", - }, - }, - }, - }) -} - -func testAccCheckIbmProjectInstanceConfigBasic(resourceGroup string, location string, name string) string { - return fmt.Sprintf(` - - resource "ibm_project_instance" "project_instance" { - resource_group = "%s" - location = "%s" - name = "%s" - } - `, resourceGroup, location, name) -} - -func testAccCheckIbmProjectInstanceConfig(name string, description string, resourceGroup string, location string) string { - return fmt.Sprintf(` - - resource "ibm_project_instance" "project_instance" { - name = "%s" - description = "%s" - resource_group = "%s" - location = "%s" - configs { - name = "name" - labels = [ "labels" ] - description = "description" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - } - setting { - name = "name" - value = "value" - } - } - } - `, name, description, resourceGroup, location) -} - -func testAccCheckIbmProjectInstanceExists(n string, obj projectv1.Project) resource.TestCheckFunc { - - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() - if err != nil { - return err - } - - getProjectOptions := &projectv1.GetProjectOptions{} - - getProjectOptions.SetID(rs.Primary.ID) - - project, _, err := projectClient.GetProject(getProjectOptions) - if err != nil { - return err - } - - obj = *project - return nil - } -} - -func testAccCheckIbmProjectInstanceDestroy(s *terraform.State) error { - projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() - if err != nil { - return err - } - for _, rs := range s.RootModule().Resources { - if rs.Type != "ibm_project_instance" { - continue - } - - getProjectOptions := &projectv1.GetProjectOptions{} - - getProjectOptions.SetID(rs.Primary.ID) - - // Try to find the key - _, response, err := projectClient.GetProject(getProjectOptions) - - if err == nil { - return fmt.Errorf("Project definition still exists: %s", rs.Primary.ID) - } else if response.StatusCode != 404 { - return fmt.Errorf("Error checking for Project definition (%s) has been destroyed: %s", rs.Primary.ID, err) - } - } - - return nil -} diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go new file mode 100644 index 0000000000..26a4d61b2b --- /dev/null +++ b/ibm/service/project/resource_ibm_project_test.go @@ -0,0 +1,182 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/project-go-sdk/projectv1" +) + +func TestAccIbmProjectBasic(t *testing.T) { + var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location, name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectExists("ibm_project.project", conf), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project", "location", location), + resource.TestCheckResourceAttr("ibm_project.project", "name", name), + ), + }, + }, + }) +} + +func TestAccIbmProjectAllArgs(t *testing.T) { + var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + destroyOnDelete := "false" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmProjectDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfig(resourceGroup, location, name, description, destroyOnDelete), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmProjectExists("ibm_project.project", conf), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project", "location", location), + resource.TestCheckResourceAttr("ibm_project.project", "name", name), + resource.TestCheckResourceAttr("ibm_project.project", "description", description), + resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDelete), + ), + }, + resource.TestStep{ + ResourceName: "ibm_project.project", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string, name string) string { + return fmt.Sprintf(` + + resource "ibm_project" "project_instance" { + resource_group = "%s" + location = "%s" + name = "%s" + } + `, resourceGroup, location, name) +} + +func testAccCheckIbmProjectConfig(resourceGroup string, location string, name string, description string, destroyOnDelete string) string { + return fmt.Sprintf(` + + resource "ibm_project" "project_instance" { + resource_group = "%s" + location = "%s" + name = "%s" + description = "%s" + destroy_on_delete = %s + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } + } + `, resourceGroup, location, name, description, destroyOnDelete) +} + +func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { + + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(rs.Primary.ID) + + project, _, err := projectClient.GetProject(getProjectOptions) + if err != nil { + return err + } + + obj = *project + return nil + } +} + +func testAccCheckIbmProjectDestroy(s *terraform.State) error { + projectClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).ProjectV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_project" { + continue + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(rs.Primary.ID) + + // Try to find the key + _, response, err := projectClient.GetProject(getProjectOptions) + + if err == nil { + return fmt.Errorf("project still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for project (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown new file mode 100644 index 0000000000..9662d5140a --- /dev/null +++ b/website/docs/d/project.html.markdown @@ -0,0 +1,134 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_project" +description: |- + Get information about Project definition +subcategory: "Projects API" +--- + +# ibm_project + +Provides a read-only data source for Project definition. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_project" "project" { + id = ibm_project.project_instance.project_id +} +``` + +## Argument Reference + +Review the argument reference that you can specify for your data source. + +* `id` - (Required, Forces new resource, String) The unique project ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +## Attribute Reference + +In addition to all argument references listed, you can access the following attribute references after your data source is created. + +* `id` - The unique identifier of the Project definition. +* `configs` - (List) The project configurations. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **configs**: + * `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested scheme for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested scheme for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `input` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `required` - (Boolean) Whether the variable is required or not. + * `type` - (String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + +* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + +* `description` - (String) A project descriptive text. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + +* `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + +* `metadata` - (List) The metadata of the project. +Nested scheme for **metadata**: + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **cumulative_needs_attention_view**: + * `config_id` - (String) A unique ID for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `config_version` - (Integer) The version number of the configuration. + * `event` - (String) The event name. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `event_id` - (String) A unique ID for that individual event. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. + * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `location` - (String) The IBM Cloud location where a resource is deployed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `resource_group` - (String) The resource group where the project's data and tools are created. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `state` - (String) The project status value. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. + +* `name` - (String) The project name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project.html.markdown similarity index 60% rename from website/docs/r/project_instance.html.markdown rename to website/docs/r/project.html.markdown index f3fdacd7f2..c9d962812d 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project.html.markdown @@ -1,36 +1,52 @@ --- layout: "ibm" -page_title: "IBM : ibm_project_instance" +page_title: "IBM : ibm_project" description: |- - Manages Project definition. -subcategory: "Project" + Manages project. +subcategory: "Projects API" --- -# ibm_project_instance +# ibm_project -Provides a resource for Project definition. This allows Project definition to be created, updated and deleted. +Provides a resource for project. This allows project to be created, updated and deleted. ## Example Usage ```hcl resource "ibm_project" "project_instance" { configs { - id = "0013790d-6cb5-4adc-8927-a725a1261d0c" - name = "static-website-dev" - labels = [ "env:dev", "billing:internal" ] - description = "Website - development" - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" input { - name = "app_repo_name" + name = "name" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } - description = "Sample static website test using the IBM catalog deployable architecture" - name = "My static website" + description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" + name = "acme-microservice" resource_group = "Default" } ``` @@ -39,9 +55,33 @@ resource "ibm_project" "project_instance" { Review the argument reference that you can specify for your resource. -* `configs` - (Optional, List) The project configurations. +* `configs` - (Optional, Forces new resource, List) The project configurations. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **configs**: + * `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested scheme for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (Optional, List) The profile required for compliance. + Nested scheme for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. @@ -65,20 +105,22 @@ Nested scheme for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. -* `description` - (Optional, String) A project's descriptive text. +* `description` - (Optional, Forces new resource, String) A project's descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `location` - (Required, String) The location where the project's data and tools are created. +* `destroy_on_delete` - (Optional, Forces new resource, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. +* `location` - (Required, Forces new resource, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Required, String) The project name. +* `name` - (Required, Forces new resource, String) The project name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. -* `resource_group` - (Required, String) The resource group where the project's data and tools are created. +* `resource_group` - (Required, Forces new resource, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. ## Attribute Reference In addition to all argument references listed, you can access the following attribute references after your resource is created. -* `id` - The unique identifier of the Project definition. +* `id` - The unique identifier of the project. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `metadata` - (List) The metadata of the project. @@ -89,14 +131,14 @@ Nested scheme for **metadata**: * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) The unique ID of a project. + * `config_id` - (String) A unique ID for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) The unique ID of a project. + * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. + * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. @@ -107,11 +149,12 @@ Nested scheme for **metadata**: * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. + ## Import -You can import the `ibm_project_instance` resource by using `id`. The unique ID of a project. +You can import the `ibm_project` resource by using `id`. The unique ID of a project. # Syntax ``` -$ terraform import ibm_project_instance.project_instance +$ terraform import ibm_project.project ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown new file mode 100644 index 0000000000..f6f6fc96b0 --- /dev/null +++ b/website/docs/r/project_config.html.markdown @@ -0,0 +1,132 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_project_config" +description: |- + Manages project_config. +subcategory: "Projects API" +--- + +# ibm_project_config + +Provides a resource for project_config. This allows project_config to be created, updated and deleted. + +## Example Usage + +```hcl +resource "ibm_project_config" "project_config_instance" { + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + input { + name = "name" + value = "anything as a string" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + name = "env-stage" + project_id = ibm_project.project_instance.id + setting { + name = "name" + value = "value" + } +} +``` + +## Argument Reference + +Review the argument reference that you can specify for your resource. + +* `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. +Nested scheme for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `compliance_profile` - (Optional, List) The profile required for compliance. +Nested scheme for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. +* `description` - (Optional, String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. +* `input` - (Optional, List) The input values to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. +* `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. +* `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. +* `name` - (Required, String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. +* `project_id` - (Required, Forces new resource, String) The unique project ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + +## Attribute Reference + +In addition to all argument references listed, you can access the following attribute references after your resource is created. + +* `id` - The unique identifier of the project_config. +* `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + + +## Import + +You can import the `ibm_project_config` resource by using `id`. +The `id` property can be formed from `project_id`, and `id` in the following format: + +``` +/ +``` +* `project_id`: A string. The unique project ID. +* `id`: A string. The unique config ID. + +# Syntax +``` +$ terraform import ibm_project_config.project_config / +``` From bc423b60f367397426b14a9afaaccf11f64d3453 Mon Sep 17 00:00:00 2001 From: rangelil Date: Sat, 20 May 2023 06:42:30 +0200 Subject: [PATCH 037/125] terraform --- ibm/provider/provider.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 281db766ab..a73c9bb069 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -804,7 +804,7 @@ func Provider() *schema.Provider { "ibm_code_engine_secret": codeengine.DataSourceIbmCodeEngineSecret(), // Added for Project - "ibm_project_event_notification": project.DataSourceIbmProjectEventNotification(), + // MISSING DATA SOURCE FOR PROJECT HERE !!!!!! }, ResourcesMap: map[string]*schema.Resource{ @@ -1276,7 +1276,8 @@ func Provider() *schema.Provider { "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecret(), // Added for Project - "ibm_project_instance": project.ResourceIbmProjectInstance(), + "ibm_project": project.ResourceIbmProject(), + "ibm_project_config": project.ResourceIbmProjectConfig(), }, ConfigureFunc: providerConfigure, @@ -1514,7 +1515,8 @@ func Validator() validate.ValidatorDict { "ibm_code_engine_secret": codeengine.ResourceIbmCodeEngineSecretValidator(), // Added for Project - "ibm_project_instance": project.ResourceIbmProjectInstanceValidator(), + "ibm_project": project.ResourceIbmProjectValidator(), + "ibm_project_config": project.ResourceIbmProjectConfigValidator(), }, DataSourceValidatorDictionary: map[string]*validate.ResourceValidator{ "ibm_is_subnet": vpc.DataSourceIBMISSubnetValidator(), From 816f0b3e34be13f5cfa6f305fe9d432d523eea7b Mon Sep 17 00:00:00 2001 From: rangelil Date: Sat, 20 May 2023 06:52:46 +0200 Subject: [PATCH 038/125] terraform --- examples/ibm-project/versions.tf | 8 +- website/docs/d/project.html.markdown | 2 +- .../project_event_notification.html.markdown | 107 ------------------ website/docs/r/project.html.markdown | 2 +- website/docs/r/project_config.html.markdown | 2 +- 5 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 website/docs/d/project_event_notification.html.markdown diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index 54c9d03e8d..d9b6f790b9 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,9 +1,3 @@ terraform { - required_version = ">= 1.0" - required_providers { - ibm = { - source = "IBM-Cloud/ibm" - version = "1.52.0-beta0" - } - } + required_version = ">= 0.12" } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 9662d5140a..78d2e39ae4 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- Get information about Project definition -subcategory: "Projects API" +subcategory: "Project" --- # ibm_project diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown deleted file mode 100644 index 689ce78b89..0000000000 --- a/website/docs/d/project_event_notification.html.markdown +++ /dev/null @@ -1,107 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_project_event_notification" -description: |- - Get information about Project definition -subcategory: "Project" ---- - -# ibm_project_event_notification - -Provides a read-only data source for Project definition. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_project_event_notification" "project_event_notification" { - project_id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `project_id` - (Required, Forces new resource, String) The unique project ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the Project definition. -* `configs` - (List) The project configurations. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **configs**: - * `description` - (String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Boolean) Whether the variable is required or not. - * `type` - (String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The configuration name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - -* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - -* `description` - (String) A project descriptive text. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - -* `metadata` - (List) The metadata of the project. -Nested scheme for **metadata**: - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `config_version` - (Integer) The version number of the configuration. - * `event` - (String) The event name. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `location` - (String) The IBM Cloud location where a resource is deployed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `resource_group` - (String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `state` - (String) The project status value. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. - -* `name` - (String) The project name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. - diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index c9d962812d..1cb7be4a90 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- Manages project. -subcategory: "Projects API" +subcategory: "Project" --- # ibm_project diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index f6f6fc96b0..83e75c27a9 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_config" description: |- Manages project_config. -subcategory: "Projects API" +subcategory: "Project" --- # ibm_project_config From bb77ff00f9f1bf260b49d8cdc20371f53c6d2609 Mon Sep 17 00:00:00 2001 From: rangelil Date: Sun, 21 May 2023 12:22:55 +0200 Subject: [PATCH 039/125] terraform --- ibm/provider/provider.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index a73c9bb069..6bcb949831 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -804,7 +804,8 @@ func Provider() *schema.Provider { "ibm_code_engine_secret": codeengine.DataSourceIbmCodeEngineSecret(), // Added for Project - // MISSING DATA SOURCE FOR PROJECT HERE !!!!!! + "ibm_project": project.DataSourceIbmProject(), + "ibm_project_config": project.DataSourceIbmProjectConfig(), }, ResourcesMap: map[string]*schema.Resource{ From 42a8de9742e5066e83f96916ec46c855d293e290 Mon Sep 17 00:00:00 2001 From: rangelil Date: Sun, 21 May 2023 14:19:16 +0200 Subject: [PATCH 040/125] terraform --- cloud-docs/project-data-sources.md | 68 ++- examples/ibm-project/README.md | 20 + examples/ibm-project/main.tf | 12 + examples/ibm-project/variables.tf | 24 + .../project/data_source_ibm_project.go | 572 ++++++++++++++++++ .../project/data_source_ibm_project_config.go | 410 +++++++++++++ .../data_source_ibm_project_config_test.go | 148 +++++ .../project/data_source_ibm_project_test.go | 128 ++++ website/docs/d/project_config.html.markdown | 108 ++++ 9 files changed, 1489 insertions(+), 1 deletion(-) create mode 100644 ibm/service/project/data_source_ibm_project.go create mode 100644 ibm/service/project/data_source_ibm_project_config.go create mode 100644 ibm/service/project/data_source_ibm_project_config_test.go create mode 100644 ibm/service/project/data_source_ibm_project_test.go create mode 100644 website/docs/d/project_config.html.markdown diff --git a/cloud-docs/project-data-sources.md b/cloud-docs/project-data-sources.md index 396e5083b7..e3b1730233 100644 --- a/cloud-docs/project-data-sources.md +++ b/cloud-docs/project-data-sources.md @@ -23,7 +23,7 @@ that you need to specify in the `provider` block of your Terraform configuration ## `ibm_project` {: #project} -Retrieve information about Project definition. +Retrieve information about project. {: shortdesc} ### Sample Terraform code @@ -100,3 +100,69 @@ Review the output parameters that you can access after you retrieved your data s |`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| |`name`|String|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.| +## `ibm_project_config` +{: #project_config} + +Retrieve information about project_config. +{: shortdesc} + +### Sample Terraform code +{: #project_config-sample} + +``` +data "ibm_project_config" "project_config" { + id = "id" + project_id = "project_id" + version = "version" +} +``` + +### Input parameters +{: #project_config-input} + +Review the input parameters that you can specify for your data source. {: shortdesc} + +|Name|Data type|Required/optional|Description| +|----|-----------|-------|----------| +|`id`|String|Required|The unique config ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`project_id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`version`|String|Optional|The version of the configuration to return. The default value is `active`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`.| + +### Output parameters +{: #project_config-output} + +Review the output parameters that you can access after you retrieved your data source. {: shortdesc} + +|Name|Data type|Description| +|----|-----------|---------| +|`authorizations`|List|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. This list contains only one item.| +|`authorizations.trusted_profile`|List|The trusted profile for authorizations. This list contains only one item.| +|`authorizations.trusted_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`authorizations.trusted_profile.target_iam_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`authorizations.method`|String|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| +|`authorizations.api_key`|String|The IBM Cloud API Key. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| +|`compliance_profile`|List|The profile required for compliance. This list contains only one item.| +|`compliance_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`compliance_profile.instance_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`compliance_profile.instance_location`|String|The location of the compliance instance. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.| +|`compliance_profile.attachment_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`compliance_profile.profile_name`|String|The name of the compliance profile. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| +|`description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| +|`input.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`input.required`|Boolean|Whether the variable is required or not.| +|`labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| +|`locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| +|`name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| +|`output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| +|`output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| +|`output.value`|String|Can be any value - a string, number, boolean, array, or object.| +|`project_config_id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| +|`setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| +|`setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| +|`type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| + diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 23241e6a37..90d692656f 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -52,6 +52,22 @@ resource "project_config" "project_config_instance" { ## ProjectV1 Data sources +project data source: + +```hcl +data "project" "project_instance" { + id = ibm_project.project_instance.id +} +``` +project_config data source: + +```hcl +data "project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + id = ibm_project_config.project_config_instance.projectConfig_id + version = var.project_config_version +} +``` ## Assumptions @@ -93,6 +109,10 @@ resource "project_config" "project_config_instance" { | compliance_profile | The profile required for compliance. | `` | false | | input | The input values to use to deploy the configuration. | `list()` | false | | setting | Schematics environment variables to use to deploy the configuration. | `list()` | false | +| id | The unique project ID. | `string` | true | +| project_id | The unique project ID. | `string` | true | +| id | The unique config ID. | `string` | true | +| version | The version of the configuration to return. | `string` | false | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index bbd9c8ba34..a26f29d3b4 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -72,3 +72,15 @@ resource "ibm_project_config" "project_config_instance" { value = "value" } } + +// Create project data source +data "ibm_project" "project_instance" { + id = ibm_project.project_instance.id +} + +// Create project_config data source +data "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + id = ibm_project_config.project_config_instance.projectConfig_id + version = var.project_config_version +} diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 1bce0fca37..8aafdadb6d 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -56,3 +56,27 @@ variable "project_config_description" { type = string default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." } + +// Data source arguments for project +variable "project_id" { + description = "The unique project ID." + type = string + default = "id" +} + +// Data source arguments for project_config +variable "project_config_project_id" { + description = "The unique project ID." + type = string + default = "project_id" +} +variable "project_config_id" { + description = "The unique config ID." + type = string + default = "id" +} +variable "project_config_version" { + description = "The version of the configuration to return." + type = string + default = "placeholder" +} diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go new file mode 100644 index 0000000000..c4aa853269 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project.go @@ -0,0 +1,572 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "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/project-go-sdk/projectv1" +) + +func DataSourceIbmProject() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmProjectRead, + + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique project ID.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A project descriptive text.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable type.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Whether the variable is required or not.", + }, + }, + }, + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + }, + }, + }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The metadata of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "cumulative_needs_attention_view": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cumulative list of needs attention items for a project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The event name.", + }, + "event_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A unique ID for that individual event.", + }, + "config_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A unique ID for the configuration.", + }, + "config_version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version number of the configuration.", + }, + }, + }, + }, + "cumulative_needs_attention_view_err": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "True indicates that the fetch of the needs attention items failed.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud location where a resource is deployed.", + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The resource group where the project's data and tools are created.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getProjectOptions := &projectv1.GetProjectOptions{} + + getProjectOptions.SetID(d.Get("id").(string)) + + project, response, err := projectClient.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)) + } + + d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) + + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", project.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + + if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) + } + + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } + + configs := []map[string]interface{}{} + if project.Configs != nil { + for _, modelItem := range project.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, modelMap) + } + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) + } + + metadata := []map[string]interface{}{} + if project.Metadata != nil { + modelMap, err := dataSourceIbmProjectProjectMetadataToMap(project.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) + } + if err = d.Set("metadata", metadata); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + } + + return nil +} + +func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + modelMap["type"] = model.Type + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["type"] = model.Type + if model.Value != nil { + modelMap["value"] = model.Value + } + if model.Required != nil { + modelMap["required"] = model.Required + } + return modelMap, nil +} + +func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func dataSourceIbmProjectProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Crn != nil { + modelMap["crn"] = model.Crn + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.CumulativeNeedsAttentionView != nil { + cumulativeNeedsAttentionView := []map[string]interface{}{} + for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { + cumulativeNeedsAttentionViewItemMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) + if err != nil { + return modelMap, err + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) + } + modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView + } + if model.CumulativeNeedsAttentionViewErr != nil { + modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr + } + if model.Location != nil { + modelMap["location"] = model.Location + } + if model.ResourceGroup != nil { + modelMap["resource_group"] = model.ResourceGroup + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.EventNotificationsCrn != nil { + modelMap["event_notifications_crn"] = model.EventNotificationsCrn + } + return modelMap, nil +} + +func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Event != nil { + modelMap["event"] = model.Event + } + if model.EventID != nil { + modelMap["event_id"] = model.EventID + } + if model.ConfigID != nil { + modelMap["config_id"] = model.ConfigID + } + if model.ConfigVersion != nil { + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go new file mode 100644 index 0000000000..eecf7f2154 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -0,0 +1,410 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/project-go-sdk/projectv1" +) + +func DataSourceIbmProjectConfig() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmProjectConfigRead, + + Schema: map[string]*schema.Schema{ + "project_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique project ID.", + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique config ID.", + }, + "version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "active", + Description: "The version of the configuration to return.", + }, + "project_config_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable type.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Whether the variable is required or not.", + }, + }, + }, + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getConfigOptions := &projectv1.GetConfigOptions{} + + getConfigOptions.SetProjectID(d.Get("project_id").(string)) + getConfigOptions.SetID(d.Get("id").(string)) + if _, ok := d.GetOk("version"); ok { + getConfigOptions.SetVersion(d.Get("version").(string)) + } + + projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err != nil { + log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) + + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + } + + if err = d.Set("name", projectConfig.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", projectConfig.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + + authorizations := []map[string]interface{}{} + if projectConfig.Authorizations != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) + if err != nil { + return diag.FromErr(err) + } + authorizations = append(authorizations, modelMap) + } + if err = d.Set("authorizations", authorizations); err != nil { + return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) + } + + complianceProfile := []map[string]interface{}{} + if projectConfig.ComplianceProfile != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) + if err != nil { + return diag.FromErr(err) + } + complianceProfile = append(complianceProfile, modelMap) + } + if err = d.Set("compliance_profile", complianceProfile); err != nil { + return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) + } + + if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } + + if err = d.Set("type", projectConfig.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + } + + input := []map[string]interface{}{} + if projectConfig.Input != nil { + for _, modelItem := range projectConfig.Input { + modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, modelMap) + } + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input %s", err)) + } + + output := []map[string]interface{}{} + if projectConfig.Output != nil { + for _, modelItem := range projectConfig.Output { + modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + output = append(output, modelMap) + } + } + if err = d.Set("output", output); err != nil { + return diag.FromErr(fmt.Errorf("Error setting output %s", err)) + } + + setting := []map[string]interface{}{} + if projectConfig.Setting != nil { + for _, modelItem := range projectConfig.Setting { + modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, modelMap) + } + } + if err = d.Set("setting", setting); err != nil { + return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) + } + + return nil +} + +func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := dataSourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["type"] = model.Type + if model.Value != nil { + modelMap["value"] = model.Value + } + if model.Required != nil { + modelMap["required"] = model.Required + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go new file mode 100644 index 0000000000..65624a02c9 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -0,0 +1,148 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" +) + +func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { + projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName, projectConfigLocatorID), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + ), + }, + }, + }) +} + +func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { + projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigLocatorID, projectConfigDescription), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.required"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigName), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), + ), + }, + }, + }) +} + +func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, projectConfigLocatorID string) string { + return fmt.Sprintf(` + resource "ibm_project" "project_instance" { + resource_group = "Default" + location = "us-south" + name = "acme-microservice" + } + + resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = "%s" + locator_id = "%s" + } + + data "ibm_project_config" "project_config_instance" { + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfig_id + version = "version" + } + `, projectConfigName, projectConfigLocatorID) +} + +func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigLocatorID string, projectConfigDescription string) string { + return fmt.Sprintf(` + resource "ibm_project" "project_instance" { + resource_group = "Default" + location = "us-south" + name = "acme-microservice" + } + + resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = "%s" + locator_id = "%s" + labels = "FIXME" + description = "%s" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } + + data "ibm_project_config" "project_config_instance" { + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfig_id + version = "version" + } + `, projectConfigName, projectConfigLocatorID, projectConfigDescription) +} diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go new file mode 100644 index 0000000000..cc93e840b3 --- /dev/null +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -0,0 +1,128 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package project_test + +import ( + "fmt" + "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" +) + +func TestAccIbmProjectDataSourceBasic(t *testing.T) { + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + ), + }, + }, + }) +} + +func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectDestroyOnDelete := "false" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectName), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectDescription), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "metadata.#"), + ), + }, + }, + }) +} + +func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, projectLocation string, projectName string) string { + return fmt.Sprintf(` + resource "ibm_project" "project_instance" { + resource_group = "%s" + location = "%s" + name = "%s" + } + + data "ibm_project" "project_instance" { + id = ibm_project.project_instance.project_id + } + `, projectResourceGroup, projectLocation, projectName) +} + +func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, projectLocation string, projectName string, projectDescription string, projectDestroyOnDelete string) string { + return fmt.Sprintf(` + resource "ibm_project" "project_instance" { + resource_group = "%s" + location = "%s" + name = "%s" + description = "%s" + destroy_on_delete = %s + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } + } + + data "ibm_project" "project_instance" { + id = ibm_project.project_instance.project_id + } + `, projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete) +} diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown new file mode 100644 index 0000000000..d3c253f25e --- /dev/null +++ b/website/docs/d/project_config.html.markdown @@ -0,0 +1,108 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_project_config" +description: |- + Get information about project_config +subcategory: "Project" +--- + +# ibm_project_config + +Provides a read-only data source for project_config. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_project_config" "project_config" { + id = ibm_project_config.project_config_instance.projectConfig_id + project_id = ibm_project_config.project_config.project_id +} +``` + +## Argument Reference + +Review the argument reference that you can specify for your data source. + +* `id` - (Required, Forces new resource, String) The unique config ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `project_id` - (Required, Forces new resource, String) The unique project ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `version` - (Optional, String) The version of the configuration to return. + * Constraints: The default value is `active`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`. + +## Attribute Reference + +In addition to all argument references listed, you can access the following attribute references after your data source is created. + +* `id` - The unique identifier of the project_config. +* `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. +Nested scheme for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +* `compliance_profile` - (List) The profile required for compliance. +Nested scheme for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + +* `description` - (String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + +* `input` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `required` - (Boolean) Whether the variable is required or not. + * `type` - (String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + +* `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + +* `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + +* `name` - (String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + +* `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + +* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +* `setting` - (List) Schematics environment variables to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + +* `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + From 0d7077e92c7253a08d6a92d3d44cbd8dd9d9874a Mon Sep 17 00:00:00 2001 From: rangelil Date: Sun, 21 May 2023 14:23:29 +0200 Subject: [PATCH 041/125] terraform --- cloud-docs/project-data-sources.md | 168 ----------------------------- cloud-docs/project-resources.md | 146 ------------------------- 2 files changed, 314 deletions(-) delete mode 100644 cloud-docs/project-data-sources.md delete mode 100644 cloud-docs/project-resources.md diff --git a/cloud-docs/project-data-sources.md b/cloud-docs/project-data-sources.md deleted file mode 100644 index e3b1730233..0000000000 --- a/cloud-docs/project-data-sources.md +++ /dev/null @@ -1,168 +0,0 @@ ---- - -copyright: - years: 2023 -lastupdated: "2023" - -keywords: terraform - -subcollection: terraform - ---- - -# Projects API data sources -{: #project-data-sources} - -Review the data sources that you can use to retrieve information about your Projects API resources. -All data sources are imported as read-only information. You can reference the output parameters for each data source by using Terraform interpolation syntax. - -Before you start working with your data source, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) -that you need to specify in the `provider` block of your Terraform configuration file. -{: important} - -## `ibm_project` -{: #project} - -Retrieve information about project. -{: shortdesc} - -### Sample Terraform code -{: #project-sample} - -``` -data "ibm_project" "project" { - id = "id" -} -``` - -### Input parameters -{: #project-input} - -Review the input parameters that you can specify for your data source. {: shortdesc} - -|Name|Data type|Required/optional|Description| -|----|-----------|-------|----------| -|`id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| - -### Output parameters -{: #project-output} - -Review the output parameters that you can access after you retrieved your data source. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`configs`|List|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| -|`configs.labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`configs.authorizations`|List|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. This list contains only one item.| -|`configs.authorizations.trusted_profile`|List|The trusted profile for authorizations. This list contains only one item.| -|`configs.authorizations.trusted_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.authorizations.trusted_profile.target_iam_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.authorizations.method`|String|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`configs.authorizations.api_key`|String|The IBM Cloud API Key. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| -|`configs.compliance_profile`|List|The profile required for compliance. This list contains only one item.| -|`configs.compliance_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.compliance_profile.instance_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.compliance_profile.instance_location`|String|The location of the compliance instance. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.| -|`configs.compliance_profile.attachment_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`configs.compliance_profile.profile_name`|String|The name of the compliance profile. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| -|`configs.locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| -|`configs.type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| -|`configs.input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| -|`configs.input.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`configs.input.required`|Boolean|Whether the variable is required or not.| -|`configs.output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`configs.output.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`configs.setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| -|`configs.setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`configs.setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`description`|String|A project descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`destroy_on_delete`|Boolean|The policy that indicates whether the resources are destroyed or not when a project is deleted. The default value is `true`.| -|`metadata`|List|The metadata of the project. This list contains only one item.| -|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| -|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| -|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.cumulative_needs_attention_view.event_id`|String|A unique ID for that individual event. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_id`|String|A unique ID for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| -|`metadata.cumulative_needs_attention_view_err`|String|True indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| -|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`name`|String|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.| - -## `ibm_project_config` -{: #project_config} - -Retrieve information about project_config. -{: shortdesc} - -### Sample Terraform code -{: #project_config-sample} - -``` -data "ibm_project_config" "project_config" { - id = "id" - project_id = "project_id" - version = "version" -} -``` - -### Input parameters -{: #project_config-input} - -Review the input parameters that you can specify for your data source. {: shortdesc} - -|Name|Data type|Required/optional|Description| -|----|-----------|-------|----------| -|`id`|String|Required|The unique config ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`project_id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`version`|String|Optional|The version of the configuration to return. The default value is `active`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`.| - -### Output parameters -{: #project_config-output} - -Review the output parameters that you can access after you retrieved your data source. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`authorizations`|List|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. This list contains only one item.| -|`authorizations.trusted_profile`|List|The trusted profile for authorizations. This list contains only one item.| -|`authorizations.trusted_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`authorizations.trusted_profile.target_iam_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`authorizations.method`|String|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`authorizations.api_key`|String|The IBM Cloud API Key. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| -|`compliance_profile`|List|The profile required for compliance. This list contains only one item.| -|`compliance_profile.id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`compliance_profile.instance_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`compliance_profile.instance_location`|String|The location of the compliance instance. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.| -|`compliance_profile.attachment_id`|String|The unique ID of a project. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`compliance_profile.profile_name`|String|The name of the compliance profile. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`.| -|`description`|String|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`input`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`input.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`input.type`|String|The variable type. Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`.| -|`input.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`input.required`|Boolean|Whether the variable is required or not.| -|`labels`|List|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.| -|`locator_id`|String|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.| -|`name`|String|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.| -|`output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`output.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`project_config_id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`setting`|List|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.| -|`setting.name`|String|The name of the configuration setting. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`setting.value`|String|The value of the configuration setting. The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| - diff --git a/cloud-docs/project-resources.md b/cloud-docs/project-resources.md deleted file mode 100644 index cb6b5b54d8..0000000000 --- a/cloud-docs/project-resources.md +++ /dev/null @@ -1,146 +0,0 @@ ---- - -copyright: - years: 2023 -lastupdated: "2023" - -keywords: terraform - -subcollection: terraform - ---- - -# Projects API resources -{: #project-resources} - -Create, update, or delete Projects API resources. -You can reference the output parameters for each resource in other resources or data sources by using Terraform interpolation syntax. - -Before you start working with your resource, make sure to review the [required parameters](/docs/terraform?topic=terraform-provider-reference#required-parameters) -that you need to specify in the `provider` block of your Terraform configuration file. -{: important} - -## `ibm_project` -{: #project} - -Create, update, or delete an project. -{: shortdesc} - -### Sample Terraform code -{: #project-sample} - -``` -resource "ibm_project" "project" { - description = "A microservice to deploy on top of ACME infrastructure." - location = "us-south" - name = "acme-microservice" - resource_group = "Default" -} -``` - -### Input parameters -{: #project-input} - -Review the input parameters that you can specify for your resource. {: shortdesc} - -|Name|Data type|Required/optional|Description|Forces new resource| -|----|-----------|-------|----------|--------------------| -|`configs`|List|Optional|The project configurations. The maximum length is `10000` items. The minimum length is `0` items.|Yes| -|`description`|String|Optional|A project's descriptive text. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|Yes| -|`destroy_on_delete`|Boolean|Optional|The policy that indicates whether the resources are destroyed or not when a project is deleted. The default value is `true`.|Yes| -|`location`|String|Required|The location where the project's data and tools are created. The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`.|Yes| -|`name`|String|Required|The project name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`.|Yes| -|`resource_group`|String|Required|The resource group where the project's data and tools are created. The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.|Yes| - -### Output parameters -{: #project-output} - -Review the output parameters that you can access after your resource is created. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`id`|String|The unique identifier of the project.| -|`crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata`|List|The metadata of the project. This list contains only one item.| -|`metadata.crn`|String|An IBM Cloud resource name, which uniquely identifies a resource. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| -|`metadata.created_at`|String|A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.| -|`metadata.cumulative_needs_attention_view`|List|The cumulative list of needs attention items for a project. The maximum length is `10000` items. The minimum length is `0` items.| -|`metadata.cumulative_needs_attention_view.event`|String|The event name. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.cumulative_needs_attention_view.event_id`|String|A unique ID for that individual event. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_id`|String|A unique ID for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`metadata.cumulative_needs_attention_view.config_version`|Integer|The version number of the configuration.| -|`metadata.cumulative_needs_attention_view_err`|String|True indicates that the fetch of the needs attention items failed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.location`|String|The IBM Cloud location where a resource is deployed. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.resource_group`|String|The resource group where the project's data and tools are created. The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`.| -|`metadata.state`|String|The project status value. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`.| -|`metadata.event_notifications_crn`|String|The CRN of the event notifications instance if one is connected to this project. The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`.| - -### Import -{: #project-import} - -`ibm_project` can be imported by ID - -``` -$ terraform import ibm_project.example sample-id -``` - -## `ibm_project_config` -{: #project_config} - -Create, update, or delete an project_config. -{: shortdesc} - -### Sample Terraform code -{: #project_config-sample} - -``` -resource "ibm_project_config" "project_config" { - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." - labels = ["env:stage","governance:test","build:0"] - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" - name = "env-stage" - project_id = ibm_project.project_instance.id -} -``` - -### Input parameters -{: #project_config-input} - -Review the input parameters that you can specify for your resource. {: shortdesc} - -|Name|Data type|Required/optional|Description|Forces new resource| -|----|-----------|-------|----------|--------------------| -|`authorizations`|List|Optional|The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. You can specify one item in this list only.|No| -|`compliance_profile`|List|Optional|The profile required for compliance. You can specify one item in this list only.|No| -|`description`|String|Optional|The project configuration description. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.|No| -|`input`|List|Optional|The input values to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.|No| -|`labels`|List|Optional|A collection of configuration labels. The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items.|No| -|`locator_id`|String|Required|A dotted value of catalogID.versionID. The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`.|No| -|`name`|String|Required|The configuration name. The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`.|No| -|`project_id`|String|Required|The unique project ID. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.|Yes| -|`setting`|List|Optional|Schematics environment variables to use to deploy the configuration. The maximum length is `10000` items. The minimum length is `0` items.|No| - -### Output parameters -{: #project_config-output} - -Review the output parameters that you can access after your resource is created. {: shortdesc} - -|Name|Data type|Description| -|----|-----------|---------| -|`id`|String|The unique identifier of the project_config.| -|`output`|List|The outputs of a Schematics template property. The maximum length is `10000` items. The minimum length is `0` items.| -|`output.name`|String|The variable name. The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`.| -|`output.description`|String|A short explanation of the output value. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`.| -|`output.value`|String|Can be any value - a string, number, boolean, array, or object.| -|`project_config_id`|String|The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`.| -|`type`|String|The type of a project configuration manual property. Allowable values are: `terraform_template`, `schematics_blueprint`.| - -### Import -{: #project_config-import} - -`ibm_project_config` can be imported by ID - -``` -$ terraform import ibm_project_config.example sample-id -``` - From d93fb4e285499041d8fd41c6be1884d057108081 Mon Sep 17 00:00:00 2001 From: rangelil Date: Sun, 21 May 2023 14:34:46 +0200 Subject: [PATCH 042/125] terraform --- ibm/service/project/resource_ibm_project.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 176f704bad..f760faffe3 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -397,12 +397,6 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("resource_group", getProjectOptions.ResourceGroup); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) - } - if err = d.Set("location", getProjectOptions.Location); err != nil { - return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) - } if err = d.Set("name", project.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } From 044244cd6f3261059863290cdfabc7bd8ed04003 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 22 May 2023 11:34:43 +0200 Subject: [PATCH 043/125] terraform --- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 3 +- ibm/service/project/resource_ibm_project.go | 2 +- .../project/resource_ibm_project_config.go | 62 +------------------ 5 files changed, 6 insertions(+), 67 deletions(-) diff --git a/go.mod b/go.mod index 77448932a0..1cc735d455 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.11 + github.com/IBM/project-go-sdk v0.0.12 github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 5fd21772da..cf120be0b6 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.11 h1:0R7Z4njvDUwmrZcvKe/om55/N0fqa9VNRNdV2IMDFLE= -github.com/IBM/project-go-sdk v0.0.11/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.12 h1:87GV7KXP/V9EFJkxhx/DTi27Y3T8R723Us9cbCaOLZ4= +github.com/IBM/project-go-sdk v0.0.12/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index c4aa853269..666b81b7f3 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -12,7 +12,6 @@ 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/project-go-sdk/projectv1" ) @@ -566,7 +565,7 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati modelMap["config_id"] = model.ConfigID } if model.ConfigVersion != nil { - modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + modelMap["config_version"] = model.ConfigVersion } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index f760faffe3..1a0fff97c0 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -749,7 +749,7 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative modelMap["config_id"] = model.ConfigID } if model.ConfigVersion != nil { - modelMap["config_version"] = flex.IntValue(model.ConfigVersion) + modelMap["config_version"] = model.ConfigVersion } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 5a4b54df60..71c00c2af3 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -455,72 +455,12 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetProjectID(parts[0]) updateConfigOptions.SetID(parts[1]) - hasChange := false + hasChange := true 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") || d.HasChange("locator_id") { - updateConfigOptions.SetName(d.Get("name").(string)) - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true - } - if d.HasChange("labels") { - var labels []string - for _, v := range d.Get("labels").([]interface{}) { - labelsItem := v.(string) - labels = append(labels, labelsItem) - } - updateConfigOptions.SetLabels(labels) - hasChange = true - } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } - if d.HasChange("authorizations") { - authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetAuthorizations(authorizations) - hasChange = true - } - if d.HasChange("compliance_profile") { - complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetComplianceProfile(complianceProfile) - hasChange = true - } - if d.HasChange("input") { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) - } - updateConfigOptions.SetSetting(setting) - hasChange = true - } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) From 6d064686de90f71266267ff6be857f263a31d999 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 22 May 2023 16:44:29 +0200 Subject: [PATCH 044/125] terraform --- .../project/data_source_ibm_project_test.go | 8 +++---- ibm/service/project/resource_ibm_project.go | 24 ++++++++++--------- .../project/resource_ibm_project_config.go | 24 ++++++++++--------- .../project/resource_ibm_project_test.go | 8 +++---- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index cc93e840b3..dc8e37eae5 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,8 +14,8 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("default") + projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -35,8 +35,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("default") + projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) projectDestroyOnDelete := "false" diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 1a0fff97c0..2572d40ab7 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -410,19 +410,21 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - if !core.IsNil(project.Configs) { - configs := []map[string]interface{}{} - for _, configsItem := range project.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) - if err != nil { - return diag.FromErr(err) + /* + if !core.IsNil(project.Configs) { + configs := []map[string]interface{}{} + for _, configsItem := range project.Configs { + configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, configsItemMap) + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } - configs = append(configs, configsItemMap) - } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs: %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)) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 71c00c2af3..0ffefea625 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -388,19 +388,21 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if !core.IsNil(projectConfig.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfig.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) + /* + if !core.IsNil(projectConfig.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfig.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, inputItemMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - } + */ if !core.IsNil(projectConfig.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfig.Setting { diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 26a4d61b2b..2da5874b00 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -18,8 +18,8 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -42,8 +42,8 @@ func TestAccIbmProjectBasic(t *testing.T) { func TestAccIbmProjectAllArgs(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDelete := "false" From a7c4a105f260799cebcc6344dab6e404dd9e92d8 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 22 May 2023 18:41:18 +0200 Subject: [PATCH 045/125] terraform --- .../data_source_ibm_project_config_test.go | 33 ++++++---------- .../project/data_source_ibm_project_test.go | 17 ++------ ibm/service/project/resource_ibm_project.go | 36 ++++++++--------- .../project/resource_ibm_project_config.go | 30 +++++++------- .../resource_ibm_project_config_test.go | 39 +++++++------------ .../project/resource_ibm_project_test.go | 17 ++------ 6 files changed, 59 insertions(+), 113 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 65624a02c9..b74acd5068 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -15,7 +15,7 @@ import ( func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -38,7 +38,7 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -81,9 +81,9 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, projectConfigLocatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" + resource_group = "default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-1" } resource "ibm_project_config" "project_config_instance" { @@ -94,7 +94,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.config_id version = "version" } `, projectConfigName, projectConfigLocatorID) @@ -103,31 +103,20 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigLocatorID string, projectConfigDescription string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" + resource_group = "default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-2" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = "xxx" } input { name = "name" @@ -141,7 +130,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.config_id version = "version" } `, projectConfigName, projectConfigLocatorID, projectConfigDescription) diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index dc8e37eae5..b0cb0dfe0c 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -95,21 +95,10 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" + method = "API_KEY" + api_key = "xxx" } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { name = "name" value = "anything as a string" diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 2572d40ab7..b6dfd03b2d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -26,32 +26,28 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), - Description: "The resource group where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "name"), - Description: "The project name.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The project name.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "description"), - Description: "A project's descriptive text.", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "A project's descriptive text.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 0ffefea625..c8259bbb3e 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -28,23 +28,20 @@ func ResourceIbmProjectConfig() *schema.Resource { Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), - Description: "The unique project ID.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The configuration name.", + Type: schema.TypeString, + Required: true, + Description: "The configuration name.", }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), - Description: "A dotted value of catalogID.versionID.", + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -53,10 +50,9 @@ func ResourceIbmProjectConfig() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The project configuration description.", + Type: schema.TypeString, + Optional: true, + Description: "The project configuration description.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 51d5e9e77e..978e6ef181 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,9 +20,8 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -38,10 +37,10 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), + Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorID), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), ), }, }, @@ -51,10 +50,9 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -72,10 +70,10 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorIDUpdate, descriptionUpdate), + Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorID, descriptionUpdate), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), ), }, @@ -91,9 +89,9 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" + resource_group = "default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-3" } resource "ibm_project_config" "project_config_instance" { @@ -108,31 +106,20 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" + resource_group = "default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-4" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = "xxx" } input { name = "name" diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 2da5874b00..55a49c49e0 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -99,21 +99,10 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" + method = "API_KEY" + api_key = "xxx" } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" input { name = "name" value = "anything as a string" From 6645eb5332060c0f4bf55e77969ab36bde8723c6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 23 May 2023 12:34:00 +0200 Subject: [PATCH 046/125] add wait for create and delete --- .../data_source_ibm_project_config_test.go | 12 +-- .../project/data_source_ibm_project_test.go | 10 +-- ibm/service/project/resource_ibm_project.go | 80 ++++++++++++++++++ .../project/resource_ibm_project_config.go | 82 +++++++++++++++++++ .../resource_ibm_project_config_test.go | 8 +- .../project/resource_ibm_project_test.go | 6 +- 6 files changed, 180 insertions(+), 18 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index b74acd5068..392c76366f 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -15,7 +15,7 @@ import ( func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -38,7 +38,7 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -81,7 +81,7 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, projectConfigLocatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "default" + resource_group = "Default" location = "us-south" name = "acme-microservice-1" } @@ -94,7 +94,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.config_id + id = ibm_project_config.project_config_instance.project_config_id version = "version" } `, projectConfigName, projectConfigLocatorID) @@ -103,7 +103,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigLocatorID string, projectConfigDescription string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "default" + resource_group = "Default" location = "us-south" name = "acme-microservice-2" } @@ -130,7 +130,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.config_id + id = ibm_project_config.project_config_instance.project_config_id version = "version" } `, projectConfigName, projectConfigLocatorID, projectConfigDescription) diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index b0cb0dfe0c..4095f6d960 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,7 +14,7 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("default") + projectResourceGroup := fmt.Sprintf("Default") projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -35,7 +35,7 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("default") + projectResourceGroup := fmt.Sprintf("Default") projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) @@ -76,7 +76,7 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } `, projectResourceGroup, projectLocation, projectName) } @@ -98,7 +98,7 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project method = "API_KEY" api_key = "xxx" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" @@ -111,7 +111,7 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } `, projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index b6dfd03b2d..84d5709dd5 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -23,6 +25,10 @@ func ResourceIbmProject() *schema.Resource { ReadContext: resourceIbmProjectRead, DeleteContext: resourceIbmProjectDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ @@ -370,9 +376,46 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m d.SetId(*project.ID) + _, err = waitForProjectInstanceCreate(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectRead(context, d, meta) } +func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + return resp, "exists", nil + } else { + return resp, "not_exists", nil + } + } else { + return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -455,11 +498,48 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectInstanceDelete(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return resp, "not_exists", nil + } else { + return resp, "exists", nil + } + } else { + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index c8259bbb3e..6893f2bb73 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -25,6 +27,10 @@ func ResourceIbmProjectConfig() *schema.Resource { UpdateContext: resourceIbmProjectConfigUpdate, DeleteContext: resourceIbmProjectConfigDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ @@ -318,9 +324,47 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) + _, err = waitForProjectConfigCreate(d.Get("project_id").(string), context, d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create config instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectConfigRead(context, d, meta) } +func waitForProjectConfigCreate(projectID string, context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + configID := d.Id() + getConfigOptions := &projectv1.GetConfigOptions{} + getConfigOptions.SetProjectID(projectID) + getConfigOptions.SetID(configID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + return resp, "exists", nil + } else { + return resp, "not_exists", nil + } + } else { + return nil, "", fmt.Errorf("[ERROR] Get the config instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -493,11 +537,49 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectConfigDelete(d.Get("project_id").(string), context, d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete config instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectConfigDelete(projectID string, context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + configID := d.Id() + getConfigOptions := &projectv1.GetConfigOptions{} + getConfigOptions.SetProjectID(projectID) + getConfigOptions.SetID(configID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return resp, "not_exists", nil + } else { + return resp, "exists", nil + } + } else { + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 978e6ef181..527a0cd4e5 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,7 +20,7 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -50,7 +50,7 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global") + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) @@ -89,7 +89,7 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "default" + resource_group = "Default" location = "us-south" name = "acme-microservice-3" } @@ -106,7 +106,7 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "default" + resource_group = "Default" location = "us-south" name = "acme-microservice-4" } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 55a49c49e0..cebdb4be75 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -18,7 +18,7 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("default") + resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -42,7 +42,7 @@ func TestAccIbmProjectBasic(t *testing.T) { func TestAccIbmProjectAllArgs(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("default") + resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) @@ -102,7 +102,7 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st method = "API_KEY" api_key = "xxx" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" From f90911fa4825d38d1cb5dae0e683f4df4ca29599 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 23 May 2023 16:12:44 +0200 Subject: [PATCH 047/125] add wait for create and delete --- .../data_source_ibm_project_config_test.go | 4 +-- .../project/resource_ibm_project_config.go | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 392c76366f..10b2f36a6e 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -93,7 +93,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id + project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id version = "version" } @@ -129,7 +129,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id + project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id version = "version" } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 6893f2bb73..2f513a05aa 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -324,7 +324,7 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) - _, err = waitForProjectConfigCreate(d.Get("project_id").(string), context, d, meta) + _, err = waitForProjectConfigCreate(context, d, meta) if err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create config instance (%s) to be succeeded: %s", d.Id(), err)) } @@ -332,15 +332,17 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD return resourceIbmProjectConfigRead(context, d, meta) } -func waitForProjectConfigCreate(projectID string, context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { +func waitForProjectConfigCreate(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { return false, err } - configID := d.Id() + + parts, err := flex.SepIdParts(d.Id(), "/") getConfigOptions := &projectv1.GetConfigOptions{} - getConfigOptions.SetProjectID(projectID) - getConfigOptions.SetID(configID) + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + getConfigOptions.SetVersion("draft") // newly created config is in "draft" state, need to pass the version state stateConf := &resource.StateChangeConf{ Pending: []string{"not_exists"}, @@ -380,6 +382,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) + getConfigOptions.SetVersion(d.Get("version").(string)) + fmt.Printf("VERSIONE %s\n", d.Get("version").(string)) projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { @@ -537,7 +541,7 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) } - _, err = waitForProjectConfigDelete(d.Get("project_id").(string), context, d, meta) + _, err = waitForProjectConfigDelete(context, d, meta) if err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete config instance (%s) to be succeeded: %s", d.Id(), err)) } @@ -547,15 +551,16 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return nil } -func waitForProjectConfigDelete(projectID string, context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { +func waitForProjectConfigDelete(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { return false, err } - configID := d.Id() + + parts, err := flex.SepIdParts(d.Id(), "/") getConfigOptions := &projectv1.GetConfigOptions{} - getConfigOptions.SetProjectID(projectID) - getConfigOptions.SetID(configID) + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) stateConf := &resource.StateChangeConf{ Pending: []string{"exists"}, From 132a1917106d1a8a4ea8a97069020669f2a25efe Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 23 May 2023 16:32:01 +0200 Subject: [PATCH 048/125] . --- ibm/service/project/resource_ibm_project_config.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 2f513a05aa..7975ad9b5d 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -382,8 +382,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - getConfigOptions.SetVersion(d.Get("version").(string)) - fmt.Printf("VERSIONE %s\n", d.Get("version").(string)) projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { From fa3261b68604c0efdc07ac687e68028b5db9857c Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 23 May 2023 18:28:00 +0200 Subject: [PATCH 049/125] fix integration tests --- .../data_source_ibm_project_config_test.go | 2 -- .../project/data_source_ibm_project_test.go | 24 +++++---------- .../resource_ibm_project_config_test.go | 28 +++++++++-------- .../project/resource_ibm_project_test.go | 30 +++++++++++-------- 4 files changed, 39 insertions(+), 45 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 10b2f36a6e..9549994ba0 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -26,7 +26,6 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), @@ -50,7 +49,6 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 4095f6d960..9b3b638e1d 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -25,9 +25,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), ), }, }, @@ -48,19 +47,11 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectName), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "metadata.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), ), }, }, @@ -90,7 +81,6 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project description = "%s" destroy_on_delete = %s configs { - id = "id" name = "name" labels = [ "labels" ] description = "description" diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 527a0cd4e5..cfa70f42e7 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -31,16 +31,16 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, }, @@ -63,22 +63,22 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(name, locatorID, description), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorID, descriptionUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", descriptionUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config", + ResourceName: "ibm_project_config.project_config_instance", ImportState: true, ImportStateVerify: true, }, @@ -155,6 +155,7 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) r getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) + getConfigOptions.SetVersion("draft") projectConfig, _, err := projectClient.GetConfig(getConfigOptions) if err != nil { @@ -185,6 +186,7 @@ func testAccCheckIbmProjectConfigDestroy(s *terraform.State) error { getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) + getConfigOptions.SetVersion("draft") // Try to find the key _, response, err := projectClient.GetConfig(getConfigOptions) diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index cebdb4be75..0811190dd9 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -30,10 +30,10 @@ func TestAccIbmProjectBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location, name), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project", conf), - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project", "location", location), - resource.TestCheckResourceAttr("ibm_project.project", "name", name), + testAccCheckIbmProjectExists("ibm_project.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), ), }, }, @@ -46,7 +46,7 @@ func TestAccIbmProjectAllArgs(t *testing.T) { location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - destroyOnDelete := "false" + destroyOnDelete := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -56,18 +56,23 @@ func TestAccIbmProjectAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfig(resourceGroup, location, name, description, destroyOnDelete), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project", conf), - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project", "location", location), - resource.TestCheckResourceAttr("ibm_project.project", "name", name), - resource.TestCheckResourceAttr("ibm_project.project", "description", description), - resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDelete), + testAccCheckIbmProjectExists("ibm_project.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project.project_instance", "description", description), + resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDelete), ), }, resource.TestStep{ - ResourceName: "ibm_project.project", + ResourceName: "ibm_project.project_instance", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "location", + "resource_group", + "configs", + }, }, }, }) @@ -94,7 +99,6 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st description = "%s" destroy_on_delete = %s configs { - id = "id" name = "name" labels = [ "labels" ] description = "description" From 91241babeb4a58f6f57fc6c3c3761c02f1aebfdc Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 24 May 2023 09:21:19 +0200 Subject: [PATCH 050/125] fix integration tests --- .../data_source_ibm_project_config_test.go | 53 ++++++++----------- .../project/data_source_ibm_project_test.go | 6 +-- .../project/resource_ibm_project_config.go | 5 ++ 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 9549994ba0..fac1c34853 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -24,11 +24,11 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName, projectConfigLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "name", projectConfigName), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "locator_id", projectConfigLocatorID), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), ), }, }, @@ -47,29 +47,22 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigLocatorID, projectConfigDescription), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.required"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigName), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), ), }, }, @@ -93,7 +86,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id - version = "version" + version = "draft" } `, projectConfigName, projectConfigLocatorID) } @@ -129,7 +122,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id - version = "version" + version = "draft" } `, projectConfigName, projectConfigLocatorID, projectConfigDescription) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 9b3b638e1d..026b095e9a 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -26,7 +26,7 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttr("data.ibm_project.project_instance", "name", projectName), ), }, }, @@ -48,8 +48,8 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), + resource.TestCheckResourceAttr("data.ibm_project.project_instance", "name", projectName), + resource.TestCheckResourceAttr("data.ibm_project.project_instance", "description", projectDescription), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), ), diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 7975ad9b5d..d572f74ebd 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -382,6 +382,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) + if _, ok := d.GetOk("version"); ok { + getConfigOptions.SetVersion(d.Get("version").(string)) + } else { + getConfigOptions.SetVersion("draft") + } projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { From dec0e69748a04d4039a59a8e1eb4012b880d41c6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 24 May 2023 15:21:50 +0200 Subject: [PATCH 051/125] fix integration tests --- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 3 +- .../project/resource_ibm_project_config.go | 104 ++++++++++++++---- .../resource_ibm_project_config_test.go | 63 ++++++----- 5 files changed, 125 insertions(+), 51 deletions(-) diff --git a/go.mod b/go.mod index 1cc735d455..9c839b2f2a 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.12 + github.com/IBM/project-go-sdk v0.0.13 github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index cf120be0b6..745509e403 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.12 h1:87GV7KXP/V9EFJkxhx/DTi27Y3T8R723Us9cbCaOLZ4= -github.com/IBM/project-go-sdk v0.0.12/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.13 h1:hDu6Xc4REG0Ht8DABkE94gG203rMwDrFH00oNwWaS1o= +github.com/IBM/project-go-sdk v0.0.13/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 666b81b7f3..c4aa853269 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -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/project-go-sdk/projectv1" ) @@ -565,7 +566,7 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati modelMap["config_id"] = model.ConfigID } if model.ConfigVersion != nil { - modelMap["config_version"] = model.ConfigVersion + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index d572f74ebd..3a60f3a3be 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -388,7 +388,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetVersion("draft") } - projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfigGetResponse, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -401,24 +401,24 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("project_id", getConfigOptions.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if err = d.Set("name", projectConfig.Name); err != nil { + if err = d.Set("name", projectConfigGetResponse.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + if err = d.Set("locator_id", projectConfigGetResponse.LocatorID); err != nil { return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) } - if !core.IsNil(projectConfig.Labels) { - if err = d.Set("labels", projectConfig.Labels); err != nil { + if !core.IsNil(projectConfigGetResponse.Labels) { + if err = d.Set("labels", projectConfigGetResponse.Labels); err != nil { return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) } } - if !core.IsNil(projectConfig.Description) { - if err = d.Set("description", projectConfig.Description); err != nil { + if !core.IsNil(projectConfigGetResponse.Description) { + if err = d.Set("description", projectConfigGetResponse.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(projectConfig.Authorizations) { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) + if !core.IsNil(projectConfigGetResponse.Authorizations) { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigGetResponse.Authorizations) if err != nil { return diag.FromErr(err) } @@ -426,8 +426,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting authorizations: %s", err)) } } - if !core.IsNil(projectConfig.ComplianceProfile) { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) + if !core.IsNil(projectConfigGetResponse.ComplianceProfile) { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigGetResponse.ComplianceProfile) if err != nil { return diag.FromErr(err) } @@ -436,9 +436,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat } } /* - if !core.IsNil(projectConfig.Input) { + if !core.IsNil(projectConfigGetResponse.Input) { input := []map[string]interface{}{} - for _, inputItem := range projectConfig.Input { + for _, inputItem := range projectConfigGetResponse.Input { inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return diag.FromErr(err) @@ -450,9 +450,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat } } */ - if !core.IsNil(projectConfig.Setting) { + if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} - for _, settingItem := range projectConfig.Setting { + for _, settingItem := range projectConfigGetResponse.Setting { settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return diag.FromErr(err) @@ -463,12 +463,12 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } - if err = d.Set("type", projectConfig.Type); err != nil { + if err = d.Set("type", projectConfigGetResponse.Type); err != nil { return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } - if !core.IsNil(projectConfig.Output) { + if !core.IsNil(projectConfigGetResponse.Output) { output := []map[string]interface{}{} - for _, outputItem := range projectConfig.Output { + for _, outputItem := range projectConfigGetResponse.Output { outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) if err != nil { return diag.FromErr(err) @@ -479,8 +479,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfig.ID) { - if err = d.Set("project_config_id", projectConfig.ID); err != nil { + if !core.IsNil(projectConfigGetResponse.ID) { + if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } } @@ -504,12 +504,74 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetProjectID(parts[0]) updateConfigOptions.SetID(parts[1]) - hasChange := true + hasChange := false 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") || d.HasChange("locator_id") { + updateConfigOptions.SetName(d.Get("name").(string)) + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + hasChange = true + } + if d.HasChange("labels") { + var labels []string + for _, v := range d.Get("labels").([]interface{}) { + labelsItem := v.(string) + labels = append(labels, labelsItem) + } + updateConfigOptions.SetLabels(labels) + hasChange = true + } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } + if d.HasChange("authorizations") { + authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetAuthorizations(authorizations) + hasChange = true + } + if d.HasChange("compliance_profile") { + complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetComplianceProfile(complianceProfile) + hasChange = true + } + if d.HasChange("input") { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } + */ if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index cfa70f42e7..9b3f14341a 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,8 +20,9 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -31,16 +32,16 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorID), + Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), ), }, }, @@ -50,9 +51,10 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -63,22 +65,22 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(name, locatorID, description), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorID, descriptionUpdate), + Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorIDUpdate, descriptionUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config_instance", + ResourceName: "ibm_project_config.project_config", ImportState: true, ImportStateVerify: true, }, @@ -91,7 +93,7 @@ func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) stri resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-3" + name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { @@ -108,18 +110,29 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-4" + name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = [ "labels" ] + labels = "FIXME" description = "%s" authorizations { - method = "API_KEY" - api_key = "xxx" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } input { name = "name" @@ -155,14 +168,13 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) r getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - getConfigOptions.SetVersion("draft") - projectConfig, _, err := projectClient.GetConfig(getConfigOptions) + projectConfigGetResponse, _, err := projectClient.GetConfig(getConfigOptions) if err != nil { return err } - obj = *projectConfig + obj = *projectConfigGetResponse return nil } } @@ -186,7 +198,6 @@ func testAccCheckIbmProjectConfigDestroy(s *terraform.State) error { getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - getConfigOptions.SetVersion("draft") // Try to find the key _, response, err := projectClient.GetConfig(getConfigOptions) From becaad94b6b4e534bb8231cedb9a6d1ab142824e Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 24 May 2023 16:59:03 +0200 Subject: [PATCH 052/125] fix integration tests --- .../resource_ibm_project_config_test.go | 66 ++++++++----------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 9b3f14341a..2720da6136 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,9 +20,8 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -32,16 +31,16 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), + Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, }, @@ -51,11 +50,9 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -65,22 +62,22 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(name, locatorID, description), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorIDUpdate, descriptionUpdate), + Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorID, description), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config", + ResourceName: "ibm_project_config.project_config_instance", ImportState: true, ImportStateVerify: true, }, @@ -117,23 +114,12 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = "FIXME" - description = "%s" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } + labels = [ "labels" ] + description = "%s" + authorizations { + method = "API_KEY" + api_key = "xxx" + } input { name = "name" value = "anything as a string" @@ -168,13 +154,15 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) r getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) + getConfigOptions.SetVersion("draft") - projectConfigGetResponse, _, err := projectClient.GetConfig(getConfigOptions) + _, response, err := projectClient.GetConfig(getConfigOptions) if err != nil { return err + } else if response.StatusCode != 200 { + return fmt.Errorf("Error checking for project_config (%s) exists: %s", rs.Primary.ID, err) } - obj = *projectConfigGetResponse return nil } } From f62cac80674910f7b0dfcca8f1c63e62131ae997 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 24 May 2023 18:07:55 +0200 Subject: [PATCH 053/125] fix integration tests --- ibm/service/project/resource_ibm_project.go | 4 ++-- ibm/service/project/resource_ibm_project_config.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 84d5709dd5..498272b3c8 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -449,7 +449,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - /* + if !core.IsNil(project.Configs) { configs := []map[string]interface{}{} for _, configsItem := range project.Configs { @@ -463,7 +463,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %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)) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 3a60f3a3be..ddd402f3e0 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -435,7 +435,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - /* + if !core.IsNil(projectConfigGetResponse.Input) { input := []map[string]interface{}{} for _, inputItem := range projectConfigGetResponse.Input { @@ -449,7 +449,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } - */ + if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -510,7 +510,7 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD 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") || d.HasChange("locator_id") { updateConfigOptions.SetName(d.Get("name").(string)) updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) From e0f9746eba2372c95fa0a4f3a45f65b059582f26 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 25 May 2023 11:58:30 +0200 Subject: [PATCH 054/125] regenerate --- ibm/service/project/data_source_ibm_project.go | 9 --------- .../data_source_ibm_project_config_test.go | 4 ++-- ibm/service/project/resource_ibm_project.go | 17 ++++------------- .../project/resource_ibm_project_config.go | 6 +++--- .../project/resource_ibm_project_config_test.go | 4 ++-- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index c4aa853269..801a829a46 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -41,11 +41,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -339,10 +334,6 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } - if err = d.Set("crn", project.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) - } - configs := []map[string]interface{}{} if project.Configs != nil { for _, modelItem := range project.Configs { diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index fac1c34853..44b7c7dc9c 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -84,7 +84,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id + project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id version = "draft" } @@ -120,7 +120,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id + project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id version = "draft" } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 498272b3c8..0ae90787c4 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -14,6 +14,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-Cloud/terraform-provider-ibm/ibm/validate" "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/project-go-sdk/projectv1" @@ -211,11 +212,6 @@ func ResourceIbmProject() *schema.Resource { }, }, }, - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, "metadata": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -449,7 +445,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - + /* if !core.IsNil(project.Configs) { configs := []map[string]interface{}{} for _, configsItem := range project.Configs { @@ -463,12 +459,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %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)) - } - } + */ if !core.IsNil(project.Metadata) { metadataMap, err := resourceIbmProjectProjectMetadataToMap(project.Metadata) if err != nil { @@ -827,7 +818,7 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative modelMap["config_id"] = model.ConfigID } if model.ConfigVersion != nil { - modelMap["config_version"] = model.ConfigVersion + modelMap["config_version"] = flex.IntValue(model.ConfigVersion) } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index ddd402f3e0..3a60f3a3be 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -435,7 +435,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - + /* if !core.IsNil(projectConfigGetResponse.Input) { input := []map[string]interface{}{} for _, inputItem := range projectConfigGetResponse.Input { @@ -449,7 +449,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } - + */ if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -510,7 +510,7 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD 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") || d.HasChange("locator_id") { updateConfigOptions.SetName(d.Get("name").(string)) updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 2720da6136..5a1f9c4967 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -90,7 +90,7 @@ func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) stri resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-3" } resource "ibm_project_config" "project_config_instance" { @@ -107,7 +107,7 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice" + name = "acme-microservice-4" } resource "ibm_project_config" "project_config_instance" { From dcba935759419d6608ac0d1b1e293cda11641617 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 26 May 2023 12:13:11 +0200 Subject: [PATCH 055/125] new code generation --- examples/ibm-project/README.md | 2 - examples/ibm-project/main.tf | 30 -- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 349 +----------------- .../project/data_source_ibm_project_config.go | 59 +++ .../project/data_source_ibm_project_test.go | 18 - ibm/service/project/resource_ibm_project.go | 196 +--------- .../project/resource_ibm_project_config.go | 183 +++++---- .../resource_ibm_project_config_test.go | 6 +- .../project/resource_ibm_project_test.go | 24 +- website/docs/d/project.html.markdown | 73 +--- website/docs/d/project_config.html.markdown | 10 + website/docs/r/project.html.markdown | 86 +---- website/docs/r/project_config.html.markdown | 9 + 15 files changed, 221 insertions(+), 830 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 90d692656f..d020178a21 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -31,7 +31,6 @@ resource "project" "project_instance" { name = var.project_name description = var.project_description destroy_on_delete = var.project_destroy_on_delete - configs = var.project_configs } ``` project_config resource: @@ -99,7 +98,6 @@ data "project_config" "project_config_instance" { | name | The project name. | `string` | true | | description | A project's descriptive text. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | -| configs | The project configurations. | `list()` | false | | project_id | The unique project ID. | `string` | true | | name | The configuration name. | `string` | true | | locator_id | A dotted value of catalogID.versionID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index a26f29d3b4..3d85aa0edd 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -9,36 +9,6 @@ resource "ibm_project" "project_instance" { name = var.project_name description = var.project_description destroy_on_delete = var.project_destroy_on_delete - configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } } // Provision project_config resource instance diff --git a/go.mod b/go.mod index 9c839b2f2a..f30fe71f96 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.13 + github.com/IBM/project-go-sdk v0.0.13-beta github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 745509e403..19ab937194 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.13 h1:hDu6Xc4REG0Ht8DABkE94gG203rMwDrFH00oNwWaS1o= -github.com/IBM/project-go-sdk v0.0.13/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.13-beta h1:kUmLVhCBWS0py/2W0o4QSP6Xx0PVMXZSW8oW3e0HXJE= +github.com/IBM/project-go-sdk v0.0.13-beta/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 801a829a46..a754dd3e93 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -41,192 +41,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, - "configs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The project configurations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The configuration name.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project configuration description.", - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable type.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the variable is required or not.", - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - }, - }, - }, "metadata": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -257,12 +71,12 @@ func DataSourceIbmProject() *schema.Resource { "event_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A unique ID for that individual event.", + Description: "The unique ID of a project.", }, "config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A unique ID for the configuration.", + Description: "The unique ID of a project.", }, "config_version": &schema.Schema{ Type: schema.TypeInt, @@ -334,20 +148,6 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } - configs := []map[string]interface{}{} - if project.Configs != nil { - for _, modelItem := range project.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, modelMap) - } - } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) - } - metadata := []map[string]interface{}{} if project.Metadata != nil { modelMap, err := dataSourceIbmProjectProjectMetadataToMap(project.Metadata) @@ -363,151 +163,6 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return nil } -func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID - modelMap["type"] = model.Type - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) - if err != nil { - return modelMap, err - } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} - } - if model.Method != nil { - modelMap["method"] = model.Method - } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID - } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation - } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID - } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName - } - return modelMap, nil -} - -func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["type"] = model.Type - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Required != nil { - modelMap["required"] = model.Required - } - return modelMap, nil -} - -func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value - return modelMap, nil -} - func dataSourceIbmProjectProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Crn != nil { diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index eecf7f2154..2a9c28273c 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -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/project-go-sdk/projectv1" ) @@ -213,6 +214,35 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration draft.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "project_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration.", + }, + }, + }, + }, }, } } @@ -325,6 +355,18 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) } + metadata := []map[string]interface{}{} + if projectConfig.Metadata != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) + } + if err = d.Set("metadata", metadata); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + } + return nil } @@ -408,3 +450,20 @@ func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projec modelMap["value"] = model.Value return modelMap, nil } + +func dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(model *projectv1.ProjectConfigDraftMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 026b095e9a..6ba68dc4a8 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -80,24 +80,6 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project name = "%s" description = "%s" destroy_on_delete = %s - configs { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - method = "API_KEY" - api_key = "xxx" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } } data "ibm_project" "project_instance" { diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 0ae90787c4..e0defbe9f5 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -63,155 +63,6 @@ func ResourceIbmProject() *schema.Resource { ForceNew: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, - "configs": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: "The project configurations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The configuration name.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The project configuration description.", - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The input values to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - }, - }, - }, "metadata": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -242,12 +93,12 @@ func ResourceIbmProject() *schema.Resource { "event_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A unique ID for that individual event.", + Description: "The unique ID of a project.", }, "config_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A unique ID for the configuration.", + Description: "The unique ID of a project.", }, "config_version": &schema.Schema{ Type: schema.TypeInt, @@ -351,18 +202,6 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m if _, ok := d.GetOk("destroy_on_delete"); ok { createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } - if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigPrototype - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) - } - createProjectOptions.SetConfigs(configs) - } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { @@ -422,7 +261,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met getProjectOptions.SetID(d.Id()) - project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + projectSummary, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -432,36 +271,21 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("name", project.Name); err != nil { + if err = d.Set("name", projectSummary.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if !core.IsNil(project.Description) { - if err = d.Set("description", project.Description); err != nil { + if !core.IsNil(projectSummary.Description) { + if err = d.Set("description", projectSummary.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(project.DestroyOnDelete) { - if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + if !core.IsNil(projectSummary.DestroyOnDelete) { + if err = d.Set("destroy_on_delete", projectSummary.DestroyOnDelete); err != nil { return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - /* - if !core.IsNil(project.Configs) { - configs := []map[string]interface{}{} - for _, configsItem := range project.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, configsItemMap) - } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) - } - } - */ - if !core.IsNil(project.Metadata) { - metadataMap, err := resourceIbmProjectProjectMetadataToMap(project.Metadata) + if !core.IsNil(projectSummary.Metadata) { + metadataMap, err := resourceIbmProjectProjectMetadataToMap(projectSummary.Metadata) if err != nil { return diag.FromErr(err) } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 3a60f3a3be..694be13b53 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -202,6 +202,35 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, + "metadata": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration draft.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "project_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The pipeline state of the configuration.", + }, + }, + }, + }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -316,13 +345,13 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions.SetSetting(setting) } - projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) + projectConfigGetResponse, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { log.Printf("[DEBUG] CreateConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("CreateConfigWithContext failed %s\n%s", err, response)) } - d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) + d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfigGetResponse.ID)) _, err = waitForProjectConfigCreate(context, d, meta) if err != nil { @@ -435,21 +464,19 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - /* - if !core.IsNil(projectConfigGetResponse.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigGetResponse.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + if !core.IsNil(projectConfigGetResponse.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfigGetResponse.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) } + input = append(input, inputItemMap) } - */ + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + } + } if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -479,6 +506,15 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } + if !core.IsNil(projectConfigGetResponse.Metadata) { + metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } + } if !core.IsNil(projectConfigGetResponse.ID) { if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) @@ -510,68 +546,66 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD 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") || d.HasChange("locator_id") { - updateConfigOptions.SetName(d.Get("name").(string)) - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true + if d.HasChange("name") || d.HasChange("locator_id") { + updateConfigOptions.SetName(d.Get("name").(string)) + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + hasChange = true + } + if d.HasChange("labels") { + var labels []string + for _, v := range d.Get("labels").([]interface{}) { + labelsItem := v.(string) + labels = append(labels, labelsItem) } - if d.HasChange("labels") { - var labels []string - for _, v := range d.Get("labels").([]interface{}) { - labelsItem := v.(string) - labels = append(labels, labelsItem) - } - updateConfigOptions.SetLabels(labels) - hasChange = true + updateConfigOptions.SetLabels(labels) + hasChange = true + } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } + if d.HasChange("authorizations") { + authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) - hasChange = true + updateConfigOptions.SetAuthorizations(authorizations) + hasChange = true + } + if d.HasChange("compliance_profile") { + complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - if d.HasChange("authorizations") { - authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) + updateConfigOptions.SetComplianceProfile(complianceProfile) + hasChange = true + } + if d.HasChange("input") { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) if err != nil { return diag.FromErr(err) } - updateConfigOptions.SetAuthorizations(authorizations) - hasChange = true + input = append(input, *inputItem) } - if d.HasChange("compliance_profile") { - complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) if err != nil { return diag.FromErr(err) } - updateConfigOptions.SetComplianceProfile(complianceProfile) - hasChange = true - } - if d.HasChange("input") { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) - } - updateConfigOptions.SetSetting(setting) - hasChange = true + setting = append(setting, *settingItem) } - */ + updateConfigOptions.SetSetting(setting) + hasChange = true + } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) @@ -791,3 +825,20 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map } return modelMap, nil } + +func resourceIbmProjectConfigProjectConfigDraftMetadataToMap(model *projectv1.ProjectConfigDraftMetadata) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 5a1f9c4967..4039ca5d7e 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -18,7 +18,7 @@ import ( ) func TestAccIbmProjectConfigBasic(t *testing.T) { - var conf projectv1.ProjectConfig + var conf projectv1.ProjectConfigDraft name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -48,7 +48,7 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { } func TestAccIbmProjectConfigAllArgs(t *testing.T) { - var conf projectv1.ProjectConfig + var conf projectv1.ProjectConfigDraft name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) @@ -132,7 +132,7 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti `, name, locatorID, description) } -func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDraft) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 0811190dd9..60397bffd9 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -17,7 +17,7 @@ import ( ) func TestAccIbmProjectBasic(t *testing.T) { - var conf projectv1.Project + var conf projectv1.ProjectSummary resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -41,7 +41,7 @@ func TestAccIbmProjectBasic(t *testing.T) { } func TestAccIbmProjectAllArgs(t *testing.T) { - var conf projectv1.Project + var conf projectv1.ProjectSummary resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -98,29 +98,11 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st name = "%s" description = "%s" destroy_on_delete = %s - configs { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - method = "API_KEY" - api_key = "xxx" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } } `, resourceGroup, location, name, description, destroyOnDelete) } -func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { +func testAccCheckIbmProjectExists(n string, obj projectv1.ProjectSummary) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 78d2e39ae4..e35d4f0cdd 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -29,74 +29,7 @@ Review the argument reference that you can specify for your data source. In addition to all argument references listed, you can access the following attribute references after your data source is created. -* `id` - The unique identifier of the Project definition. -* `configs` - (List) The project configurations. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **configs**: - * `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested scheme for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested scheme for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Boolean) Whether the variable is required or not. - * `type` - (String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The configuration name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - -* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - +* `id` - The unique identifier of the project. * `description` - (String) A project descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -111,12 +44,12 @@ Nested scheme for **metadata**: * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) A unique ID for the configuration. + * `config_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) A unique ID for that individual event. + * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index d3c253f25e..1bbc013388 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -80,6 +80,16 @@ Nested scheme for **input**: * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. +* `metadata` - (List) The project configuration draft. +Nested scheme for **metadata**: + * `pipeline_state` - (String) The pipeline state of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(PIPELINE_RUNNING|PIPELINE_FAILED|PIPELINE_SUCCEEDED)$/`. + * `project_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `state` - (String) The state of the configuration draft. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(DISCARDED|MERGED|ACTIVE)$/`. + * `version` - (Integer) The version number of the configuration. + * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 1cb7be4a90..843163b47b 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,36 +14,6 @@ Provides a resource for project. This allows project to be created, updated and ```hcl resource "ibm_project" "project_instance" { - configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" name = "acme-microservice" @@ -55,56 +25,6 @@ resource "ibm_project" "project_instance" { Review the argument reference that you can specify for your resource. -* `configs` - (Optional, Forces new resource, List) The project configurations. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **configs**: - * `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested scheme for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested scheme for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (Optional, String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The input values to use to deploy the configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Required, String) The configuration name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `description` - (Optional, Forces new resource, String) A project's descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Optional, Forces new resource, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. @@ -121,8 +41,6 @@ Nested scheme for **configs**: In addition to all argument references listed, you can access the following attribute references after your resource is created. * `id` - The unique identifier of the project. -* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `metadata` - (List) The metadata of the project. Nested scheme for **metadata**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -131,12 +49,12 @@ Nested scheme for **metadata**: * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) A unique ID for the configuration. + * `config_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) A unique ID for that individual event. + * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 83e75c27a9..74dabc72f6 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -101,6 +101,15 @@ Nested scheme for **setting**: In addition to all argument references listed, you can access the following attribute references after your resource is created. * `id` - The unique identifier of the project_config. +* `metadata` - (List) The project configuration draft. +Nested scheme for **metadata**: + * `pipeline_state` - (String) The pipeline state of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(PIPELINE_RUNNING|PIPELINE_FAILED|PIPELINE_SUCCEEDED)$/`. + * `project_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `state` - (String) The state of the configuration draft. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(DISCARDED|MERGED|ACTIVE)$/`. + * `version` - (Integer) The version number of the configuration. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **output**: From 5440927c5ae8b9ac42a7f988250095dd40a2f616 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 29 May 2023 16:32:23 +0200 Subject: [PATCH 056/125] new generated code --- examples/ibm-project/README.md | 4 +- examples/ibm-project/main.tf | 30 ++ go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 331 ++++++++++++++++++ .../project/data_source_ibm_project_config.go | 15 +- .../project/data_source_ibm_project_test.go | 19 +- ibm/service/project/resource_ibm_project.go | 161 +++++++++ .../project/resource_ibm_project_config.go | 49 ++- .../resource_ibm_project_config_test.go | 1 - .../project/resource_ibm_project_test.go | 19 + website/docs/d/project.html.markdown | 64 ++++ website/docs/d/project_config.html.markdown | 2 +- website/docs/r/project.html.markdown | 80 +++++ website/docs/r/project_config.html.markdown | 2 +- 15 files changed, 743 insertions(+), 40 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index d020178a21..425692543e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -31,6 +31,7 @@ resource "project" "project_instance" { name = var.project_name description = var.project_description destroy_on_delete = var.project_destroy_on_delete + configs = var.project_configs } ``` project_config resource: @@ -98,6 +99,7 @@ data "project_config" "project_config_instance" { | name | The project name. | `string` | true | | description | A project's descriptive text. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | +| configs | The project configurations. | `list()` | false | | project_id | The unique project ID. | `string` | true | | name | The configuration name. | `string` | true | | locator_id | A dotted value of catalogID.versionID. | `string` | true | @@ -105,7 +107,7 @@ data "project_config" "project_config_instance" { | description | The project configuration description. | `string` | false | | authorizations | The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | -| input | The input values to use to deploy the configuration. | `list()` | false | +| input | The inputs of a Schematics template property. | `list()` | false | | setting | Schematics environment variables to use to deploy the configuration. | `list()` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 3d85aa0edd..a26f29d3b4 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -9,6 +9,36 @@ resource "ibm_project" "project_instance" { name = var.project_name description = var.project_description destroy_on_delete = var.project_destroy_on_delete + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } } // Provision project_config resource instance diff --git a/go.mod b/go.mod index f30fe71f96..ed3b371e1a 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.13-beta + github.com/IBM/project-go-sdk v0.0.15-beta github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 19ab937194..893542b64c 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.13-beta h1:kUmLVhCBWS0py/2W0o4QSP6Xx0PVMXZSW8oW3e0HXJE= -github.com/IBM/project-go-sdk v0.0.13-beta/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.15-beta h1:bttFsK1P9kvpPDbcJ5+ut0MQXkJrfQjFSb2PTPihcMM= +github.com/IBM/project-go-sdk v0.0.15-beta/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index a754dd3e93..2ffeb19c4a 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -114,6 +114,192 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable type.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Whether the variable is required or not.", + }, + }, + }, + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + }, + }, + }, }, } } @@ -216,3 +402,148 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati } return modelMap, nil } + +func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + modelMap["type"] = model.Type + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["type"] = model.Type + if model.Value != nil { + modelMap["value"] = model.Value + } + if model.Required != nil { + modelMap["required"] = model.Required + } + return modelMap, nil +} + +func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 2a9c28273c..a9cd72f429 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -34,7 +34,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { "version": &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "active", Description: "The version of the configuration to return.", }, "project_config_id": &schema.Schema{ @@ -356,13 +355,15 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD } metadata := []map[string]interface{}{} - if projectConfig.Metadata != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) - if err != nil { - return diag.FromErr(err) + /* + if projectConfig.Metadata != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) } - metadata = append(metadata, modelMap) - } + */ if err = d.Set("metadata", metadata); err != nil { return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 6ba68dc4a8..53f627f6f5 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -51,7 +51,6 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_project.project_instance", "name", projectName), resource.TestCheckResourceAttr("data.ibm_project.project_instance", "description", projectDescription), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), ), }, }, @@ -80,6 +79,24 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project name = "%s" description = "%s" destroy_on_delete = %s + configs { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + method = "API_KEY" + api_key = "xxx" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } } data "ibm_project" "project_instance" { diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index e0defbe9f5..d2b2ff39a2 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -63,6 +63,155 @@ func ResourceIbmProject() *schema.Resource { ForceNew: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "The project configurations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The configuration name.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The project configuration description.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + }, + }, + }, "metadata": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -202,6 +351,18 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m if _, ok := d.GetOk("destroy_on_delete"); ok { createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } + if _, ok := d.GetOk("configs"); ok { + var configs []projectv1.ProjectConfigPrototype + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + createProjectOptions.SetConfigs(configs) + } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 694be13b53..7f468302ba 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -138,7 +138,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The input values to use to deploy the configuration.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -411,11 +411,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - if _, ok := d.GetOk("version"); ok { - getConfigOptions.SetVersion(d.Get("version").(string)) - } else { - getConfigOptions.SetVersion("draft") - } projectConfigGetResponse, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { @@ -464,19 +459,21 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if !core.IsNil(projectConfigGetResponse.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigGetResponse.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) + /* + if !core.IsNil(projectConfigGetResponse.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfigGetResponse.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, inputItemMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - } + */ if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -506,15 +503,17 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfigGetResponse.Metadata) { - metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + /* + if !core.IsNil(projectConfigGetResponse.Metadata) { + metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } } - } + */ if !core.IsNil(projectConfigGetResponse.ID) { if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 4039ca5d7e..441fa6377d 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -154,7 +154,6 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDra getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - getConfigOptions.SetVersion("draft") _, response, err := projectClient.GetConfig(getConfigOptions) if err != nil { diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 60397bffd9..759d34739f 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -98,6 +98,25 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st name = "%s" description = "%s" destroy_on_delete = %s + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + method = "API_KEY" + api_key = "xxx" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } } `, resourceGroup, location, name, description, destroyOnDelete) } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index e35d4f0cdd..7fb38263ea 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -30,6 +30,70 @@ Review the argument reference that you can specify for your data source. In addition to all argument references listed, you can access the following attribute references after your data source is created. * `id` - The unique identifier of the project. +* `configs` - (List) The project configurations. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **configs**: + * `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested scheme for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested scheme for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `input` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `required` - (Boolean) Whether the variable is required or not. + * `type` - (String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `description` - (String) A project descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 1bbc013388..b33ac07b18 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -28,7 +28,7 @@ Review the argument reference that you can specify for your data source. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `version` - (Optional, String) The version of the configuration to return. - * Constraints: The default value is `active`. The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`. + * Constraints: The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`. ## Attribute Reference diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 843163b47b..fefb31c123 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,6 +14,36 @@ Provides a resource for project. This allows project to be created, updated and ```hcl resource "ibm_project" "project_instance" { + configs { + id = "id" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" name = "acme-microservice" @@ -25,6 +55,56 @@ resource "ibm_project" "project_instance" { Review the argument reference that you can specify for your resource. +* `configs` - (Optional, Forces new resource, List) The project configurations. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested scheme for **configs**: + * `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested scheme for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested scheme for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (Optional, List) The profile required for compliance. + Nested scheme for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (Optional, String) The project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (Required, String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested scheme for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `description` - (Optional, Forces new resource, String) A project's descriptive text. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Optional, Forces new resource, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 74dabc72f6..552800014b 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -74,7 +74,7 @@ Nested scheme for **compliance_profile**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The input values to use to deploy the configuration. +* `input` - (Optional, List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested scheme for **input**: * `name` - (Required, String) The variable name. From a65b190a7629f09857021f4c4d65d1c6a39858cf Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 30 May 2023 10:55:41 +0200 Subject: [PATCH 057/125] point to latest sdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ed3b371e1a..798d8f246e 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.40.0 github.com/IBM/platform-services-go-sdk v0.37.3 + github.com/IBM/project-go-sdk v0.0.16 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 @@ -58,7 +59,6 @@ require ( require ( github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/project-go-sdk v0.0.15-beta github.com/pkg/errors v0.9.1 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 893542b64c..41e67008cf 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.15-beta h1:bttFsK1P9kvpPDbcJ5+ut0MQXkJrfQjFSb2PTPihcMM= -github.com/IBM/project-go-sdk v0.0.15-beta/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.16 h1:LfiRnBGrkcqkwFYki8WNdSL5wIPHWHowXQm+igLoZH8= +github.com/IBM/project-go-sdk v0.0.16/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= From d9f91acd60a8de502641f8eb269426b6320cd361 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 30 May 2023 10:57:56 +0200 Subject: [PATCH 058/125] point to latest sdk --- .../project/data_source_ibm_project_config.go | 16 +++---- .../project/resource_ibm_project_config.go | 46 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index a9cd72f429..9c28d54e5f 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -355,15 +355,15 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD } metadata := []map[string]interface{}{} - /* - if projectConfig.Metadata != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) - if err != nil { - return diag.FromErr(err) - } - metadata = append(metadata, modelMap) + + if projectConfig.Metadata != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) + if err != nil { + return diag.FromErr(err) } - */ + metadata = append(metadata, modelMap) + } + if err = d.Set("metadata", metadata); err != nil { return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 7f468302ba..dfd02f5fd7 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -459,21 +459,21 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - /* - if !core.IsNil(projectConfigGetResponse.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigGetResponse.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + + if !core.IsNil(projectConfigGetResponse.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfigGetResponse.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) } + input = append(input, inputItemMap) } - */ + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + } + } + if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -503,17 +503,17 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - /* - if !core.IsNil(projectConfigGetResponse.Metadata) { - metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) - } + + if !core.IsNil(projectConfigGetResponse.Metadata) { + metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) } - */ + } + if !core.IsNil(projectConfigGetResponse.ID) { if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) From eacfccac76b173d9ae0b95f68906d69a657f7ff3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 30 May 2023 19:32:56 +0200 Subject: [PATCH 059/125] adjust test cases and doc --- examples/ibm-project/README.md | 2 +- examples/ibm-project/main.tf | 39 +++++----------- .../project/data_source_ibm_project_config.go | 24 +++++----- .../data_source_ibm_project_config_test.go | 9 ++-- .../project/data_source_ibm_project_test.go | 19 ++++---- .../project/resource_ibm_project_config.go | 46 +++++++++---------- .../resource_ibm_project_config_test.go | 17 ++++--- .../project/resource_ibm_project_test.go | 26 +++++------ website/docs/d/project_config.html.markdown | 2 +- website/docs/r/project.html.markdown | 36 ++++++--------- website/docs/r/project_config.html.markdown | 28 ++++------- 11 files changed, 106 insertions(+), 142 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 425692543e..921d8b1c2e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -64,7 +64,7 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id version = var.project_config_version } ``` diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index a26f29d3b4..72a0d53151 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -15,28 +15,16 @@ resource "ibm_project" "project_instance" { labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = "api_key_value" } locator_id = "locator_id" input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } } @@ -50,26 +38,23 @@ resource "ibm_project_config" "project_config_instance" { description = var.project_config_description authorizations { trusted_profile { - id = "id" - target_iam_id = "target_iam_id" + id = "Profile-047ef95f-2f90-4276-8ba3-92512cc4a6ae" } - method = "method" - api_key = "api_key" + method = "TRUSTED_PROFILE" } compliance_profile { - id = "id" + id = "compliance_profile_id" instance_id = "instance_id" instance_location = "instance_location" attachment_id = "attachment_id" profile_name = "profile_name" } input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } @@ -81,6 +66,6 @@ data "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id version = var.project_config_version } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 9c28d54e5f..38b0028fb5 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -354,20 +354,20 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) } - metadata := []map[string]interface{}{} - - if projectConfig.Metadata != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) - if err != nil { - return diag.FromErr(err) + /* + metadata := []map[string]interface{}{} + if projectConfig.Metadata != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) } - metadata = append(metadata, modelMap) - } - - if err = d.Set("metadata", metadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) - } + if err = d.Set("metadata", metadata); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + } + */ return nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 44b7c7dc9c..ec3da3a6ff 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -103,19 +103,18 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = [ "labels" ] + labels = [ "env:staging" ] description = "%s" authorizations { method = "API_KEY" api_key = "xxx" } input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 53f627f6f5..a1b5854335 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -80,22 +80,21 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project description = "%s" destroy_on_delete = %s configs { - name = "name" - labels = [ "labels" ] - description = "description" + name = "static-website-dev" + labels = [ "env:staging" ] + description = "static-website-dev description" authorizations { method = "API_KEY" api_key = "xxx" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } + name = "app_repo_name" + } + setting { + name = "app_repo_name" + value = "static-website-dev-app-repo" + } } } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index dfd02f5fd7..7f468302ba 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -459,21 +459,21 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - - if !core.IsNil(projectConfigGetResponse.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigGetResponse.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) + /* + if !core.IsNil(projectConfigGetResponse.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfigGetResponse.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, inputItemMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } - } - + */ if !core.IsNil(projectConfigGetResponse.Setting) { setting := []map[string]interface{}{} for _, settingItem := range projectConfigGetResponse.Setting { @@ -503,17 +503,17 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - - if !core.IsNil(projectConfigGetResponse.Metadata) { - metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + /* + if !core.IsNil(projectConfigGetResponse.Metadata) { + metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + } } - } - + */ if !core.IsNil(projectConfigGetResponse.ID) { if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 441fa6377d..7b40ca312e 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -114,20 +114,19 @@ func testAccCheckIbmProjectConfigConfig(name string, locatorID string, descripti project_id = ibm_project.project_instance.id name = "%s" locator_id = "%s" - labels = [ "labels" ] + labels = [ "env:staging" ] description = "%s" authorizations { method = "API_KEY" api_key = "xxx" } - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } + input { + name = "app_repo_name" + } + setting { + name = "app_repo_name" + value = "static-website-dev-app-repo" + } } `, name, locatorID, description) } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 759d34739f..e65f572ca4 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -99,23 +99,21 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st description = "%s" destroy_on_delete = %s configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { + name = "static-website-dev" + labels = [ "env:staging" ] + description = "static-website-dev description" + authorizations { method = "API_KEY" api_key = "xxx" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + input { + name = "app_repo_name" + } + setting { + name = "app_repo_name" + value = "static-website-dev-app-repo" + } } } `, resourceGroup, location, name, description, destroyOnDelete) diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index b33ac07b18..1b517e87eb 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source for project_config. You can then reference the ```hcl data "ibm_project_config" "project_config" { - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id project_id = ibm_project_config.project_config.project_id } ``` diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index fefb31c123..346ae8f7d0 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,40 +14,34 @@ Provides a resource for project. This allows project to be created, updated and ```hcl resource "ibm_project" "project_instance" { + name = "acme-microservice" + description = "A microservice to deploy on top of ACME infrastructure." + location = "us-south" + resource_group = "Default" configs { - id = "id" - name = "name" - labels = [ "labels" ] - description = "description" + name = "config-stage" + labels = [ "env:stage" ] + description = "config-stage description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" + method = "API_EKY" + api_key = "api_key_value" } compliance_profile { - id = "id" + id = "compliance_profile_id" instance_id = "instance_id" instance_location = "instance_location" attachment_id = "attachment_id" profile_name = "profile_name" } - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } setting { - name = "name" - value = "value" - } + name = "app_repo_name" + value = "static-website-dev-app-repo" + } } - description = "A microservice to deploy on top of ACME infrastructure." - location = "us-south" - name = "acme-microservice" - resource_group = "Default" } ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 552800014b..b38420b493 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -14,32 +14,22 @@ Provides a resource for project_config. This allows project_config to be created ```hcl resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id + name = "env-stage" + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" authorizations { + method = "TRUSTED_PROFILE" trusted_profile { - id = "id" - target_iam_id = "target_iam_id" + id = "Profile-047ef95f-2f90-4276-8ba3-92512cc4a6ae" } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" } - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." input { - name = "name" - value = "anything as a string" + name = "app_repo_name" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" - name = "env-stage" - project_id = ibm_project.project_instance.id setting { - name = "name" - value = "value" + name = "app_repo_name" + value = "static-website-dev-app-repo" } } ``` From 7e9e7c69d3196e9979381282b377e40bbd9c3b63 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 31 May 2023 16:52:58 +0200 Subject: [PATCH 060/125] adjust samples --- examples/ibm-project/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 8aafdadb6d..098ba487d4 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -44,7 +44,7 @@ variable "project_config_name" { variable "project_config_locator_id" { description = "A dotted value of catalogID.versionID." type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } variable "project_config_labels" { description = "A collection of configuration labels." @@ -78,5 +78,5 @@ variable "project_config_id" { variable "project_config_version" { description = "The version of the configuration to return." type = string - default = "placeholder" + default = "draft" } From 1298edca3311def65693d6f09f401d9715091e81 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 6 Jun 2023 09:23:39 +0200 Subject: [PATCH 061/125] update to latest node sdk --- examples/ibm-project/README.md | 2 -- examples/ibm-project/main.tf | 1 - examples/ibm-project/variables.tf | 5 --- go.mod | 2 +- go.sum | 4 +-- .../project/data_source_ibm_project_config.go | 33 +++++++------------ .../data_source_ibm_project_config_test.go | 3 -- .../project/resource_ibm_project_config.go | 1 - website/docs/d/project_config.html.markdown | 4 +-- website/docs/r/project.html.markdown | 2 +- website/docs/r/project_config.html.markdown | 2 +- 11 files changed, 18 insertions(+), 41 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 921d8b1c2e..6512e31119 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -65,7 +65,6 @@ project_config data source: data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id - version = var.project_config_version } ``` @@ -112,7 +111,6 @@ data "project_config" "project_config_instance" { | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | -| version | The version of the configuration to return. | `string` | false | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 72a0d53151..cd1312b629 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -67,5 +67,4 @@ data "ibm_project" "project_instance" { data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id id = ibm_project_config.project_config_instance.project_config_id - version = var.project_config_version } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 098ba487d4..20dfac2a61 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -75,8 +75,3 @@ variable "project_config_id" { type = string default = "id" } -variable "project_config_version" { - description = "The version of the configuration to return." - type = string - default = "draft" -} diff --git a/go.mod b/go.mod index 9301a2fbd4..a64bba67f0 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.40.0 github.com/IBM/platform-services-go-sdk v0.37.3 - github.com/IBM/project-go-sdk v0.0.16 + github.com/IBM/project-go-sdk v0.0.17 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 1a19b50f13..4808772d21 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.37.3 h1:xPJ7M6F+Qmd+4IOMn2eM/UHy2Y1iHB2jRBrKynJA7QE= github.com/IBM/platform-services-go-sdk v0.37.3/go.mod h1:oFW/DQyAXGBcGytB+DtKjE3yNdEGM2bmw5SDOjrRwTw= -github.com/IBM/project-go-sdk v0.0.16 h1:LfiRnBGrkcqkwFYki8WNdSL5wIPHWHowXQm+igLoZH8= -github.com/IBM/project-go-sdk v0.0.16/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.17 h1:s9d/YQjLjtepYCtP3mIaFwpnX4CqJd3i63eZqnU0IKc= +github.com/IBM/project-go-sdk v0.0.17/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 38b0028fb5..473e5279e8 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -31,11 +31,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the configuration to return.", - }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -256,9 +251,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD getConfigOptions.SetProjectID(d.Get("project_id").(string)) getConfigOptions.SetID(d.Get("id").(string)) - if _, ok := d.GetOk("version"); ok { - getConfigOptions.SetVersion(d.Get("version").(string)) - } projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { @@ -353,21 +345,20 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD if err = d.Set("setting", setting); err != nil { return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) } - /* - metadata := []map[string]interface{}{} - if projectConfig.Metadata != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) - if err != nil { - return diag.FromErr(err) - } - metadata = append(metadata, modelMap) - } - - if err = d.Set("metadata", metadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) - } + metadata := []map[string]interface{}{} + if projectConfig.Metadata != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) + if err != nil { + return diag.FromErr(err) + } + metadata = append(metadata, modelMap) + } + if err = d.Set("metadata", metadata); err != nil { + return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + } */ + return nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index ec3da3a6ff..3c1626d178 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -49,7 +49,6 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), @@ -86,7 +85,6 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id - version = "draft" } `, projectConfigName, projectConfigLocatorID) } @@ -121,7 +119,6 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id - version = "draft" } `, projectConfigName, projectConfigLocatorID, projectConfigDescription) } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 7f468302ba..70b1a21702 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -371,7 +371,6 @@ func waitForProjectConfigCreate(context context.Context, d *schema.ResourceData, getConfigOptions := &projectv1.GetConfigOptions{} getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - getConfigOptions.SetVersion("draft") // newly created config is in "draft" state, need to pass the version state stateConf := &resource.StateChangeConf{ Pending: []string{"not_exists"}, diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 1b517e87eb..9bba051693 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -27,8 +27,6 @@ Review the argument reference that you can specify for your data source. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `version` - (Optional, String) The version of the configuration to return. - * Constraints: The maximum length is `10` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(active|draft|\\d+)$/`. ## Attribute Reference @@ -59,7 +57,7 @@ Nested scheme for **compliance_profile**: * `instance_location` - (String) The location of the compliance instance. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 346ae8f7d0..ab3e3928ca 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -75,7 +75,7 @@ Nested scheme for **configs**: * `instance_location` - (Optional, String) The location of the compliance instance. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index b38420b493..0150603b57 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -61,7 +61,7 @@ Nested scheme for **compliance_profile**: * `instance_location` - (Optional, String) The location of the compliance instance. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `input` - (Optional, List) The inputs of a Schematics template property. From 388f702eff412cfb96cad3c8465282836be13d64 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 15 Jun 2023 14:37:30 +0200 Subject: [PATCH 062/125] merge with master --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index f194bbbff0..080e1d3dba 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.40.0 h1:NdHTG0YXtN2D/B62BRgy6iJRFLdiJtSFCdTz github.com/IBM/networking-go-sdk v0.40.0/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8= -github.com/IBM/project-go-sdk v0.0.10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.17 h1:s9d/YQjLjtepYCtP3mIaFwpnX4CqJd3i63eZqnU0IKc= +github.com/IBM/project-go-sdk v0.0.17/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= From e5fb11415c0536717f2c2e8dfb2c5dea55d8fb72 Mon Sep 17 00:00:00 2001 From: knee-na <130502432+knee-na@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:25:09 -0400 Subject: [PATCH 063/125] Update project_instance.html.markdown Fixing formatting issues --- website/docs/r/project_instance.html.markdown | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/website/docs/r/project_instance.html.markdown b/website/docs/r/project_instance.html.markdown index 71fc66d409..5193113914 100644 --- a/website/docs/r/project_instance.html.markdown +++ b/website/docs/r/project_instance.html.markdown @@ -70,9 +70,9 @@ Nested scheme for **configs**: * `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `name` - (Required, String) The project name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]+$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. ## Attribute Reference @@ -83,7 +83,7 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `metadata` - (List) The metadata of the project. Nested scheme for **metadata**: - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format `YYYY-MM-DDTHH:mm:ssZ` or `YYYY-MM-DDTHH:mm:ss.sssZ`, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. @@ -93,17 +93,17 @@ Nested scheme for **metadata**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `cumulative_needs_attention_view_err` - (String) `True` indicates that the fetch of the needs attention items failed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `location` - (String) The IBM Cloud location where a resource is deployed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `resource_group` - (String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. From 0a855f622ac2cacea576638a2f54bde491dcbf8d Mon Sep 17 00:00:00 2001 From: knee-na <130502432+knee-na@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:28:54 -0400 Subject: [PATCH 064/125] Update project_event_notification.html.markdown --- .../d/project_event_notification.html.markdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index 689ce78b89..0859c0bf1d 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -78,7 +78,7 @@ Nested scheme for **configs**: * `metadata` - (List) The metadata of the project. Nested scheme for **metadata**: - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format `YYYY-MM-DDTHH:mm:ssZ` or `YYYY-MM-DDTHH:mm:ss.sssZ`, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. @@ -88,20 +88,20 @@ Nested scheme for **metadata**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `config_version` - (Integer) The version number of the configuration. * `event` - (String) The event name. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `event_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) \"True\" indicates that the fetch of the needs attention items failed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `cumulative_needs_attention_view_err` - (String) `True` indicates that the fetch of the needs attention items failed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `location` - (String) The IBM Cloud location where a resource is deployed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `resource_group` - (String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]*$/`. * `state` - (String) The project status value. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. * `name` - (String) The project name. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"<>{}\\x00-\\x1F]+$/`. From 4a79f6a3c895c2fd2f80503a96d3e8a491dc46a0 Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Wed, 12 Jul 2023 10:32:37 +0200 Subject: [PATCH 065/125] Update README.md --- examples/ibm-project/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index e68dff870a..010899110e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -39,7 +39,7 @@ project_event_notification data source: ```hcl data "project_event_notification" "project_event_notification_instance" { - project_id = var.project_event_notification_id + id = var.project_event_notification_id } ``` From bd549b163c0119a61f52ff455a4db27e8ef964d2 Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Wed, 12 Jul 2023 10:33:09 +0200 Subject: [PATCH 066/125] Update variables.tf --- examples/ibm-project/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 77f31eace5..240c070647 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -29,5 +29,5 @@ variable "project_instance_location" { variable "project_event_notification_id" { description = "The unique project ID." type = string - default = "project_id" + default = "id" } From bea919d342e7bab6cae004f138dc885f1c1fead9 Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Wed, 12 Jul 2023 10:36:00 +0200 Subject: [PATCH 067/125] Update project_event_notification.html.markdown --- website/docs/d/project_event_notification.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/project_event_notification.html.markdown b/website/docs/d/project_event_notification.html.markdown index 0859c0bf1d..6818a34bc8 100644 --- a/website/docs/d/project_event_notification.html.markdown +++ b/website/docs/d/project_event_notification.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source for Project definition. You can then reference ```hcl data "ibm_project_event_notification" "project_event_notification" { - project_id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" + id = "072b70cb-4db7-4c5c-bf1b-8d93d422537d" } ``` @@ -22,7 +22,7 @@ data "ibm_project_event_notification" "project_event_notification" { Review the argument reference that you can specify for your data source. -* `project_id` - (Required, Forces new resource, String) The unique project ID. +* `id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. ## Attribute Reference From 36239653b48c77cfb49c159b9f10e80d96c944c5 Mon Sep 17 00:00:00 2001 From: rangelil Date: Sun, 16 Jul 2023 19:14:14 +0200 Subject: [PATCH 068/125] new version --- examples/ibm-project/README.md | 28 +- examples/ibm-project/main.tf | 53 +- examples/ibm-project/outputs.tf | 8 +- examples/ibm-project/variables.tf | 18 +- examples/ibm-project/versions.tf | 8 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 240 +++--- .../project/data_source_ibm_project_config.go | 583 ++++++++++++- .../data_source_ibm_project_config_test.go | 121 ++- .../project/data_source_ibm_project_test.go | 98 ++- ibm/service/project/resource_ibm_project.go | 444 +++++----- .../project/resource_ibm_project_config.go | 796 +++++++++++++----- .../resource_ibm_project_config_test.go | 99 ++- .../project/resource_ibm_project_test.go | 121 ++- website/docs/d/project.html.markdown | 98 +-- website/docs/d/project_config.html.markdown | 114 ++- website/docs/r/project.html.markdown | 144 ++-- website/docs/r/project_config.html.markdown | 130 ++- 19 files changed, 2162 insertions(+), 947 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 6512e31119..a517fcd279 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -2,14 +2,14 @@ This example illustrates how to use the ProjectV1 -These types of resources are supported: +The following types of resources are supported: * project * project_config ## Usage -To run this example you need to execute: +To run this example, execute the following commands: ```bash $ terraform init @@ -40,17 +40,17 @@ project_config resource: resource "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - locator_id = var.project_config_locator_id labels = var.project_config_labels description = var.project_config_description authorizations = var.project_config_authorizations compliance_profile = var.project_config_compliance_profile + locator_id = var.project_config_locator_id input = var.project_config_input setting = var.project_config_setting } ``` -## ProjectV1 Data sources +## ProjectV1 data sources project data source: @@ -64,7 +64,7 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + id = ibm_project_config.project_config_instance.projectConfig_id } ``` @@ -95,19 +95,19 @@ data "project_config" "project_config_instance" { | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| name | The project name. | `string` | true | -| description | A project's descriptive text. | `string` | false | +| name | The name of the project. | `string` | true | +| description | A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | -| configs | The project configurations. | `list()` | false | +| configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | `list()` | false | | project_id | The unique project ID. | `string` | true | -| name | The configuration name. | `string` | true | -| locator_id | A dotted value of catalogID.versionID. | `string` | true | +| name | The name of the configuration. | `string` | true | | labels | A collection of configuration labels. | `list(string)` | false | -| description | The project configuration description. | `string` | false | -| authorizations | The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | +| description | The description of the project configuration. | `string` | false | +| authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | -| input | The inputs of a Schematics template property. | `list()` | false | -| setting | Schematics environment variables to use to deploy the configuration. | `list()` | false | +| locator_id | A dotted value of catalogID.versionID. | `string` | true | +| input | The outputs of a Schematics template property. | `list()` | false | +| setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index cd1312b629..dd8f821939 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -10,22 +10,42 @@ resource "ibm_project" "project_instance" { description = var.project_description destroy_on_delete = var.project_destroy_on_delete configs { - id = "id" name = "name" labels = [ "labels" ] description = "description" authorizations { - method = "API_KEY" - api_key = "api_key_value" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } locator_id = "locator_id" + type = "terraform_template" input { - name = "app_repo_name" + name = "name" + type = "array" + value = "anything as a string" + required = true + } + output { + name = "name" + description = "description" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } + id = "id" } } @@ -33,28 +53,33 @@ resource "ibm_project" "project_instance" { resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - locator_id = var.project_config_locator_id labels = var.project_config_labels description = var.project_config_description authorizations { trusted_profile { - id = "Profile-047ef95f-2f90-4276-8ba3-92512cc4a6ae" + id = "id" + target_iam_id = "target_iam_id" } - method = "TRUSTED_PROFILE" + method = "method" + api_key = "api_key" } compliance_profile { - id = "compliance_profile_id" + id = "id" instance_id = "instance_id" instance_location = "instance_location" attachment_id = "attachment_id" profile_name = "profile_name" } + locator_id = var.project_config_locator_id input { - name = "app_repo_name" + name = "name" + type = "array" + value = "anything as a string" + required = true } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } @@ -66,5 +91,5 @@ data "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + id = ibm_project_config.project_config_instance.projectConfig_id } diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 4a20a363b6..2ab29c7f63 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -1,11 +1,11 @@ -// This allows project data to be referenced by other resources and the terraform CLI -// Modify this if only certain data should be exposed +// This output allows project data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed output "ibm_project" { value = ibm_project.project_instance description = "project resource instance" } -// This allows project_config data to be referenced by other resources and the terraform CLI -// Modify this if only certain data should be exposed +// This output allows project_config data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed output "ibm_project_config" { value = ibm_project_config.project_config_instance description = "project_config resource instance" diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 20dfac2a61..1e2a97e4d3 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -15,12 +15,12 @@ variable "project_location" { default = "us-south" } variable "project_name" { - description = "The project name." + description = "The name of the project." type = string default = "acme-microservice" } variable "project_description" { - description = "A project's descriptive text." + description = "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description." type = string default = "A microservice to deploy on top of ACME infrastructure." } @@ -37,25 +37,25 @@ variable "project_config_project_id" { default = "project_id" } variable "project_config_name" { - description = "The configuration name." + description = "The name of the configuration." type = string default = "env-stage" } -variable "project_config_locator_id" { - description = "A dotted value of catalogID.versionID." - type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" -} variable "project_config_labels" { description = "A collection of configuration labels." type = list(string) default = ["env:stage","governance:test","build:0"] } variable "project_config_description" { - description = "The project configuration description." + description = "The description of the project configuration." type = string default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." } +variable "project_config_locator_id" { + description = "A dotted value of catalogID.versionID." + type = string + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" +} // Data source arguments for project variable "project_id" { diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index d9b6f790b9..54c9d03e8d 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,3 +1,9 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 1.0" + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + version = "1.52.0-beta0" + } + } } diff --git a/go.mod b/go.mod index eeffb51d86..a955de5fcd 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.1 github.com/IBM/platform-services-go-sdk v0.38.1 - github.com/IBM/project-go-sdk v0.0.17 + github.com/IBM/project-go-sdk v0.0.26-7 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index f2fc4bbaac..adc0147ebe 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.42.1 h1:79ktSkNGsPS7zxJoVVKxPpQZCLdD3u+MHOqC github.com/IBM/networking-go-sdk v0.42.1/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.17 h1:s9d/YQjLjtepYCtP3mIaFwpnX4CqJd3i63eZqnU0IKc= -github.com/IBM/project-go-sdk v0.0.17/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-7 h1:E3eGopxrzCL/irgebNziwcl0FESKjBg6a7NHocUu228= +github.com/IBM/project-go-sdk v0.0.26-7/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 2ffeb19c4a..f685228800 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -26,109 +26,95 @@ func DataSourceIbmProject() *schema.Resource { Required: true, Description: "The unique project ID.", }, - "name": &schema.Schema{ + "crn": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The project name.", + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, - "description": &schema.Schema{ + "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A project descriptive text.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "metadata": &schema.Schema{ + "cumulative_needs_attention_view": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The metadata of the project.", + Description: "The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "crn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cumulative_needs_attention_view": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cumulative list of needs attention items for a project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "event": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The event name.", - }, - "event_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "config_version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - }, - }, - }, - "cumulative_needs_attention_view_err": &schema.Schema{ + "event": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "True indicates that the fetch of the needs attention items failed.", + Description: "The event name.", }, - "location": &schema.Schema{ + "event_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The IBM Cloud location where a resource is deployed.", + Description: "A unique ID for that individual event.", }, - "resource_group": &schema.Schema{ + "config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The resource group where the project's data and tools are created.", + Description: "A unique ID for the configuration.", }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The project status value.", - }, - "event_notifications_crn": &schema.Schema{ - Type: schema.TypeString, + "config_version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "The CRN of the event notifications instance if one is connected to this project.", + Description: "The version number of the configuration.", }, }, }, }, + "cumulative_needs_attention_view_error": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud location where a resource is deployed.", + }, + "resource_group": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The resource group where the project's data and tools are created.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the project.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configurations.", + Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The configuration name.", + Description: "The name of the configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -141,12 +127,12 @@ func DataSourceIbmProject() *schema.Resource { "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The project configuration description.", + Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "trusted_profile": &schema.Schema{ @@ -281,7 +267,7 @@ func DataSourceIbmProject() *schema.Resource { "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -297,6 +283,11 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, }, }, }, @@ -322,68 +313,75 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) - if err = d.Set("name", project.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if err = d.Set("description", project.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - - if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { - return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) + if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - metadata := []map[string]interface{}{} - if project.Metadata != nil { - modelMap, err := dataSourceIbmProjectProjectMetadataToMap(project.Metadata) - if err != nil { - return diag.FromErr(err) + cumulativeNeedsAttentionView := []map[string]interface{}{} + if project.CumulativeNeedsAttentionView != nil { + for _, modelItem := range project.CumulativeNeedsAttentionView { + modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, modelMap) } - metadata = append(metadata, modelMap) } - if err = d.Set("metadata", metadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) + if err = d.Set("cumulative_needs_attention_view", cumulativeNeedsAttentionView); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view %s", err)) } - return nil -} + if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) + } -func dataSourceIbmProjectProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Crn != nil { - modelMap["crn"] = model.Crn + if err = d.Set("location", project.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() + + if err = d.Set("resource_group", project.ResourceGroup); err != nil { + return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if model.CumulativeNeedsAttentionView != nil { - cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { - cumulativeNeedsAttentionViewItemMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) - if err != nil { - return modelMap, err - } - cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) - } - modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView + + if err = d.Set("state", project.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if model.CumulativeNeedsAttentionViewErr != nil { - modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr + + if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } - if model.Location != nil { - modelMap["location"] = model.Location + + if err = d.Set("name", project.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", project.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } - if model.ResourceGroup != nil { - modelMap["resource_group"] = model.ResourceGroup + + if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } - if model.State != nil { - modelMap["state"] = model.State + + configs := []map[string]interface{}{} + if project.Configs != nil { + for _, modelItem := range project.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, modelMap) + } } - if model.EventNotificationsCrn != nil { - modelMap["event_notifications_crn"] = model.EventNotificationsCrn + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) } - return modelMap, nil + + return nil } func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { @@ -405,9 +403,6 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } modelMap["name"] = model.Name if model.Labels != nil { modelMap["labels"] = model.Labels @@ -464,6 +459,7 @@ func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map } modelMap["setting"] = setting } + modelMap["id"] = model.ID return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 473e5279e8..ebe315ef98 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -31,15 +32,10 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, - "project_config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The configuration name.", + Description: "The name of the configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -52,12 +48,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The project configuration description.", + Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "trusted_profile": &schema.Schema{ @@ -192,7 +188,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -208,31 +204,310 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, - "metadata": &schema.Schema{ + "project_config_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration draft.", + Description: "The last approved metadata of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The unique ID of a project.", }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "The version of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration draft.", + Description: "The currency of the cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The pipeline state of the configuration.", + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_deployment_job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, @@ -260,10 +535,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) - if err = d.Set("project_config_id", projectConfig.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) - } - if err = d.Set("name", projectConfig.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } @@ -345,19 +616,106 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD if err = d.Set("setting", setting); err != nil { return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) } - /* - metadata := []map[string]interface{}{} - if projectConfig.Metadata != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfig.Metadata) - if err != nil { - return diag.FromErr(err) - } - metadata = append(metadata, modelMap) - } - if err = d.Set("metadata", metadata); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata %s", err)) - } - */ + + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + } + + if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + } + + if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) + } + + if err = d.Set("needs_attention_state", projectConfig.NeedsAttentionState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) + } + + if err = d.Set("state", projectConfig.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + + if err = d.Set("pipeline_state", projectConfig.PipelineState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) + } + + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } + + if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } + + if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + } + + lastApproved := []map[string]interface{}{} + if projectConfig.LastApproved != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) + if err != nil { + return diag.FromErr(err) + } + lastApproved = append(lastApproved, modelMap) + } + if err = d.Set("last_approved", lastApproved); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_approved %s", err)) + } + + if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + } + + jobSummary := []map[string]interface{}{} + if projectConfig.JobSummary != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.JobSummary) + if err != nil { + return diag.FromErr(err) + } + jobSummary = append(jobSummary, modelMap) + } + if err = d.Set("job_summary", jobSummary); err != nil { + return diag.FromErr(fmt.Errorf("Error setting job_summary %s", err)) + } + + craLogs := []map[string]interface{}{} + if projectConfig.CraLogs != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfig.CraLogs) + if err != nil { + return diag.FromErr(err) + } + craLogs = append(craLogs, modelMap) + } + if err = d.Set("cra_logs", craLogs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) + } + + costEstimate := []map[string]interface{}{} + if projectConfig.CostEstimate != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfig.CostEstimate) + if err != nil { + return diag.FromErr(err) + } + costEstimate = append(costEstimate, modelMap) + } + if err = d.Set("cost_estimate", costEstimate); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) + } + + lastDeploymentJobSummary := []map[string]interface{}{} + if projectConfig.LastDeploymentJobSummary != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.LastDeploymentJobSummary) + if err != nil { + return diag.FromErr(err) + } + lastDeploymentJobSummary = append(lastDeploymentJobSummary, modelMap) + } + if err = d.Set("last_deployment_job_summary", lastDeploymentJobSummary); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_deployment_job_summary %s", err)) + } return nil } @@ -443,19 +801,158 @@ func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projec return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigDraftMetadataToMap(model *projectv1.ProjectConfigDraftMetadata) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost } - if model.State != nil { - modelMap["state"] = model.State + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 3c1626d178..8ee7a31dc9 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -15,7 +15,7 @@ import ( func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -24,11 +24,19 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName, projectConfigLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "name", projectConfigName), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "locator_id", projectConfigLocatorID), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), ), }, }, @@ -37,31 +45,54 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigLocatorID, projectConfigDescription), + Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigDescription, projectConfigLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.required"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigName), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "pipeline_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_approved.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_save"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "job_summary.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "cra_logs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "cost_estimate.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_deployment_job_summary.#"), ), }, }, @@ -73,7 +104,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-1" + name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { @@ -83,42 +114,56 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfig_id } `, projectConfigName, projectConfigLocatorID) } -func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigLocatorID string, projectConfigDescription string) string { +func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigDescription string, projectConfigLocatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-2" + name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - locator_id = "%s" - labels = [ "env:staging" ] + labels = "FIXME" description = "%s" authorizations { - method = "API_KEY" - api_key = "xxx" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } + locator_id = "%s" input { - name = "app_repo_name" + name = "name" + type = "array" + value = "anything as a string" + required = true } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfig_id } - `, projectConfigName, projectConfigLocatorID, projectConfigDescription) + `, projectConfigName, projectConfigDescription, projectConfigLocatorID) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index a1b5854335..56c3a44e14 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,8 +14,8 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -25,8 +25,16 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttr("data.ibm_project.project_instance", "name", projectName), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), ), }, }, @@ -34,8 +42,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) projectDestroyOnDelete := "false" @@ -47,10 +55,29 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttr("data.ibm_project.project_instance", "name", projectName), - resource.TestCheckResourceAttr("data.ibm_project.project_instance", "description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_version"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view_error"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "event_notifications_crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectName), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectDescription), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), ), }, }, @@ -66,7 +93,7 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.project_id } `, projectResourceGroup, projectLocation, projectName) } @@ -80,26 +107,47 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project description = "%s" destroy_on_delete = %s configs { - name = "static-website-dev" - labels = [ "env:staging" ] - description = "static-website-dev description" + name = "name" + labels = [ "labels" ] + description = "description" authorizations { - method = "API_KEY" - api_key = "xxx" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + type = "terraform_template" input { - name = "app_repo_name" - } - setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } + name = "name" + type = "array" + value = "anything as a string" + required = true + } + output { + name = "name" + description = "description" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + id = "id" } } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.project_id } `, projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index d2b2ff39a2..dc45d08d04 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -7,10 +7,8 @@ import ( "context" "fmt" "log" - "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -24,61 +22,51 @@ func ResourceIbmProject() *schema.Resource { return &schema.Resource{ CreateContext: resourceIbmProjectCreate, ReadContext: resourceIbmProjectRead, + UpdateContext: resourceIbmProjectUpdate, DeleteContext: resourceIbmProjectDelete, Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The resource group where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The location where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "location"), + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The project name.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "A project's descriptive text.", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, Optional: true, Default: true, - ForceNew: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, "configs": &schema.Schema{ Type: schema.TypeList, Optional: true, - ForceNew: true, - Description: "The project configurations.", + Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The configuration name.", + Description: "The name of the configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -89,13 +77,14 @@ func ResourceIbmProject() *schema.Resource { "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The project configuration description.", + Default: "", + Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "trusted_profile": &schema.Schema{ @@ -171,10 +160,15 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "A dotted value of catalogID.versionID.", }, + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The type of a project configuration manual property.", + }, "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -182,109 +176,129 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The variable name.", }, + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable type.", + }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "Can be any value - a string, number, boolean, array, or object.", }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "Whether the variable is required or not.", + }, }, }, }, - "setting": &schema.Schema{ + "output": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The name of the configuration setting.", + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", }, "value": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - }, - }, - }, - "metadata": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The metadata of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "crn": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "An IBM Cloud resource name, which uniquely identifies a resource.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cumulative_needs_attention_view": &schema.Schema{ + "setting": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The cumulative list of needs attention items for a project.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "event": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The event name.", - }, - "event_id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", + Required: true, + Description: "The name of the configuration setting.", }, - "config_id": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "config_version": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Description: "The version number of the configuration.", + Required: true, + Description: "The value of the configuration setting.", }, }, }, }, - "cumulative_needs_attention_view_err": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "True indicates that the fetch of the needs attention items failed.", + Required: true, + Description: "The unique ID of a project.", }, - "location": &schema.Schema{ + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "cumulative_needs_attention_view": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The IBM Cloud location where a resource is deployed.", + Description: "The event name.", }, - "resource_group": &schema.Schema{ + "event_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The resource group where the project's data and tools are created.", + Description: "A unique ID for that individual event.", }, - "state": &schema.Schema{ + "config_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The project status value.", + Description: "A unique ID for the configuration.", }, - "event_notifications_crn": &schema.Schema{ - Type: schema.TypeString, + "config_version": &schema.Schema{ + Type: schema.TypeInt, Optional: true, - Description: "The CRN of the event notifications instance if one is connected to this project.", + Description: "The version number of the configuration.", }, }, }, }, + "cumulative_needs_attention_view_error": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The project status value.", + }, + "event_notifications_crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The CRN of the event notifications instance if one is connected to this project.", + }, }, } } @@ -297,7 +311,7 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^$|^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]*$`, + Regexp: `^$|^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]*$`, MinValueLength: 0, MaxValueLength: 40, }, @@ -315,7 +329,7 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^(?!\s)(?!.*\s$)[^'"<>{}\x00-\x1F]+$`, + Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]+$`, MinValueLength: 1, MaxValueLength: 64, }, @@ -372,46 +386,9 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m d.SetId(*project.ID) - _, err = waitForProjectInstanceCreate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) - } - return resourceIbmProjectRead(context, d, meta) } -func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -422,7 +399,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met getProjectOptions.SetID(d.Id()) - projectSummary, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -432,95 +409,133 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("name", projectSummary.Name); err != nil { + if err = d.Set("resource_group", project.ResourceGroup); err != nil { + return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) + } + if err = d.Set("location", project.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + } + if err = d.Set("name", project.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if !core.IsNil(projectSummary.Description) { - if err = d.Set("description", projectSummary.Description); err != nil { + if !core.IsNil(project.Description) { + if err = d.Set("description", project.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(projectSummary.DestroyOnDelete) { - if err = d.Set("destroy_on_delete", projectSummary.DestroyOnDelete); err != nil { + if !core.IsNil(project.DestroyOnDelete) { + if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - if !core.IsNil(projectSummary.Metadata) { - metadataMap, err := resourceIbmProjectProjectMetadataToMap(projectSummary.Metadata) - if err != nil { - return diag.FromErr(err) + if !core.IsNil(project.Configs) { + configs := []map[string]interface{}{} + for _, configsItem := range project.Configs { + configsItemMap, err := resourceIbmProjectProjectConfigToMap(&configsItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, configsItemMap) + } + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) + } + } + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } + if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } + if !core.IsNil(project.CumulativeNeedsAttentionView) { + cumulativeNeedsAttentionView := []map[string]interface{}{} + for _, cumulativeNeedsAttentionViewItem := range project.CumulativeNeedsAttentionView { + cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) + if err != nil { + return diag.FromErr(err) + } + cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) + if err = d.Set("cumulative_needs_attention_view", cumulativeNeedsAttentionView); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view: %s", err)) + } + } + if !core.IsNil(project.CumulativeNeedsAttentionViewError) { + if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) + } + } + if err = d.Set("state", project.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + if !core.IsNil(project.EventNotificationsCrn) { + if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } } return nil } -func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func resourceIbmProjectUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { return diag.FromErr(err) } - deleteProjectOptions := &projectv1.DeleteProjectOptions{} + updateProjectOptions := &projectv1.UpdateProjectOptions{} - deleteProjectOptions.SetID(d.Id()) + updateProjectOptions.SetID(d.Id()) - response, err := projectClient.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)) - } + hasChange := false - _, err = waitForProjectInstanceDelete(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) + if d.HasChange("name") { + updateProjectOptions.SetName(d.Get("name").(string)) + hasChange = true + } + if d.HasChange("description") { + updateProjectOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } + if d.HasChange("destroy_on_delete") { + updateProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) + hasChange = true } - d.SetId("") + if hasChange { + _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) + if err != nil { + log.Printf("[DEBUG] UpdateProjectWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("UpdateProjectWithContext failed %s\n%s", err, response)) + } + } - return nil + return resourceIbmProjectRead(context, d, meta) } -func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { +func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { - return false, err + return diag.FromErr(err) } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, + deleteProjectOptions := &projectv1.DeleteProjectOptions{} + + deleteProjectOptions.SetID(d.Id()) + + response, err := projectClient.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)) } - return stateConf.WaitForState() + d.SetId("") + + return nil } func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["labels"] != nil { labels := []string{} @@ -637,11 +652,8 @@ func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]i return model, nil } -func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } modelMap["name"] = model.Name if model.Labels != nil { modelMap["labels"] = model.Labels @@ -664,10 +676,11 @@ func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfi modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } modelMap["locator_id"] = model.LocatorID + modelMap["type"] = model.Type if model.Input != nil { input := []map[string]interface{}{} for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + inputItemMap, err := resourceIbmProjectInputVariableToMap(&inputItem) if err != nil { return modelMap, err } @@ -675,6 +688,17 @@ func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfi } modelMap["input"] = input } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } if model.Setting != nil { setting := []map[string]interface{}{} for _, settingItem := range model.Setting { @@ -686,6 +710,7 @@ func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfi } modelMap["setting"] = setting } + modelMap["id"] = model.ID return modelMap, nil } @@ -738,56 +763,35 @@ func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.Proj return modelMap, nil } -func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func resourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name + modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } + if model.Required != nil { + modelMap["required"] = model.Required + } return modelMap, nil } -func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name - modelMap["value"] = model.Value + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } return modelMap, nil } -func resourceIbmProjectProjectMetadataToMap(model *projectv1.ProjectMetadata) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Crn != nil { - modelMap["crn"] = model.Crn - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.CumulativeNeedsAttentionView != nil { - cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range model.CumulativeNeedsAttentionView { - cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) - if err != nil { - return modelMap, err - } - cumulativeNeedsAttentionView = append(cumulativeNeedsAttentionView, cumulativeNeedsAttentionViewItemMap) - } - modelMap["cumulative_needs_attention_view"] = cumulativeNeedsAttentionView - } - if model.CumulativeNeedsAttentionViewErr != nil { - modelMap["cumulative_needs_attention_view_err"] = model.CumulativeNeedsAttentionViewErr - } - if model.Location != nil { - modelMap["location"] = model.Location - } - if model.ResourceGroup != nil { - modelMap["resource_group"] = model.ResourceGroup - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.EventNotificationsCrn != nil { - modelMap["event_notifications_crn"] = model.EventNotificationsCrn - } + modelMap["name"] = model.Name + modelMap["value"] = model.Value return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 70b1a21702..b93c184eed 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,12 +5,11 @@ package project import ( "context" + "encoding/json" "fmt" "log" - "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -27,27 +26,20 @@ func ResourceIbmProjectConfig() *schema.Resource { UpdateContext: resourceIbmProjectConfigUpdate, DeleteContext: resourceIbmProjectConfigDelete, Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The unique project ID.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The configuration name.", - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), + Description: "The name of the configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -56,15 +48,17 @@ func ResourceIbmProjectConfig() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The project configuration description.", + Type: schema.TypeString, + Optional: true, + Default: "", + ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "trusted_profile": &schema.Schema{ @@ -135,10 +129,16 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Description: "A dotted value of catalogID.versionID.", + }, "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -146,18 +146,28 @@ func ResourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The variable name.", }, + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable type.", + }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "Can be any value - a string, number, boolean, array, or object.", }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "Whether the variable is required or not.", + }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -202,31 +212,274 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, - "metadata": &schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration draft.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "project_id": &schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ Type: schema.TypeString, Optional: true, + Default: "", + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, Description: "The unique ID of a project.", }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The version number of the configuration.", + Description: "The currency of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The state of the configuration draft.", + Description: "The total hourly cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The pipeline state of the configuration.", + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_deployment_job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -260,15 +513,6 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { MinValueLength: 1, MaxValueLength: 64, }, - validate.ValidateSchema{ - Identifier: "locator_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, - MinValueLength: 1, - MaxValueLength: 512, - }, validate.ValidateSchema{ Identifier: "description", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -278,6 +522,15 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { MinValueLength: 0, MaxValueLength: 1024, }, + validate.ValidateSchema{ + Identifier: "locator_id", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, + MinValueLength: 1, + MaxValueLength: 512, + }, ) resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project_config", Schema: validateSchema} @@ -345,56 +598,17 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions.SetSetting(setting) } - projectConfigGetResponse, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) + projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { log.Printf("[DEBUG] CreateConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("CreateConfigWithContext failed %s\n%s", err, response)) } - d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfigGetResponse.ID)) - - _, err = waitForProjectConfigCreate(context, d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create config instance (%s) to be succeeded: %s", d.Id(), err)) - } + d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) return resourceIbmProjectConfigRead(context, d, meta) } -func waitForProjectConfigCreate(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - - parts, err := flex.SepIdParts(d.Id(), "/") - getConfigOptions := &projectv1.GetConfigOptions{} - getConfigOptions.SetProjectID(parts[0]) - getConfigOptions.SetID(parts[1]) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetConfigWithContext(context, getConfigOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the config instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -411,7 +625,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - projectConfigGetResponse, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -421,27 +635,24 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) } - if err = d.Set("project_id", getConfigOptions.ProjectID); err != nil { + if err = d.Set("project_id", projectConfig.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if err = d.Set("name", projectConfigGetResponse.Name); err != nil { + if err = d.Set("name", projectConfig.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if err = d.Set("locator_id", projectConfigGetResponse.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) - } - if !core.IsNil(projectConfigGetResponse.Labels) { - if err = d.Set("labels", projectConfigGetResponse.Labels); err != nil { + if !core.IsNil(projectConfig.Labels) { + if err = d.Set("labels", projectConfig.Labels); err != nil { return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) } } - if !core.IsNil(projectConfigGetResponse.Description) { - if err = d.Set("description", projectConfigGetResponse.Description); err != nil { + if !core.IsNil(projectConfig.Description) { + if err = d.Set("description", projectConfig.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(projectConfigGetResponse.Authorizations) { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigGetResponse.Authorizations) + if !core.IsNil(projectConfig.Authorizations) { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) if err != nil { return diag.FromErr(err) } @@ -449,8 +660,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting authorizations: %s", err)) } } - if !core.IsNil(projectConfigGetResponse.ComplianceProfile) { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigGetResponse.ComplianceProfile) + if !core.IsNil(projectConfig.ComplianceProfile) { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) if err != nil { return diag.FromErr(err) } @@ -458,24 +669,25 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - /* - if !core.IsNil(projectConfigGetResponse.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigGetResponse.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, inputItemMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } + if !core.IsNil(projectConfig.Input) { + input := []map[string]interface{}{} + for _, inputItem := range projectConfig.Input { + inputItemMap, err := resourceIbmProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) } + input = append(input, inputItemMap) } - */ - if !core.IsNil(projectConfigGetResponse.Setting) { + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) + } + } + if !core.IsNil(projectConfig.Setting) { setting := []map[string]interface{}{} - for _, settingItem := range projectConfigGetResponse.Setting { + for _, settingItem := range projectConfig.Setting { settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return diag.FromErr(err) @@ -486,12 +698,12 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } - if err = d.Set("type", projectConfigGetResponse.Type); err != nil { + if err = d.Set("type", projectConfig.Type); err != nil { return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } - if !core.IsNil(projectConfigGetResponse.Output) { + if !core.IsNil(projectConfig.Output) { output := []map[string]interface{}{} - for _, outputItem := range projectConfigGetResponse.Output { + for _, outputItem := range projectConfig.Output { outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) if err != nil { return diag.FromErr(err) @@ -502,22 +714,91 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - /* - if !core.IsNil(projectConfigGetResponse.Metadata) { - metadataMap, err := resourceIbmProjectConfigProjectConfigDraftMetadataToMap(projectConfigGetResponse.Metadata) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("metadata", []map[string]interface{}{metadataMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting metadata: %s", err)) - } + if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + } + if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) + } + if !core.IsNil(projectConfig.NeedsAttentionState) { + needsAttentionState := []interface{}{} + for _, needsAttentionStateItem := range projectConfig.NeedsAttentionState { + needsAttentionState = append(needsAttentionState, needsAttentionStateItem) + } + if err = d.Set("needs_attention_state", needsAttentionState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) + } + } + if err = d.Set("state", projectConfig.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + if !core.IsNil(projectConfig.PipelineState) { + if err = d.Set("pipeline_state", projectConfig.PipelineState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) + } + } + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } + if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } + if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + } + if !core.IsNil(projectConfig.LastApproved) { + lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) + } + } + if !core.IsNil(projectConfig.LastSave) { + if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + } + } + if !core.IsNil(projectConfig.JobSummary) { + jobSummaryMap, err := resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.JobSummary) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("job_summary", []map[string]interface{}{jobSummaryMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting job_summary: %s", err)) + } + } + if !core.IsNil(projectConfig.CraLogs) { + craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfig.CraLogs) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) + } + } + if !core.IsNil(projectConfig.CostEstimate) { + costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfig.CostEstimate) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) + } + } + if !core.IsNil(projectConfig.LastDeploymentJobSummary) { + lastDeploymentJobSummaryMap, err := resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.LastDeploymentJobSummary) + if err != nil { + return diag.FromErr(err) } - */ - if !core.IsNil(projectConfigGetResponse.ID) { - if err = d.Set("project_config_id", projectConfigGetResponse.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + if err = d.Set("last_deployment_job_summary", []map[string]interface{}{lastDeploymentJobSummaryMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_deployment_job_summary: %s", err)) } } + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + } return nil } @@ -544,11 +825,40 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD 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") || d.HasChange("locator_id") { - updateConfigOptions.SetName(d.Get("name").(string)) + if d.HasChange("locator_id") { updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) hasChange = true } + if d.HasChange("input") { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } + if d.HasChange("name") { + updateConfigOptions.SetName(d.Get("name").(string)) + hasChange = true + } if d.HasChange("labels") { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -578,32 +888,6 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetComplianceProfile(complianceProfile) hasChange = true } - if d.HasChange("input") { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) - } - updateConfigOptions.SetSetting(setting) - hasChange = true - } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) @@ -638,50 +922,11 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) } - _, err = waitForProjectConfigDelete(context, d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete config instance (%s) to be succeeded: %s", d.Id(), err)) - } - d.SetId("") return nil } -func waitForProjectConfigDelete(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - - parts, err := flex.SepIdParts(d.Id(), "/") - getConfigOptions := &projectv1.GetConfigOptions{} - getConfigOptions.SetProjectID(parts[0]) - getConfigOptions.SetID(parts[1]) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetConfigWithContext(context, getConfigOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { @@ -796,12 +1041,16 @@ func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv return modelMap, nil } -func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name + modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } + if model.Required != nil { + modelMap["required"] = model.Required + } return modelMap, nil } @@ -824,19 +1073,158 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map return modelMap, nil } -func resourceIbmProjectConfigProjectConfigDraftMetadataToMap(model *projectv1.ProjectConfigDraftMetadata) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost } - if model.State != nil { - modelMap["state"] = model.State + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 7b40ca312e..780612a1f9 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -18,10 +18,11 @@ import ( ) func TestAccIbmProjectConfigBasic(t *testing.T) { - var conf projectv1.ProjectConfigDraft + var conf projectv1.ProjectConfigDraftResponse name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -31,16 +32,16 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorID), + Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), ), }, }, @@ -48,11 +49,13 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { } func TestAccIbmProjectConfigAllArgs(t *testing.T) { - var conf projectv1.ProjectConfigDraft + var conf projectv1.ProjectConfigDraftResponse name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -60,24 +63,24 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { CheckDestroy: testAccCheckIbmProjectConfigDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(name, locatorID, description), + Config: testAccCheckIbmProjectConfigConfig(name, description, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(nameUpdate, locatorID, description), + Config: testAccCheckIbmProjectConfigConfig(nameUpdate, descriptionUpdate, locatorIDUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config_instance", + ResourceName: "ibm_project_config.project_config", ImportState: true, ImportStateVerify: true, }, @@ -90,9 +93,8 @@ func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) stri resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-3" + name = "acme-microservice" } - resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" @@ -101,37 +103,51 @@ func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) stri `, name, locatorID) } -func testAccCheckIbmProjectConfigConfig(name string, locatorID string, description string) string { +func testAccCheckIbmProjectConfigConfig(name string, description string, locatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice-4" + name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" + labels = "FIXME" + description = "%s" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } locator_id = "%s" - labels = [ "env:staging" ] - description = "%s" - authorizations { - method = "API_KEY" - api_key = "xxx" - } - input { - name = "app_repo_name" - } - setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } + input { + name = "name" + type = "array" + value = "anything as a string" + required = true + } + setting { + name = "name" + value = "value" + } } - `, name, locatorID, description) + `, name, description, locatorID) } -func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDraft) resource.TestCheckFunc { +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDraftResponse) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -154,13 +170,12 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDra getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - _, response, err := projectClient.GetConfig(getConfigOptions) + projectConfig, _, err := projectClient.GetConfig(getConfigOptions) if err != nil { return err - } else if response.StatusCode != 200 { - return fmt.Errorf("Error checking for project_config (%s) exists: %s", rs.Primary.ID, err) } + obj = *projectConfig return nil } } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index e65f572ca4..c5d52bf3a7 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -17,10 +17,13 @@ import ( ) func TestAccIbmProjectBasic(t *testing.T) { - var conf projectv1.ProjectSummary - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") + var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -30,10 +33,18 @@ func TestAccIbmProjectBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location, name), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), + testAccCheckIbmProjectExists("ibm_project.project", conf), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project", "location", location), + resource.TestCheckResourceAttr("ibm_project.project", "name", name), + ), + }, + resource.TestStep{ + Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate, nameUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "name", nameUpdate), ), }, }, @@ -41,12 +52,17 @@ func TestAccIbmProjectBasic(t *testing.T) { } func TestAccIbmProjectAllArgs(t *testing.T) { - var conf projectv1.ProjectSummary - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") + var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - destroyOnDelete := "true" + destroyOnDelete := "false" + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + destroyOnDeleteUpdate := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -56,23 +72,28 @@ func TestAccIbmProjectAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfig(resourceGroup, location, name, description, destroyOnDelete), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project.project_instance", "description", description), - resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDelete), + testAccCheckIbmProjectExists("ibm_project.project", conf), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project", "location", location), + resource.TestCheckResourceAttr("ibm_project.project", "name", name), + resource.TestCheckResourceAttr("ibm_project.project", "description", description), + resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDelete), ), }, resource.TestStep{ - ResourceName: "ibm_project.project_instance", + Config: testAccCheckIbmProjectConfig(resourceGroupUpdate, locationUpdate, nameUpdate, descriptionUpdate, destroyOnDeleteUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDeleteUpdate), + ), + }, + resource.TestStep{ + ResourceName: "ibm_project.project", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "location", - "resource_group", - "configs", - }, }, }, }) @@ -80,7 +101,6 @@ func TestAccIbmProjectAllArgs(t *testing.T) { func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string, name string) string { return fmt.Sprintf(` - resource "ibm_project" "project_instance" { resource_group = "%s" location = "%s" @@ -99,27 +119,48 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st description = "%s" destroy_on_delete = %s configs { - name = "static-website-dev" - labels = [ "env:staging" ] - description = "static-website-dev description" - authorizations { - method = "API_KEY" - api_key = "xxx" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "app_repo_name" - } - setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + type = "terraform_template" + input { + name = "name" + type = "array" + value = "anything as a string" + required = true + } + output { + name = "name" + description = "description" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + id = "id" } } `, resourceGroup, location, name, description, destroyOnDelete) } -func testAccCheckIbmProjectExists(n string, obj projectv1.ProjectSummary) resource.TestCheckFunc { +func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 7fb38263ea..673795391d 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -2,13 +2,13 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- - Get information about Project definition -subcategory: "Project" + Get information about project +subcategory: "Projects API" --- # ibm_project -Provides a read-only data source for Project definition. 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 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,33 +20,33 @@ data "ibm_project" "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. * `id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. ## 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 project. -* `configs` - (List) The project configurations. +* `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **configs**: - * `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested scheme for **authorizations**: +Nested schema for **configs**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: + Nested schema for **trusted_profile**: * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `target_iam_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. - Nested scheme for **compliance_profile**: + Nested schema for **compliance_profile**: * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `id` - (String) The unique ID of a project. @@ -56,14 +56,14 @@ Nested scheme for **configs**: * `instance_location` - (String) The location of the compliance instance. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **input**: + Nested schema for **input**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `required` - (Boolean) Whether the variable is required or not. @@ -74,19 +74,19 @@ Nested scheme for **configs**: * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The configuration name. + * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **output**: + Nested schema for **output**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **setting**: + Nested schema for **setting**: * `name` - (String) The name of the configuration setting. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) The value of the configuration setting. @@ -94,38 +94,42 @@ Nested scheme for **configs**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `description` - (String) A project descriptive text. +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + +* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + +* `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **cumulative_needs_attention_view**: + * `config_id` - (String) A unique ID for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `config_version` - (Integer) The version number of the configuration. + * `event` - (String) The event name. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `event_id` - (String) A unique ID for that individual event. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +* `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. + +* `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. * Constraints: The default value is `true`. -* `metadata` - (List) The metadata of the project. -Nested scheme for **metadata**: - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `config_version` - (Integer) The version number of the configuration. - * `event` - (String) The event name. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `location` - (String) The IBM Cloud location where a resource is deployed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `resource_group` - (String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `state` - (String) The project status value. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. +* `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. + * Constraints: The default value is ``. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + +* `location` - (String) The IBM Cloud location where a resource is deployed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. -* `name` - (String) The project name. +* `name` - (String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. +* `resource_group` - (String) The resource group where the project's data and tools are created. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + +* `state` - (String) The project status value. + * Constraints: Allowable values are: `ready`, `deleting`, `deleting_failed`. + diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 9bba051693..f86da4549a 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -3,25 +3,25 @@ layout: "ibm" page_title: "IBM : ibm_project_config" description: |- Get information about project_config -subcategory: "Project" +subcategory: "Projects API" --- # ibm_project_config -Provides a read-only data source for project_config. 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 project_config. 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_project_config" "project_config" { - id = ibm_project_config.project_config_instance.project_config_id + id = ibm_project_config.project_config_instance.projectConfig_id project_id = ibm_project_config.project_config.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. * `id` - (Required, Forces new resource, String) The unique config ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -30,24 +30,24 @@ 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 project_config. -* `authorizations` - (List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. -Nested scheme for **authorizations**: +* `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. +Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: + Nested schema for **trusted_profile**: * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `target_iam_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. -Nested scheme for **compliance_profile**: +Nested schema for **compliance_profile**: * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `id` - (String) The unique ID of a project. @@ -59,12 +59,36 @@ Nested scheme for **compliance_profile**: * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `description` - (String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + +* `description` - (String) The description of the project configuration. + * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `input` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **input**: +Nested schema for **input**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `required` - (Boolean) Whether the variable is required or not. @@ -72,45 +96,83 @@ Nested scheme for **input**: * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. + +* `job_summary` - (List) The summaries of jobs that were performed on the configuration. +Nested schema for **job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. +* `last_approved` - (List) The last approved metadata of the configuration. +Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +* `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. +Nested schema for **last_deployment_job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + +* `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `metadata` - (List) The project configuration draft. -Nested scheme for **metadata**: - * `pipeline_state` - (String) The pipeline state of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(PIPELINE_RUNNING|PIPELINE_FAILED|PIPELINE_SUCCEEDED)$/`. - * `project_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `state` - (String) The state of the configuration draft. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(DISCARDED|MERGED|ACTIVE)$/`. - * `version` - (Integer) The version number of the configuration. - -* `name` - (String) The configuration name. +* `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. +* `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **output**: +Nested schema for **output**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (List) Schematics environment variables to use to deploy the configuration. +* `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **setting**: +Nested schema for **setting**: * `name` - (String) The name of the configuration setting. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. +* `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. + * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + +* `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + +* `version` - (Integer) The version of the configuration. + diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index ab3e3928ca..eea1142f25 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -3,69 +3,83 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- Manages project. -subcategory: "Project" +subcategory: "Projects API" --- # ibm_project -Provides a resource for project. This allows project to be created, updated and deleted. +Create, update, and delete projects with this resource. ## Example Usage ```hcl resource "ibm_project" "project_instance" { - name = "acme-microservice" - description = "A microservice to deploy on top of ACME infrastructure." - location = "us-south" - resource_group = "Default" configs { - name = "config-stage" - labels = [ "env:stage" ] - description = "config-stage description" + name = "name" + labels = [ "labels" ] + description = "description" authorizations { - method = "API_EKY" - api_key = "api_key_value" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" } compliance_profile { - id = "compliance_profile_id" + id = "id" instance_id = "instance_id" instance_location = "instance_location" attachment_id = "attachment_id" profile_name = "profile_name" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + locator_id = "locator_id" + type = "terraform_template" input { - name = "app_repo_name" + name = "name" + type = "array" + value = "anything as a string" + required = true + } + output { + name = "name" + description = "description" + value = "anything as a string" } setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } + name = "name" + value = "value" + } + id = "id" } + description = "A microservice to deploy on top of ACME infrastructure." + location = "us-south" + name = "acme-microservice" + resource_group = "Default" } ``` ## Argument Reference -Review the argument reference that you can specify for your resource. +You can specify the following arguments for this resource. -* `configs` - (Optional, Forces new resource, List) The project configurations. +* `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **configs**: - * `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested scheme for **authorizations**: +Nested schema for **configs**: + * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: * `api_key` - (Optional, String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: + Nested schema for **trusted_profile**: * `id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `target_iam_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested scheme for **compliance_profile**: + Nested schema for **compliance_profile**: * `attachment_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `id` - (Optional, String) The unique ID of a project. @@ -76,70 +90,76 @@ Nested scheme for **configs**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (Optional, String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * `description` - (Optional, String) The description of the project configuration. + * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `id` - (Required, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. + * `input` - (Optional, List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **input**: + Nested schema for **input**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `required` - (Optional, Boolean) Whether the variable is required or not. + * `type` - (Required, String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Required, String) The configuration name. + * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. + * `output` - (Optional, List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **setting**: + Nested schema for **output**: + * `description` - (Optional, String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: * `name` - (Required, String) The name of the configuration setting. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. -* `description` - (Optional, Forces new resource, String) A project's descriptive text. + * `type` - (Required, String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `destroy_on_delete` - (Optional, Forces new resource, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. +* `destroy_on_delete` - (Optional, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. * Constraints: The default value is `true`. -* `location` - (Required, Forces new resource, String) The location where the project's data and tools are created. +* `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Required, Forces new resource, String) The project name. +* `name` - (Required, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. -* `resource_group` - (Required, Forces new resource, String) The resource group where the project's data and tools are created. +* `resource_group` - (Required, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. ## 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 project. -* `metadata` - (List) The metadata of the project. -Nested scheme for **metadata**: - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested scheme for **cumulative_needs_attention_view**: - * `config_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `config_version` - (Integer) The version number of the configuration. - * `event` - (String) The event name. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `cumulative_needs_attention_view_err` - (String) True indicates that the fetch of the needs attention items failed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * Constraints: The maximum length is `512` characters. The minimum length is `9` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. - * `location` - (String) The IBM Cloud location where a resource is deployed. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `resource_group` - (String) The resource group where the project's data and tools are created. +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. +* `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **cumulative_needs_attention_view**: + * `config_id` - (String) A unique ID for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `config_version` - (Integer) The version number of the configuration. + * `event` - (String) The event name. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `state` - (String) The project status value. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(CREATING|CREATING_FAILED|UPDATING|UPDATING_FAILED|READY)$/`. + * `event_id` - (String) A unique ID for that individual event. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. + * Constraints: The default value is ``. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. +* `state` - (String) The project status value. + * Constraints: Allowable values are: `ready`, `deleting`, `deleting_failed`. ## Import diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 0150603b57..740cc31bab 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -3,55 +3,67 @@ layout: "ibm" page_title: "IBM : ibm_project_config" description: |- Manages project_config. -subcategory: "Project" +subcategory: "Projects API" --- # ibm_project_config -Provides a resource for project_config. This allows project_config to be created, updated and deleted. +Create, update, and delete project_configs with this resource. ## Example Usage ```hcl resource "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - name = "env-stage" - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" authorizations { - method = "TRUSTED_PROFILE" trusted_profile { - id = "Profile-047ef95f-2f90-4276-8ba3-92512cc4a6ae" + id = "id" + target_iam_id = "target_iam_id" } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." input { - name = "app_repo_name" + name = "name" + type = "array" + value = "anything as a string" + required = true } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + name = "env-stage" + project_id = ibm_project.project_instance.id setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" + name = "name" + value = "value" } } ``` ## Argument Reference -Review the argument reference that you can specify for your resource. +You can specify the following arguments for this resource. -* `authorizations` - (Optional, List) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. -Nested scheme for **authorizations**: +* `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. +Nested schema for **authorizations**: * `api_key` - (Optional, String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested scheme for **trusted_profile**: + Nested schema for **trusted_profile**: * `id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `target_iam_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. -Nested scheme for **compliance_profile**: +Nested schema for **compliance_profile**: * `attachment_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `id` - (Optional, String) The unique ID of a project. @@ -62,25 +74,28 @@ Nested scheme for **compliance_profile**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `description` - (Optional, String) The project configuration description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The inputs of a Schematics template property. +* `description` - (Optional, String) The description of the project configuration. + * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. +* `input` - (Optional, List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **input**: +Nested schema for **input**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `required` - (Optional, Boolean) Whether the variable is required or not. + * `type` - (Required, String) The variable type. + * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `name` - (Required, String) The configuration name. +* `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. +* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **setting**: +Nested schema for **setting**: * `name` - (Required, String) The name of the configuration setting. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. @@ -88,30 +103,79 @@ Nested scheme for **setting**: ## 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 project_config. -* `metadata` - (List) The project configuration draft. -Nested scheme for **metadata**: - * `pipeline_state` - (String) The pipeline state of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(PIPELINE_RUNNING|PIPELINE_FAILED|PIPELINE_SUCCEEDED)$/`. - * `project_id` - (String) The unique ID of a project. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `state` - (String) The state of the configuration draft. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(DISCARDED|MERGED|ACTIVE)$/`. - * `version` - (Integer) The version number of the configuration. + * `version` - (String) The version of the cost estimate of the configuration. +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. +* `job_summary` - (List) The summaries of jobs that were performed on the configuration. +Nested schema for **job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `last_approved` - (List) The last approved metadata of the configuration. +Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. +Nested schema for **last_deployment_job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested scheme for **output**: +Nested schema for **output**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `update_available` - (Boolean) The flag that indicates whether a configuration update is available. +* `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `version` - (Integer) The version of the configuration. ## Import From 48337c990301d584a302b16dffd0166529210f3f Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 17 Jul 2023 10:35:42 +0200 Subject: [PATCH 069/125] terraform --- examples/ibm-project/variables.tf | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 681b8b85d9..1e2a97e4d3 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -34,7 +34,7 @@ variable "project_destroy_on_delete" { variable "project_config_project_id" { description = "The unique project ID." type = string - default = "id" + default = "project_id" } variable "project_config_name" { description = "The name of the configuration." diff --git a/go.mod b/go.mod index e06456e9d5..db81ebb1b4 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.38.1 - github.com/IBM/project-go-sdk v0.0.26-7 + github.com/IBM/project-go-sdk v0.0.26-8 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 67737e748f..730f46add2 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-7 h1:E3eGopxrzCL/irgebNziwcl0FESKjBg6a7NHocUu228= -github.com/IBM/project-go-sdk v0.0.26-7/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-8 h1:0a/MFJn5ifDvMpv05Rsmwc+pG0whXHiX6qNqtlGOdkE= +github.com/IBM/project-go-sdk v0.0.26-8/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= From 7eb98dfe36c71fa39ec623cc460d26bbe849ee2b Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 12:19:15 +0200 Subject: [PATCH 070/125] terraform --- examples/ibm-project/README.md | 3 + examples/ibm-project/main.tf | 53 ++ go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 530 ++++++++++++++++++ .../project/data_source_ibm_project_test.go | 63 +++ ibm/service/project/resource_ibm_project.go | 504 +++++++++++++++++ .../resource_ibm_project_config_test.go | 6 +- .../project/resource_ibm_project_test.go | 53 ++ website/docs/d/project.html.markdown | 60 ++ website/docs/r/project.html.markdown | 113 ++++ 11 files changed, 1385 insertions(+), 6 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 1e3f316f20..ded7c5580f 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -110,6 +110,7 @@ data "project_config" "project_config_instance" { | setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | +| id | The unique config ID. | `string` | true | ## Outputs @@ -117,3 +118,5 @@ data "project_config" "project_config_instance" { |------|-------------| | project | project object | | project_config | project_config object | +| project | project object | +| project_config | project_config object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index dd8f821939..73b876bb2e 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -46,6 +46,59 @@ resource "ibm_project" "project_instance" { value = "value" } id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "deleted" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" + job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" + } + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_deployment_job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } } } diff --git a/go.mod b/go.mod index db81ebb1b4..8b38f4ed05 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.38.1 - github.com/IBM/project-go-sdk v0.0.26-8 + github.com/IBM/project-go-sdk v0.0.26-10 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 730f46add2..e90e520fe2 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-8 h1:0a/MFJn5ifDvMpv05Rsmwc+pG0whXHiX6qNqtlGOdkE= -github.com/IBM/project-go-sdk v0.0.26-8/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-10 h1:pbliLWlEj1Vy+QtOF4NrMApwm/gj5nUIdXw5FJiXXyA= +github.com/IBM/project-go-sdk v0.0.26-10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index f685228800..cb814b942e 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -288,6 +289,314 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The unique ID of a project.", }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_deployment_job_summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, }, }, }, @@ -460,6 +769,71 @@ func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map modelMap["setting"] = setting } modelMap["id"] = model.ID + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.IsDraft != nil { + modelMap["is_draft"] = model.IsDraft + } + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if err != nil { + return modelMap, err + } + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } + if model.JobSummary != nil { + jobSummaryMap, err := dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.JobSummary) + if err != nil { + return modelMap, err + } + modelMap["job_summary"] = []map[string]interface{}{jobSummaryMap} + } + if model.CraLogs != nil { + craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.LastDeploymentJobSummary != nil { + lastDeploymentJobSummaryMap, err := dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.LastDeploymentJobSummary) + if err != nil { + return modelMap, err + } + modelMap["last_deployment_job_summary"] = []map[string]interface{}{lastDeploymentJobSummaryMap} + } return modelMap, nil } @@ -543,3 +917,159 @@ func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Pr modelMap["value"] = model.Value return modelMap, nil } + +func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 56c3a44e14..5dd31e8c8b 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -78,6 +78,16 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.version"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.needs_attention_state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.pipeline_state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.last_save"), ), }, }, @@ -143,6 +153,59 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project value = "value" } id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "deleted" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" + job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" + } + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_deployment_job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } } } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index dc45d08d04..be2a9340b8 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -242,6 +243,288 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The unique ID of a project.", }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "job_summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_deployment_job_summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, @@ -711,6 +994,71 @@ func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[s modelMap["setting"] = setting } modelMap["id"] = model.ID + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.IsDraft != nil { + modelMap["is_draft"] = model.IsDraft + } + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if err != nil { + return modelMap, err + } + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } + if model.JobSummary != nil { + jobSummaryMap, err := resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.JobSummary) + if err != nil { + return modelMap, err + } + modelMap["job_summary"] = []map[string]interface{}{jobSummaryMap} + } + if model.CraLogs != nil { + craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.LastDeploymentJobSummary != nil { + lastDeploymentJobSummaryMap, err := resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.LastDeploymentJobSummary) + if err != nil { + return modelMap, err + } + modelMap["last_deployment_job_summary"] = []map[string]interface{}{lastDeploymentJobSummaryMap} + } return modelMap, nil } @@ -795,6 +1143,162 @@ func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Proj return modelMap, nil } +func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} + func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Event != nil { diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 780612a1f9..d519a3167f 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -18,7 +18,7 @@ import ( ) func TestAccIbmProjectConfigBasic(t *testing.T) { - var conf projectv1.ProjectConfigDraftResponse + var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) @@ -49,7 +49,7 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { } func TestAccIbmProjectConfigAllArgs(t *testing.T) { - var conf projectv1.ProjectConfigDraftResponse + var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) @@ -147,7 +147,7 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator `, name, description, locatorID) } -func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigDraftResponse) resource.TestCheckFunc { +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index c5d52bf3a7..59464558a3 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -155,6 +155,59 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st value = "value" } id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "deleted" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" + job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" + } + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_deployment_job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } } } `, resourceGroup, location, name, description, destroyOnDelete) diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 673795391d..292b6cb29b 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -57,6 +57,27 @@ Nested schema for **configs**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `description` - (String) The description of the project configuration. * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `id` - (String) The unique ID of a project. @@ -70,12 +91,42 @@ Nested schema for **configs**: * `type` - (String) The variable type. * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `job_summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **last_deployment_job_summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **output**: @@ -84,6 +135,10 @@ Nested schema for **configs**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -91,8 +146,13 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index eea1142f25..97be42af95 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -51,6 +51,59 @@ resource "ibm_project" "project_instance" { value = "value" } id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "deleted" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" + job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" + } + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_deployment_job_summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } + } } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" @@ -90,6 +143,27 @@ Nested schema for **configs**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `cost_estimate` - (Optional, List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (Optional, String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (Optional, String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (Optional, String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (Optional, String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (Optional, String) The past total monthly cost estimate of the configuration. + * `time_generated` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (Optional, String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (Optional, String) The total monthly cost estimate of the configuration. + * `user_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (Optional, String) The version of the cost estimate of the configuration. + * `cra_logs` - (Optional, List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (Optional, String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (Optional, String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (Optional, String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Optional, Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `description` - (Optional, String) The description of the project configuration. * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `id` - (Required, String) The unique ID of a project. @@ -103,12 +177,42 @@ Nested schema for **configs**: * `type` - (Required, String) The variable type. * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `job_summary` - (Optional, List) The summaries of jobs that were performed on the configuration. + Nested schema for **job_summary**: + * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (Optional, List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (Optional, String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (Required, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_deployment_job_summary` - (Optional, List) The summaries of jobs that were performed on the configuration. + Nested schema for **last_deployment_job_summary**: + * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. + * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `output` - (Optional, List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **output**: @@ -117,6 +221,10 @@ Nested schema for **configs**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -124,8 +232,13 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `state` - (Optional, String) The state of the configuration. + * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. * `type` - (Required, String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Optional, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. From 320325e8111388f933fb837e3279b941d57e8b5a Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 15:12:24 +0200 Subject: [PATCH 071/125] terraform --- examples/ibm-project/main.tf | 62 -- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 613 +----------------- .../project/data_source_ibm_project_test.go | 74 --- ibm/service/project/resource_ibm_project.go | 587 +---------------- .../project/resource_ibm_project_test.go | 62 -- website/docs/d/project.html.markdown | 77 +-- website/docs/r/project.html.markdown | 139 +--- 9 files changed, 15 insertions(+), 1605 deletions(-) diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 73b876bb2e..f2e6638d9c 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -29,76 +29,14 @@ resource "ibm_project" "project_instance" { profile_name = "profile_name" } locator_id = "locator_id" - type = "terraform_template" input { name = "name" - type = "array" - value = "anything as a string" - required = true - } - output { - name = "name" - description = "description" value = "anything as a string" } setting { name = "name" value = "value" } - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "deleted" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" - } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_deployment_job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } } diff --git a/go.mod b/go.mod index 8b38f4ed05..26b2d5a1b1 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.38.1 - github.com/IBM/project-go-sdk v0.0.26-10 + github.com/IBM/project-go-sdk v0.0.26-11 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index e90e520fe2..639fe78aa0 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-10 h1:pbliLWlEj1Vy+QtOF4NrMApwm/gj5nUIdXw5FJiXXyA= -github.com/IBM/project-go-sdk v0.0.26-10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-11 h1:zl8RN7OOKWX6pjiF6Ax7fPq9RC+O8iVblQ/QMyeZ9X4= +github.com/IBM/project-go-sdk v0.0.26-11/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index cb814b942e..ff2e8a87ca 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -207,44 +206,10 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A dotted value of catalogID.versionID.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable type.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the variable is required or not.", - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -252,11 +217,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The variable name.", }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, "value": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -284,319 +244,6 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "job_summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_deployment_job_summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, }, }, }, @@ -679,7 +326,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m configs := []map[string]interface{}{} if project.Configs != nil { for _, modelItem := range project.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigToMap(&modelItem) + modelMap, err := dataSourceIbmProjectProjectConfigPrototypeToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -710,7 +357,7 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Labels != nil { @@ -734,11 +381,10 @@ func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } modelMap["locator_id"] = model.LocatorID - modelMap["type"] = model.Type if model.Input != nil { input := []map[string]interface{}{} for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectInputVariableToMap(&inputItem) + inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } @@ -746,17 +392,6 @@ func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map } modelMap["input"] = input } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } if model.Setting != nil { setting := []map[string]interface{}{} for _, settingItem := range model.Setting { @@ -768,72 +403,6 @@ func dataSourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map } modelMap["setting"] = setting } - modelMap["id"] = model.ID - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID - } - if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) - } - if model.IsDraft != nil { - modelMap["is_draft"] = model.IsDraft - } - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) - if err != nil { - return modelMap, err - } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.JobSummary != nil { - jobSummaryMap, err := dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.JobSummary) - if err != nil { - return modelMap, err - } - modelMap["job_summary"] = []map[string]interface{}{jobSummaryMap} - } - if model.CraLogs != nil { - craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.LastDeploymentJobSummary != nil { - lastDeploymentJobSummaryMap, err := dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.LastDeploymentJobSummary) - if err != nil { - return modelMap, err - } - modelMap["last_deployment_job_summary"] = []map[string]interface{}{lastDeploymentJobSummaryMap} - } return modelMap, nil } @@ -886,25 +455,9 @@ func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.Pr return modelMap, nil } -func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name - modelMap["type"] = model.Type - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Required != nil { - modelMap["required"] = model.Required - } - return modelMap, nil -} - -func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } if model.Value != nil { modelMap["value"] = model.Value } @@ -917,159 +470,3 @@ func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Pr modelMap["value"] = model.Value return modelMap, nil } - -func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 5dd31e8c8b..5d459ab703 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -76,18 +76,6 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectName), resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectDescription), resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.version"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.needs_attention_state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.pipeline_state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.last_save"), ), }, }, @@ -136,76 +124,14 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project profile_name = "profile_name" } locator_id = "locator_id" - type = "terraform_template" input { name = "name" - type = "array" - value = "anything as a string" - required = true - } - output { - name = "name" - description = "description" value = "anything as a string" } setting { name = "name" value = "value" } - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "deleted" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" - } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_deployment_job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index be2a9340b8..1c17c3ec18 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -161,44 +160,10 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "A dotted value of catalogID.versionID.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The type of a project configuration manual property.", - }, "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable type.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "Whether the variable is required or not.", - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -206,11 +171,6 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The variable name.", }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -238,293 +198,6 @@ func ResourceIbmProject() *schema.Resource { }, }, }, - "id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID of a project.", - }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "", - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "job_summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_deployment_job_summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, }, }, }, @@ -714,7 +387,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if !core.IsNil(project.Configs) { configs := []map[string]interface{}{} for _, configsItem := range project.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigToMap(&configsItem) + configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) if err != nil { return diag.FromErr(err) } @@ -935,7 +608,7 @@ func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]i return model, nil } -func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Labels != nil { @@ -959,11 +632,10 @@ func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[s modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } modelMap["locator_id"] = model.LocatorID - modelMap["type"] = model.Type if model.Input != nil { input := []map[string]interface{}{} for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectInputVariableToMap(&inputItem) + inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } @@ -971,17 +643,6 @@ func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[s } modelMap["input"] = input } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } if model.Setting != nil { setting := []map[string]interface{}{} for _, settingItem := range model.Setting { @@ -993,72 +654,6 @@ func resourceIbmProjectProjectConfigToMap(model *projectv1.ProjectConfig) (map[s } modelMap["setting"] = setting } - modelMap["id"] = model.ID - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID - } - if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) - } - if model.IsDraft != nil { - modelMap["is_draft"] = model.IsDraft - } - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) - if err != nil { - return modelMap, err - } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.JobSummary != nil { - jobSummaryMap, err := resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.JobSummary) - if err != nil { - return modelMap, err - } - modelMap["job_summary"] = []map[string]interface{}{jobSummaryMap} - } - if model.CraLogs != nil { - craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.LastDeploymentJobSummary != nil { - lastDeploymentJobSummaryMap, err := resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model.LastDeploymentJobSummary) - if err != nil { - return modelMap, err - } - modelMap["last_deployment_job_summary"] = []map[string]interface{}{lastDeploymentJobSummaryMap} - } return modelMap, nil } @@ -1111,25 +706,9 @@ func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.Proj return modelMap, nil } -func resourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name - modelMap["type"] = model.Type - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Required != nil { - modelMap["required"] = model.Required - } - return modelMap, nil -} - -func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } if model.Value != nil { modelMap["value"] = model.Value } @@ -1143,162 +722,6 @@ func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Proj return modelMap, nil } -func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Event != nil { diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 59464558a3..6e2f35f480 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -138,76 +138,14 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st profile_name = "profile_name" } locator_id = "locator_id" - type = "terraform_template" input { name = "name" - type = "array" - value = "anything as a string" - required = true - } - output { - name = "name" - description = "description" value = "anything as a string" } setting { name = "name" value = "value" } - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "deleted" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" - } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_deployment_job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } } `, resourceGroup, location, name, description, destroyOnDelete) diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 292b6cb29b..ba2769786d 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -57,88 +57,20 @@ Nested schema for **configs**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `description` - (String) The description of the project configuration. * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The outputs of a Schematics template property. + * `input` - (List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Boolean) Whether the variable is required or not. - * `type` - (String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `job_summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **last_deployment_job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -146,13 +78,6 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 97be42af95..691da6c52c 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -34,76 +34,14 @@ resource "ibm_project" "project_instance" { profile_name = "profile_name" } locator_id = "locator_id" - type = "terraform_template" input { name = "name" - type = "array" - value = "anything as a string" - required = true - } - output { - name = "name" - description = "description" value = "anything as a string" } setting { name = "name" value = "value" } - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "deleted" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" - } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_deployment_job_summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" @@ -143,88 +81,20 @@ Nested schema for **configs**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `cost_estimate` - (Optional, List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (Optional, String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (Optional, String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (Optional, String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (Optional, String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (Optional, String) The past total monthly cost estimate of the configuration. - * `time_generated` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (Optional, String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (Optional, String) The total monthly cost estimate of the configuration. - * `user_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (Optional, String) The version of the cost estimate of the configuration. - * `cra_logs` - (Optional, List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (Optional, String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (Optional, String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (Optional, String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Optional, Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `description` - (Optional, String) The description of the project configuration. * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `id` - (Required, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The outputs of a Schematics template property. + * `input` - (Optional, List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Optional, Boolean) Whether the variable is required or not. - * `type` - (Required, String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `job_summary` - (Optional, List) The summaries of jobs that were performed on the configuration. - Nested schema for **job_summary**: - * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (Optional, List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (Optional, String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (Required, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_deployment_job_summary` - (Optional, List) The summaries of jobs that were performed on the configuration. - Nested schema for **last_deployment_job_summary**: - * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. - * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -232,13 +102,6 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `state` - (Optional, String) The state of the configuration. - * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. - * `type` - (Required, String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Optional, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. From c38a9da8694c9507c684371411b9a51b598b2813 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 15:34:25 +0200 Subject: [PATCH 072/125] terraform --- examples/ibm-project/README.md | 2 +- examples/ibm-project/main.tf | 28 +++---------------- .../data_source_ibm_project_config_test.go | 4 +-- ibm/service/project/resource_ibm_project.go | 24 ++++++++-------- .../project/resource_ibm_project_config.go | 18 ++++++------ website/docs/d/project_config.html.markdown | 2 +- 6 files changed, 29 insertions(+), 49 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index ded7c5580f..7b35e9a06d 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -64,7 +64,7 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id } ``` diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index f2e6638d9c..ce2e627b25 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -14,19 +14,8 @@ resource "ibm_project" "project_instance" { labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = var.ibmcloud_api_key } locator_id = "locator_id" input { @@ -49,17 +38,8 @@ resource "ibm_project_config" "project_config_instance" { authorizations { trusted_profile { id = "id" - target_iam_id = "target_iam_id" } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "TRUSTED_PROFILE" } locator_id = var.project_config_locator_id input { @@ -82,5 +62,5 @@ data "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 8ee7a31dc9..8f980a8a7a 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -115,7 +115,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id } `, projectConfigName, projectConfigLocatorID) } @@ -163,7 +163,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id } `, projectConfigName, projectConfigDescription, projectConfigLocatorID) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 1c17c3ec18..a1dcf709fb 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -28,10 +28,10 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), - Description: "The resource group where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ Type: schema.TypeString, @@ -40,16 +40,16 @@ func ResourceIbmProject() *schema.Resource { Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "name"), - Description: "The name of the project.", + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "description"), - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index b93c184eed..b4b28f32bc 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -48,11 +48,11 @@ func ResourceIbmProjectConfig() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "", - ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", + Type: schema.TypeString, + Optional: true, + Default: "", + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ Type: schema.TypeList, @@ -130,10 +130,10 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), - Description: "A dotted value of catalogID.versionID.", + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index f86da4549a..6daae3d4af 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project_config. ```hcl data "ibm_project_config" "project_config" { - id = ibm_project_config.project_config_instance.projectConfig_id + id = ibm_project_config.project_config_instance.project_config_id project_id = ibm_project_config.project_config.project_id } ``` From bb60e9d09398aac74d808e77b027b4d35a188db6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 16:04:19 +0200 Subject: [PATCH 073/125] terraform --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index d0ef4edf71..732ac45aa9 100644 --- a/go.sum +++ b/go.sum @@ -154,8 +154,6 @@ github.com/IBM/keyprotect-go-client v0.10.0 h1:UdVOwJfyVNmL4O3Aw2eGluiEr5FpV5h8E github.com/IBM/keyprotect-go-client v0.10.0/go.mod h1:yr8h2noNgU8vcbs+vhqoXp3Lmv73PI0zAc6VMgFvWwM= github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCBmvdyqkA= github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= -github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc= -github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= github.com/IBM/platform-services-go-sdk v0.41.0 h1:2aeHcLnQgat7UAKrtIF6jGyFW2hwq4oroO26fIX94kA= github.com/IBM/platform-services-go-sdk v0.41.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= github.com/IBM/project-go-sdk v0.0.26-11 h1:zl8RN7OOKWX6pjiF6Ax7fPq9RC+O8iVblQ/QMyeZ9X4= From 23025c46baf3c706b550486da8e41c4d290ef917 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 16:10:06 +0200 Subject: [PATCH 074/125] terraform --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2e0ee42b64..e6ffc11e84 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 - github.com/IBM/platform-services-go-sdk v0.41.1 + github.com/IBM/platform-services-go-sdk v0.41.0 github.com/IBM/project-go-sdk v0.0.26-11 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 From e33f0f9366c0290e668113c0ff64e9dac1b04cd7 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 18 Jul 2023 19:58:29 +0200 Subject: [PATCH 075/125] terraform --- .../data_source_ibm_project_config_test.go | 127 ++++++++---------- .../project/data_source_ibm_project_test.go | 83 +++++------- .../resource_ibm_project_config_test.go | 27 ++-- .../project/resource_ibm_project_test.go | 35 ++--- 4 files changed, 109 insertions(+), 163 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 8f980a8a7a..419fd11fc1 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -15,7 +15,7 @@ import ( func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -24,19 +24,18 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName, projectConfigLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), ), }, }, @@ -46,7 +45,7 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -55,44 +54,43 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigDescription, projectConfigLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.required"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigName), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "pipeline_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_approved.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_save"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "job_summary.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "cra_logs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "cost_estimate.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_deployment_job_summary.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "labels.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "input.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.required"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "output.0.name", projectConfigName), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "output.0.description", projectConfigDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "setting.0.name", projectConfigName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "pipeline_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_approved.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_save"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "job_summary.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "cra_logs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "cost_estimate.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_deployment_job_summary.#"), ), }, }, @@ -114,7 +112,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id + project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id } `, projectConfigName, projectConfigLocatorID) @@ -131,23 +129,12 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } + method = "API_KEY" + api_key = "xxx" + } locator_id = "%s" input { name = "name" @@ -162,7 +149,7 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id + project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id } `, projectConfigName, projectConfigDescription, projectConfigLocatorID) diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 5d459ab703..113897b200 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,8 +14,8 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") + projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -25,16 +25,15 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), ), }, }, @@ -42,8 +41,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") + projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) projectDestroyOnDelete := "false" @@ -55,27 +54,20 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_version"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view_error"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "event_notifications_crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectName), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), + resource.TestCheckResourceAttr("data.ibm_project.project_instance", "configs.0.name", projectName), + resource.TestCheckResourceAttr("data.ibm_project.project_instance", "configs.0.description", projectDescription), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.0.locator_id"), ), }, }, @@ -91,7 +83,7 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } `, projectResourceGroup, projectLocation, projectName) } @@ -109,21 +101,10 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" + method = "API_KEY" + api_key = "xxx" } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" @@ -136,7 +117,7 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } `, projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete) } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index d519a3167f..4ec23261a6 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,9 +20,9 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -52,10 +52,10 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfig name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -115,23 +115,12 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } + method = "API_KEY" + api_key = "xxx" + } locator_id = "%s" input { name = "name" diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 6e2f35f480..4874cced81 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -18,11 +18,11 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("Default") + locationUpdate := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -53,13 +53,13 @@ func TestAccIbmProjectBasic(t *testing.T) { func TestAccIbmProjectAllArgs(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDelete := "false" - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("Default") + locationUpdate := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDeleteUpdate := "true" @@ -123,21 +123,10 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" + method = "API_KEY" + api_key = "xxx" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" From a97b7f6279499f5f865ab09a346a895c7bcfc872 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 19 Jul 2023 07:35:19 +0200 Subject: [PATCH 076/125] terraform --- website/docs/d/project_config.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 6daae3d4af..3dd7c6d204 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -13,9 +13,9 @@ Provides a read-only data source to retrieve information about a project_config. ## Example Usage ```hcl -data "ibm_project_config" "project_config" { +data "ibm_project_config" "project_config_instance" { id = ibm_project_config.project_config_instance.project_config_id - project_id = ibm_project_config.project_config.project_id + project_id = ibm_project_config.project_config_instance.project_id } ``` From 8df47b6d966bcab6ae5bb16e02193f410cfe298a Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 19 Jul 2023 12:49:08 +0200 Subject: [PATCH 077/125] terraform --- ibm/service/project/resource_ibm_project.go | 80 ++++++++++++++++++ .../project/resource_ibm_project_config.go | 82 +++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index a1dcf709fb..a2f0f77bf0 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -25,6 +27,10 @@ func ResourceIbmProject() *schema.Resource { UpdateContext: resourceIbmProjectUpdate, DeleteContext: resourceIbmProjectDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ @@ -342,9 +348,46 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m d.SetId(*project.ID) + _, err = waitForProjectInstanceCreate(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectRead(context, d, meta) } +func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + return resp, "exists", nil + } else { + return resp, "not_exists", nil + } + } else { + return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -485,11 +528,48 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectInstanceDelete(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + instanceID := d.Id() + getProjectOptions := &projectv1.GetProjectOptions{} + getProjectOptions.SetID(instanceID) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetProject(getProjectOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return resp, "not_exists", nil + } else { + return resp, "exists", nil + } + } else { + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} model.Name = core.StringPtr(modelMap["name"].(string)) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index b4b28f32bc..b56d1fd302 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -8,8 +8,10 @@ import ( "encoding/json" "fmt" "log" + "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -26,6 +28,10 @@ func ResourceIbmProjectConfig() *schema.Resource { UpdateContext: resourceIbmProjectConfigUpdate, DeleteContext: resourceIbmProjectConfigDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(1 * time.Minute), + Delete: schema.DefaultTimeout(1 * time.Minute), + }, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ @@ -606,9 +612,47 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) + _, err = waitForProjectConfigInstanceCreate(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project config instance (%s) to be succeeded: %s", d.Id(), err)) + } + return resourceIbmProjectConfigRead(context, d, meta) } +func waitForProjectConfigInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + getConfigOptions := &projectv1.GetConfigOptions{} + parts, err := flex.SepIdParts(d.Id(), "/") + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"not_exists"}, + Target: []string{"exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetConfig(getConfigOptions) + if err == nil { + if resp != nil && resp.StatusCode == 200 { + return resp, "exists", nil + } else { + return resp, "not_exists", nil + } + } else { + return nil, "", fmt.Errorf("[ERROR] Get the project config instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) + } + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -922,11 +966,49 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) } + _, err = waitForProjectConfigInstanceDelete(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project config instance (%s) to be succeeded: %s", d.Id(), err)) + } + d.SetId("") return nil } +func waitForProjectConfigInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return false, err + } + getConfigOptions := &projectv1.GetConfigOptions{} + parts, err := flex.SepIdParts(d.Id(), "/") + getConfigOptions.SetProjectID(parts[0]) + getConfigOptions.SetID(parts[1]) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"exists"}, + Target: []string{"not_exists"}, + Refresh: func() (interface{}, string, error) { + _, resp, err := projectClient.GetConfig(getConfigOptions) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return resp, "not_exists", nil + } else { + return resp, "exists", nil + } + } else { + return resp, "exists", nil + } + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 2 * time.Second, + MinTimeout: 10 * time.Second, + } + + return stateConf.WaitForState() +} + func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { From 5011fe327dd7ec4d53e04a6945d143c1cf377d41 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 19 Jul 2023 17:06:18 +0200 Subject: [PATCH 078/125] terraform --- ibm/service/project/data_source_ibm_project_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 113897b200..5782ed8e80 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -32,7 +32,6 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), ), }, @@ -45,7 +44,7 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { projectLocation := fmt.Sprintf("us-south") projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectDestroyOnDelete := "false" + projectDestroyOnDelete := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -54,7 +53,6 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), From 19d198f5386e10d959053fae2528aa3f6b1de70c Mon Sep 17 00:00:00 2001 From: Mark-Kulube Date: Fri, 28 Jul 2023 12:06:33 -0400 Subject: [PATCH 079/125] feat: projects graph fragment pattern --- examples/ibm-project/README.md | 4 +- examples/ibm-project/main.tf | 95 +- examples/ibm-project/variables.tf | 8 +- go.mod | 4 +- go.sum | 8 +- ibm/provider/provider.go | 431 ++------ ibm/service/project/README.md | 6 +- .../project/data_source_ibm_project.go | 569 ++++++++++- .../project/data_source_ibm_project_config.go | 927 ++++++++---------- .../data_source_ibm_project_config_test.go | 140 +-- .../project/data_source_ibm_project_test.go | 180 +++- ibm/service/project/resource_ibm_project.go | 677 ++++++++++--- .../project/resource_ibm_project_config.go | 785 ++++++--------- .../resource_ibm_project_config_test.go | 39 +- .../project/resource_ibm_project_test.go | 110 ++- website/docs/d/project.html.markdown | 118 ++- website/docs/d/project_config.html.markdown | 133 ++- website/docs/r/project.html.markdown | 180 +++- website/docs/r/project_config.html.markdown | 127 ++- 19 files changed, 2781 insertions(+), 1760 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 7b35e9a06d..9c23f3287d 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -64,7 +64,7 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + id = ibm_project_config.project_config_instance.projectConfigCanonical_id } ``` @@ -106,7 +106,7 @@ data "project_config" "project_config_instance" { | authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | | locator_id | A dotted value of catalogID.versionID. | `string` | true | -| input | The outputs of a Schematics template property. | `list()` | false | +| input | The inputs of a Schematics template property. | `list()` | false | | setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index ce2e627b25..cea26480b9 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -10,12 +10,40 @@ resource "ibm_project" "project_instance" { description = var.project_description destroy_on_delete = var.project_destroy_on_delete configs { + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" authorizations { - method = "API_KEY" - api_key = var.ibmcloud_api_key + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } locator_id = "locator_id" input { @@ -26,6 +54,54 @@ resource "ibm_project" "project_instance" { name = "name" value = "value" } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" + href = "href" + } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } + href = "href" } } @@ -38,15 +114,22 @@ resource "ibm_project_config" "project_config_instance" { authorizations { trusted_profile { id = "id" + target_iam_id = "target_iam_id" } - method = "TRUSTED_PROFILE" + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } locator_id = var.project_config_locator_id input { name = "name" - type = "array" value = "anything as a string" - required = true } setting { name = "name" @@ -62,5 +145,5 @@ data "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + id = ibm_project_config.project_config_instance.projectConfigCanonical_id } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 1e2a97e4d3..86b9bf2534 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -39,22 +39,22 @@ variable "project_config_project_id" { variable "project_config_name" { description = "The name of the configuration." type = string - default = "env-stage" + default = "name" } variable "project_config_labels" { description = "A collection of configuration labels." type = list(string) - default = ["env:stage","governance:test","build:0"] + default = [ "labels" ] } variable "project_config_description" { description = "The description of the project configuration." type = string - default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + default = "description" } variable "project_config_locator_id" { description = "A dotted value of catalogID.versionID." type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + default = "locator_id" } // Data source arguments for project diff --git a/go.mod b/go.mod index e6ffc11e84..e87d266874 100644 --- a/go.mod +++ b/go.mod @@ -24,14 +24,14 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.41.0 - github.com/IBM/project-go-sdk v0.0.26-11 + github.com/IBM/project-go-sdk v0.0.26-33 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 github.com/IBM/schematics-go-sdk v0.2.1 github.com/IBM/secrets-manager-go-sdk/v2 v2.0.0 github.com/IBM/vpc-beta-go-sdk v0.4.0 - github.com/IBM/vpc-go-sdk v0.38.0 + github.com/IBM/vpc-go-sdk v0.40.0 github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 github.com/Shopify/sarama v1.29.1 github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105 diff --git a/go.sum b/go.sum index 732ac45aa9..a161a317c1 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.41.0 h1:2aeHcLnQgat7UAKrtIF6jGyFW2hwq4oroO26fIX94kA= github.com/IBM/platform-services-go-sdk v0.41.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-11 h1:zl8RN7OOKWX6pjiF6Ax7fPq9RC+O8iVblQ/QMyeZ9X4= -github.com/IBM/project-go-sdk v0.0.26-11/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-33 h1:LbWD0/wzoNsEItoECsCxA+vB38e/MCxdL5H9E16ai1c= +github.com/IBM/project-go-sdk v0.0.26-33/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= @@ -170,8 +170,8 @@ github.com/IBM/secrets-manager-go-sdk/v2 v2.0.0 h1:Lx4Bvim/MfoHEYR+n312bty5DirAJ github.com/IBM/secrets-manager-go-sdk/v2 v2.0.0/go.mod h1:jagqWmjZ0zUEqh5jdGB42ApSQS40fu2LWw6pdg8JJko= github.com/IBM/vpc-beta-go-sdk v0.4.0 h1:OxABcc2GeclCMN/bpcQfM2cmNB2GuajwuocsPJSFdl0= github.com/IBM/vpc-beta-go-sdk v0.4.0/go.mod h1:fzHDAQIqH/5yJmYsKodKHLcqxMDT+yfH6vZjdiw8CQA= -github.com/IBM/vpc-go-sdk v0.38.0 h1:iB2/ukDciK6s2VBnMmNQeZqenOaUXJSt+V2M4fMjAnM= -github.com/IBM/vpc-go-sdk v0.38.0/go.mod h1:MgZrbITC067AlcE5oy4hwylasFvrePL4RVxeF6GTdKQ= +github.com/IBM/vpc-go-sdk v0.40.0 h1:p4E1dIQc6+WmqLwRTzgWA2udqFw6nypOg+8R0WxTgX0= +github.com/IBM/vpc-go-sdk v0.40.0/go.mod h1:MgZrbITC067AlcE5oy4hwylasFvrePL4RVxeF6GTdKQ= github.com/Jeffail/gabs v1.1.1 h1:V0uzR08Hj22EX8+8QMhyI9sX2hwRu+/RJhJUmnwda/E= github.com/Jeffail/gabs v1.1.1/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 7f06ae3b94..efa4b65a2a 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -50,7 +50,6 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/schematics" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/secretsmanager" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/transitgateway" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -362,180 +361,29 @@ func Provider() *schema.Provider { "ibm_iam_trusted_profile_policy": iampolicy.DataSourceIBMIAMTrustedProfilePolicy(), "ibm_iam_user_mfa_enrollments": iamidentity.DataSourceIBMIamUserMfaEnrollments(), - //backup as Service - "ibm_is_backup_policy": vpc.DataSourceIBMIsBackupPolicy(), - "ibm_is_backup_policies": vpc.DataSourceIBMIsBackupPolicies(), - "ibm_is_backup_policy_plan": vpc.DataSourceIBMIsBackupPolicyPlan(), - "ibm_is_backup_policy_plans": vpc.DataSourceIBMIsBackupPolicyPlans(), - "ibm_is_backup_policy_job": vpc.DataSourceIBMIsBackupPolicyJob(), - "ibm_is_backup_policy_jobs": vpc.DataSourceIBMIsBackupPolicyJobs(), - - // bare_metal_server - "ibm_is_bare_metal_server_disk": vpc.DataSourceIBMIsBareMetalServerDisk(), - "ibm_is_bare_metal_server_disks": vpc.DataSourceIBMIsBareMetalServerDisks(), - "ibm_is_bare_metal_server_initialization": vpc.DataSourceIBMIsBareMetalServerInitialization(), - "ibm_is_bare_metal_server_network_interface_floating_ip": vpc.DataSourceIBMIsBareMetalServerNetworkInterfaceFloatingIP(), - "ibm_is_bare_metal_server_network_interface_floating_ips": vpc.DataSourceIBMIsBareMetalServerNetworkInterfaceFloatingIPs(), - "ibm_is_bare_metal_server_network_interface_reserved_ip": vpc.DataSourceIBMISBareMetalServerNICReservedIP(), - "ibm_is_bare_metal_server_network_interface_reserved_ips": vpc.DataSourceIBMISBareMetalServerNICReservedIPs(), - "ibm_is_bare_metal_server_network_interface": vpc.DataSourceIBMIsBareMetalServerNetworkInterface(), - "ibm_is_bare_metal_server_network_interfaces": vpc.DataSourceIBMIsBareMetalServerNetworkInterfaces(), - "ibm_is_bare_metal_server_profile": vpc.DataSourceIBMIsBareMetalServerProfile(), - "ibm_is_bare_metal_server_profiles": vpc.DataSourceIBMIsBareMetalServerProfiles(), - "ibm_is_bare_metal_server": vpc.DataSourceIBMIsBareMetalServer(), - "ibm_is_bare_metal_servers": vpc.DataSourceIBMIsBareMetalServers(), - - "ibm_is_dedicated_host": vpc.DataSourceIbmIsDedicatedHost(), - "ibm_is_dedicated_hosts": vpc.DataSourceIbmIsDedicatedHosts(), - "ibm_is_dedicated_host_profile": vpc.DataSourceIbmIsDedicatedHostProfile(), - "ibm_is_dedicated_host_profiles": vpc.DataSourceIbmIsDedicatedHostProfiles(), - "ibm_is_dedicated_host_group": vpc.DataSourceIbmIsDedicatedHostGroup(), - "ibm_is_dedicated_host_groups": vpc.DataSourceIbmIsDedicatedHostGroups(), - "ibm_is_dedicated_host_disk": vpc.DataSourceIbmIsDedicatedHostDisk(), - "ibm_is_dedicated_host_disks": vpc.DataSourceIbmIsDedicatedHostDisks(), - "ibm_is_placement_group": vpc.DataSourceIbmIsPlacementGroup(), - "ibm_is_placement_groups": vpc.DataSourceIbmIsPlacementGroups(), - "ibm_is_floating_ip": vpc.DataSourceIBMISFloatingIP(), - "ibm_is_floating_ips": vpc.DataSourceIBMIsFloatingIps(), - "ibm_is_flow_log": vpc.DataSourceIBMIsFlowLog(), - "ibm_is_flow_logs": vpc.DataSourceIBMISFlowLogs(), - "ibm_is_image": vpc.DataSourceIBMISImage(), - "ibm_is_images": vpc.DataSourceIBMISImages(), - "ibm_is_image_export_job": vpc.DataSourceIBMIsImageExport(), - "ibm_is_image_export_jobs": vpc.DataSourceIBMIsImageExports(), - "ibm_is_endpoint_gateway_targets": vpc.DataSourceIBMISEndpointGatewayTargets(), - "ibm_is_instance_group": vpc.DataSourceIBMISInstanceGroup(), - "ibm_is_instance_groups": vpc.DataSourceIBMISInstanceGroups(), - "ibm_is_instance_group_memberships": vpc.DataSourceIBMISInstanceGroupMemberships(), - "ibm_is_instance_group_membership": vpc.DataSourceIBMISInstanceGroupMembership(), - "ibm_is_instance_group_manager": vpc.DataSourceIBMISInstanceGroupManager(), - "ibm_is_instance_group_managers": vpc.DataSourceIBMISInstanceGroupManagers(), - "ibm_is_instance_group_manager_policies": vpc.DataSourceIBMISInstanceGroupManagerPolicies(), - "ibm_is_instance_group_manager_policy": vpc.DataSourceIBMISInstanceGroupManagerPolicy(), - "ibm_is_instance_group_manager_action": vpc.DataSourceIBMISInstanceGroupManagerAction(), - "ibm_is_instance_group_manager_actions": vpc.DataSourceIBMISInstanceGroupManagerActions(), - "ibm_is_virtual_endpoint_gateways": vpc.DataSourceIBMISEndpointGateways(), - "ibm_is_virtual_endpoint_gateway_ips": vpc.DataSourceIBMISEndpointGatewayIPs(), - "ibm_is_virtual_endpoint_gateway": vpc.DataSourceIBMISEndpointGateway(), - "ibm_is_instance_template": vpc.DataSourceIBMISInstanceTemplate(), - "ibm_is_instance_templates": vpc.DataSourceIBMISInstanceTemplates(), - "ibm_is_instance_profile": vpc.DataSourceIBMISInstanceProfile(), - "ibm_is_instance_profiles": vpc.DataSourceIBMISInstanceProfiles(), - "ibm_is_instance": vpc.DataSourceIBMISInstance(), - "ibm_is_instances": vpc.DataSourceIBMISInstances(), - "ibm_is_instance_network_interface": vpc.DataSourceIBMIsInstanceNetworkInterface(), - "ibm_is_instance_network_interfaces": vpc.DataSourceIBMIsInstanceNetworkInterfaces(), - "ibm_is_instance_disk": vpc.DataSourceIbmIsInstanceDisk(), - "ibm_is_instance_disks": vpc.DataSourceIbmIsInstanceDisks(), - - // reserved ips - "ibm_is_instance_network_interface_reserved_ip": vpc.DataSourceIBMISInstanceNICReservedIP(), - "ibm_is_instance_network_interface_reserved_ips": vpc.DataSourceIBMISInstanceNICReservedIPs(), - - "ibm_is_instance_volume_attachment": vpc.DataSourceIBMISInstanceVolumeAttachment(), - "ibm_is_instance_volume_attachments": vpc.DataSourceIBMISInstanceVolumeAttachments(), - "ibm_is_ipsec_policy": vpc.DataSourceIBMIsIpsecPolicy(), - "ibm_is_ipsec_policies": vpc.DataSourceIBMIsIpsecPolicies(), - "ibm_is_ike_policies": vpc.DataSourceIBMIsIkePolicies(), - "ibm_is_ike_policy": vpc.DataSourceIBMIsIkePolicy(), - "ibm_is_lb": vpc.DataSourceIBMISLB(), - "ibm_is_lb_listener": vpc.DataSourceIBMISLBListener(), - "ibm_is_lb_listeners": vpc.DataSourceIBMISLBListeners(), - "ibm_is_lb_listener_policies": vpc.DataSourceIBMISLBListenerPolicies(), - "ibm_is_lb_listener_policy": vpc.DataSourceIBMISLBListenerPolicy(), - "ibm_is_lb_listener_policy_rule": vpc.DataSourceIBMISLBListenerPolicyRule(), - "ibm_is_lb_listener_policy_rules": vpc.DataSourceIBMISLBListenerPolicyRules(), - "ibm_is_lb_pool": vpc.DataSourceIBMISLBPool(), - "ibm_is_lb_pools": vpc.DataSourceIBMISLBPools(), - "ibm_is_lb_pool_member": vpc.DataSourceIBMIBLBPoolMember(), - "ibm_is_lb_pool_members": vpc.DataSourceIBMISLBPoolMembers(), - "ibm_is_lb_profile": vpc.DataSourceIBMISLbProfile(), - "ibm_is_lb_profiles": vpc.DataSourceIBMISLbProfiles(), - "ibm_is_lbs": vpc.DataSourceIBMISLBS(), - "ibm_is_public_gateway": vpc.DataSourceIBMISPublicGateway(), - "ibm_is_public_gateways": vpc.DataSourceIBMISPublicGateways(), - "ibm_is_region": vpc.DataSourceIBMISRegion(), - "ibm_is_regions": vpc.DataSourceIBMISRegions(), - "ibm_is_ssh_key": vpc.DataSourceIBMISSSHKey(), - "ibm_is_ssh_keys": vpc.DataSourceIBMIsSshKeys(), - "ibm_is_subnet": vpc.DataSourceIBMISSubnet(), - "ibm_is_subnets": vpc.DataSourceIBMISSubnets(), - "ibm_is_subnet_reserved_ip": vpc.DataSourceIBMISReservedIP(), - "ibm_is_subnet_reserved_ips": vpc.DataSourceIBMISReservedIPs(), - "ibm_is_security_group": vpc.DataSourceIBMISSecurityGroup(), - "ibm_is_security_groups": vpc.DataSourceIBMIsSecurityGroups(), - "ibm_is_security_group_rule": vpc.DataSourceIBMIsSecurityGroupRule(), - "ibm_is_security_group_rules": vpc.DataSourceIBMIsSecurityGroupRules(), - "ibm_is_security_group_target": vpc.DataSourceIBMISSecurityGroupTarget(), - "ibm_is_security_group_targets": vpc.DataSourceIBMISSecurityGroupTargets(), - "ibm_is_snapshot_clone": vpc.DataSourceSnapshotClone(), - "ibm_is_snapshot_clones": vpc.DataSourceSnapshotClones(), - "ibm_is_snapshot": vpc.DataSourceSnapshot(), - "ibm_is_snapshots": vpc.DataSourceSnapshots(), - "ibm_is_share": vpc.DataSourceIbmIsShare(), - "ibm_is_source_share": vpc.DataSourceIbmIsSourceShare(), - "ibm_is_shares": vpc.DataSourceIbmIsShares(), - "ibm_is_share_profile": vpc.DataSourceIbmIsShareProfile(), - "ibm_is_share_profiles": vpc.DataSourceIbmIsShareProfiles(), - "ibm_is_share_target": vpc.DataSourceIbmIsShareTarget(), - "ibm_is_share_targets": vpc.DataSourceIbmIsShareTargets(), - "ibm_is_share_mount_target": vpc.DataSourceIBMIsShareTarget(), - "ibm_is_share_mount_targets": vpc.DataSourceIBMIsShareTargets(), - "ibm_is_volume": vpc.DataSourceIBMISVolume(), - "ibm_is_volumes": vpc.DataSourceIBMIsVolumes(), - "ibm_is_volume_profile": vpc.DataSourceIBMISVolumeProfile(), - "ibm_is_volume_profiles": vpc.DataSourceIBMISVolumeProfiles(), - "ibm_is_vpc": vpc.DataSourceIBMISVPC(), - "ibm_is_vpcs": vpc.DataSourceIBMISVPCs(), - "ibm_is_vpn_gateway": vpc.DataSourceIBMISVPNGateway(), - "ibm_is_vpn_gateways": vpc.DataSourceIBMISVPNGateways(), - "ibm_is_vpc_address_prefixes": vpc.DataSourceIbmIsVpcAddressPrefixes(), - "ibm_is_vpc_address_prefix": vpc.DataSourceIBMIsVPCAddressPrefix(), - "ibm_is_vpn_gateway_connection": vpc.DataSourceIBMISVPNGatewayConnection(), - "ibm_is_vpn_gateway_connections": vpc.DataSourceIBMISVPNGatewayConnections(), - "ibm_is_vpc_default_routing_table": vpc.DataSourceIBMISVPCDefaultRoutingTable(), - "ibm_is_vpc_routing_table": vpc.DataSourceIBMIBMIsVPCRoutingTable(), - "ibm_is_vpc_routing_tables": vpc.DataSourceIBMISVPCRoutingTables(), - "ibm_is_vpc_routing_table_route": vpc.DataSourceIBMIBMIsVPCRoutingTableRoute(), - "ibm_is_vpc_routing_table_routes": vpc.DataSourceIBMISVPCRoutingTableRoutes(), - "ibm_is_vpn_server": vpc.DataSourceIBMIsVPNServer(), - "ibm_is_vpn_servers": vpc.DataSourceIBMIsVPNServers(), - "ibm_is_vpn_server_client": vpc.DataSourceIBMIsVPNServerClient(), - "ibm_is_vpn_server_client_configuration": vpc.DataSourceIBMIsVPNServerClientConfiguration(), - "ibm_is_vpn_server_clients": vpc.DataSourceIBMIsVPNServerClients(), - "ibm_is_vpn_server_route": vpc.DataSourceIBMIsVPNServerRoute(), - "ibm_is_vpn_server_routes": vpc.DataSourceIBMIsVPNServerRoutes(), - "ibm_is_zone": vpc.DataSourceIBMISZone(), - "ibm_is_zones": vpc.DataSourceIBMISZones(), - "ibm_is_operating_system": vpc.DataSourceIBMISOperatingSystem(), - "ibm_is_operating_systems": vpc.DataSourceIBMISOperatingSystems(), - "ibm_is_network_acls": vpc.DataSourceIBMIsNetworkAcls(), - "ibm_is_network_acl": vpc.DataSourceIBMIsNetworkACL(), - "ibm_is_network_acl_rule": vpc.DataSourceIBMISNetworkACLRule(), - "ibm_is_network_acl_rules": vpc.DataSourceIBMISNetworkACLRules(), - "ibm_lbaas": classicinfrastructure.DataSourceIBMLbaas(), - "ibm_network_vlan": classicinfrastructure.DataSourceIBMNetworkVlan(), - "ibm_org": cloudfoundry.DataSourceIBMOrg(), - "ibm_org_quota": cloudfoundry.DataSourceIBMOrgQuota(), - "ibm_kms_instance_policies": kms.DataSourceIBMKmsInstancePolicies(), - "ibm_kp_key": kms.DataSourceIBMkey(), - "ibm_kms_key_rings": kms.DataSourceIBMKMSkeyRings(), - "ibm_kms_key_policies": kms.DataSourceIBMKMSkeyPolicies(), - "ibm_kms_keys": kms.DataSourceIBMKMSkeys(), - "ibm_kms_key": kms.DataSourceIBMKMSkey(), - "ibm_pn_application_chrome": pushnotification.DataSourceIBMPNApplicationChrome(), - "ibm_app_config_environment": appconfiguration.DataSourceIBMAppConfigEnvironment(), - "ibm_app_config_environments": appconfiguration.DataSourceIBMAppConfigEnvironments(), - "ibm_app_config_collection": appconfiguration.DataSourceIBMAppConfigCollection(), - "ibm_app_config_collections": appconfiguration.DataSourceIBMAppConfigCollections(), - "ibm_app_config_feature": appconfiguration.DataSourceIBMAppConfigFeature(), - "ibm_app_config_features": appconfiguration.DataSourceIBMAppConfigFeatures(), - "ibm_app_config_property": appconfiguration.DataSourceIBMAppConfigProperty(), - "ibm_app_config_properties": appconfiguration.DataSourceIBMAppConfigProperties(), - "ibm_app_config_segment": appconfiguration.DataSourceIBMAppConfigSegment(), - "ibm_app_config_segments": appconfiguration.DataSourceIBMAppConfigSegments(), - "ibm_app_config_snapshot": appconfiguration.DataSourceIBMAppConfigSnapshot(), - "ibm_app_config_snapshots": appconfiguration.DataSourceIBMAppConfigSnapshots(), + "ibm_lbaas": classicinfrastructure.DataSourceIBMLbaas(), + "ibm_network_vlan": classicinfrastructure.DataSourceIBMNetworkVlan(), + "ibm_org": cloudfoundry.DataSourceIBMOrg(), + "ibm_org_quota": cloudfoundry.DataSourceIBMOrgQuota(), + "ibm_kms_instance_policies": kms.DataSourceIBMKmsInstancePolicies(), + "ibm_kp_key": kms.DataSourceIBMkey(), + "ibm_kms_key_rings": kms.DataSourceIBMKMSkeyRings(), + "ibm_kms_key_policies": kms.DataSourceIBMKMSkeyPolicies(), + "ibm_kms_keys": kms.DataSourceIBMKMSkeys(), + "ibm_kms_key": kms.DataSourceIBMKMSkey(), + "ibm_pn_application_chrome": pushnotification.DataSourceIBMPNApplicationChrome(), + "ibm_app_config_environment": appconfiguration.DataSourceIBMAppConfigEnvironment(), + "ibm_app_config_environments": appconfiguration.DataSourceIBMAppConfigEnvironments(), + "ibm_app_config_collection": appconfiguration.DataSourceIBMAppConfigCollection(), + "ibm_app_config_collections": appconfiguration.DataSourceIBMAppConfigCollections(), + "ibm_app_config_feature": appconfiguration.DataSourceIBMAppConfigFeature(), + "ibm_app_config_features": appconfiguration.DataSourceIBMAppConfigFeatures(), + "ibm_app_config_property": appconfiguration.DataSourceIBMAppConfigProperty(), + "ibm_app_config_properties": appconfiguration.DataSourceIBMAppConfigProperties(), + "ibm_app_config_segment": appconfiguration.DataSourceIBMAppConfigSegment(), + "ibm_app_config_segments": appconfiguration.DataSourceIBMAppConfigSegments(), + "ibm_app_config_snapshot": appconfiguration.DataSourceIBMAppConfigSnapshot(), + "ibm_app_config_snapshots": appconfiguration.DataSourceIBMAppConfigSnapshots(), "ibm_resource_quota": resourcecontroller.DataSourceIBMResourceQuota(), "ibm_resource_group": resourcemanager.DataSourceIBMResourceGroup(), @@ -958,123 +806,55 @@ func Provider() *schema.Provider { "ibm_iam_trusted_profile_policy": iampolicy.ResourceIBMIAMTrustedProfilePolicy(), "ibm_ipsec_vpn": classicinfrastructure.ResourceIBMIPSecVPN(), - "ibm_is_backup_policy": vpc.ResourceIBMIsBackupPolicy(), - "ibm_is_backup_policy_plan": vpc.ResourceIBMIsBackupPolicyPlan(), - - // bare_metal_server - "ibm_is_bare_metal_server_action": vpc.ResourceIBMIsBareMetalServerAction(), - "ibm_is_bare_metal_server_disk": vpc.ResourceIBMIsBareMetalServerDisk(), - "ibm_is_bare_metal_server_network_interface_allow_float": vpc.ResourceIBMIsBareMetalServerNetworkInterfaceAllowFloat(), - "ibm_is_bare_metal_server_network_interface_floating_ip": vpc.ResourceIBMIsBareMetalServerNetworkInterfaceFloatingIp(), - "ibm_is_bare_metal_server_network_interface": vpc.ResourceIBMIsBareMetalServerNetworkInterface(), - "ibm_is_bare_metal_server": vpc.ResourceIBMIsBareMetalServer(), - - "ibm_is_dedicated_host": vpc.ResourceIbmIsDedicatedHost(), - "ibm_is_dedicated_host_group": vpc.ResourceIbmIsDedicatedHostGroup(), - "ibm_is_dedicated_host_disk_management": vpc.ResourceIBMISDedicatedHostDiskManagement(), - "ibm_is_placement_group": vpc.ResourceIbmIsPlacementGroup(), - "ibm_is_floating_ip": vpc.ResourceIBMISFloatingIP(), - "ibm_is_flow_log": vpc.ResourceIBMISFlowLog(), - "ibm_is_instance": vpc.ResourceIBMISInstance(), - "ibm_is_instance_action": vpc.ResourceIBMISInstanceAction(), - "ibm_is_instance_network_interface": vpc.ResourceIBMIsInstanceNetworkInterface(), - "ibm_is_instance_network_interface_floating_ip": vpc.ResourceIBMIsInstanceNetworkInterfaceFloatingIp(), - "ibm_is_instance_disk_management": vpc.ResourceIBMISInstanceDiskManagement(), - "ibm_is_instance_group": vpc.ResourceIBMISInstanceGroup(), - "ibm_is_instance_group_membership": vpc.ResourceIBMISInstanceGroupMembership(), - "ibm_is_instance_group_manager": vpc.ResourceIBMISInstanceGroupManager(), - "ibm_is_instance_group_manager_policy": vpc.ResourceIBMISInstanceGroupManagerPolicy(), - "ibm_is_instance_group_manager_action": vpc.ResourceIBMISInstanceGroupManagerAction(), - "ibm_is_instance_volume_attachment": vpc.ResourceIBMISInstanceVolumeAttachment(), - "ibm_is_virtual_endpoint_gateway": vpc.ResourceIBMISEndpointGateway(), - "ibm_is_virtual_endpoint_gateway_ip": vpc.ResourceIBMISEndpointGatewayIP(), - "ibm_is_instance_template": vpc.ResourceIBMISInstanceTemplate(), - "ibm_is_ike_policy": vpc.ResourceIBMISIKEPolicy(), - "ibm_is_ipsec_policy": vpc.ResourceIBMISIPSecPolicy(), - "ibm_is_lb": vpc.ResourceIBMISLB(), - "ibm_is_lb_listener": vpc.ResourceIBMISLBListener(), - "ibm_is_lb_listener_policy": vpc.ResourceIBMISLBListenerPolicy(), - "ibm_is_lb_listener_policy_rule": vpc.ResourceIBMISLBListenerPolicyRule(), - "ibm_is_lb_pool": vpc.ResourceIBMISLBPool(), - "ibm_is_lb_pool_member": vpc.ResourceIBMISLBPoolMember(), - "ibm_is_network_acl": vpc.ResourceIBMISNetworkACL(), - "ibm_is_network_acl_rule": vpc.ResourceIBMISNetworkACLRule(), - "ibm_is_public_gateway": vpc.ResourceIBMISPublicGateway(), - "ibm_is_security_group": vpc.ResourceIBMISSecurityGroup(), - "ibm_is_security_group_rule": vpc.ResourceIBMISSecurityGroupRule(), - "ibm_is_security_group_target": vpc.ResourceIBMISSecurityGroupTarget(), - "ibm_is_share": vpc.ResourceIbmIsShare(), - "ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperations(), - "ibm_is_share_target": vpc.ResourceIbmIsShareMountTarget(), - "ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTarget(), - "ibm_is_subnet": vpc.ResourceIBMISSubnet(), - "ibm_is_subnet_reserved_ip": vpc.ResourceIBMISReservedIP(), - "ibm_is_subnet_network_acl_attachment": vpc.ResourceIBMISSubnetNetworkACLAttachment(), - "ibm_is_subnet_public_gateway_attachment": vpc.ResourceIBMISSubnetPublicGatewayAttachment(), - "ibm_is_subnet_routing_table_attachment": vpc.ResourceIBMISSubnetRoutingTableAttachment(), - "ibm_is_ssh_key": vpc.ResourceIBMISSSHKey(), - "ibm_is_snapshot": vpc.ResourceIBMSnapshot(), - "ibm_is_volume": vpc.ResourceIBMISVolume(), - "ibm_is_vpn_gateway": vpc.ResourceIBMISVPNGateway(), - "ibm_is_vpn_gateway_connection": vpc.ResourceIBMISVPNGatewayConnection(), - "ibm_is_vpc": vpc.ResourceIBMISVPC(), - "ibm_is_vpc_address_prefix": vpc.ResourceIBMISVpcAddressPrefix(), - "ibm_is_vpc_routing_table": vpc.ResourceIBMISVPCRoutingTable(), - "ibm_is_vpc_routing_table_route": vpc.ResourceIBMISVPCRoutingTableRoute(), - "ibm_is_vpn_server": vpc.ResourceIBMIsVPNServer(), - "ibm_is_vpn_server_client": vpc.ResourceIBMIsVPNServerClient(), - "ibm_is_vpn_server_route": vpc.ResourceIBMIsVPNServerRoute(), - "ibm_is_image": vpc.ResourceIBMISImage(), - "ibm_is_image_export_job": vpc.ResourceIBMIsImageExportJob(), - "ibm_lb": classicinfrastructure.ResourceIBMLb(), - "ibm_lbaas": classicinfrastructure.ResourceIBMLbaas(), - "ibm_lbaas_health_monitor": classicinfrastructure.ResourceIBMLbaasHealthMonitor(), - "ibm_lbaas_server_instance_attachment": classicinfrastructure.ResourceIBMLbaasServerInstanceAttachment(), - "ibm_lb_service": classicinfrastructure.ResourceIBMLbService(), - "ibm_lb_service_group": classicinfrastructure.ResourceIBMLbServiceGroup(), - "ibm_lb_vpx": classicinfrastructure.ResourceIBMLbVpx(), - "ibm_lb_vpx_ha": classicinfrastructure.ResourceIBMLbVpxHa(), - "ibm_lb_vpx_service": classicinfrastructure.ResourceIBMLbVpxService(), - "ibm_lb_vpx_vip": classicinfrastructure.ResourceIBMLbVpxVip(), - "ibm_multi_vlan_firewall": classicinfrastructure.ResourceIBMMultiVlanFirewall(), - "ibm_network_gateway": classicinfrastructure.ResourceIBMNetworkGateway(), - "ibm_network_gateway_vlan_association": classicinfrastructure.ResourceIBMNetworkGatewayVlanAttachment(), - "ibm_network_interface_sg_attachment": classicinfrastructure.ResourceIBMNetworkInterfaceSGAttachment(), - "ibm_network_public_ip": classicinfrastructure.ResourceIBMNetworkPublicIp(), - "ibm_network_vlan": classicinfrastructure.ResourceIBMNetworkVlan(), - "ibm_network_vlan_spanning": classicinfrastructure.ResourceIBMNetworkVlanSpan(), - "ibm_object_storage_account": classicinfrastructure.ResourceIBMObjectStorageAccount(), - "ibm_org": cloudfoundry.ResourceIBMOrg(), - "ibm_pn_application_chrome": pushnotification.ResourceIBMPNApplicationChrome(), - "ibm_app_config_environment": appconfiguration.ResourceIBMAppConfigEnvironment(), - "ibm_app_config_collection": appconfiguration.ResourceIBMAppConfigCollection(), - "ibm_app_config_feature": appconfiguration.ResourceIBMIbmAppConfigFeature(), - "ibm_app_config_property": appconfiguration.ResourceIBMIbmAppConfigProperty(), - "ibm_app_config_segment": appconfiguration.ResourceIBMIbmAppConfigSegment(), - "ibm_app_config_snapshot": appconfiguration.ResourceIBMIbmAppConfigSnapshot(), - "ibm_kms_key": kms.ResourceIBMKmskey(), - "ibm_kms_key_with_policy_overrides": kms.ResourceIBMKmsKeyWithPolicyOverrides(), - "ibm_kms_key_alias": kms.ResourceIBMKmskeyAlias(), - "ibm_kms_key_rings": kms.ResourceIBMKmskeyRings(), - "ibm_kms_key_policies": kms.ResourceIBMKmskeyPolicies(), - "ibm_kp_key": kms.ResourceIBMkey(), - "ibm_kms_instance_policies": kms.ResourceIBMKmsInstancePolicy(), - "ibm_resource_group": resourcemanager.ResourceIBMResourceGroup(), - "ibm_resource_instance": resourcecontroller.ResourceIBMResourceInstance(), - "ibm_resource_key": resourcecontroller.ResourceIBMResourceKey(), - "ibm_security_group": classicinfrastructure.ResourceIBMSecurityGroup(), - "ibm_security_group_rule": classicinfrastructure.ResourceIBMSecurityGroupRule(), - "ibm_service_instance": cloudfoundry.ResourceIBMServiceInstance(), - "ibm_service_key": cloudfoundry.ResourceIBMServiceKey(), - "ibm_space": cloudfoundry.ResourceIBMSpace(), - "ibm_storage_evault": classicinfrastructure.ResourceIBMStorageEvault(), - "ibm_storage_block": classicinfrastructure.ResourceIBMStorageBlock(), - "ibm_storage_file": classicinfrastructure.ResourceIBMStorageFile(), - "ibm_subnet": classicinfrastructure.ResourceIBMSubnet(), - "ibm_dns_reverse_record": classicinfrastructure.ResourceIBMDNSReverseRecord(), - "ibm_ssl_certificate": classicinfrastructure.ResourceIBMSSLCertificate(), - "ibm_cdn": classicinfrastructure.ResourceIBMCDN(), - "ibm_hardware_firewall_shared": classicinfrastructure.ResourceIBMFirewallShared(), + "ibm_lb": classicinfrastructure.ResourceIBMLb(), + "ibm_lbaas": classicinfrastructure.ResourceIBMLbaas(), + "ibm_lbaas_health_monitor": classicinfrastructure.ResourceIBMLbaasHealthMonitor(), + "ibm_lbaas_server_instance_attachment": classicinfrastructure.ResourceIBMLbaasServerInstanceAttachment(), + "ibm_lb_service": classicinfrastructure.ResourceIBMLbService(), + "ibm_lb_service_group": classicinfrastructure.ResourceIBMLbServiceGroup(), + "ibm_lb_vpx": classicinfrastructure.ResourceIBMLbVpx(), + "ibm_lb_vpx_ha": classicinfrastructure.ResourceIBMLbVpxHa(), + "ibm_lb_vpx_service": classicinfrastructure.ResourceIBMLbVpxService(), + "ibm_lb_vpx_vip": classicinfrastructure.ResourceIBMLbVpxVip(), + "ibm_multi_vlan_firewall": classicinfrastructure.ResourceIBMMultiVlanFirewall(), + "ibm_network_gateway": classicinfrastructure.ResourceIBMNetworkGateway(), + "ibm_network_gateway_vlan_association": classicinfrastructure.ResourceIBMNetworkGatewayVlanAttachment(), + "ibm_network_interface_sg_attachment": classicinfrastructure.ResourceIBMNetworkInterfaceSGAttachment(), + "ibm_network_public_ip": classicinfrastructure.ResourceIBMNetworkPublicIp(), + "ibm_network_vlan": classicinfrastructure.ResourceIBMNetworkVlan(), + "ibm_network_vlan_spanning": classicinfrastructure.ResourceIBMNetworkVlanSpan(), + "ibm_object_storage_account": classicinfrastructure.ResourceIBMObjectStorageAccount(), + "ibm_org": cloudfoundry.ResourceIBMOrg(), + "ibm_pn_application_chrome": pushnotification.ResourceIBMPNApplicationChrome(), + "ibm_app_config_environment": appconfiguration.ResourceIBMAppConfigEnvironment(), + "ibm_app_config_collection": appconfiguration.ResourceIBMAppConfigCollection(), + "ibm_app_config_feature": appconfiguration.ResourceIBMIbmAppConfigFeature(), + "ibm_app_config_property": appconfiguration.ResourceIBMIbmAppConfigProperty(), + "ibm_app_config_segment": appconfiguration.ResourceIBMIbmAppConfigSegment(), + "ibm_app_config_snapshot": appconfiguration.ResourceIBMIbmAppConfigSnapshot(), + "ibm_kms_key": kms.ResourceIBMKmskey(), + "ibm_kms_key_with_policy_overrides": kms.ResourceIBMKmsKeyWithPolicyOverrides(), + "ibm_kms_key_alias": kms.ResourceIBMKmskeyAlias(), + "ibm_kms_key_rings": kms.ResourceIBMKmskeyRings(), + "ibm_kms_key_policies": kms.ResourceIBMKmskeyPolicies(), + "ibm_kp_key": kms.ResourceIBMkey(), + "ibm_kms_instance_policies": kms.ResourceIBMKmsInstancePolicy(), + "ibm_resource_group": resourcemanager.ResourceIBMResourceGroup(), + "ibm_resource_instance": resourcecontroller.ResourceIBMResourceInstance(), + "ibm_resource_key": resourcecontroller.ResourceIBMResourceKey(), + "ibm_security_group": classicinfrastructure.ResourceIBMSecurityGroup(), + "ibm_security_group_rule": classicinfrastructure.ResourceIBMSecurityGroupRule(), + "ibm_service_instance": cloudfoundry.ResourceIBMServiceInstance(), + "ibm_service_key": cloudfoundry.ResourceIBMServiceKey(), + "ibm_space": cloudfoundry.ResourceIBMSpace(), + "ibm_storage_evault": classicinfrastructure.ResourceIBMStorageEvault(), + "ibm_storage_block": classicinfrastructure.ResourceIBMStorageBlock(), + "ibm_storage_file": classicinfrastructure.ResourceIBMStorageFile(), + "ibm_subnet": classicinfrastructure.ResourceIBMSubnet(), + "ibm_dns_reverse_record": classicinfrastructure.ResourceIBMDNSReverseRecord(), + "ibm_ssl_certificate": classicinfrastructure.ResourceIBMSSLCertificate(), + "ibm_cdn": classicinfrastructure.ResourceIBMCDN(), + "ibm_hardware_firewall_shared": classicinfrastructure.ResourceIBMFirewallShared(), // //Added for Power Colo @@ -1365,64 +1145,6 @@ func Validator() validate.ValidatorDict { "ibm_hpcs_key_template": hpcs.ResourceIbmKeyTemplateValidator(), "ibm_hpcs_vault": hpcs.ResourceIbmVaultValidator(), - "ibm_is_backup_policy": vpc.ResourceIBMIsBackupPolicyValidator(), - "ibm_is_backup_policy_plan": vpc.ResourceIBMIsBackupPolicyPlanValidator(), - - // bare_metal_server - "ibm_is_bare_metal_server_disk": vpc.ResourceIBMIsBareMetalServerDiskValidator(), - "ibm_is_bare_metal_server_network_interface": vpc.ResourceIBMIsBareMetalServerNetworkInterfaceValidator(), - "ibm_is_bare_metal_server": vpc.ResourceIBMIsBareMetalServerValidator(), - - "ibm_is_dedicated_host_group": vpc.ResourceIbmIsDedicatedHostGroupValidator(), - "ibm_is_dedicated_host": vpc.ResourceIbmIsDedicatedHostValidator(), - "ibm_is_dedicated_host_disk_management": vpc.ResourceIBMISDedicatedHostDiskManagementValidator(), - "ibm_is_flow_log": vpc.ResourceIBMISFlowLogValidator(), - "ibm_is_instance_group": vpc.ResourceIBMISInstanceGroupValidator(), - "ibm_is_instance_group_membership": vpc.ResourceIBMISInstanceGroupMembershipValidator(), - "ibm_is_instance_group_manager": vpc.ResourceIBMISInstanceGroupManagerValidator(), - "ibm_is_instance_group_manager_policy": vpc.ResourceIBMISInstanceGroupManagerPolicyValidator(), - "ibm_is_instance_group_manager_action": vpc.ResourceIBMISInstanceGroupManagerActionValidator(), - "ibm_is_floating_ip": vpc.ResourceIBMISFloatingIPValidator(), - "ibm_is_ike_policy": vpc.ResourceIBMISIKEValidator(), - "ibm_is_image": vpc.ResourceIBMISImageValidator(), - "ibm_is_image_export_job": vpc.ResourceIBMIsImageExportValidator(), - "ibm_is_instance_template": vpc.ResourceIBMISInstanceTemplateValidator(), - "ibm_is_instance": vpc.ResourceIBMISInstanceValidator(), - "ibm_is_instance_action": vpc.ResourceIBMISInstanceActionValidator(), - "ibm_is_instance_network_interface": vpc.ResourceIBMIsInstanceNetworkInterfaceValidator(), - "ibm_is_instance_disk_management": vpc.ResourceIBMISInstanceDiskManagementValidator(), - "ibm_is_instance_volume_attachment": vpc.ResourceIBMISInstanceVolumeAttachmentValidator(), - "ibm_is_ipsec_policy": vpc.ResourceIBMISIPSECValidator(), - "ibm_is_lb_listener_policy_rule": vpc.ResourceIBMISLBListenerPolicyRuleValidator(), - "ibm_is_lb_listener_policy": vpc.ResourceIBMISLBListenerPolicyValidator(), - "ibm_is_lb_listener": vpc.ResourceIBMISLBListenerValidator(), - "ibm_is_lb_pool_member": vpc.ResourceIBMISLBPoolMemberValidator(), - "ibm_is_lb_pool": vpc.ResourceIBMISLBPoolValidator(), - "ibm_is_lb": vpc.ResourceIBMISLBValidator(), - "ibm_is_network_acl": vpc.ResourceIBMISNetworkACLValidator(), - "ibm_is_network_acl_rule": vpc.ResourceIBMISNetworkACLRuleValidator(), - "ibm_is_public_gateway": vpc.ResourceIBMISPublicGatewayValidator(), - "ibm_is_placement_group": vpc.ResourceIbmIsPlacementGroupValidator(), - "ibm_is_security_group_target": vpc.ResourceIBMISSecurityGroupTargetValidator(), - "ibm_is_security_group_rule": vpc.ResourceIBMISSecurityGroupRuleValidator(), - "ibm_is_security_group": vpc.ResourceIBMISSecurityGroupValidator(), - "ibm_is_share": vpc.ResourceIbmIsShareValidator(), - "ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperationsValidator(), - "ibm_is_share_target": vpc.ResourceIbmIsShareMountTargetValidator(), - "ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTargetValidator(), - "ibm_is_snapshot": vpc.ResourceIBMISSnapshotValidator(), - "ibm_is_ssh_key": vpc.ResourceIBMISSHKeyValidator(), - "ibm_is_subnet": vpc.ResourceIBMISSubnetValidator(), - "ibm_is_subnet_reserved_ip": vpc.ResourceIBMISSubnetReservedIPValidator(), - "ibm_is_volume": vpc.ResourceIBMISVolumeValidator(), - "ibm_is_address_prefix": vpc.ResourceIBMISAddressPrefixValidator(), - "ibm_is_vpc": vpc.ResourceIBMISVPCValidator(), - "ibm_is_vpc_routing_table": vpc.ResourceIBMISVPCRoutingTableValidator(), - "ibm_is_vpc_routing_table_route": vpc.ResourceIBMISVPCRoutingTableRouteValidator(), - "ibm_is_vpn_gateway_connection": vpc.ResourceIBMISVPNGatewayConnectionValidator(), - "ibm_is_vpn_gateway": vpc.ResourceIBMISVPNGatewayValidator(), - "ibm_is_vpn_server": vpc.ResourceIBMIsVPNServerValidator(), - "ibm_is_vpn_server_route": vpc.ResourceIBMIsVPNServerRouteValidator(), "ibm_kms_key_rings": kms.ResourceIBMKeyRingValidator(), "ibm_dns_glb_monitor": dnsservices.ResourceIBMPrivateDNSGLBMonitorValidator(), "ibm_dns_custom_resolver_forwarding_rule": dnsservices.ResourceIBMPrivateDNSForwardingRuleValidator(), @@ -1433,7 +1155,6 @@ func Validator() validate.ValidatorDict { "ibm_schematics_resource_query": schematics.ResourceIBMSchematicsResourceQueryValidator(), "ibm_resource_instance": resourcecontroller.ResourceIBMResourceInstanceValidator(), "ibm_resource_key": resourcecontroller.ResourceIBMResourceKeyValidator(), - "ibm_is_virtual_endpoint_gateway": vpc.ResourceIBMISEndpointGatewayValidator(), "ibm_resource_tag": globaltagging.ResourceIBMResourceTagValidator(), "ibm_satellite_location": satellite.ResourceIBMSatelliteLocationValidator(), "ibm_satellite_cluster": satellite.ResourceIBMSatelliteClusterValidator(), @@ -1530,20 +1251,12 @@ func Validator() validate.ValidatorDict { "ibm_project_config": project.ResourceIbmProjectConfigValidator(), }, DataSourceValidatorDictionary: map[string]*validate.ResourceValidator{ - "ibm_is_subnet": vpc.DataSourceIBMISSubnetValidator(), - "ibm_is_snapshot": vpc.DataSourceIBMISSnapshotValidator(), - "ibm_is_images": vpc.DataSourceIBMISImagesValidator(), "ibm_dl_offering_speeds": directlink.DataSourceIBMDLOfferingSpeedsValidator(), "ibm_dl_routers": directlink.DataSourceIBMDLRoutersValidator(), "ibm_resource_instance": resourcecontroller.DataSourceIBMResourceInstanceValidator(), "ibm_resource_key": resourcecontroller.DataSourceIBMResourceKeyValidator(), "ibm_resource_group": resourcemanager.DataSourceIBMResourceGroupValidator(), - // bare_metal_server - "ibm_is_bare_metal_server": vpc.DataSourceIBMIsBareMetalServerValidator(), - - "ibm_is_vpc": vpc.DataSourceIBMISVpcValidator(), - "ibm_is_volume": vpc.DataSourceIBMISVolumeValidator(), "ibm_secrets_manager_secret": secretsmanager.DataSourceIBMSecretsManagerSecretValidator(), "ibm_secrets_manager_secrets": secretsmanager.DataSourceIBMSecretsManagerSecretsValidator(), "ibm_cis_webhooks": cis.DataSourceIBMCISAlertWebhooksValidator(), diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index 452ed8d034..f0cba45706 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -6,6 +6,6 @@ This area is primarily for IBM provider contributors and maintainers. For inform ## Handy Links * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project_instance) -* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) -* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) +* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/project) +* IBM API Docs: [IBM API Docs for ]() +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index ff2e8a87ca..5dd91af5c6 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -105,12 +105,123 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the project.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, + }, + }, + }, "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -244,6 +355,240 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "active_draft": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration version.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + }, + }, + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + }, + }, + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, }, }, }, @@ -261,7 +606,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m getProjectOptions.SetID(d.Get("id").(string)) - project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + projectCanonical, response, err := projectClient.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)) @@ -269,17 +614,17 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) - if err = d.Set("crn", project.Crn); err != nil { + if err = d.Set("crn", projectCanonical.Crn); err != nil { return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { + if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } cumulativeNeedsAttentionView := []map[string]interface{}{} - if project.CumulativeNeedsAttentionView != nil { - for _, modelItem := range project.CumulativeNeedsAttentionView { + if projectCanonical.CumulativeNeedsAttentionView != nil { + for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -291,42 +636,54 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view %s", err)) } - if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { + if err = d.Set("cumulative_needs_attention_view_error", projectCanonical.CumulativeNeedsAttentionViewError); err != nil { return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } - if err = d.Set("location", project.Location); err != nil { + if err = d.Set("location", projectCanonical.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if err = d.Set("resource_group", project.ResourceGroup); err != nil { + if err = d.Set("resource_group", projectCanonical.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if err = d.Set("state", project.State); err != nil { + if err = d.Set("state", projectCanonical.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { + if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } - if err = d.Set("name", project.Name); err != nil { + if err = d.Set("name", projectCanonical.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if err = d.Set("description", project.Description); err != nil { + if err = d.Set("description", projectCanonical.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } - if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + if err = d.Set("destroy_on_delete", projectCanonical.DestroyOnDelete); err != nil { return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } + definition := []map[string]interface{}{} + if projectCanonical.Definition != nil { + modelMap, err := dataSourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + definition = append(definition, modelMap) + } + if err = d.Set("definition", definition); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) + } + configs := []map[string]interface{}{} - if project.Configs != nil { - for _, modelItem := range project.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigPrototypeToMap(&modelItem) + if projectCanonical.Configs != nil { + for _, modelItem := range projectCanonical.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigCanonicalToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -357,8 +714,56 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["description"] = model.Description + modelMap["destroy_on_delete"] = model.DestroyOnDelete + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.IsDraft != nil { + modelMap["is_draft"] = model.IsDraft + } + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if err != nil { + return modelMap, err + } + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } modelMap["name"] = model.Name if model.Labels != nil { modelMap["labels"] = model.Labels @@ -403,6 +808,48 @@ func dataSourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectCon } modelMap["setting"] = setting } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.ActiveDraft != nil { + activeDraftMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) + if err != nil { + return modelMap, err + } + modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} + } + if model.Definition != nil { + definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + } + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID return modelMap, nil } @@ -470,3 +917,91 @@ func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Pr modelMap["value"] = model.Value return modelMap, nil } + +func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index ebe315ef98..3e912ccca2 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -32,6 +31,88 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, + "project_config_canonical_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -127,15 +208,10 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A dotted value of catalogID.versionID.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -143,40 +219,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The variable name.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable type.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the variable is required or not.", - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, "value": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -204,314 +246,240 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, - "project_config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ + "type": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The type of a project configuration manual property.", }, - "last_approved": &schema.Schema{ + "output": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The last approved metadata of the configuration.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The comment left by the user who approved the configuration.", + Description: "The variable name.", }, - "timestamp": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A short explanation of the output value.", }, - "user_id": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "job_summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "cra_logs": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", + Description: "The version number of the configuration.", }, - "schema_version": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", + Description: "The state of the configuration draft.", }, - "status": &schema.Schema{ + "pipeline_state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timestamp": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A relative URL.", }, }, }, }, - "cost_estimate": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The project configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", + Description: "The name of the configuration.", }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, + "labels": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "user_id": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The description of the project configuration.", }, - }, - }, - }, - "last_deployment_job_summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, + "authorizations": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, }, }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, }, }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, + "locator_id": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "A dotted value of catalogID.versionID.", }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, + "input": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, + "setting": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, }, }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, + "type": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "The type of a project configuration manual property.", }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, + "output": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, }, } } @@ -527,7 +495,7 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD getConfigOptions.SetProjectID(d.Get("project_id").(string)) getConfigOptions.SetID(d.Get("id").(string)) - projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) @@ -535,17 +503,69 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) - if err = d.Set("name", projectConfig.Name); err != nil { + if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) + } + + if err = d.Set("version", flex.IntValue(projectConfigCanonical.Version)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + } + + if err = d.Set("is_draft", projectConfigCanonical.IsDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) + } + + if err = d.Set("needs_attention_state", projectConfigCanonical.NeedsAttentionState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) + } + + if err = d.Set("state", projectConfigCanonical.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + + if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) + } + + if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } + + if err = d.Set("created_at", flex.DateTimeToString(projectConfigCanonical.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } + + if err = d.Set("updated_at", flex.DateTimeToString(projectConfigCanonical.UpdatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + } + + lastApproved := []map[string]interface{}{} + if projectConfigCanonical.LastApproved != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfigCanonical.LastApproved) + if err != nil { + return diag.FromErr(err) + } + lastApproved = append(lastApproved, modelMap) + } + if err = d.Set("last_approved", lastApproved); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_approved %s", err)) + } + + if err = d.Set("last_save", flex.DateTimeToString(projectConfigCanonical.LastSave)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + } + + if err = d.Set("name", projectConfigCanonical.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if err = d.Set("description", projectConfig.Description); err != nil { + if err = d.Set("description", projectConfigCanonical.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } authorizations := []map[string]interface{}{} - if projectConfig.Authorizations != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) + if projectConfigCanonical.Authorizations != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { return diag.FromErr(err) } @@ -556,8 +576,8 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD } complianceProfile := []map[string]interface{}{} - if projectConfig.ComplianceProfile != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) + if projectConfigCanonical.ComplianceProfile != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) if err != nil { return diag.FromErr(err) } @@ -567,18 +587,14 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) } - if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) } - if err = d.Set("type", projectConfig.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - input := []map[string]interface{}{} - if projectConfig.Input != nil { - for _, modelItem := range projectConfig.Input { - modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(&modelItem) + if projectConfigCanonical.Input != nil { + for _, modelItem := range projectConfigCanonical.Input { + modelMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -589,23 +605,9 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting input %s", err)) } - output := []map[string]interface{}{} - if projectConfig.Output != nil { - for _, modelItem := range projectConfig.Output { - modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - output = append(output, modelMap) - } - } - if err = d.Set("output", output); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output %s", err)) - } - setting := []map[string]interface{}{} - if projectConfig.Setting != nil { - for _, modelItem := range projectConfig.Setting { + if projectConfigCanonical.Setting != nil { + for _, modelItem := range projectConfigCanonical.Setting { modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -617,109 +619,66 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) } - if err = d.Set("project_config_id", projectConfig.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) - } - - if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) - } - - if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) - } - - if err = d.Set("needs_attention_state", projectConfig.NeedsAttentionState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) - } - - if err = d.Set("state", projectConfig.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } - - if err = d.Set("pipeline_state", projectConfig.PipelineState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) - } - - if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) - } - - if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } - - if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) - } - - lastApproved := []map[string]interface{}{} - if projectConfig.LastApproved != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) - if err != nil { - return diag.FromErr(err) - } - lastApproved = append(lastApproved, modelMap) - } - if err = d.Set("last_approved", lastApproved); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_approved %s", err)) - } - - if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } - jobSummary := []map[string]interface{}{} - if projectConfig.JobSummary != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.JobSummary) - if err != nil { - return diag.FromErr(err) + output := []map[string]interface{}{} + if projectConfigCanonical.Output != nil { + for _, modelItem := range projectConfigCanonical.Output { + modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + output = append(output, modelMap) } - jobSummary = append(jobSummary, modelMap) } - if err = d.Set("job_summary", jobSummary); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_summary %s", err)) + if err = d.Set("output", output); err != nil { + return diag.FromErr(fmt.Errorf("Error setting output %s", err)) } - craLogs := []map[string]interface{}{} - if projectConfig.CraLogs != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfig.CraLogs) + activeDraft := []map[string]interface{}{} + if projectConfigCanonical.ActiveDraft != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) if err != nil { return diag.FromErr(err) } - craLogs = append(craLogs, modelMap) + activeDraft = append(activeDraft, modelMap) } - if err = d.Set("cra_logs", craLogs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) + if err = d.Set("active_draft", activeDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting active_draft %s", err)) } - costEstimate := []map[string]interface{}{} - if projectConfig.CostEstimate != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfig.CostEstimate) + definition := []map[string]interface{}{} + if projectConfigCanonical.Definition != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } - costEstimate = append(costEstimate, modelMap) + definition = append(definition, modelMap) } - if err = d.Set("cost_estimate", costEstimate); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) + if err = d.Set("definition", definition); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) } - lastDeploymentJobSummary := []map[string]interface{}{} - if projectConfig.LastDeploymentJobSummary != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.LastDeploymentJobSummary) - if err != nil { - return diag.FromErr(err) - } - lastDeploymentJobSummary = append(lastDeploymentJobSummary, modelMap) - } - if err = d.Set("last_deployment_job_summary", lastDeploymentJobSummary); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_deployment_job_summary %s", err)) + if err = d.Set("href", projectConfigCanonical.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) } return nil } +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.TrustedProfile != nil { @@ -769,16 +728,19 @@ func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projec return modelMap, nil } -func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name - modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } - if model.Required != nil { - modelMap["required"] = model.Required - } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value return modelMap, nil } @@ -794,165 +756,78 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.Href != nil { + modelMap["href"] = model.Href } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary + if model.Description != nil { + modelMap["description"] = model.Description } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err } - modelMap["message_summary"] = messageSummary + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err } - modelMap["plan_messages"] = planMessages + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } - applyMessages[k] = string(bytes) + input = append(input, inputItemMap) } - modelMap["apply_messages"] = applyMessages + modelMap["input"] = input } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return modelMap, err } - destroyMessages[k] = string(bytes) + setting = append(setting, settingItemMap) } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion + modelMap["setting"] = setting } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion + if model.Type != nil { + modelMap["type"] = model.Type } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) if err != nil { return modelMap, err } - summary[k] = string(bytes) + output = append(output, outputItemMap) } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + modelMap["output"] = output } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 419fd11fc1..6b5e114fdf 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -14,28 +14,21 @@ import ( ) func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { - projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectConfigCanonicalLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName, projectConfigLocatorID), + Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalName, projectConfigCanonicalLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), ), }, }, @@ -43,61 +36,59 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { } func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { - projectConfigName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectConfigLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectConfigCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectConfigCanonicalLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName, projectConfigDescription, projectConfigLocatorID), + Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "labels.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "input.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.required"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "output.0.name", projectConfigName), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "output.0.description", projectConfigDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config_instance", "setting.0.name", projectConfigName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "pipeline_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_approved.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_save"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "job_summary.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "cra_logs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "cost_estimate.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_deployment_job_summary.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_canonical_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "pipeline_state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_approved.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_save"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigCanonicalName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigCanonicalName), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigCanonicalName), + resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigCanonicalDescription), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "active_draft.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "href"), ), }, }, }) } -func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, projectConfigLocatorID string) string { +func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalName string, projectConfigCanonicalLocatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" @@ -112,13 +103,13 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigName string, } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfigCanonical_id } - `, projectConfigName, projectConfigLocatorID) + `, projectConfigCanonicalName, projectConfigCanonicalLocatorID) } -func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, projectConfigDescription string, projectConfigLocatorID string) string { +func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName string, projectConfigCanonicalDescription string, projectConfigCanonicalLocatorID string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" @@ -129,18 +120,27 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = [ "labels" ] + labels = "FIXME" description = "%s" authorizations { - method = "API_KEY" - api_key = "xxx" - } + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } locator_id = "%s" input { name = "name" - type = "array" value = "anything as a string" - required = true } setting { name = "name" @@ -149,8 +149,8 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigName string, proj } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfigCanonical_id } - `, projectConfigName, projectConfigDescription, projectConfigLocatorID) + `, projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 5782ed8e80..dd4756fecd 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,25 +14,27 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectCanonicalResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectCanonicalLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation, projectName), + Config: testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), ), }, }, @@ -40,39 +42,61 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectResourceGroup := fmt.Sprintf("Default") - projectLocation := fmt.Sprintf("us-south") - projectName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectDestroyOnDelete := "true" + projectCanonicalResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectCanonicalLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) + projectCanonicalDestroyOnDelete := "false" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectDataSourceConfig(projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete), + Config: testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), - resource.TestCheckResourceAttr("data.ibm_project.project_instance", "configs.0.name", projectName), - resource.TestCheckResourceAttr("data.ibm_project.project_instance", "configs.0.description", projectDescription), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_version"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view_error"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "event_notifications_crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.version"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.needs_attention_state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.pipeline_state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.last_save"), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectCanonicalName), + resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectCanonicalDescription), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.href"), ), }, }, }) } -func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, projectLocation string, projectName string) string { +func testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup string, projectCanonicalLocation string, projectCanonicalName string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "%s" @@ -81,12 +105,12 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.projectCanonical_id } - `, projectResourceGroup, projectLocation, projectName) + `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName) } -func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, projectLocation string, projectName string, projectDescription string, projectDestroyOnDelete string) string { +func testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup string, projectCanonicalLocation string, projectCanonicalName string, projectCanonicalDescription string, projectCanonicalDestroyOnDelete string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "%s" @@ -95,14 +119,42 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project description = "%s" destroy_on_delete = %s configs { + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" authorizations { - method = "API_KEY" - api_key = "xxx" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + locator_id = "locator_id" input { name = "name" value = "anything as a string" @@ -111,11 +163,59 @@ func testAccCheckIbmProjectDataSourceConfig(projectResourceGroup string, project name = "name" value = "value" } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" + href = "href" + } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } + href = "href" } } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.projectCanonical_id } - `, projectResourceGroup, projectLocation, projectName, projectDescription, projectDestroyOnDelete) + `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index a2f0f77bf0..bfe0804f85 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -7,10 +7,8 @@ import ( "context" "fmt" "log" - "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -27,10 +25,6 @@ func ResourceIbmProject() *schema.Resource { UpdateContext: resourceIbmProjectUpdate, DeleteContext: resourceIbmProjectDelete, Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ @@ -40,10 +34,10 @@ func ResourceIbmProject() *schema.Resource { Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "location"), + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ Type: schema.TypeString, @@ -69,6 +63,92 @@ func ResourceIbmProject() *schema.Resource { Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The state of the configuration.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, "name": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -83,7 +163,6 @@ func ResourceIbmProject() *schema.Resource { "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "", Description: "The description of the project configuration.", }, "authorizations": &schema.Schema{ @@ -204,6 +283,243 @@ func ResourceIbmProject() *schema.Resource { }, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "active_draft": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The project configuration version.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + }, + }, + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The project configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + }, + }, + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, }, }, }, @@ -261,6 +577,30 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the project.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, + }, + }, + }, }, } } @@ -328,10 +668,10 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigPrototype + var configs []projectv1.ProjectConfig for _, v := range d.Get("configs").([]interface{}) { value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) + configsItem, err := resourceIbmProjectMapToProjectConfig(value) if err != nil { return diag.FromErr(err) } @@ -340,54 +680,17 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetConfigs(configs) } - project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) + projectCanonical, response, err := projectClient.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)) } - d.SetId(*project.ID) - - _, err = waitForProjectInstanceCreate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project instance (%s) to be succeeded: %s", d.Id(), err)) - } + d.SetId(*projectCanonical.ID) return resourceIbmProjectRead(context, d, meta) } -func waitForProjectInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the project instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -398,7 +701,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met getProjectOptions.SetID(d.Id()) - project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + projectCanonical, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -408,29 +711,29 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("resource_group", project.ResourceGroup); err != nil { + if err = d.Set("resource_group", projectCanonical.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if err = d.Set("location", project.Location); err != nil { + if err = d.Set("location", projectCanonical.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if err = d.Set("name", project.Name); err != nil { + if err = d.Set("name", projectCanonical.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if !core.IsNil(project.Description) { - if err = d.Set("description", project.Description); err != nil { + if !core.IsNil(projectCanonical.Description) { + if err = d.Set("description", projectCanonical.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(project.DestroyOnDelete) { - if err = d.Set("destroy_on_delete", project.DestroyOnDelete); err != nil { + if !core.IsNil(projectCanonical.DestroyOnDelete) { + if err = d.Set("destroy_on_delete", projectCanonical.DestroyOnDelete); err != nil { return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } } - if !core.IsNil(project.Configs) { + if !core.IsNil(projectCanonical.Configs) { configs := []map[string]interface{}{} - for _, configsItem := range project.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigPrototypeToMap(&configsItem) + for _, configsItem := range projectCanonical.Configs { + configsItemMap, err := resourceIbmProjectProjectConfigCanonicalToMap(&configsItem) if err != nil { return diag.FromErr(err) } @@ -440,15 +743,15 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } - if err = d.Set("crn", project.Crn); err != nil { + if err = d.Set("crn", projectCanonical.Crn); err != nil { return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { + if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - if !core.IsNil(project.CumulativeNeedsAttentionView) { + if !core.IsNil(projectCanonical.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range project.CumulativeNeedsAttentionView { + for _, cumulativeNeedsAttentionViewItem := range projectCanonical.CumulativeNeedsAttentionView { cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) if err != nil { return diag.FromErr(err) @@ -459,19 +762,28 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view: %s", err)) } } - if !core.IsNil(project.CumulativeNeedsAttentionViewError) { - if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { + if !core.IsNil(projectCanonical.CumulativeNeedsAttentionViewError) { + if err = d.Set("cumulative_needs_attention_view_error", projectCanonical.CumulativeNeedsAttentionViewError); err != nil { return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if err = d.Set("state", project.State); err != nil { + if err = d.Set("state", projectCanonical.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if !core.IsNil(project.EventNotificationsCrn) { - if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { + if !core.IsNil(projectCanonical.EventNotificationsCrn) { + if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } } + if !core.IsNil(projectCanonical.Definition) { + definitionMap, err := resourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) + } + } return nil } @@ -528,50 +840,13 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("DeleteProjectWithContext failed %s\n%s", err, response)) } - _, err = waitForProjectInstanceDelete(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project instance (%s) to be succeeded: %s", d.Id(), err)) - } - d.SetId("") return nil } -func waitForProjectInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - instanceID := d.Id() - getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(instanceID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetProject(getProjectOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - -func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { - model := &projectv1.ProjectConfigPrototype{} +func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*projectv1.ProjectConfig, error) { + model := &projectv1.ProjectConfig{} model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["labels"] != nil { labels := []string{} @@ -688,8 +963,48 @@ func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]i return model, nil } -func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfigPrototype) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.ProjectID != nil { + modelMap["project_id"] = model.ProjectID + } + if model.Version != nil { + modelMap["version"] = flex.IntValue(model.Version) + } + if model.IsDraft != nil { + modelMap["is_draft"] = model.IsDraft + } + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + if model.State != nil { + modelMap["state"] = model.State + } + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if err != nil { + return modelMap, err + } + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } modelMap["name"] = model.Name if model.Labels != nil { modelMap["labels"] = model.Labels @@ -734,6 +1049,48 @@ func resourceIbmProjectProjectConfigPrototypeToMap(model *projectv1.ProjectConfi } modelMap["setting"] = setting } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.ActiveDraft != nil { + activeDraftMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) + if err != nil { + return modelMap, err + } + modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} + } + if model.Definition != nil { + definitionMap, err := resourceIbmProjectProjectConfigDefinitionToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + } + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID return modelMap, nil } @@ -802,6 +1159,94 @@ func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.Proj return modelMap, nil } +func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + return modelMap, nil +} + func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Event != nil { @@ -818,3 +1263,11 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative } return modelMap, nil } + +func resourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["description"] = model.Description + modelMap["destroy_on_delete"] = model.DestroyOnDelete + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index b56d1fd302..f85c08695f 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,13 +5,10 @@ package project import ( "context" - "encoding/json" "fmt" "log" - "time" "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/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" @@ -28,10 +25,6 @@ func ResourceIbmProjectConfig() *schema.Resource { UpdateContext: resourceIbmProjectConfigUpdate, DeleteContext: resourceIbmProjectConfigDelete, Importer: &schema.ResourceImporter{}, - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), - }, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ @@ -56,7 +49,6 @@ func ResourceIbmProjectConfig() *schema.Resource { "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "", // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), Description: "The description of the project configuration.", }, @@ -144,7 +136,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -152,21 +144,11 @@ func ResourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The variable name.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable type.", - }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "Can be any value - a string, number, boolean, array, or object.", }, - "required": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "Whether the variable is required or not.", - }, }, }, }, @@ -189,35 +171,6 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, "version": &schema.Schema{ Type: schema.TypeInt, Computed: true, @@ -273,7 +226,6 @@ func ResourceIbmProjectConfig() *schema.Resource { "comment": &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "", Description: "The comment left by the user who approved the configuration.", }, "timestamp": &schema.Schema{ @@ -294,203 +246,242 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "job_summary": &schema.Schema{ + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, + "description": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "A short explanation of the output value.", }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, + "value": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "cra_logs": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version number of the configuration.", }, - "schema_version": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", + Required: true, + Description: "The state of the configuration draft.", }, - "status": &schema.Schema{ + "pipeline_state": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, - "timestamp": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A relative URL.", }, }, }, }, - "cost_estimate": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The project configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", + Required: true, + Description: "The name of the configuration.", }, - "currency": &schema.Schema{ - Type: schema.TypeString, + "labels": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The currency of the cost estimate of the configuration.", + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "total_hourly_cost": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The total hourly cost estimate of the configuration.", + Description: "The description of the project configuration.", }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The total monthly cost estimate of the configuration.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The past total hourly cost estimate of the configuration.", + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, }, - "past_total_monthly_cost": &schema.Schema{ + "locator_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", + Required: true, + Description: "A dotted value of catalogID.versionID.", }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, + "input": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, + "setting": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, }, - "time_generated": &schema.Schema{ + "type": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The type of a project configuration manual property.", }, - "user_id": &schema.Schema{ - Type: schema.TypeString, + "output": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The unique ID of a project.", + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, }, }, }, }, - "last_deployment_job_summary": &schema.Schema{ - Type: schema.TypeList, + "href": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, + Description: "A relative URL.", }, - "project_config_id": &schema.Schema{ + "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", @@ -604,55 +595,17 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions.SetSetting(setting) } - projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) + projectConfigCanonical, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { log.Printf("[DEBUG] CreateConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("CreateConfigWithContext failed %s\n%s", err, response)) } - d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) - - _, err = waitForProjectConfigInstanceCreate(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for create project config instance (%s) to be succeeded: %s", d.Id(), err)) - } + d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfigCanonical.ID)) return resourceIbmProjectConfigRead(context, d, meta) } -func waitForProjectConfigInstanceCreate(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - getConfigOptions := &projectv1.GetConfigOptions{} - parts, err := flex.SepIdParts(d.Id(), "/") - getConfigOptions.SetProjectID(parts[0]) - getConfigOptions.SetID(parts[1]) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"not_exists"}, - Target: []string{"exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetConfig(getConfigOptions) - if err == nil { - if resp != nil && resp.StatusCode == 200 { - return resp, "exists", nil - } else { - return resp, "not_exists", nil - } - } else { - return nil, "", fmt.Errorf("[ERROR] Get the project config instance %s failed with resp code: %d, err: %v", d.Id(), resp.StatusCode, err) - } - }, - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectClient, err := meta.(conns.ClientSession).ProjectV1() if err != nil { @@ -669,7 +622,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -679,24 +632,24 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) } - if err = d.Set("project_id", projectConfig.ProjectID); err != nil { + if err = d.Set("project_id", projectConfigCanonical.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if err = d.Set("name", projectConfig.Name); err != nil { + if err = d.Set("name", projectConfigCanonical.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if !core.IsNil(projectConfig.Labels) { - if err = d.Set("labels", projectConfig.Labels); err != nil { + if !core.IsNil(projectConfigCanonical.Labels) { + if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) } } - if !core.IsNil(projectConfig.Description) { - if err = d.Set("description", projectConfig.Description); err != nil { + if !core.IsNil(projectConfigCanonical.Description) { + if err = d.Set("description", projectConfigCanonical.Description); err != nil { return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(projectConfig.Authorizations) { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfig.Authorizations) + if !core.IsNil(projectConfigCanonical.Authorizations) { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { return diag.FromErr(err) } @@ -704,8 +657,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting authorizations: %s", err)) } } - if !core.IsNil(projectConfig.ComplianceProfile) { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfig.ComplianceProfile) + if !core.IsNil(projectConfigCanonical.ComplianceProfile) { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) if err != nil { return diag.FromErr(err) } @@ -713,13 +666,13 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if err = d.Set("locator_id", projectConfig.LocatorID); err != nil { + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) } - if !core.IsNil(projectConfig.Input) { + if !core.IsNil(projectConfigCanonical.Input) { input := []map[string]interface{}{} - for _, inputItem := range projectConfig.Input { - inputItemMap, err := resourceIbmProjectConfigInputVariableToMap(&inputItem) + for _, inputItem := range projectConfigCanonical.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return diag.FromErr(err) } @@ -729,9 +682,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } - if !core.IsNil(projectConfig.Setting) { + if !core.IsNil(projectConfigCanonical.Setting) { setting := []map[string]interface{}{} - for _, settingItem := range projectConfig.Setting { + for _, settingItem := range projectConfigCanonical.Setting { settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return diag.FromErr(err) @@ -742,56 +695,52 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } - if err = d.Set("type", projectConfig.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - if !core.IsNil(projectConfig.Output) { - output := []map[string]interface{}{} - for _, outputItem := range projectConfig.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) - if err != nil { - return diag.FromErr(err) - } - output = append(output, outputItemMap) + if !core.IsNil(projectConfigCanonical.Version) { + if err = d.Set("version", flex.IntValue(projectConfigCanonical.Version)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) } - if err = d.Set("output", output); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) - } - } - if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) } - if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) + if !core.IsNil(projectConfigCanonical.IsDraft) { + if err = d.Set("is_draft", projectConfigCanonical.IsDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) + } } - if !core.IsNil(projectConfig.NeedsAttentionState) { + if !core.IsNil(projectConfigCanonical.NeedsAttentionState) { needsAttentionState := []interface{}{} - for _, needsAttentionStateItem := range projectConfig.NeedsAttentionState { + for _, needsAttentionStateItem := range projectConfigCanonical.NeedsAttentionState { needsAttentionState = append(needsAttentionState, needsAttentionStateItem) } if err = d.Set("needs_attention_state", needsAttentionState); err != nil { return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } } - if err = d.Set("state", projectConfig.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + if !core.IsNil(projectConfigCanonical.State) { + if err = d.Set("state", projectConfigCanonical.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } } - if !core.IsNil(projectConfig.PipelineState) { - if err = d.Set("pipeline_state", projectConfig.PipelineState); err != nil { + if !core.IsNil(projectConfigCanonical.PipelineState) { + if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) } } - if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + if !core.IsNil(projectConfigCanonical.UpdateAvailable) { + if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } } - if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + if !core.IsNil(projectConfigCanonical.CreatedAt) { + if err = d.Set("created_at", flex.DateTimeToString(projectConfigCanonical.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } } - if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + if !core.IsNil(projectConfigCanonical.UpdatedAt) { + if err = d.Set("updated_at", flex.DateTimeToString(projectConfigCanonical.UpdatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + } } - if !core.IsNil(projectConfig.LastApproved) { - lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) + if !core.IsNil(projectConfigCanonical.LastApproved) { + lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfigCanonical.LastApproved) if err != nil { return diag.FromErr(err) } @@ -799,49 +748,56 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) } } - if !core.IsNil(projectConfig.LastSave) { - if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { + if !core.IsNil(projectConfigCanonical.LastSave) { + if err = d.Set("last_save", flex.DateTimeToString(projectConfigCanonical.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfig.JobSummary) { - jobSummaryMap, err := resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.JobSummary) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("job_summary", []map[string]interface{}{jobSummaryMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting job_summary: %s", err)) + if !core.IsNil(projectConfigCanonical.Type) { + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } } - if !core.IsNil(projectConfig.CraLogs) { - craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfig.CraLogs) - if err != nil { - return diag.FromErr(err) + if !core.IsNil(projectConfigCanonical.Output) { + output := []map[string]interface{}{} + for _, outputItem := range projectConfigCanonical.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return diag.FromErr(err) + } + output = append(output, outputItemMap) } - if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) + if err = d.Set("output", output); err != nil { + return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfig.CostEstimate) { - costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfig.CostEstimate) + if !core.IsNil(projectConfigCanonical.ActiveDraft) { + activeDraftMap, err := resourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) if err != nil { return diag.FromErr(err) } - if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) + if err = d.Set("active_draft", []map[string]interface{}{activeDraftMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting active_draft: %s", err)) } } - if !core.IsNil(projectConfig.LastDeploymentJobSummary) { - lastDeploymentJobSummaryMap, err := resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(projectConfig.LastDeploymentJobSummary) + if !core.IsNil(projectConfigCanonical.Definition) { + definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } - if err = d.Set("last_deployment_job_summary", []map[string]interface{}{lastDeploymentJobSummaryMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_deployment_job_summary: %s", err)) + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } } - if err = d.Set("project_config_id", projectConfig.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) + if !core.IsNil(projectConfigCanonical.Href) { + if err = d.Set("href", projectConfigCanonical.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.ID) { + if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) + } } return nil @@ -966,49 +922,11 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("DeleteConfigWithContext failed %s\n%s", err, response)) } - _, err = waitForProjectConfigInstanceDelete(d, meta) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for delete project config instance (%s) to be succeeded: %s", d.Id(), err)) - } - d.SetId("") return nil } -func waitForProjectConfigInstanceDelete(d *schema.ResourceData, meta interface{}) (interface{}, error) { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return false, err - } - getConfigOptions := &projectv1.GetConfigOptions{} - parts, err := flex.SepIdParts(d.Id(), "/") - getConfigOptions.SetProjectID(parts[0]) - getConfigOptions.SetID(parts[1]) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"exists"}, - Target: []string{"not_exists"}, - Refresh: func() (interface{}, string, error) { - _, resp, err := projectClient.GetConfig(getConfigOptions) - if err != nil { - if resp != nil && resp.StatusCode == 404 { - return resp, "not_exists", nil - } else { - return resp, "exists", nil - } - } else { - return resp, "exists", nil - } - }, - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 2 * time.Second, - MinTimeout: 10 * time.Second, - } - - return stateConf.WaitForState() -} - func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { @@ -1123,16 +1041,12 @@ func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv return modelMap, nil } -func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name - modelMap["type"] = model.Type if model.Value != nil { modelMap["value"] = model.Value } - if model.Required != nil { - modelMap["required"] = model.Required - } return modelMap, nil } @@ -1143,6 +1057,17 @@ func resourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv return modelMap, nil } +func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name @@ -1155,158 +1080,78 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map return modelMap, nil } -func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.Href != nil { + modelMap["href"] = model.Href } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } -func resourceIbmProjectConfigProjectConfigMetadataJobSummaryToMap(model *projectv1.ProjectConfigMetadataJobSummary) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary + if model.Description != nil { + modelMap["description"] = model.Description } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err } - modelMap["message_summary"] = messageSummary + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err } - modelMap["plan_messages"] = planMessages + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } - applyMessages[k] = string(bytes) + input = append(input, inputItemMap) } - modelMap["apply_messages"] = applyMessages + modelMap["input"] = input } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return modelMap, err } - destroyMessages[k] = string(bytes) + setting = append(setting, settingItemMap) } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion + modelMap["setting"] = setting } - if model.Status != nil { - modelMap["status"] = model.Status + if model.Type != nil { + modelMap["type"] = model.Type } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) if err != nil { return modelMap, err } - summary[k] = string(bytes) + output = append(output, outputItemMap) } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + modelMap["output"] = output } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 4ec23261a6..ee62990f13 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -18,11 +18,11 @@ import ( ) func TestAccIbmProjectConfigBasic(t *testing.T) { - var conf projectv1.ProjectConfig + var conf projectv1.ProjectConfigCanonical name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -49,13 +49,13 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { } func TestAccIbmProjectConfigAllArgs(t *testing.T) { - var conf projectv1.ProjectConfig + var conf projectv1.ProjectConfigCanonical name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -115,18 +115,27 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = [ "labels" ] + labels = "FIXME" description = "%s" authorizations { - method = "API_KEY" - api_key = "xxx" - } + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } locator_id = "%s" input { name = "name" - type = "array" value = "anything as a string" - required = true } setting { name = "name" @@ -136,7 +145,7 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator `, name, description, locatorID) } -func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigCanonical) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -159,12 +168,12 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) r getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - projectConfig, _, err := projectClient.GetConfig(getConfigOptions) + projectConfigCanonical, _, err := projectClient.GetConfig(getConfigOptions) if err != nil { return err } - obj = *projectConfig + obj = *projectConfigCanonical return nil } } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 4874cced81..29fbe4eb54 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -17,12 +17,12 @@ import ( ) func TestAccIbmProjectBasic(t *testing.T) { - var conf projectv1.Project - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") + var conf projectv1.ProjectCanonical + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("Default") - locationUpdate := fmt.Sprintf("us-south") + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -52,14 +52,14 @@ func TestAccIbmProjectBasic(t *testing.T) { } func TestAccIbmProjectAllArgs(t *testing.T) { - var conf projectv1.Project - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") + var conf projectv1.ProjectCanonical + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDelete := "false" - resourceGroupUpdate := fmt.Sprintf("Default") - locationUpdate := fmt.Sprintf("us-south") + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDeleteUpdate := "true" @@ -119,14 +119,42 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st description = "%s" destroy_on_delete = %s configs { + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" authorizations { - method = "API_KEY" - api_key = "xxx" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" input { name = "name" value = "anything as a string" @@ -135,12 +163,60 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st name = "name" value = "value" } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" + href = "href" + } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } + href = "href" } } `, resourceGroup, location, name, description, destroyOnDelete) } -func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { +func testAccCheckIbmProjectExists(n string, obj projectv1.ProjectCanonical) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -157,12 +233,12 @@ func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.Test getProjectOptions.SetID(rs.Primary.ID) - project, _, err := projectClient.GetProject(getProjectOptions) + projectCanonical, _, err := projectClient.GetProject(getProjectOptions) if err != nil { return err } - obj = *project + obj = *projectCanonical return nil } } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index ba2769786d..28eb4e68ae 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project. You ca ```hcl data "ibm_project" "project" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.projectCanonical_id } ``` @@ -33,6 +33,15 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: + * `active_draft` - (List) The project configuration version. + Nested schema for **active_draft**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Integer) The version number of the configuration. * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -54,23 +63,108 @@ Nested schema for **configs**: * `instance_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The project configuration definition. + Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (String) The description of the project configuration. - * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -78,6 +172,13 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -97,6 +198,15 @@ Nested schema for **cumulative_needs_attention_view**: * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `definition` - (List) The definition of the project. +Nested schema for **definition**: + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -104,7 +214,7 @@ Nested schema for **cumulative_needs_attention_view**: * Constraints: The default value is `true`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * Constraints: The default value is ``. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `location` - (String) The IBM Cloud location where a resource is deployed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 3dd7c6d204..ab0c368f20 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -13,9 +13,9 @@ Provides a read-only data source to retrieve information about a project_config. ## Example Usage ```hcl -data "ibm_project_config" "project_config_instance" { - id = ibm_project_config.project_config_instance.project_config_id - project_id = ibm_project_config.project_config_instance.project_id +data "ibm_project_config" "project_config" { + id = ibm_project_config.project_config_instance.projectConfigCanonical_id + project_id = ibm_project_config.project_config.project_id } ``` @@ -33,6 +33,16 @@ 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 project_config. +* `active_draft` - (List) The project configuration version. +Nested schema for **active_draft**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Integer) The version number of the configuration. + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -55,81 +65,96 @@ Nested schema for **compliance_profile**: * `instance_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `definition` - (List) The project configuration definition. +Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `description` - (String) The description of the project configuration. - * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (List) The outputs of a Schematics template property. +* `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + +* `input` - (List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Boolean) Whether the variable is required or not. - * `type` - (String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `job_summary` - (List) The summaries of jobs that were performed on the configuration. -Nested schema for **job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. -Nested schema for **last_deployment_job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -153,7 +178,7 @@ Nested schema for **output**: * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. -* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. +* `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. @@ -165,7 +190,7 @@ Nested schema for **setting**: * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 691da6c52c..f16f557f82 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -15,6 +15,23 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { configs { + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" + } + last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" @@ -42,6 +59,54 @@ resource "ibm_project" "project_instance" { name = "name" value = "value" } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" + href = "href" + } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } + href = "href" } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" @@ -57,6 +122,15 @@ You can specify the following arguments for this resource. * `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: + * `active_draft` - (Optional, List) The project configuration version. + Nested schema for **active_draft**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (Required, String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Required, Integer) The version number of the configuration. * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (Optional, String) The IBM Cloud API Key. @@ -78,23 +152,108 @@ Nested schema for **configs**: * `instance_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (Optional, List) The project configuration definition. + Nested schema for **definition**: + * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (Optional, List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (Optional, String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (Required, String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (Optional, List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (Optional, String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (Optional, String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (Optional, String) The description of the project configuration. - * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (Optional, List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (Optional, List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (Optional, String) The comment left by the user who approved the configuration. + * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (Required, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `output` - (Optional, List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (Optional, String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: @@ -102,6 +261,13 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Required, String) The value of the configuration setting. * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `state` - (Optional, String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `type` - (Optional, String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Optional, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. @@ -132,8 +298,16 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `definition` - (List) The definition of the project. +Nested schema for **definition**: + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. - * Constraints: The default value is ``. The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. * Constraints: Allowable values are: `ready`, `deleting`, `deleting_failed`. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 740cc31bab..ed003b67e1 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -29,15 +29,12 @@ resource "ibm_project_config" "project_config_instance" { attachment_id = "attachment_id" profile_name = "profile_name" } - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." input { name = "name" - type = "array" value = "anything as a string" - required = true } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" - name = "env-stage" + locator_id = "locator_id" + name = "name" project_id = ibm_project.project_instance.id setting { name = "name" @@ -71,19 +68,16 @@ Nested schema for **compliance_profile**: * `instance_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. - * Constraints: The default value is ``. The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The outputs of a Schematics template property. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. +* `input` - (Optional, List) The inputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `required` - (Optional, Boolean) Whether the variable is required or not. - * `type` - (Required, String) The variable type. - * Constraints: Allowable values are: `array`, `boolean`, `float`, `int`, `number`, `password`, `string`, `object`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. @@ -106,54 +100,83 @@ Nested schema for **setting**: After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the project_config. -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `active_draft` - (List) The project configuration version. +Nested schema for **active_draft**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Integer) The version number of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `definition` - (List) The project configuration definition. +Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `job_summary` - (List) The summaries of jobs that were performed on the configuration. -Nested schema for **job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `last_deployment_job_summary` - (List) The summaries of jobs that were performed on the configuration. -Nested schema for **last_deployment_job_summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. @@ -167,10 +190,10 @@ Nested schema for **output**: * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. -* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. +* `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `deleted`, `deleting`, `deleting_failed`, `installed`, `installed_failed`, `installing`, `not_installed`, `uninstalling`, `uninstalling_failed`, `active`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. From e26a73c4ab038175d82f26a345f98d2af8ea871a Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 31 Jul 2023 10:50:47 +0200 Subject: [PATCH 080/125] align with origin/master --- go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/go.sum b/go.sum index 178a85addf..094e0ed065 100644 --- a/go.sum +++ b/go.sum @@ -135,7 +135,6 @@ github.com/IBM/go-sdk-core/v3 v3.2.4/go.mod h1:lk9eOzNbNltPf3CBpcg1Ewkhw4qC3u2QC github.com/IBM/go-sdk-core/v5 v5.0.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek= -github.com/IBM/go-sdk-core/v5 v5.6.5/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek= github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc= github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= From 6d8027b38bf84686175ba97c2eeacd74ef39665b Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 2 Aug 2023 13:13:59 +0200 Subject: [PATCH 081/125] update test cases --- .../data_source_ibm_project_config_test.go | 101 +++++------ .../project/data_source_ibm_project_test.go | 160 ++++-------------- .../resource_ibm_project_config_test.go | 53 +++--- .../project/resource_ibm_project_test.go | 146 ++++------------ 4 files changed, 126 insertions(+), 334 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 6b5e114fdf..e232e315f1 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -15,7 +15,7 @@ import ( func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigCanonicalLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigCanonicalLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -24,11 +24,10 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalName, projectConfigCanonicalLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), ), }, }, @@ -38,7 +37,7 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectConfigCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectConfigCanonicalLocatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + projectConfigCanonicalLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -47,41 +46,32 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_canonical_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "needs_attention_state.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "pipeline_state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_approved.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "last_save"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "labels.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "input.0.name", projectConfigCanonicalName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "input.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "setting.0.name", projectConfigCanonicalName), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "setting.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "type"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.#"), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.name", projectConfigCanonicalName), - resource.TestCheckResourceAttr("data.ibm_project_config.project_config", "output.0.description", projectConfigCanonicalDescription), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "output.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "active_draft.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "href"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_canonical_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_approved.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "active_draft.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), ), }, }, @@ -103,8 +93,8 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalNam } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfigCanonical_id + project_id = ibm_project_config.project_config_instance.project_id + id = ibm_project_config.project_config_instance.project_config_canonical_id } `, projectConfigCanonicalName, projectConfigCanonicalLocatorID) } @@ -120,23 +110,12 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName str resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } + method = "API_KEY" + api_key = "" + } locator_id = "%s" input { name = "name" @@ -149,8 +128,8 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName str } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfigCanonical_id + project_id = ibm_project_config.project_config_instance.project_id + id = ibm_project_config.project_config_instance.project_config_canonical_id } `, projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index dd4756fecd..3f870f9271 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,8 +14,8 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectCanonicalResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectCanonicalLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectCanonicalResourceGroup := fmt.Sprintf("Default") + projectCanonicalLocation := fmt.Sprintf("us-south") projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -25,16 +25,14 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), ), }, }, @@ -42,11 +40,11 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { } func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectCanonicalResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectCanonicalLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectCanonicalResourceGroup := fmt.Sprintf("Default") + projectCanonicalLocation := fmt.Sprintf("us-south") projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) projectCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectCanonicalDestroyOnDelete := "false" + projectCanonicalDestroyOnDelete := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -55,41 +53,17 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.event_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view.0.config_version"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "cumulative_needs_attention_view_error"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "event_notifications_crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "destroy_on_delete"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.version"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.needs_attention_state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.pipeline_state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.last_save"), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.name", projectCanonicalName), - resource.TestCheckResourceAttr("data.ibm_project.project", "configs.0.description", projectCanonicalDescription), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.locator_id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.type"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "configs.0.href"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), ), }, }, @@ -105,7 +79,7 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup s } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.projectCanonical_id + id = ibm_project.project_instance.id } `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName) } @@ -119,42 +93,14 @@ func testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup string description = "%s" destroy_on_delete = %s configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = "" } - locator_id = "locator_id" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" @@ -163,59 +109,11 @@ func testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup string name = "name" value = "value" } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } - active_draft { - version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" - href = "href" - } - definition { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } - } - href = "href" } } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.projectCanonical_id + id = ibm_project.project_instance.id } `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete) } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index ee62990f13..f00685538b 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -20,9 +20,9 @@ import ( func TestAccIbmProjectConfigBasic(t *testing.T) { var conf projectv1.ProjectConfigCanonical name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -32,16 +32,16 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorIDUpdate), ), }, }, @@ -52,10 +52,10 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { var conf projectv1.ProjectConfigCanonical name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("tf_locator_id_%d", acctest.RandIntRange(10, 100)) + locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -65,22 +65,22 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(name, description, locatorID), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", description), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigConfig(nameUpdate, descriptionUpdate, locatorIDUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config", "locator_id", locatorIDUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorIDUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config", + ResourceName: "ibm_project_config.project_config_instance", ImportState: true, ImportStateVerify: true, }, @@ -115,23 +115,12 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = "%s" - labels = "FIXME" + labels = [ "labels" ] description = "%s" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } + method = "API_KEY" + api_key = "" + } locator_id = "%s" input { name = "name" diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 29fbe4eb54..d0217ccef8 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -18,11 +18,11 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.ProjectCanonical - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("Default") + locationUpdate := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -33,18 +33,18 @@ func TestAccIbmProjectBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location, name), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project", conf), - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project", "location", location), - resource.TestCheckResourceAttr("ibm_project.project", "name", name), + testAccCheckIbmProjectExists("ibm_project.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate, nameUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", nameUpdate), ), }, }, @@ -53,13 +53,13 @@ func TestAccIbmProjectBasic(t *testing.T) { func TestAccIbmProjectAllArgs(t *testing.T) { var conf projectv1.ProjectCanonical - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - destroyOnDelete := "false" - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + destroyOnDelete := "true" + resourceGroupUpdate := fmt.Sprintf("Default") + locationUpdate := fmt.Sprintf("us-south") nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) destroyOnDeleteUpdate := "true" @@ -72,28 +72,30 @@ func TestAccIbmProjectAllArgs(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfig(resourceGroup, location, name, description, destroyOnDelete), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project", conf), - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project", "location", location), - resource.TestCheckResourceAttr("ibm_project.project", "name", name), - resource.TestCheckResourceAttr("ibm_project.project", "description", description), - resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDelete), + testAccCheckIbmProjectExists("ibm_project.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), + resource.TestCheckResourceAttr("ibm_project.project_instance", "description", description), + resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDelete), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfig(resourceGroupUpdate, locationUpdate, nameUpdate, descriptionUpdate, destroyOnDeleteUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "destroy_on_delete", destroyOnDeleteUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "description", descriptionUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDeleteUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project.project", - ImportState: true, - ImportStateVerify: true, + ResourceName: "ibm_project.project_instance", + ImportState: true, + ImportStateVerifyIgnore: []string{ + "configs", + }, }, }, }) @@ -119,42 +121,14 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st description = "%s" destroy_on_delete = %s configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" name = "name" labels = [ "labels" ] description = "description" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" + method = "API_KEY" + api_key = "" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" input { name = "name" value = "anything as a string" @@ -163,54 +137,6 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st name = "name" value = "value" } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } - active_draft { - version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" - href = "href" - } - definition { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } - } - href = "href" } } `, resourceGroup, location, name, description, destroyOnDelete) From 612d87579221ec47810067480e98d384671a0a2c Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 2 Aug 2023 15:37:18 +0200 Subject: [PATCH 082/125] restore README.md and versions.tf to master branch --- examples/ibm-project/versions.tf | 8 +------- ibm/service/project/README.md | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index 54c9d03e8d..d9b6f790b9 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,9 +1,3 @@ terraform { - required_version = ">= 1.0" - required_providers { - ibm = { - source = "IBM-Cloud/ibm" - version = "1.52.0-beta0" - } - } + required_version = ">= 0.12" } diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index f0cba45706..452ed8d034 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -6,6 +6,6 @@ This area is primarily for IBM provider contributors and maintainers. For inform ## Handy Links * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project) -* IBM API Docs: [IBM API Docs for ]() -* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) +* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/project_instance) +* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) +* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) From 6d9ac3cb3ef3702b6e37e2c9dc8f4e176f94050b Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 4 Aug 2023 12:26:41 +0200 Subject: [PATCH 083/125] remove duplicated entries --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 094e0ed065..82e0840140 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,6 @@ github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTp github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs= github.com/IBM/continuous-delivery-go-sdk v1.1.1 h1:bYrK0+rJgoWfBmIJAlAfo/AxI5vOr8DSLJPrM3iEOzQ= github.com/IBM/continuous-delivery-go-sdk v1.1.1/go.mod h1:A9rI1HPbccBBFgwJxXB999yXXpj1l+MnlE+rsxKtxw0= -github.com/IBM/event-notifications-go-admin-sdk v0.2.2 h1:Aww+OUcKgsbXyY7a/nlMH7nvZGn0sBTr6p6rUjOyy1Y= -github.com/IBM/event-notifications-go-admin-sdk v0.2.2/go.mod h1:1TlGAFP47DybbovJfHtYYgSI8xpLL8Q0wao6vsAlb6c= github.com/IBM/event-notifications-go-admin-sdk v0.2.4 h1:WWUxwrKQxvExEK+xaAQOs6gP54LvJDPi3KatDTMfwh0= github.com/IBM/event-notifications-go-admin-sdk v0.2.4/go.mod h1:1TlGAFP47DybbovJfHtYYgSI8xpLL8Q0wao6vsAlb6c= github.com/IBM/eventstreams-go-sdk v1.2.0 h1:eP0afHArMGjwhGqvZAhhu/3EDKRch2JehpveqF1TUjs= From 1f1800d3b19b7b97fedbb774f25277d2a0c4c8e2 Mon Sep 17 00:00:00 2001 From: Mark-Kulube Date: Thu, 24 Aug 2023 18:14:19 -0400 Subject: [PATCH 084/125] feat: graph fragment pattern poc --- examples/ibm-project/README.md | 14 +- examples/ibm-project/main.tf | 147 +-- examples/ibm-project/variables.tf | 16 +- examples/ibm-project/versions.tf | 8 +- go.mod | 2 +- go.sum | 4 +- ibm/service/project/README.md | 6 +- .../project/data_source_ibm_project.go | 973 +++++++++------ .../project/data_source_ibm_project_config.go | 973 +++++++++------ ibm/service/project/resource_ibm_project.go | 1083 ++++++++++------- .../project/resource_ibm_project_config.go | 889 ++++++++------ website/docs/d/project.html.markdown | 173 ++- website/docs/d/project_config.html.markdown | 171 ++- website/docs/r/project.html.markdown | 321 +++-- website/docs/r/project_config.html.markdown | 177 ++- 15 files changed, 2794 insertions(+), 2163 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 9c23f3287d..05be1c0282 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -40,8 +40,8 @@ project_config resource: resource "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - labels = var.project_config_labels description = var.project_config_description + labels = var.project_config_labels authorizations = var.project_config_authorizations compliance_profile = var.project_config_compliance_profile locator_id = var.project_config_locator_id @@ -95,19 +95,19 @@ data "project_config" "project_config_instance" { | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| name | The name of the project. | `string` | true | +| name | The name of the project. | `string` | false | | description | A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | | configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | `list()` | false | | project_id | The unique project ID. | `string` | true | -| name | The name of the configuration. | `string` | true | -| labels | A collection of configuration labels. | `list(string)` | false | +| name | The name of the configuration. | `string` | false | | description | The description of the project configuration. | `string` | false | +| labels | A collection of configuration labels. | `list(string)` | false | | authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | -| locator_id | A dotted value of catalogID.versionID. | `string` | true | -| input | The inputs of a Schematics template property. | `list()` | false | -| setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | +| locator_id | A dotted value of catalogID.versionID. | `string` | false | +| input | The input variables for the configuration definition. | `` | false | +| setting | Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. | `` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index cea26480b9..c4dd9de096 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -10,26 +10,9 @@ resource "ibm_project" "project_instance" { description = var.project_description destroy_on_delete = var.project_destroy_on_delete configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" name = "name" - labels = [ "labels" ] description = "description" + labels = [ "labels" ] authorizations { trusted_profile { id = "id" @@ -46,62 +29,88 @@ resource "ibm_project" "project_instance" { profile_name = "profile_name" } locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" + input = { } + setting = { } + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" } - setting { - name = "name" - value = "value" + last_save = "2021-01-31T09:44:12Z" + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" } - active_draft { - version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" + check_job { + id = "id" href = "href" - } - definition { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } - setting { - name = "name" - value = "value" + } + install_job { + id = "id" + href = "href" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + } + uninstall_job { + id = "id" + href = "href" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } } - href = "href" + output { + name = "name" + description = "description" + value = "anything as a string" + } + type = "terraform_template" } } @@ -109,8 +118,8 @@ resource "ibm_project" "project_instance" { resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - labels = var.project_config_labels description = var.project_config_description + labels = var.project_config_labels authorizations { trusted_profile { id = "id" @@ -128,12 +137,8 @@ resource "ibm_project_config" "project_config_instance" { } locator_id = var.project_config_locator_id input { - name = "name" - value = "anything as a string" } setting { - name = "name" - value = "value" } } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 86b9bf2534..11b08d1c56 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -39,22 +39,22 @@ variable "project_config_project_id" { variable "project_config_name" { description = "The name of the configuration." type = string - default = "name" -} -variable "project_config_labels" { - description = "A collection of configuration labels." - type = list(string) - default = [ "labels" ] + default = "env-stage" } variable "project_config_description" { description = "The description of the project configuration." type = string - default = "description" + default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." +} +variable "project_config_labels" { + description = "A collection of configuration labels." + type = list(string) + default = ["env:stage","governance:test","build:0"] } variable "project_config_locator_id" { description = "A dotted value of catalogID.versionID." type = string - default = "locator_id" + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" } // Data source arguments for project diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index d9b6f790b9..54c9d03e8d 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,3 +1,9 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 1.0" + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + version = "1.52.0-beta0" + } + } } diff --git a/go.mod b/go.mod index d26284fd03..ea4777746e 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.41.0 - github.com/IBM/project-go-sdk v0.0.26-33 + github.com/IBM/project-go-sdk v0.0.26-51 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 82e0840140..8efb72940e 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.41.0 h1:2aeHcLnQgat7UAKrtIF6jGyFW2hwq4oroO26fIX94kA= github.com/IBM/platform-services-go-sdk v0.41.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-33 h1:LbWD0/wzoNsEItoECsCxA+vB38e/MCxdL5H9E16ai1c= -github.com/IBM/project-go-sdk v0.0.26-33/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-51 h1:QrVTshQsVeoh4YDavu/pt9ZPGUxN/p/SNk34Bf0WJq0= +github.com/IBM/project-go-sdk v0.0.26-51/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index 452ed8d034..f0cba45706 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -6,6 +6,6 @@ This area is primarily for IBM provider contributors and maintainers. For inform ## Handy Links * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project_instance) -* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) -* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) +* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/project) +* IBM API Docs: [IBM API Docs for ]() +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 5dd91af5c6..a56973b4f3 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -105,127 +106,21 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, - "definition": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The definition of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the project.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", - }, - }, - }, - }, "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The name of the configuration.", }, - "name": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -235,11 +130,6 @@ func DataSourceIbmProject() *schema.Resource { Type: schema.TypeString, }, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -255,12 +145,12 @@ func DataSourceIbmProject() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -287,12 +177,12 @@ func DataSourceIbmProject() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -302,7 +192,7 @@ func DataSourceIbmProject() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -320,263 +210,444 @@ func DataSourceIbmProject() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration setting.", + Description: "The comment left by the user who approved the configuration.", }, - "value": &schema.Schema{ + "timestamp": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The value of the configuration setting.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", }, }, }, }, - "type": &schema.Schema{ + "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "output": &schema.Schema{ + "cra_logs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The Code Risk Analyzer logs of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "cra_version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The variable name.", + Description: "The version of the Code Risk Analyzer logs of the configuration.", }, - "description": &schema.Schema{ + "schema_version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A short explanation of the output value.", + Description: "The schema version of Code Risk Analyzer logs of the configuration.", }, - "value": &schema.Schema{ + "status": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, }, }, }, - "active_draft": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "The version of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration draft.", + Description: "The currency of the cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The total hourly cost estimate of the configuration.", }, - "href": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", }, }, }, }, - "definition": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The unique ID.", }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", + Description: "A relative URL.", }, - "authorizations": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, - "method": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "api_key": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The IBM Cloud API Key.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - "compliance_profile": &schema.Schema{ + }, + }, + }, + "install_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The profile required for compliance.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The unique ID of a project.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The unique ID of a project.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The location of the compliance instance.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The unique ID of a project.", + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The name of the compliance profile.", + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - "locator_id": &schema.Schema{ + }, + }, + }, + "uninstall_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A dotted value of catalogID.versionID.", + Description: "A relative URL.", }, - "input": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The variable name.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The name of the configuration setting.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The value of the configuration setting.", + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The variable name.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "description": &schema.Schema{ - Type: schema.TypeString, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "A short explanation of the output value.", + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, @@ -584,10 +655,34 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, - "href": &schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The type of a project configuration manual property.", }, }, }, @@ -624,7 +719,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m cumulativeNeedsAttentionView := []map[string]interface{}{} if projectCanonical.CumulativeNeedsAttentionView != nil { - for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { + for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -668,21 +763,9 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } - definition := []map[string]interface{}{} - if projectCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) - if err != nil { - return diag.FromErr(err) - } - definition = append(definition, modelMap) - } - if err = d.Set("definition", definition); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) - } - configs := []map[string]interface{}{} if projectCanonical.Configs != nil { - for _, modelItem := range projectCanonical.Configs { + for _, modelItem := range projectCanonical.Configs { modelMap, err := dataSourceIbmProjectProjectConfigCanonicalToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -714,16 +797,48 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["description"] = model.Description - modelMap["destroy_on_delete"] = model.DestroyOnDelete - return modelMap, nil -} - func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := dataSourceIbmProjectInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := dataSourceIbmProjectProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } if model.ID != nil { modelMap["id"] = model.ID } @@ -742,9 +857,6 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon if model.State != nil { modelMap["state"] = model.State } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } if model.UpdateAvailable != nil { modelMap["update_available"] = model.UpdateAvailable } @@ -764,52 +876,40 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.CraLogs != nil { + craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if model.CostEstimate != nil { + costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) if err != nil { return modelMap, err } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) + if model.CheckJob != nil { + checkJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.CheckJob) + if err != nil { + return modelMap, err } - modelMap["input"] = input + modelMap["check_job"] = []map[string]interface{}{checkJobMap} } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) + if model.InstallJob != nil { + installJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.InstallJob) + if err != nil { + return modelMap, err } - modelMap["setting"] = setting + modelMap["install_job"] = []map[string]interface{}{installJobMap} } - if model.Type != nil { - modelMap["type"] = model.Type + if model.UninstallJob != nil { + uninstallJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.UninstallJob) + if err != nil { + return modelMap, err + } + modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } if model.Output != nil { output := []map[string]interface{}{} @@ -822,34 +922,9 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon } modelMap["output"] = output } - if model.ActiveDraft != nil { - activeDraftMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) - if err != nil { - return modelMap, err - } - modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} - } - if model.Definition != nil { - definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionToMap(model.Definition) - if err != nil { - return modelMap, err - } - modelMap["definition"] = []map[string]interface{}{definitionMap} - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + if model.Type != nil { + modelMap["type"] = model.Type } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } @@ -902,106 +977,198 @@ func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.Pr return modelMap, nil } -func dataSourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value return modelMap, nil } -func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } - if model.Value != nil { - modelMap["value"] = model.Value + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() } return modelMap, nil } -func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Href != nil { - modelMap["href"] = model.Href + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func dataSourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.ID != nil { + modelMap["id"] = model.ID } - if model.Description != nil { - modelMap["description"] = model.Description + if model.Href != nil { + modelMap["href"] = model.Href } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.Summary != nil { + summaryMap, err := dataSourceIbmProjectActionJobSummaryToMap(model.Summary) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["summary"] = []map[string]interface{}{summaryMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + return modelMap, nil +} + +func dataSourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["plan_summary"] = planSummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + applySummary[k] = string(bytes) } - modelMap["input"] = input + modelMap["apply_summary"] = applySummary } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + destroySummary[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["destroy_summary"] = destroySummary } - if model.Type != nil { - modelMap["type"] = model.Type + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) + planMessages[k] = string(bytes) } - modelMap["output"] = output + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 3e912ccca2..dfe52a81b8 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -31,92 +32,15 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, - "project_config_canonical_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The name of the configuration.", }, - "name": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -126,11 +50,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, }, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -146,12 +65,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -178,12 +97,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -193,7 +112,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -211,263 +130,439 @@ func DataSourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + }, + }, + }, + "project_config_canonical_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration setting.", + Description: "The comment left by the user who approved the configuration.", }, - "value": &schema.Schema{ + "timestamp": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The value of the configuration setting.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", }, }, }, }, - "type": &schema.Schema{ + "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "output": &schema.Schema{ + "cra_logs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The Code Risk Analyzer logs of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "cra_version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The variable name.", + Description: "The version of the Code Risk Analyzer logs of the configuration.", }, - "description": &schema.Schema{ + "schema_version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A short explanation of the output value.", + Description: "The schema version of Code Risk Analyzer logs of the configuration.", }, - "value": &schema.Schema{ + "status": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, }, }, }, - "active_draft": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "The version of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration draft.", + Description: "The currency of the cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The total hourly cost estimate of the configuration.", }, - "href": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", }, }, }, }, - "definition": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The unique ID.", }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", + Description: "A relative URL.", }, - "authorizations": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, - "method": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "api_key": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The unique ID of a project.", + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The location of the compliance instance.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The unique ID of a project.", + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The name of the compliance profile.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - "locator_id": &schema.Schema{ + }, + }, + }, + "install_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A dotted value of catalogID.versionID.", + Description: "A relative URL.", }, - "input": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The variable name.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The name of the configuration setting.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The value of the configuration setting.", + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - "type": &schema.Schema{ + }, + }, + }, + "uninstall_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "A relative URL.", }, - "output": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "The variable name.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "description": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "A short explanation of the output value.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, @@ -475,10 +570,34 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, - "href": &schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The type of a project configuration manual property.", }, }, } @@ -503,6 +622,67 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", projectConfigCanonical.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + + + authorizations := []map[string]interface{}{} + if projectConfigCanonical.Authorizations != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) + if err != nil { + return diag.FromErr(err) + } + authorizations = append(authorizations, modelMap) + } + if err = d.Set("authorizations", authorizations); err != nil { + return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) + } + + complianceProfile := []map[string]interface{}{} + if projectConfigCanonical.ComplianceProfile != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) + if err != nil { + return diag.FromErr(err) + } + complianceProfile = append(complianceProfile, modelMap) + } + if err = d.Set("compliance_profile", complianceProfile); err != nil { + return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) + } + + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } + + input := []map[string]interface{}{} + if projectConfigCanonical.Input != nil { + modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) + if err != nil { + return diag.FromErr(err) + } + input = append(input, modelMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input %s", err)) + } + + setting := []map[string]interface{}{} + if projectConfigCanonical.Setting != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, modelMap) + } + if err = d.Set("setting", setting); err != nil { + return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) + } + if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) } @@ -523,10 +703,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) - } - if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } @@ -555,77 +731,69 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + craLogs := []map[string]interface{}{} + if projectConfigCanonical.CraLogs != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) + if err != nil { + return diag.FromErr(err) + } + craLogs = append(craLogs, modelMap) } - - if err = d.Set("description", projectConfigCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + if err = d.Set("cra_logs", craLogs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) } - authorizations := []map[string]interface{}{} - if projectConfigCanonical.Authorizations != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) + costEstimate := []map[string]interface{}{} + if projectConfigCanonical.CostEstimate != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) if err != nil { return diag.FromErr(err) } - authorizations = append(authorizations, modelMap) + costEstimate = append(costEstimate, modelMap) } - if err = d.Set("authorizations", authorizations); err != nil { - return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) + if err = d.Set("cost_estimate", costEstimate); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) } - complianceProfile := []map[string]interface{}{} - if projectConfigCanonical.ComplianceProfile != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) + checkJob := []map[string]interface{}{} + if projectConfigCanonical.CheckJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) if err != nil { return diag.FromErr(err) } - complianceProfile = append(complianceProfile, modelMap) - } - if err = d.Set("compliance_profile", complianceProfile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) + checkJob = append(checkJob, modelMap) } - - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + if err = d.Set("check_job", checkJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting check_job %s", err)) } - input := []map[string]interface{}{} - if projectConfigCanonical.Input != nil { - for _, modelItem := range projectConfigCanonical.Input { - modelMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, modelMap) + installJob := []map[string]interface{}{} + if projectConfigCanonical.InstallJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) + if err != nil { + return diag.FromErr(err) } + installJob = append(installJob, modelMap) } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input %s", err)) + if err = d.Set("install_job", installJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting install_job %s", err)) } - setting := []map[string]interface{}{} - if projectConfigCanonical.Setting != nil { - for _, modelItem := range projectConfigCanonical.Setting { - modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, modelMap) + uninstallJob := []map[string]interface{}{} + if projectConfigCanonical.UninstallJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) + if err != nil { + return diag.FromErr(err) } + uninstallJob = append(uninstallJob, modelMap) } - if err = d.Set("setting", setting); err != nil { - return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) - } - - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + if err = d.Set("uninstall_job", uninstallJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting uninstall_job %s", err)) } output := []map[string]interface{}{} if projectConfigCanonical.Output != nil { - for _, modelItem := range projectConfigCanonical.Output { + for _, modelItem := range projectConfigCanonical.Output { modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -637,48 +805,13 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting output %s", err)) } - activeDraft := []map[string]interface{}{} - if projectConfigCanonical.ActiveDraft != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) - if err != nil { - return diag.FromErr(err) - } - activeDraft = append(activeDraft, modelMap) - } - if err = d.Set("active_draft", activeDraft); err != nil { - return diag.FromErr(fmt.Errorf("Error setting active_draft %s", err)) - } - - definition := []map[string]interface{}{} - if projectConfigCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) - if err != nil { - return diag.FromErr(err) - } - definition = append(definition, modelMap) - } - if err = d.Set("definition", definition); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) - } - - if err = d.Set("href", projectConfigCanonical.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } return nil } -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.TrustedProfile != nil { @@ -728,106 +861,198 @@ func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projec return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value return modelMap, nil } -func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } - if model.Value != nil { - modelMap["value"] = model.Value + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() } return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Href != nil { - modelMap["href"] = model.Href + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.ID != nil { + modelMap["id"] = model.ID } - if model.Description != nil { - modelMap["description"] = model.Description + if model.Href != nil { + modelMap["href"] = model.Href } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if model.Summary != nil { + summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["summary"] = []map[string]interface{}{summaryMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + return modelMap, nil +} + +func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["destroy_summary"] = destroySummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + messageSummary[k] = string(bytes) } - modelMap["input"] = input + modelMap["message_summary"] = messageSummary } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + planMessages[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["plan_messages"] = planMessages } - if model.Type != nil { - modelMap["type"] = model.Type + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) + destroyMessages[k] = string(bytes) } - modelMap["output"] = output + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index bfe0804f85..11ea5fbd37 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -20,35 +20,35 @@ import ( func ResourceIbmProject() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectCreate, - ReadContext: resourceIbmProjectRead, - UpdateContext: resourceIbmProjectUpdate, - DeleteContext: resourceIbmProjectDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectCreate, + ReadContext: resourceIbmProjectRead, + UpdateContext: resourceIbmProjectUpdate, + DeleteContext: resourceIbmProjectDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "location"), + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "location"), Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "name"), Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "description"), Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ @@ -63,96 +63,15 @@ func ResourceIbmProject() *schema.Resource { Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The state of the configuration.", - }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID of a project.", - }, - }, - }, + Description: "The name of the configuration.", }, - "last_save": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -160,11 +79,6 @@ func ResourceIbmProject() *schema.Resource { Description: "A collection of configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -182,12 +96,12 @@ func ResourceIbmProject() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -215,12 +129,12 @@ func ResourceIbmProject() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -230,7 +144,7 @@ func ResourceIbmProject() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -242,272 +156,415 @@ func ResourceIbmProject() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The name of the configuration setting.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "value": &schema.Schema{ + "user_id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The value of the configuration setting.", + Description: "The unique ID.", }, }, }, }, - "type": &schema.Schema{ + "last_save": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The type of a project configuration manual property.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "output": &schema.Schema{ + "cra_logs": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The Code Risk Analyzer logs of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "cra_version": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The variable name.", + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", }, - "description": &schema.Schema{ + "schema_version": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A short explanation of the output value.", + Description: "The schema version of Code Risk Analyzer logs of the configuration.", }, - "value": &schema.Schema{ + "status": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, }, }, }, - "active_draft": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration version.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The state of the configuration draft.", + Optional: true, + Description: "The currency of the cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The total hourly cost estimate of the configuration.", }, - "href": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", }, }, }, }, - "definition": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The unique ID.", }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The description of the project configuration.", + Description: "A relative URL.", }, - "authorizations": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "method": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "api_key": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The IBM Cloud API Key.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, }, - "compliance_profile": &schema.Schema{ + }, + }, + }, + "install_job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "summary": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The profile required for compliance.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The location of the compliance instance.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The name of the compliance profile.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, }, - "setting": &schema.Schema{ - Type: schema.TypeList, + }, + }, + }, + "uninstall_job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, + Description: "The unique ID.", }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The type of a project configuration manual property.", + Description: "A relative URL.", }, - "output": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "A short explanation of the output value.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -515,10 +572,34 @@ func ResourceIbmProject() *schema.Resource { }, }, }, - "href": &schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The type of a project configuration manual property.", }, }, }, @@ -577,30 +658,6 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, - "definition": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The definition of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the project.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", - }, - }, - }, - }, }, } } @@ -630,7 +687,7 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]+$`, MinValueLength: 1, MaxValueLength: 64, @@ -660,7 +717,9 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) createProjectOptions.SetLocation(d.Get("location").(string)) - createProjectOptions.SetName(d.Get("name").(string)) + if _, ok := d.GetOk("name"); ok { + createProjectOptions.SetName(d.Get("name").(string)) + } if _, ok := d.GetOk("description"); ok { createProjectOptions.SetDescription(d.Get("description").(string)) } @@ -668,10 +727,10 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfig + var configs []projectv1.ProjectConfigTerraform for _, v := range d.Get("configs").([]interface{}) { value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfig(value) + configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) if err != nil { return diag.FromErr(err) } @@ -717,8 +776,10 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if err = d.Set("location", projectCanonical.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if err = d.Set("name", projectCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + if !core.IsNil(projectCanonical.Name) { + if err = d.Set("name", projectCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } } if !core.IsNil(projectCanonical.Description) { if err = d.Set("description", projectCanonical.Description); err != nil { @@ -743,11 +804,15 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } - if err = d.Set("crn", projectCanonical.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + if !core.IsNil(projectCanonical.Crn) { + if err = d.Set("crn", projectCanonical.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } } - if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + if !core.IsNil(projectCanonical.CreatedAt) { + if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } } if !core.IsNil(projectCanonical.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} @@ -767,23 +832,16 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if err = d.Set("state", projectCanonical.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + if !core.IsNil(projectCanonical.State) { + if err = d.Set("state", projectCanonical.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } } if !core.IsNil(projectCanonical.EventNotificationsCrn) { if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } } - if !core.IsNil(projectCanonical.Definition) { - definitionMap, err := resourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) - } - } return nil } @@ -812,6 +870,19 @@ func resourceIbmProjectUpdate(context context.Context, d *schema.ResourceData, m updateProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) hasChange = true } + if d.HasChange("configs") { + var configs []projectv1.ProjectConfigTerraform + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + updateProjectOptions.SetConfigs(configs) + hasChange = true + } if hasChange { _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) @@ -845,9 +916,14 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return nil } -func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*projectv1.ProjectConfig, error) { - model := &projectv1.ProjectConfig{} - model.Name = core.StringPtr(modelMap["name"].(string)) +func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface{}) (*projectv1.ProjectConfigTerraform, error) { + model := &projectv1.ProjectConfigTerraform{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } if modelMap["labels"] != nil { labels := []string{} for _, labelsItem := range modelMap["labels"].([]interface{}) { @@ -855,9 +931,6 @@ func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*pro } model.Labels = labels } - if modelMap["description"] != nil && modelMap["description"].(string) != "" { - model.Description = core.StringPtr(modelMap["description"].(string)) - } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -872,28 +945,22 @@ func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*pro } model.ComplianceProfile = ComplianceProfileModel } - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) - if modelMap["input"] != nil { - input := []projectv1.ProjectConfigInputVariable{} - for _, inputItem := range modelMap["input"].([]interface{}) { - inputItemModel, err := resourceIbmProjectMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) - if err != nil { - return model, err - } - input = append(input, *inputItemModel) + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { + InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err } - model.Input = input + model.Input = InputModel } - if modelMap["setting"] != nil { - setting := []projectv1.ProjectConfigSettingCollection{} - for _, settingItem := range modelMap["setting"].([]interface{}) { - settingItemModel, err := resourceIbmProjectMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) - if err != nil { - return model, err - } - setting = append(setting, *settingItemModel) + if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { + SettingModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err } - model.Setting = setting + model.Setting = SettingModel } return model, nil } @@ -947,24 +1014,58 @@ func resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap map[string]i return model, nil } -func resourceIbmProjectMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { - model := &projectv1.ProjectConfigInputVariable{} - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["value"] != nil { - model.Value = modelMap["value"].(string) - } +func resourceIbmProjectMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { + model := &projectv1.InputVariable{} return model, nil } -func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { - model := &projectv1.ProjectConfigSettingCollection{} - model.Name = core.StringPtr(modelMap["name"].(string)) - model.Value = core.StringPtr(modelMap["value"].(string)) +func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { + model := &projectv1.ProjectConfigSetting{} return model, nil } func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := resourceIbmProjectInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := resourceIbmProjectProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } if model.ID != nil { modelMap["id"] = model.ID } @@ -983,9 +1084,6 @@ func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfi if model.State != nil { modelMap["state"] = model.State } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } if model.UpdateAvailable != nil { modelMap["update_available"] = model.UpdateAvailable } @@ -1005,52 +1103,40 @@ func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfi if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.CraLogs != nil { + craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if model.CostEstimate != nil { + costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) if err != nil { return modelMap, err } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) + if model.CheckJob != nil { + checkJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.CheckJob) + if err != nil { + return modelMap, err } - modelMap["input"] = input + modelMap["check_job"] = []map[string]interface{}{checkJobMap} } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) + if model.InstallJob != nil { + installJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.InstallJob) + if err != nil { + return modelMap, err } - modelMap["setting"] = setting + modelMap["install_job"] = []map[string]interface{}{installJobMap} } - if model.Type != nil { - modelMap["type"] = model.Type + if model.UninstallJob != nil { + uninstallJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.UninstallJob) + if err != nil { + return modelMap, err + } + modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } if model.Output != nil { output := []map[string]interface{}{} @@ -1063,34 +1149,9 @@ func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfi } modelMap["output"] = output } - if model.ActiveDraft != nil { - activeDraftMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) - if err != nil { - return modelMap, err - } - modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} - } - if model.Definition != nil { - definitionMap, err := resourceIbmProjectProjectConfigDefinitionToMap(model.Definition) - if err != nil { - return modelMap, err - } - modelMap["definition"] = []map[string]interface{}{definitionMap} - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + if model.Type != nil { + modelMap["type"] = model.Type } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } @@ -1143,106 +1204,198 @@ func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.Proj return modelMap, nil } -func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func resourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value return modelMap, nil } -func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } - if model.Value != nil { - modelMap["value"] = model.Value + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() } return modelMap, nil } -func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Href != nil { - modelMap["href"] = model.Href + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func resourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func resourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.ID != nil { + modelMap["id"] = model.ID } - if model.Description != nil { - modelMap["description"] = model.Description + if model.Href != nil { + modelMap["href"] = model.Href } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.Summary != nil { + summaryMap, err := resourceIbmProjectActionJobSummaryToMap(model.Summary) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["summary"] = []map[string]interface{}{summaryMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + return modelMap, nil +} + +func resourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["plan_summary"] = planSummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + applySummary[k] = string(bytes) } - modelMap["input"] = input + modelMap["apply_summary"] = applySummary } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + destroySummary[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["destroy_summary"] = destroySummary } - if model.Type != nil { - modelMap["type"] = model.Type + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) + planMessages[k] = string(bytes) } - modelMap["output"] = output + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } @@ -1263,11 +1416,3 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative } return modelMap, nil } - -func resourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["description"] = model.Description - modelMap["destroy_on_delete"] = model.DestroyOnDelete - return modelMap, nil -} diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f85c08695f..68d5f414bc 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -20,25 +21,31 @@ import ( func ResourceIbmProjectConfig() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectConfigCreate, - ReadContext: resourceIbmProjectConfigRead, - UpdateContext: resourceIbmProjectConfigUpdate, - DeleteContext: resourceIbmProjectConfigDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectConfigCreate, + ReadContext: resourceIbmProjectConfigRead, + UpdateContext: resourceIbmProjectConfigUpdate, + DeleteContext: resourceIbmProjectConfigDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), - Description: "The unique project ID.", + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The name of the configuration.", + Description: "The name of the configuration.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -46,12 +53,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "A collection of configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -69,12 +70,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -102,12 +103,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -117,7 +118,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -128,46 +129,28 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, }, }, }, @@ -192,11 +175,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, "update_available": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -236,7 +214,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "user_id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -246,229 +224,306 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ + "cra_logs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The Code Risk Analyzer logs of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "cra_version": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The variable name.", + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", }, - "description": &schema.Schema{ + "schema_version": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A short explanation of the output value.", + Description: "The schema version of Code Risk Analyzer logs of the configuration.", }, - "value": &schema.Schema{ + "status": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, }, }, }, - "active_draft": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", }, - "state": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The state of the configuration draft.", + Optional: true, + Description: "The currency of the cost estimate of the configuration.", }, - "pipeline_state": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The total hourly cost estimate of the configuration.", }, - "href": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", }, }, }, }, - "definition": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The unique ID.", }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The description of the project configuration.", + Description: "A relative URL.", }, - "authorizations": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "method": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "api_key": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The IBM Cloud API Key.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, }, - "compliance_profile": &schema.Schema{ + }, + }, + }, + "install_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "summary": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The profile required for compliance.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The location of the compliance instance.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The unique ID of a project.", + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "The name of the compliance profile.", + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, }, - "setting": &schema.Schema{ - Type: schema.TypeList, + }, + }, + }, + "uninstall_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, + Description: "The unique ID.", }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The type of a project configuration manual property.", + Description: "A relative URL.", }, - "output": &schema.Schema{ + "summary": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The summaries of jobs that were performed on the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": &schema.Schema{ - Type: schema.TypeString, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "A short explanation of the output value.", + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "value": &schema.Schema{ - Type: schema.TypeString, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -476,10 +531,34 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, - "href": &schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The type of a project configuration manual property.", }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, @@ -505,7 +584,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$`, MinValueLength: 1, MaxValueLength: 64, @@ -523,7 +602,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "locator_id", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, MinValueLength: 1, MaxValueLength: 512, @@ -543,8 +622,12 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions := &projectv1.CreateConfigOptions{} createConfigOptions.SetProjectID(d.Get("project_id").(string)) - createConfigOptions.SetName(d.Get("name").(string)) - createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + if _, ok := d.GetOk("name"); ok { + createConfigOptions.SetName(d.Get("name").(string)) + } + if _, ok := d.GetOk("description"); ok { + createConfigOptions.SetDescription(d.Get("description").(string)) + } if _, ok := d.GetOk("labels"); ok { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -553,9 +636,6 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetLabels(labels) } - if _, ok := d.GetOk("description"); ok { - createConfigOptions.SetDescription(d.Get("description").(string)) - } if _, ok := d.GetOk("authorizations"); ok { authorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -570,29 +650,22 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetComplianceProfile(complianceProfileModel) } + if _, ok := d.GetOk("locator_id"); ok { + createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + } if _, ok := d.GetOk("input"); ok { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) + inputModel, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - createConfigOptions.SetInput(input) + createConfigOptions.SetInput(inputModel) } if _, ok := d.GetOk("setting"); ok { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) + settingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - createConfigOptions.SetSetting(setting) + createConfigOptions.SetSetting(settingModel) } projectConfigCanonical, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) @@ -635,12 +708,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("project_id", projectConfigCanonical.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if !core.IsNil(projectConfigCanonical.Labels) { - if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { - return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) + if !core.IsNil(projectConfigCanonical.Name) { + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } } if !core.IsNil(projectConfigCanonical.Description) { @@ -648,6 +718,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } + if !core.IsNil(projectConfigCanonical.Labels) { + if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { + return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) + } + } if !core.IsNil(projectConfigCanonical.Authorizations) { authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { @@ -666,32 +741,26 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + if !core.IsNil(projectConfigCanonical.LocatorID) { + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } } if !core.IsNil(projectConfigCanonical.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigCanonical.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, inputItemMap) + inputMap, err := resourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("input", input); err != nil { + if err = d.Set("input", []map[string]interface{}{inputMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } if !core.IsNil(projectConfigCanonical.Setting) { - setting := []map[string]interface{}{} - for _, settingItem := range projectConfigCanonical.Setting { - settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, settingItemMap) + settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("setting", setting); err != nil { + if err = d.Set("setting", []map[string]interface{}{settingMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } @@ -719,11 +788,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } } - if !core.IsNil(projectConfigCanonical.PipelineState) { - if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) - } - } if !core.IsNil(projectConfigCanonical.UpdateAvailable) { if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) @@ -753,45 +817,67 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Type) { - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + if !core.IsNil(projectConfigCanonical.CraLogs) { + craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Output) { - output := []map[string]interface{}{} - for _, outputItem := range projectConfigCanonical.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) - if err != nil { - return diag.FromErr(err) - } - output = append(output, outputItemMap) + if !core.IsNil(projectConfigCanonical.CostEstimate) { + costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("output", output); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) + if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) } } - if !core.IsNil(projectConfigCanonical.ActiveDraft) { - activeDraftMap, err := resourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) + if !core.IsNil(projectConfigCanonical.CheckJob) { + checkJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) if err != nil { return diag.FromErr(err) } - if err = d.Set("active_draft", []map[string]interface{}{activeDraftMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting active_draft: %s", err)) + if err = d.Set("check_job", []map[string]interface{}{checkJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting check_job: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Definition) { - definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) + if !core.IsNil(projectConfigCanonical.InstallJob) { + installJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) if err != nil { return diag.FromErr(err) } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) + if err = d.Set("install_job", []map[string]interface{}{installJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting install_job: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.UninstallJob) { + uninstallJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("uninstall_job", []map[string]interface{}{uninstallJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting uninstall_job: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.Output) { + output := []map[string]interface{}{} + for _, outputItem := range projectConfigCanonical.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return diag.FromErr(err) + } + output = append(output, outputItemMap) + } + if err = d.Set("output", output); err != nil { + return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Href) { - if err = d.Set("href", projectConfigCanonical.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + if !core.IsNil(projectConfigCanonical.Type) { + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } } if !core.IsNil(projectConfigCanonical.ID) { @@ -822,43 +908,17 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false 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("locator_id") { - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true - } - if d.HasChange("input") { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) - } - updateConfigOptions.SetSetting(setting) - hasChange = true + 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") { updateConfigOptions.SetName(d.Get("name").(string)) hasChange = true } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } if d.HasChange("labels") { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -868,10 +928,6 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetLabels(labels) hasChange = true } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } if d.HasChange("authorizations") { authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -888,6 +944,26 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetComplianceProfile(complianceProfile) hasChange = true } + if d.HasChange("locator_id") { + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + hasChange = true + } + if d.HasChange("input") { + input, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + setting, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) @@ -976,19 +1052,13 @@ func resourceIbmProjectConfigMapToProjectConfigComplianceProfile(modelMap map[st return model, nil } -func resourceIbmProjectConfigMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { - model := &projectv1.ProjectConfigInputVariable{} - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["value"] != nil { - model.Value = modelMap["value"].(string) - } +func resourceIbmProjectConfigMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { + model := &projectv1.InputVariable{} return model, nil } -func resourceIbmProjectConfigMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { - model := &projectv1.ProjectConfigSettingCollection{} - model.Name = core.StringPtr(modelMap["name"].(string)) - model.Value = core.StringPtr(modelMap["value"].(string)) +func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { + model := &projectv1.ProjectConfigSetting{} return model, nil } @@ -1041,19 +1111,13 @@ func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv return modelMap, nil } -func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value return modelMap, nil } @@ -1068,90 +1132,177 @@ func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *proje return modelMap, nil } -func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion } - if model.Value != nil { - modelMap["value"] = model.Value + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Href != nil { - modelMap["href"] = model.Href + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.ID != nil { + modelMap["id"] = model.ID } - if model.Description != nil { - modelMap["description"] = model.Description + if model.Href != nil { + modelMap["href"] = model.Href } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if model.Summary != nil { + summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["summary"] = []map[string]interface{}{summaryMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + return modelMap, nil +} + +func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["apply_summary"] = applySummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + destroySummary[k] = string(bytes) } - modelMap["input"] = input + modelMap["destroy_summary"] = destroySummary } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + messageSummary[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["message_summary"] = messageSummary } - if model.Type != nil { - modelMap["type"] = model.Type + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) } - modelMap["output"] = output + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 28eb4e68ae..8d81698ff0 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -33,15 +33,6 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `active_draft` - (List) The project configuration version. - Nested schema for **active_draft**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Integer) The version number of the configuration. * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -50,92 +41,79 @@ Nested schema for **configs**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. + * `target_iam_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `check_job` - (List) The action job performed on the project configuration. + Nested schema for **check_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. + * `attachment_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `instance_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `definition` - (List) The project configuration definition. - Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `install_job` - (List) The action job performed on the project configuration. + Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. @@ -144,7 +122,7 @@ Nested schema for **configs**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -161,21 +139,29 @@ Nested schema for **configs**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (String) The unique ID of a project. + * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `uninstall_job` - (List) The action job performed on the project configuration. + Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. @@ -198,15 +184,6 @@ Nested schema for **cumulative_needs_attention_view**: * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. -* `definition` - (List) The definition of the project. -Nested schema for **definition**: - * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. - * `name` - (String) The name of the project. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. - * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index ab0c368f20..60b250900c 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -33,16 +33,6 @@ 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 project_config. -* `active_draft` - (List) The project configuration version. -Nested schema for **active_draft**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Integer) The version number of the configuration. - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -51,96 +41,85 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. + * `target_iam_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `check_job` - (List) The action job performed on the project configuration. +Nested schema for **check_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. + * `attachment_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `instance_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The project configuration definition. -Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - -* `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + +* `install_job` - (List) The action job performed on the project configuration. +Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. @@ -152,7 +131,7 @@ Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -175,19 +154,11 @@ Nested schema for **output**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. -* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. @@ -195,6 +166,22 @@ Nested schema for **setting**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `uninstall_job` - (List) The action job performed on the project configuration. +Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index f16f557f82..daefdb3b81 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -15,26 +15,9 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" name = "name" - labels = [ "labels" ] description = "description" + labels = [ "labels" ] authorizations { trusted_profile { id = "id" @@ -51,62 +34,88 @@ resource "ibm_project" "project_instance" { profile_name = "profile_name" } locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" + input = { } + setting = { } + id = "id" + project_id = "project_id" + version = 1 + is_draft = true + needs_attention_state = [ "anything as a string" ] + state = "approved" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" } - setting { - name = "name" - value = "value" + last_save = "2021-01-31T09:44:12Z" + cra_logs { + cra_version = "cra_version" + schema_version = "schema_version" + status = "status" + summary = { "key" = "anything as a string" } + timestamp = "2021-01-31T09:44:12Z" } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + cost_estimate { + version = "version" + currency = "currency" + total_hourly_cost = "total_hourly_cost" + total_monthly_cost = "total_monthly_cost" + past_total_hourly_cost = "past_total_hourly_cost" + past_total_monthly_cost = "past_total_monthly_cost" + diff_total_hourly_cost = "diff_total_hourly_cost" + diff_total_monthly_cost = "diff_total_monthly_cost" + time_generated = "2021-01-31T09:44:12Z" + user_id = "user_id" } - active_draft { - version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" + check_job { + id = "id" href = "href" - } - definition { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" + } + install_job { + id = "id" + href = "href" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + } + uninstall_job { + id = "id" + href = "href" + summary { + plan_summary = { "key" = "anything as a string" } + apply_summary = { "key" = "anything as a string" } + destroy_summary = { "key" = "anything as a string" } + message_summary = { "key" = "anything as a string" } + plan_messages = { "key" = "anything as a string" } + apply_messages = { "key" = "anything as a string" } + destroy_messages = { "key" = "anything as a string" } } } - href = "href" + output { + name = "name" + description = "description" + value = "anything as a string" + } + type = "terraform_template" } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" @@ -122,15 +131,6 @@ You can specify the following arguments for this resource. * `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `active_draft` - (Optional, List) The project configuration version. - Nested schema for **active_draft**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (Required, String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Required, Integer) The version number of the configuration. * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (Optional, String) The IBM Cloud API Key. @@ -139,92 +139,79 @@ Nested schema for **configs**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. + * `target_iam_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `check_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **check_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. + * `attachment_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. + * `instance_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `cost_estimate` - (Optional, List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (Optional, String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (Optional, String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (Optional, String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (Optional, String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (Optional, String) The past total monthly cost estimate of the configuration. + * `time_generated` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (Optional, String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (Optional, String) The total monthly cost estimate of the configuration. + * `user_id` - (Optional, String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (Optional, String) The version of the cost estimate of the configuration. + * `cra_logs` - (Optional, List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (Optional, String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (Optional, String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (Optional, String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Optional, Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `definition` - (Optional, List) The project configuration definition. - Nested schema for **definition**: - * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (Optional, String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Required, String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (Optional, String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `input` - (Optional, List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `install_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **install_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. @@ -233,12 +220,12 @@ Nested schema for **configs**: * `comment` - (Optional, String) The comment left by the user who approved the configuration. * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (Required, String) The unique ID of a project. + * `user_id` - (Required, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * `locator_id` - (Optional, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Required, String) The name of the configuration. + * `name` - (Optional, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. @@ -250,21 +237,29 @@ Nested schema for **configs**: * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (Optional, String) The unique ID of a project. + * `project_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (Optional, String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (Optional, String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `uninstall_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **uninstall_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Optional, Integer) The version of the configuration. @@ -274,7 +269,7 @@ Nested schema for **configs**: * Constraints: The default value is `true`. * `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Required, String) The name of the project. +* `name` - (Optional, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. @@ -298,14 +293,6 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. -* `definition` - (List) The definition of the project. -Nested schema for **definition**: - * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. - * `name` - (String) The name of the project. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. @@ -314,7 +301,7 @@ Nested schema for **definition**: ## Import -You can import the `ibm_project` resource by using `id`. The unique ID of a project. +You can import the `ibm_project` resource by using `id`. The unique ID. # Syntax ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index ed003b67e1..3ecf37b35b 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -29,17 +29,12 @@ resource "ibm_project_config" "project_config_instance" { attachment_id = "attachment_id" profile_name = "profile_name" } - input { - name = "name" - value = "anything as a string" - } - locator_id = "locator_id" - name = "name" + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + input = {"account_id":"$configs[].name["account-stage"].input.account_id","resource_group":"stage","access_tags":["env:stage"],"logdna_name":"Name of the LogDNA stage service instance","sysdig_name":"Name of the SysDig stage service instance"} + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + name = "env-stage" project_id = ibm_project.project_instance.id - setting { - name = "name" - value = "value" - } + setting = {"IBMCLOUD_TOOLCHAIN_ENDPOINT":"https://api.us-south.devops.dev.cloud.ibm.com"} } ``` @@ -55,127 +50,100 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. + * `target_iam_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. + * `attachment_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. + * `instance_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `input` - (Optional, List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. -* `locator_id` - (Required, String) A dotted value of catalogID.versionID. +* `locator_id` - (Optional, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `name` - (Required, String) The name of the configuration. +* `name` - (Optional, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. ## Attribute Reference After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the project_config. -* `active_draft` - (List) The project configuration version. -Nested schema for **active_draft**: +* `check_job` - (List) The action job performed on the project configuration. +Nested schema for **check_job**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Integer) The version number of the configuration. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The project configuration definition. -Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. +* `install_job` - (List) The action job performed on the project configuration. +Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. @@ -188,14 +156,27 @@ Nested schema for **output**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. -* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `uninstall_job` - (List) The action job performed on the project configuration. +Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From 9dddb70c0691910a267a72efd7c9eb7feeca4191 Mon Sep 17 00:00:00 2001 From: Mark-Kulube Date: Mon, 28 Aug 2023 16:17:03 -0400 Subject: [PATCH 085/125] feat: restore definition blocks --- examples/ibm-project/main.tf | 94 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 826 +++-------------- .../project/data_source_ibm_project_config.go | 229 ++++- ibm/service/project/resource_ibm_project.go | 853 +++--------------- .../project/resource_ibm_project_config.go | 310 ++++++- website/docs/d/project.html.markdown | 139 +-- website/docs/d/project_config.html.markdown | 49 + website/docs/r/project.html.markdown | 232 +---- website/docs/r/project_config.html.markdown | 48 + 11 files changed, 920 insertions(+), 1866 deletions(-) diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index c4dd9de096..5747f37e54 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -10,107 +10,41 @@ resource "ibm_project" "project_instance" { description = var.project_description destroy_on_delete = var.project_destroy_on_delete configs { - name = "name" - description = "description" - labels = [ "labels" ] - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input = { } - setting = { } id = "id" project_id = "project_id" version = 1 is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" + approved_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - last_save = "2021-01-31T09:44:12Z" - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" + installed_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" + definition { + name = "name" + description = "description" } check_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } install_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } uninstall_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } - } - output { - name = "name" - description = "description" - value = "anything as a string" } - type = "terraform_template" + href = "href" } } diff --git a/go.mod b/go.mod index ea4777746e..811f24ce8a 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.41.0 - github.com/IBM/project-go-sdk v0.0.26-51 + github.com/IBM/project-go-sdk v0.0.26-53 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 8efb72940e..4452ba73e3 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.41.0 h1:2aeHcLnQgat7UAKrtIF6jGyFW2hwq4oroO26fIX94kA= github.com/IBM/platform-services-go-sdk v0.41.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-51 h1:QrVTshQsVeoh4YDavu/pt9ZPGUxN/p/SNk34Bf0WJq0= -github.com/IBM/project-go-sdk v0.0.26-51/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-53 h1:E8NeGAplAsV9TsSmKpSPhGpLguBvTQR6FZywIXmUrnY= +github.com/IBM/project-go-sdk v0.0.26-53/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index a56973b4f3..de12c422a6 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -106,125 +105,36 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, - "configs": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", + Description: "The definition of the project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The name of the project.", }, "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The input variables for the configuration definition.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, - }, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, + }, + }, + }, + "configs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ "id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -258,147 +168,85 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ + "approved_version": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The last approved metadata of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "comment": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The comment left by the user who approved the configuration.", + Description: "The state of the configuration.", }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The version number of the configuration.", }, - "user_id": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "A relative URL.", }, }, }, }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cra_logs": &schema.Schema{ + "installed_version": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "status": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", + Description: "The state of the configuration.", }, - "summary": &schema.Schema{ - Type: schema.TypeMap, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "The version number of the configuration.", }, - "timestamp": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A relative URL.", }, }, }, }, - "cost_estimate": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The project configuration definition summary.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The name of the configuration.", }, - "user_id": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The description of the project configuration.", }, }, }, @@ -419,71 +267,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, }, }, }, @@ -503,71 +286,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, }, }, }, @@ -587,102 +305,13 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, }, }, }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "A relative URL.", }, }, }, @@ -719,7 +348,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m cumulativeNeedsAttentionView := []map[string]interface{}{} if projectCanonical.CumulativeNeedsAttentionView != nil { - for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { + for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -763,10 +392,22 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) } + definition := []map[string]interface{}{} + if projectCanonical.Definition != nil { + modelMap, err := dataSourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + definition = append(definition, modelMap) + } + if err = d.Set("definition", definition); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) + } + configs := []map[string]interface{}{} if projectCanonical.Configs != nil { - for _, modelItem := range projectCanonical.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigCanonicalToMap(&modelItem) + for _, modelItem := range projectCanonical.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -797,7 +438,7 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { modelMap["name"] = model.Name @@ -805,40 +446,14 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon if model.Description != nil { modelMap["description"] = model.Description } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := dataSourceIbmProjectInputVariableToMap(model.Input) - if err != nil { - return modelMap, err - } - modelMap["input"] = []map[string]interface{}{inputMap} - } - if model.Setting != nil { - settingMap, err := dataSourceIbmProjectProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} + if model.DestroyOnDelete != nil { + modelMap["destroy_on_delete"] = model.DestroyOnDelete } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID } @@ -857,211 +472,77 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon if model.State != nil { modelMap["state"] = model.State } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if model.ApprovedVersion != nil { + approvedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) if err != nil { return modelMap, err } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.CraLogs != nil { - craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if model.InstalledVersion != nil { + installedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) if err != nil { return modelMap, err } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} } - if model.CostEstimate != nil { - costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if model.Definition != nil { + definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + modelMap["definition"] = []map[string]interface{}{definitionMap} } if model.CheckJob != nil { - checkJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.CheckJob) + checkJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) if err != nil { return modelMap, err } modelMap["check_job"] = []map[string]interface{}{checkJobMap} } if model.InstallJob != nil { - installJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.InstallJob) + installJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) if err != nil { return modelMap, err } modelMap["install_job"] = []map[string]interface{}{installJobMap} } if model.UninstallJob != nil { - uninstallJobMap, err := dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model.UninstallJob) + uninstallJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) if err != nil { return modelMap, err } modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Type != nil { - modelMap["type"] = model.Type - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) - if err != nil { - return modelMap, err - } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} - } - if model.Method != nil { - modelMap["method"] = model.Method - } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID - } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation - } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID - } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName - } - return modelMap, nil -} - -func dataSourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + if model.Href != nil { + modelMap["href"] = model.Href } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } -func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description } return modelMap, nil } -func dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { +func dataSourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -1069,106 +550,5 @@ func dataSourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.Actio if model.Href != nil { modelMap["href"] = model.Href } - if model.Summary != nil { - summaryMap, err := dataSourceIbmProjectActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index dfe52a81b8..7dc1672fbd 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -132,8 +132,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -141,8 +140,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "project_config_canonical_id": &schema.Schema{ @@ -599,6 +597,155 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The type of a project configuration manual property.", }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The input variables for the configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{}, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{}, + }, + }, + }, + }, + }, }, } } @@ -630,7 +777,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } - authorizations := []map[string]interface{}{} if projectConfigCanonical.Authorizations != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) @@ -793,7 +939,7 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD output := []map[string]interface{}{} if projectConfigCanonical.Output != nil { - for _, modelItem := range projectConfigCanonical.Output { + for _, modelItem := range projectConfigCanonical.Output { modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -809,6 +955,18 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } + definition := []map[string]interface{}{} + if projectConfigCanonical.Definition != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + definition = append(definition, modelMap) + } + if err = d.Set("definition", definition); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) + } + return nil } @@ -1056,3 +1214,62 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m } return modelMap, nil } + +func dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 11ea5fbd37..bd1e38f21d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -20,35 +20,35 @@ import ( func ResourceIbmProject() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectCreate, - ReadContext: resourceIbmProjectRead, - UpdateContext: resourceIbmProjectUpdate, - DeleteContext: resourceIbmProjectDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectCreate, + ReadContext: resourceIbmProjectRead, + UpdateContext: resourceIbmProjectUpdate, + DeleteContext: resourceIbmProjectDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ @@ -63,122 +63,6 @@ func ResourceIbmProject() *schema.Resource { Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The description of the project configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The input variables for the configuration definition.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, - }, - }, "id": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -210,148 +94,84 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "The state of the configuration.", }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ + "approved_version": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The last approved metadata of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The comment left by the user who approved the configuration.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "timestamp": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The state of the configuration.", }, - "user_id": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Required: true, - Description: "The unique ID.", + Description: "The version number of the configuration.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", }, }, }, }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cra_logs": &schema.Schema{ + "installed_version": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The Code Risk Analyzer logs of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "status": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", + Required: true, + Description: "The state of the configuration.", }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version number of the configuration.", }, - "timestamp": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "A relative URL.", }, }, }, }, - "cost_estimate": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The project configuration definition summary.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Required: true, + Description: "The name of the configuration.", }, - "user_id": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The description of the project configuration.", }, }, }, @@ -373,58 +193,6 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, }, }, }, @@ -445,58 +213,6 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, }, }, }, @@ -517,89 +233,13 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The type of a project configuration manual property.", + Description: "A relative URL.", }, }, }, @@ -658,6 +298,31 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the project.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + }, + }, + }, + }, }, } } @@ -794,7 +459,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if !core.IsNil(projectCanonical.Configs) { configs := []map[string]interface{}{} for _, configsItem := range projectCanonical.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigCanonicalToMap(&configsItem) + configsItemMap, err := resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&configsItem) if err != nil { return diag.FromErr(err) } @@ -842,6 +507,15 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } } + if !core.IsNil(projectCanonical.Definition) { + definitionMap, err := resourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) + } + } return nil } @@ -1024,48 +698,8 @@ func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{} return model, nil } -func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := resourceIbmProjectInputVariableToMap(model.Input) - if err != nil { - return modelMap, err - } - modelMap["input"] = []map[string]interface{}{inputMap} - } - if model.Setting != nil { - settingMap, err := resourceIbmProjectProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} - } if model.ID != nil { modelMap["id"] = model.ID } @@ -1084,211 +718,77 @@ func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfi if model.State != nil { modelMap["state"] = model.State } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if model.ApprovedVersion != nil { + approvedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) if err != nil { return modelMap, err } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.CraLogs != nil { - craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if model.InstalledVersion != nil { + installedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) if err != nil { return modelMap, err } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} } - if model.CostEstimate != nil { - costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if model.Definition != nil { + definitionMap, err := resourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + modelMap["definition"] = []map[string]interface{}{definitionMap} } if model.CheckJob != nil { - checkJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.CheckJob) + checkJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) if err != nil { return modelMap, err } modelMap["check_job"] = []map[string]interface{}{checkJobMap} } if model.InstallJob != nil { - installJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.InstallJob) + installJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) if err != nil { return modelMap, err } modelMap["install_job"] = []map[string]interface{}{installJobMap} } if model.UninstallJob != nil { - uninstallJobMap, err := resourceIbmProjectActionJobWithSummaryAndHrefToMap(model.UninstallJob) + uninstallJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) if err != nil { return modelMap, err } modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Type != nil { - modelMap["type"] = model.Type - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) - if err != nil { - return modelMap, err - } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} - } - if model.Method != nil { - modelMap["method"] = model.Method - } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID - } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation - } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID - } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName - } - return modelMap, nil -} - -func resourceIbmProjectInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func resourceIbmProjectProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + if model.Href != nil { + modelMap["href"] = model.Href } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } -func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description } return modelMap, nil } -func resourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { +func resourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -1296,107 +796,6 @@ func resourceIbmProjectActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJ if model.Href != nil { modelMap["href"] = model.Href } - if model.Summary != nil { - summaryMap, err := resourceIbmProjectActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func resourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } @@ -1416,3 +815,17 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative } return modelMap, nil } + +func resourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.DestroyOnDelete != nil { + modelMap["destroy_on_delete"] = model.DestroyOnDelete + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 68d5f414bc..f938bdb91c 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -21,30 +21,30 @@ import ( func ResourceIbmProjectConfig() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectConfigCreate, - ReadContext: resourceIbmProjectConfigRead, - UpdateContext: resourceIbmProjectConfigUpdate, - DeleteContext: resourceIbmProjectConfigDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectConfigCreate, + ReadContext: resourceIbmProjectConfigRead, + UpdateContext: resourceIbmProjectConfigUpdate, + DeleteContext: resourceIbmProjectConfigDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), - Description: "The unique project ID.", + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The name of the configuration.", + Description: "The name of the configuration.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), Description: "The description of the project configuration.", }, "labels": &schema.Schema{ @@ -129,9 +129,9 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ @@ -140,8 +140,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -150,8 +149,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "version": &schema.Schema{ @@ -249,7 +247,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "timestamp": &schema.Schema{ Type: schema.TypeString, @@ -345,43 +343,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -416,43 +414,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -487,43 +485,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -560,6 +558,158 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The type of a project configuration manual property.", }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the configuration.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The description of the project configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The input variables for the configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{}, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{}, + }, + }, + }, + }, + }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -880,6 +1030,15 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } } + if !core.IsNil(projectConfigCanonical.Definition) { + definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) + } + } if !core.IsNil(projectConfigCanonical.ID) { if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) @@ -908,8 +1067,8 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false 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")) + 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") { updateConfigOptions.SetName(d.Get("name").(string)) @@ -1306,3 +1465,62 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map } return modelMap, nil } + +func resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } + return modelMap, nil +} diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 8d81698ff0..7e5b78c9d7 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -33,137 +33,59 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `approved_version` - (List) The project configuration version. + Nested schema for **approved_version**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Integer) The version number of the configuration. * `check_job` - (List) The action job performed on the project configuration. Nested schema for **check_job**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `definition` - (List) The project configuration definition summary. + Nested schema for **definition**: + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The input variables for the configuration definition. - Nested schema for **input**: * `install_job` - (List) The action job performed on the project configuration. Nested schema for **install_job**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `installed_version` - (List) The project configuration version. + Nested schema for **installed_version**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Integer) The version number of the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **setting**: * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `uninstall_job` - (List) The action job performed on the project configuration. Nested schema for **uninstall_job**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -184,6 +106,15 @@ Nested schema for **cumulative_needs_attention_view**: * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `definition` - (List) The definition of the project. +Nested schema for **definition**: + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 60b250900c..8f3da95577 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -99,6 +99,55 @@ Nested schema for **cra_logs**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `definition` - (List) The Schematics template property. +Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The input variables for the configuration definition. + Nested schema for **input**: + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + Nested schema for **setting**: + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index daefdb3b81..ae09fcff3a 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -15,107 +15,41 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { configs { - name = "name" - description = "description" - labels = [ "labels" ] - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input = { } - setting = { } id = "id" project_id = "project_id" version = 1 is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" + approved_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - last_save = "2021-01-31T09:44:12Z" - cra_logs { - cra_version = "cra_version" - schema_version = "schema_version" - status = "status" - summary = { "key" = "anything as a string" } - timestamp = "2021-01-31T09:44:12Z" + installed_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - cost_estimate { - version = "version" - currency = "currency" - total_hourly_cost = "total_hourly_cost" - total_monthly_cost = "total_monthly_cost" - past_total_hourly_cost = "past_total_hourly_cost" - past_total_monthly_cost = "past_total_monthly_cost" - diff_total_hourly_cost = "diff_total_hourly_cost" - diff_total_monthly_cost = "diff_total_monthly_cost" - time_generated = "2021-01-31T09:44:12Z" - user_id = "user_id" + definition { + name = "name" + description = "description" } check_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } install_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } uninstall_job { id = "id" href = "href" - summary { - plan_summary = { "key" = "anything as a string" } - apply_summary = { "key" = "anything as a string" } - destroy_summary = { "key" = "anything as a string" } - message_summary = { "key" = "anything as a string" } - plan_messages = { "key" = "anything as a string" } - apply_messages = { "key" = "anything as a string" } - destroy_messages = { "key" = "anything as a string" } - } } - output { - name = "name" - description = "description" - value = "anything as a string" - } - type = "terraform_template" + href = "href" } description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" @@ -131,137 +65,59 @@ You can specify the following arguments for this resource. * `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `approved_version` - (Optional, List) The project configuration version. + Nested schema for **approved_version**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (Required, String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Required, Integer) The version number of the configuration. * `check_job` - (Optional, List) The action job performed on the project configuration. Nested schema for **check_job**: * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. - * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `cost_estimate` - (Optional, List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (Optional, String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (Optional, String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (Optional, String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (Optional, String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (Optional, String) The past total monthly cost estimate of the configuration. - * `time_generated` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (Optional, String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (Optional, String) The total monthly cost estimate of the configuration. - * `user_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (Optional, String) The version of the cost estimate of the configuration. - * `cra_logs` - (Optional, List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (Optional, String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (Optional, String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (Optional, String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Optional, Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `description` - (Optional, String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `definition` - (Optional, List) The project configuration definition summary. + Nested schema for **definition**: + * `description` - (Optional, String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The input variables for the configuration definition. - Nested schema for **input**: * `install_job` - (Optional, List) The action job performed on the project configuration. Nested schema for **install_job**: * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. + * `installed_version` - (Optional, List) The project configuration version. + Nested schema for **installed_version**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (Required, String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Required, Integer) The version number of the configuration. * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (Optional, List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (Optional, String) The comment left by the user who approved the configuration. - * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (Required, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `locator_id` - (Optional, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Optional, String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `project_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **setting**: * `state` - (Optional, String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `type` - (Optional, String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `uninstall_job` - (Optional, List) The action job performed on the project configuration. Nested schema for **uninstall_job**: * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (Optional, List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Optional, Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Optional, Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Optional, Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Optional, Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Optional, Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Optional, Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Optional, Map) The summary of the plan jobs on the configuration. - * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -293,6 +149,14 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `definition` - (List) The definition of the project. +Nested schema for **definition**: + * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 3ecf37b35b..28da460453 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -122,6 +122,54 @@ Nested schema for **cra_logs**: * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `definition` - (List) The Schematics template property. +Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The input variables for the configuration definition. + Nested schema for **input**: + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + Nested schema for **setting**: + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `install_job` - (List) The action job performed on the project configuration. Nested schema for **install_job**: * `href` - (String) A relative URL. From 9af08d60a63d723b939b24e4473f8ca28cae86bf Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 29 Aug 2023 16:18:41 +0200 Subject: [PATCH 086/125] regenerate the terraform code based on latest YAML --- examples/ibm-project/README.md | 14 +- examples/ibm-project/main.tf | 103 +- examples/ibm-project/variables.tf | 16 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 641 ++++++++-- .../project/data_source_ibm_project_config.go | 1064 +++++------------ ibm/service/project/resource_ibm_project.go | 764 +++++++++--- .../project/resource_ibm_project_config.go | 977 +++++---------- website/docs/d/project.html.markdown | 160 ++- website/docs/d/project_config.html.markdown | 140 +-- website/docs/r/project.html.markdown | 261 +++- website/docs/r/project_config.html.markdown | 147 +-- 13 files changed, 2307 insertions(+), 1986 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 05be1c0282..9c23f3287d 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -40,8 +40,8 @@ project_config resource: resource "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - description = var.project_config_description labels = var.project_config_labels + description = var.project_config_description authorizations = var.project_config_authorizations compliance_profile = var.project_config_compliance_profile locator_id = var.project_config_locator_id @@ -95,19 +95,19 @@ data "project_config" "project_config_instance" { | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| name | The name of the project. | `string` | false | +| name | The name of the project. | `string` | true | | description | A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | | configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | `list()` | false | | project_id | The unique project ID. | `string` | true | -| name | The name of the configuration. | `string` | false | -| description | The description of the project configuration. | `string` | false | +| name | The name of the configuration. | `string` | true | | labels | A collection of configuration labels. | `list(string)` | false | +| description | The description of the project configuration. | `string` | false | | authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | -| locator_id | A dotted value of catalogID.versionID. | `string` | false | -| input | The input variables for the configuration definition. | `` | false | -| setting | Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. | `` | false | +| locator_id | A dotted value of catalogID.versionID. | `string` | true | +| input | The inputs of a Schematics template property. | `list()` | false | +| setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 5747f37e54..cea26480b9 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -16,34 +16,91 @@ resource "ibm_project" "project_instance" { is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - approved_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" } - installed_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" + last_save = "2021-01-31T09:44:12Z" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" } - definition { + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { name = "name" - description = "description" + value = "anything as a string" } - check_job { - id = "id" - href = "href" + setting { + name = "name" + value = "value" } - install_job { - id = "id" - href = "href" + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" } - uninstall_job { - id = "id" + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" href = "href" } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } href = "href" } } @@ -52,8 +109,8 @@ resource "ibm_project" "project_instance" { resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - description = var.project_config_description labels = var.project_config_labels + description = var.project_config_description authorizations { trusted_profile { id = "id" @@ -71,8 +128,12 @@ resource "ibm_project_config" "project_config_instance" { } locator_id = var.project_config_locator_id input { + name = "name" + value = "anything as a string" } setting { + name = "name" + value = "value" } } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 11b08d1c56..86b9bf2534 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -39,22 +39,22 @@ variable "project_config_project_id" { variable "project_config_name" { description = "The name of the configuration." type = string - default = "env-stage" -} -variable "project_config_description" { - description = "The description of the project configuration." - type = string - default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + default = "name" } variable "project_config_labels" { description = "A collection of configuration labels." type = list(string) - default = ["env:stage","governance:test","build:0"] + default = [ "labels" ] +} +variable "project_config_description" { + description = "The description of the project configuration." + type = string + default = "description" } variable "project_config_locator_id" { description = "A dotted value of catalogID.versionID." type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + default = "locator_id" } // Data source arguments for project diff --git a/go.mod b/go.mod index dc845370e0..b2a48f60a5 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.42.0 - github.com/IBM/project-go-sdk v0.0.26-53 + github.com/IBM/project-go-sdk v0.0.26-54 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 60f7660207..73ff9e7388 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.42.0 h1:2it30wdvjDRqN8Yc/vqUJpJPVIeTNXpkIOSjwG+P/xc= github.com/IBM/platform-services-go-sdk v0.42.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-53 h1:E8NeGAplAsV9TsSmKpSPhGpLguBvTQR6FZywIXmUrnY= -github.com/IBM/project-go-sdk v0.0.26-53/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-54 h1:dsaocaBpUf0nVB6uJDZ23AEQYjdclFkO15Ehynk30oc= +github.com/IBM/project-go-sdk v0.0.26-54/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index de12c422a6..5dd91af5c6 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -143,7 +143,7 @@ func DataSourceIbmProject() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "version": &schema.Schema{ Type: schema.TypeInt, @@ -168,137 +168,242 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "approved_version": &schema.Schema{ + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The last approved metadata of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, + "is_forced": &schema.Schema{ + Type: schema.TypeBool, Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "The flag that indicates whether the approval was forced approved.", }, - "state": &schema.Schema{ + "comment": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration.", + Description: "The comment left by the user who approved the configuration.", }, - "version": &schema.Schema{ - Type: schema.TypeInt, + "timestamp": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "href": &schema.Schema{ + "user_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The unique ID of a project.", }, }, }, }, - "installed_version": &schema.Schema{ + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ + "trusted_profile": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, }, }, - "state": &schema.Schema{ + "method": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration.", + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", }, - "version": &schema.Schema{ - Type: schema.TypeInt, + "api_key": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "The IBM Cloud API Key.", }, - "href": &schema.Schema{ + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", }, }, }, }, - "definition": &schema.Schema{ + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition summary.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The variable name.", }, - "description": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "check_job": &schema.Schema{ + "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The name of the configuration setting.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The value of the configuration setting.", }, }, }, }, - "install_job": &schema.Schema{ + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The variable name.", }, - "href": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "uninstall_job": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, "href": &schema.Schema{ Type: schema.TypeString, @@ -308,6 +413,177 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + }, + }, + }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -394,7 +670,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m definition := []map[string]interface{}{} if projectCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) + modelMap, err := dataSourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -407,7 +683,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m configs := []map[string]interface{}{} if projectCanonical.Configs != nil { for _, modelItem := range projectCanonical.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&modelItem) + modelMap, err := dataSourceIbmProjectProjectConfigCanonicalToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -438,21 +714,15 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.DestroyOnDelete != nil { - modelMap["destroy_on_delete"] = model.DestroyOnDelete - } + modelMap["name"] = model.Name + modelMap["description"] = model.Description + modelMap["destroy_on_delete"] = model.DestroyOnDelete return modelMap, nil } -func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -472,47 +742,99 @@ func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *proj if model.State != nil { modelMap["state"] = model.State } - if model.ApprovedVersion != nil { - approvedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) if err != nil { return modelMap, err } - modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() } - if model.InstalledVersion != nil { - installedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) if err != nil { return modelMap, err } - modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.Definition != nil { - definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) if err != nil { return modelMap, err } - modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.CheckJob != nil { - checkJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) - if err != nil { - return modelMap, err + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) } - modelMap["check_job"] = []map[string]interface{}{checkJobMap} + modelMap["input"] = input } - if model.InstallJob != nil { - installJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + if model.ActiveDraft != nil { + activeDraftMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) if err != nil { return modelMap, err } - modelMap["install_job"] = []map[string]interface{}{installJobMap} + modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} } - if model.UninstallJob != nil { - uninstallJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) + if model.Definition != nil { + definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} + modelMap["definition"] = []map[string]interface{}{definitionMap} } if model.Href != nil { modelMap["href"] = model.Href @@ -520,35 +842,166 @@ func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *proj return modelMap, nil } -func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } - modelMap["state"] = model.State - modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } -func dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Description != nil { modelMap["description"] = model.Description } + if model.Value != nil { + modelMap["value"] = model.Value + } return modelMap, nil } -func dataSourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState } if model.Href != nil { modelMap["href"] = model.Href } return modelMap, nil } + +func dataSourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + return modelMap, nil +} diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 7dc1672fbd..3e912ccca2 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -32,117 +31,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The input variables for the configuration definition.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -171,6 +59,11 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, "update_available": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -210,7 +103,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "user_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, }, }, @@ -220,354 +113,144 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "cra_logs": &schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID of a project.", + }, + }, + }, }, - "status": &schema.Schema{ + "method": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", }, - "timestamp": &schema.Schema{ + "api_key": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The IBM Cloud API Key.", }, }, }, }, - "cost_estimate": &schema.Schema{ + "compliance_profile": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The profile required for compliance.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The past total monthly cost estimate of the configuration.", + Description: "The unique ID of a project.", }, - "diff_total_hourly_cost": &schema.Schema{ + "instance_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", + Description: "The unique ID of a project.", }, - "diff_total_monthly_cost": &schema.Schema{ + "instance_location": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", + Description: "The location of the compliance instance.", }, - "time_generated": &schema.Schema{ + "attachment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The unique ID of a project.", }, - "user_id": &schema.Schema{ + "profile_name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The name of the compliance profile.", }, }, }, }, - "check_job": &schema.Schema{ - Type: schema.TypeList, + "locator_id": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, + Description: "A dotted value of catalogID.versionID.", }, - "install_job": &schema.Schema{ + "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The variable name.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "uninstall_job": &schema.Schema{ + "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The name of the configuration setting.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, + Description: "The value of the configuration setting.", }, }, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, "output": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -592,55 +275,45 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "definition": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Schematics template property.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "output": &schema.Schema{ - Type: schema.TypeList, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, + Description: "The version number of the configuration.", }, - "type": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "The state of the configuration draft.", }, - "name": &schema.Schema{ + "pipeline_state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", + Description: "A relative URL.", + }, + }, + }, + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -650,6 +323,11 @@ func DataSourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, }, }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -665,12 +343,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, }, }, @@ -697,12 +375,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -712,7 +390,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -730,104 +408,100 @@ func DataSourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The input variables for the configuration definition.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, }, } -} - -func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) - } - - getConfigOptions := &projectv1.GetConfigOptions{} - - getConfigOptions.SetProjectID(d.Get("project_id").(string)) - getConfigOptions.SetID(d.Get("id").(string)) - - projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) - if err != nil { - log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) - } - - d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) - - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - - if err = d.Set("description", projectConfigCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } +} - authorizations := []map[string]interface{}{} - if projectConfigCanonical.Authorizations != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) - if err != nil { - return diag.FromErr(err) - } - authorizations = append(authorizations, modelMap) - } - if err = d.Set("authorizations", authorizations); err != nil { - return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) +func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) } - complianceProfile := []map[string]interface{}{} - if projectConfigCanonical.ComplianceProfile != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) - if err != nil { - return diag.FromErr(err) - } - complianceProfile = append(complianceProfile, modelMap) - } - if err = d.Set("compliance_profile", complianceProfile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) - } + getConfigOptions := &projectv1.GetConfigOptions{} - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) - } + getConfigOptions.SetProjectID(d.Get("project_id").(string)) + getConfigOptions.SetID(d.Get("id").(string)) - input := []map[string]interface{}{} - if projectConfigCanonical.Input != nil { - modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) - if err != nil { - return diag.FromErr(err) - } - input = append(input, modelMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input %s", err)) + projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err != nil { + log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) } - setting := []map[string]interface{}{} - if projectConfigCanonical.Setting != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, modelMap) - } - if err = d.Set("setting", setting); err != nil { - return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) - } + d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) @@ -849,6 +523,10 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } + if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) + } + if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } @@ -877,64 +555,72 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } - craLogs := []map[string]interface{}{} - if projectConfigCanonical.CraLogs != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) - if err != nil { - return diag.FromErr(err) - } - craLogs = append(craLogs, modelMap) + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } - if err = d.Set("cra_logs", craLogs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) + + if err = d.Set("description", projectConfigCanonical.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } - costEstimate := []map[string]interface{}{} - if projectConfigCanonical.CostEstimate != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) + authorizations := []map[string]interface{}{} + if projectConfigCanonical.Authorizations != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { return diag.FromErr(err) } - costEstimate = append(costEstimate, modelMap) + authorizations = append(authorizations, modelMap) } - if err = d.Set("cost_estimate", costEstimate); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) + if err = d.Set("authorizations", authorizations); err != nil { + return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) } - checkJob := []map[string]interface{}{} - if projectConfigCanonical.CheckJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) + complianceProfile := []map[string]interface{}{} + if projectConfigCanonical.ComplianceProfile != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) if err != nil { return diag.FromErr(err) } - checkJob = append(checkJob, modelMap) + complianceProfile = append(complianceProfile, modelMap) } - if err = d.Set("check_job", checkJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting check_job %s", err)) + if err = d.Set("compliance_profile", complianceProfile); err != nil { + return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) } - installJob := []map[string]interface{}{} - if projectConfigCanonical.InstallJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) - if err != nil { - return diag.FromErr(err) + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } + + input := []map[string]interface{}{} + if projectConfigCanonical.Input != nil { + for _, modelItem := range projectConfigCanonical.Input { + modelMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, modelMap) } - installJob = append(installJob, modelMap) } - if err = d.Set("install_job", installJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting install_job %s", err)) + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input %s", err)) } - uninstallJob := []map[string]interface{}{} - if projectConfigCanonical.UninstallJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) - if err != nil { - return diag.FromErr(err) + setting := []map[string]interface{}{} + if projectConfigCanonical.Setting != nil { + for _, modelItem := range projectConfigCanonical.Setting { + modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, modelMap) } - uninstallJob = append(uninstallJob, modelMap) } - if err = d.Set("uninstall_job", uninstallJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting uninstall_job %s", err)) + if err = d.Set("setting", setting); err != nil { + return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) + } + + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } output := []map[string]interface{}{} @@ -951,13 +637,21 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting output %s", err)) } - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + activeDraft := []map[string]interface{}{} + if projectConfigCanonical.ActiveDraft != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) + if err != nil { + return diag.FromErr(err) + } + activeDraft = append(activeDraft, modelMap) + } + if err = d.Set("active_draft", activeDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting active_draft %s", err)) } definition := []map[string]interface{}{} if projectConfigCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) + modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -967,9 +661,24 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) } + if err = d.Set("href", projectConfigCanonical.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + return nil } +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.TrustedProfile != nil { @@ -1019,204 +728,96 @@ func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projec return modelMap, nil } -func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } + modelMap["name"] = model.Name + modelMap["value"] = model.Value return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } -func dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState } if model.Href != nil { modelMap["href"] = model.Href } - if model.Summary != nil { - summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } return modelMap, nil } -func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary + if model.Description != nil { + modelMap["description"] = model.Description } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err } - modelMap["message_summary"] = messageSummary + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err } - modelMap["plan_messages"] = planMessages + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } - applyMessages[k] = string(bytes) + input = append(input, inputItemMap) } - modelMap["apply_messages"] = applyMessages + modelMap["input"] = input } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return modelMap, err } - destroyMessages[k] = string(bytes) + setting = append(setting, settingItemMap) } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + modelMap["setting"] = setting } - if model.Value != nil { - modelMap["value"] = model.Value + if model.Type != nil { + modelMap["type"] = model.Type } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) if model.Output != nil { output := []map[string]interface{}{} for _, outputItem := range model.Output { @@ -1228,48 +829,5 @@ func dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(mod } modelMap["output"] = output } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) - if err != nil { - return modelMap, err - } - modelMap["input"] = []map[string]interface{}{inputMap} - } - if model.Setting != nil { - settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} - } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index bd1e38f21d..31e54a41a5 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -41,7 +41,7 @@ func ResourceIbmProject() *schema.Resource { }, "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), Description: "The name of the project.", }, @@ -71,7 +71,7 @@ func ResourceIbmProject() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "version": &schema.Schema{ Type: schema.TypeInt, @@ -94,119 +94,245 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "The state of the configuration.", }, - "approved_version": &schema.Schema{ + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration version.", + Description: "The last approved metadata of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The comment left by the user who approved the configuration.", }, - "state": &schema.Schema{ + "timestamp": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The state of the configuration.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "version": &schema.Schema{ - Type: schema.TypeInt, + "user_id": &schema.Schema{ + Type: schema.TypeString, Required: true, - Description: "The version number of the configuration.", + Description: "The unique ID of a project.", }, - "href": &schema.Schema{ + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", }, }, }, }, - "installed_version": &schema.Schema{ + "compliance_profile": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration version.", + Description: "The profile required for compliance.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, + "id": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The unique ID of a project.", }, - "state": &schema.Schema{ + "instance_id": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The state of the configuration.", + Optional: true, + Description: "The unique ID of a project.", }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", }, - "href": &schema.Schema{ + "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", }, }, }, }, - "definition": &schema.Schema{ + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "The project configuration definition summary.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The name of the configuration.", + Description: "The variable name.", }, - "description": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The description of the project configuration.", + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "check_job": &schema.Schema{ + "setting": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "The action job performed on the project configuration.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "A short explanation of the output value.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "install_job": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The action job performed on the project configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version number of the configuration.", + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The state of the configuration draft.", + }, + "pipeline_state": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, "href": &schema.Schema{ Type: schema.TypeString, @@ -216,22 +342,175 @@ func ResourceIbmProject() *schema.Resource { }, }, }, - "uninstall_job": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The action job performed on the project configuration.", + Description: "The project configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, + Required: true, + Description: "The name of the configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The unique ID.", + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "href": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", + Description: "The description of the project configuration.", + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID of a project.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The inputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, }, }, }, @@ -306,18 +585,17 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, Description: "The name of the project.", }, "description": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, - Optional: true, - Default: true, + Required: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, }, @@ -352,7 +630,7 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, + Required: true, Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]+$`, MinValueLength: 1, MaxValueLength: 64, @@ -382,9 +660,7 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) createProjectOptions.SetLocation(d.Get("location").(string)) - if _, ok := d.GetOk("name"); ok { - createProjectOptions.SetName(d.Get("name").(string)) - } + createProjectOptions.SetName(d.Get("name").(string)) if _, ok := d.GetOk("description"); ok { createProjectOptions.SetDescription(d.Get("description").(string)) } @@ -392,10 +668,10 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigTerraform + var configs []projectv1.ProjectConfig for _, v := range d.Get("configs").([]interface{}) { value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) + configsItem, err := resourceIbmProjectMapToProjectConfig(value) if err != nil { return diag.FromErr(err) } @@ -441,10 +717,8 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if err = d.Set("location", projectCanonical.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if !core.IsNil(projectCanonical.Name) { - if err = d.Set("name", projectCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } + if err = d.Set("name", projectCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } if !core.IsNil(projectCanonical.Description) { if err = d.Set("description", projectCanonical.Description); err != nil { @@ -459,7 +733,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if !core.IsNil(projectCanonical.Configs) { configs := []map[string]interface{}{} for _, configsItem := range projectCanonical.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&configsItem) + configsItemMap, err := resourceIbmProjectProjectConfigCanonicalToMap(&configsItem) if err != nil { return diag.FromErr(err) } @@ -469,15 +743,11 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } - if !core.IsNil(projectCanonical.Crn) { - if err = d.Set("crn", projectCanonical.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) - } + if err = d.Set("crn", projectCanonical.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if !core.IsNil(projectCanonical.CreatedAt) { - if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } + if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } if !core.IsNil(projectCanonical.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} @@ -497,10 +767,8 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if !core.IsNil(projectCanonical.State) { - if err = d.Set("state", projectCanonical.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } + if err = d.Set("state", projectCanonical.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } if !core.IsNil(projectCanonical.EventNotificationsCrn) { if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { @@ -508,7 +776,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met } } if !core.IsNil(projectCanonical.Definition) { - definitionMap, err := resourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) + definitionMap, err := resourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -544,19 +812,6 @@ func resourceIbmProjectUpdate(context context.Context, d *schema.ResourceData, m updateProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) hasChange = true } - if d.HasChange("configs") { - var configs []projectv1.ProjectConfigTerraform - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) - } - updateProjectOptions.SetConfigs(configs) - hasChange = true - } if hasChange { _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) @@ -590,14 +845,9 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return nil } -func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface{}) (*projectv1.ProjectConfigTerraform, error) { - model := &projectv1.ProjectConfigTerraform{} - if modelMap["name"] != nil && modelMap["name"].(string) != "" { - model.Name = core.StringPtr(modelMap["name"].(string)) - } - if modelMap["description"] != nil && modelMap["description"].(string) != "" { - model.Description = core.StringPtr(modelMap["description"].(string)) - } +func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*projectv1.ProjectConfig, error) { + model := &projectv1.ProjectConfig{} + model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["labels"] != nil { labels := []string{} for _, labelsItem := range modelMap["labels"].([]interface{}) { @@ -605,6 +855,9 @@ func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface } model.Labels = labels } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -619,22 +872,28 @@ func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface } model.ComplianceProfile = ComplianceProfileModel } - if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) - } - if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { - InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["input"] != nil { + input := []projectv1.ProjectConfigInputVariable{} + for _, inputItem := range modelMap["input"].([]interface{}) { + inputItemModel, err := resourceIbmProjectMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) + if err != nil { + return model, err + } + input = append(input, *inputItemModel) } - model.Input = InputModel + model.Input = input } - if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { - SettingModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err + if modelMap["setting"] != nil { + setting := []projectv1.ProjectConfigSettingCollection{} + for _, settingItem := range modelMap["setting"].([]interface{}) { + settingItemModel, err := resourceIbmProjectMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) + if err != nil { + return model, err + } + setting = append(setting, *settingItemModel) } - model.Setting = SettingModel + model.Setting = setting } return model, nil } @@ -688,17 +947,23 @@ func resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap map[string]i return model, nil } -func resourceIbmProjectMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { - model := &projectv1.InputVariable{} +func resourceIbmProjectMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { + model := &projectv1.ProjectConfigInputVariable{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["value"] != nil { + model.Value = modelMap["value"].(string) + } return model, nil } -func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { - model := &projectv1.ProjectConfigSetting{} +func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { + model := &projectv1.ProjectConfigSettingCollection{} + model.Name = core.StringPtr(modelMap["name"].(string)) + model.Value = core.StringPtr(modelMap["value"].(string)) return model, nil } -func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -718,47 +983,99 @@ func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projec if model.State != nil { modelMap["state"] = model.State } - if model.ApprovedVersion != nil { - approvedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState + } + if model.UpdateAvailable != nil { + modelMap["update_available"] = model.UpdateAvailable + } + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) if err != nil { return modelMap, err } - modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels } - if model.InstalledVersion != nil { - installedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) if err != nil { return modelMap, err } - modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.Definition != nil { - definitionMap, err := resourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) if err != nil { return modelMap, err } - modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.CheckJob != nil { - checkJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) - if err != nil { - return modelMap, err + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) } - modelMap["check_job"] = []map[string]interface{}{checkJobMap} + modelMap["output"] = output } - if model.InstallJob != nil { - installJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) + if model.ActiveDraft != nil { + activeDraftMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) if err != nil { return modelMap, err } - modelMap["install_job"] = []map[string]interface{}{installJobMap} + modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} } - if model.UninstallJob != nil { - uninstallJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) + if model.Definition != nil { + definitionMap, err := resourceIbmProjectProjectConfigDefinitionToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} + modelMap["definition"] = []map[string]interface{}{definitionMap} } if model.Href != nil { modelMap["href"] = model.Href @@ -766,32 +1083,100 @@ func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projec return modelMap, nil } -func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } - modelMap["state"] = model.State - modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func resourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfile != nil { + trustedProfileMap, err := resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if err != nil { + return modelMap, err + } + modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.TargetIamID != nil { + modelMap["target_iam_id"] = model.TargetIamID + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } -func resourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value + return modelMap, nil +} + +func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Description != nil { modelMap["description"] = model.Description } + if model.Value != nil { + modelMap["value"] = model.Value + } return modelMap, nil } -func resourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState } if model.Href != nil { modelMap["href"] = model.Href @@ -799,6 +1184,69 @@ func resourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWit return modelMap, nil } +func resourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return modelMap, err + } + input = append(input, inputItemMap) + } + modelMap["input"] = input + } + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return modelMap, err + } + setting = append(setting, settingItemMap) + } + modelMap["setting"] = setting + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + return modelMap, nil +} + func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Event != nil { @@ -816,16 +1264,10 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative return modelMap, nil } -func resourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { +func resourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.DestroyOnDelete != nil { - modelMap["destroy_on_delete"] = model.DestroyOnDelete - } + modelMap["name"] = model.Name + modelMap["description"] = model.Description + modelMap["destroy_on_delete"] = model.DestroyOnDelete return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f938bdb91c..f85c08695f 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -37,22 +36,22 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), Description: "The name of the configuration.", }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", - }, "labels": &schema.Schema{ Type: schema.TypeList, Optional: true, Description: "A collection of configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", + }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -70,12 +69,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, }, }, @@ -103,12 +102,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -118,7 +117,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -130,26 +129,46 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "The input variables for the configuration definition.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, }, }, "version": &schema.Schema{ @@ -173,6 +192,11 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, + "pipeline_state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + }, "update_available": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -212,7 +236,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "user_id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, }, }, @@ -222,393 +246,86 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, + "type": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, + Description: "The type of a project configuration manual property.", }, - "cost_estimate": &schema.Schema{ + "output": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", + Required: true, + Description: "The variable name.", }, - }, - }, - }, - "check_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "A short explanation of the output value.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, - "install_job": &schema.Schema{ + "active_draft": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version number of the configuration.", }, - "href": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, + Required: true, + Description: "The state of the configuration draft.", }, - }, - }, - }, - "uninstall_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "pipeline_state": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", }, "href": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "A relative URL.", }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, }, }, }, - "output": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The project configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The name of the configuration.", }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "definition": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "output": &schema.Schema{ + "labels": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The type of a project configuration manual property.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the configuration.", + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, }, "description": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "The description of the project configuration.", }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -626,12 +343,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, }, }, @@ -659,12 +376,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -674,7 +391,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", + Description: "The unique ID of a project.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -686,30 +403,84 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "The input variables for the configuration definition.", + Description: "The inputs of a Schematics template property.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, - MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the configuration setting.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The value of the configuration setting.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, }, }, }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -734,7 +505,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, + Required: true, Regexp: `^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$`, MinValueLength: 1, MaxValueLength: 64, @@ -752,7 +523,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "locator_id", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, + Required: true, Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, MinValueLength: 1, MaxValueLength: 512, @@ -772,12 +543,8 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions := &projectv1.CreateConfigOptions{} createConfigOptions.SetProjectID(d.Get("project_id").(string)) - if _, ok := d.GetOk("name"); ok { - createConfigOptions.SetName(d.Get("name").(string)) - } - if _, ok := d.GetOk("description"); ok { - createConfigOptions.SetDescription(d.Get("description").(string)) - } + createConfigOptions.SetName(d.Get("name").(string)) + createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) if _, ok := d.GetOk("labels"); ok { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -786,6 +553,9 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetLabels(labels) } + if _, ok := d.GetOk("description"); ok { + createConfigOptions.SetDescription(d.Get("description").(string)) + } if _, ok := d.GetOk("authorizations"); ok { authorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -800,22 +570,29 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetComplianceProfile(complianceProfileModel) } - if _, ok := d.GetOk("locator_id"); ok { - createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - } if _, ok := d.GetOk("input"); ok { - inputModel, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) } - createConfigOptions.SetInput(inputModel) + createConfigOptions.SetInput(input) } if _, ok := d.GetOk("setting"); ok { - settingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) } - createConfigOptions.SetSetting(settingModel) + createConfigOptions.SetSetting(setting) } projectConfigCanonical, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) @@ -858,9 +635,12 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("project_id", projectConfigCanonical.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if !core.IsNil(projectConfigCanonical.Name) { - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if !core.IsNil(projectConfigCanonical.Labels) { + if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { + return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) } } if !core.IsNil(projectConfigCanonical.Description) { @@ -868,11 +648,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Labels) { - if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { - return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) - } - } if !core.IsNil(projectConfigCanonical.Authorizations) { authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { @@ -891,26 +666,32 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if !core.IsNil(projectConfigCanonical.LocatorID) { - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) - } + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) } if !core.IsNil(projectConfigCanonical.Input) { - inputMap, err := resourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) - if err != nil { - return diag.FromErr(err) + input := []map[string]interface{}{} + for _, inputItem := range projectConfigCanonical.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if err != nil { + return diag.FromErr(err) + } + input = append(input, inputItemMap) } - if err = d.Set("input", []map[string]interface{}{inputMap}); err != nil { + if err = d.Set("input", input); err != nil { return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } if !core.IsNil(projectConfigCanonical.Setting) { - settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) - if err != nil { - return diag.FromErr(err) + setting := []map[string]interface{}{} + for _, settingItem := range projectConfigCanonical.Setting { + settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, settingItemMap) } - if err = d.Set("setting", []map[string]interface{}{settingMap}); err != nil { + if err = d.Set("setting", setting); err != nil { return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } @@ -938,6 +719,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } } + if !core.IsNil(projectConfigCanonical.PipelineState) { + if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { + return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) + } + } if !core.IsNil(projectConfigCanonical.UpdateAvailable) { if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) @@ -967,49 +753,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfigCanonical.CraLogs) { - craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.CostEstimate) { - costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.CheckJob) { - checkJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("check_job", []map[string]interface{}{checkJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting check_job: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.InstallJob) { - installJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("install_job", []map[string]interface{}{installJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting install_job: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.UninstallJob) { - uninstallJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("uninstall_job", []map[string]interface{}{uninstallJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting uninstall_job: %s", err)) + if !core.IsNil(projectConfigCanonical.Type) { + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } } if !core.IsNil(projectConfigCanonical.Output) { @@ -1025,13 +771,17 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Type) { - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + if !core.IsNil(projectConfigCanonical.ActiveDraft) { + activeDraftMap, err := resourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("active_draft", []map[string]interface{}{activeDraftMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting active_draft: %s", err)) } } if !core.IsNil(projectConfigCanonical.Definition) { - definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) + definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -1039,6 +789,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } } + if !core.IsNil(projectConfigCanonical.Href) { + if err = d.Set("href", projectConfigCanonical.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + } if !core.IsNil(projectConfigCanonical.ID) { if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) @@ -1070,12 +825,38 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD 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") { - updateConfigOptions.SetName(d.Get("name").(string)) + if d.HasChange("locator_id") { + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) hasChange = true } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) + if d.HasChange("input") { + var input []projectv1.ProjectConfigInputVariable + for _, v := range d.Get("input").([]interface{}) { + value := v.(map[string]interface{}) + inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) + if err != nil { + return diag.FromErr(err) + } + input = append(input, *inputItem) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + var setting []projectv1.ProjectConfigSettingCollection + for _, v := range d.Get("setting").([]interface{}) { + value := v.(map[string]interface{}) + settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, *settingItem) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } + if d.HasChange("name") { + updateConfigOptions.SetName(d.Get("name").(string)) hasChange = true } if d.HasChange("labels") { @@ -1087,6 +868,10 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetLabels(labels) hasChange = true } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } if d.HasChange("authorizations") { authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -1103,26 +888,6 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetComplianceProfile(complianceProfile) hasChange = true } - if d.HasChange("locator_id") { - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true - } - if d.HasChange("input") { - input, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - setting, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetSetting(setting) - hasChange = true - } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) @@ -1211,13 +976,19 @@ func resourceIbmProjectConfigMapToProjectConfigComplianceProfile(modelMap map[st return model, nil } -func resourceIbmProjectConfigMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { - model := &projectv1.InputVariable{} +func resourceIbmProjectConfigMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { + model := &projectv1.ProjectConfigInputVariable{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["value"] != nil { + model.Value = modelMap["value"].(string) + } return model, nil } -func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { - model := &projectv1.ProjectConfigSetting{} +func resourceIbmProjectConfigMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { + model := &projectv1.ProjectConfigSettingCollection{} + model.Name = core.StringPtr(modelMap["name"].(string)) + model.Value = core.StringPtr(modelMap["value"].(string)) return model, nil } @@ -1270,13 +1041,19 @@ func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv return modelMap, nil } -func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Value != nil { + modelMap["value"] = model.Value + } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + modelMap["value"] = model.Value return modelMap, nil } @@ -1291,183 +1068,80 @@ func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *proje return modelMap, nil } -func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { +func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description } - if model.UserID != nil { - modelMap["user_id"] = model.UserID + if model.Value != nil { + modelMap["value"] = model.Value } return modelMap, nil } -func resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["state"] = model.State + if model.PipelineState != nil { + modelMap["pipeline_state"] = model.PipelineState } if model.Href != nil { modelMap["href"] = model.Href } - if model.Summary != nil { - summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } return modelMap, nil } -func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary + modelMap["name"] = model.Name + if model.Labels != nil { + modelMap["labels"] = model.Labels } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary + if model.Description != nil { + modelMap["description"] = model.Description } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err } - modelMap["message_summary"] = messageSummary + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err } - modelMap["plan_messages"] = planMessages + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + input := []map[string]interface{}{} + for _, inputItem := range model.Input { + inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) if err != nil { return modelMap, err } - applyMessages[k] = string(bytes) + input = append(input, inputItemMap) } - modelMap["apply_messages"] = applyMessages + modelMap["input"] = input } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) + if model.Setting != nil { + setting := []map[string]interface{}{} + for _, settingItem := range model.Setting { + settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) if err != nil { return modelMap, err } - destroyMessages[k] = string(bytes) + setting = append(setting, settingItemMap) } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + modelMap["setting"] = setting } - if model.Value != nil { - modelMap["value"] = model.Value + if model.Type != nil { + modelMap["type"] = model.Type } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) if model.Output != nil { output := []map[string]interface{}{} for _, outputItem := range model.Output { @@ -1479,48 +1153,5 @@ func resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model } modelMap["output"] = output } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) - if err != nil { - return modelMap, err - } - modelMap["input"] = []map[string]interface{}{inputMap} - } - if model.Setting != nil { - settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} - } return modelMap, nil } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 7e5b78c9d7..28eb4e68ae 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -33,59 +33,151 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `approved_version` - (List) The project configuration version. - Nested schema for **approved_version**: + * `active_draft` - (List) The project configuration version. + Nested schema for **active_draft**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. * `version` - (Integer) The version number of the configuration. - * `check_job` - (List) The action job performed on the project configuration. - Nested schema for **check_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `definition` - (List) The project configuration definition summary. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The project configuration definition. Nested schema for **definition**: + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `description` - (String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `install_job` - (List) The action job performed on the project configuration. - Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `installed_version` - (List) The project configuration version. - Nested schema for **installed_version**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Integer) The version number of the configuration. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `labels` - (List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `locator_id` - (String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `project_id` - (String) The unique ID. + * `output` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `uninstall_job` - (List) The action job performed on the project configuration. - Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `type` - (String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 8f3da95577..ab0c368f20 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -33,6 +33,16 @@ 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 project_config. +* `active_draft` - (List) The project configuration version. +Nested schema for **active_draft**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Integer) The version number of the configuration. + * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -41,65 +51,27 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. + * `target_iam_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `check_job` - (List) The action job performed on the project configuration. -Nested schema for **check_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. + * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. + * `instance_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The Schematics template property. +* `definition` - (List) The project configuration definition. Nested schema for **definition**: * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -109,26 +81,30 @@ Nested schema for **definition**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. + * `target_iam_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. + * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. + * `instance_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The input variables for the configuration definition. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -143,32 +119,28 @@ Nested schema for **definition**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (List) The input variables for the configuration definition. -Nested schema for **input**: +* `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. -* `install_job` - (List) The action job performed on the project configuration. -Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. @@ -180,7 +152,7 @@ Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. + * `user_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -203,11 +175,19 @@ Nested schema for **output**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. +* `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. @@ -215,22 +195,6 @@ Nested schema for **setting**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `uninstall_job` - (List) The action job performed on the project configuration. -Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index ae09fcff3a..f16f557f82 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -21,34 +21,91 @@ resource "ibm_project" "project_instance" { is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - approved_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" + pipeline_state = "pipeline_failed" + update_available = true + created_at = "2021-01-31T09:44:12Z" + updated_at = "2021-01-31T09:44:12Z" + last_approved { + is_forced = true + comment = "comment" + timestamp = "2021-01-31T09:44:12Z" + user_id = "user_id" } - installed_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" + last_save = "2021-01-31T09:44:12Z" + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" } - definition { + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { name = "name" - description = "description" + value = "anything as a string" } - check_job { - id = "id" - href = "href" + setting { + name = "name" + value = "value" } - install_job { - id = "id" - href = "href" + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" } - uninstall_job { - id = "id" + active_draft { + version = 1 + state = "discarded" + pipeline_state = "pipeline_failed" href = "href" } + definition { + name = "name" + labels = [ "labels" ] + description = "description" + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input { + name = "name" + value = "anything as a string" + } + setting { + name = "name" + value = "value" + } + type = "terraform_template" + output { + name = "name" + description = "description" + value = "anything as a string" + } + } href = "href" } description = "A microservice to deploy on top of ACME infrastructure." @@ -65,59 +122,151 @@ You can specify the following arguments for this resource. * `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `approved_version` - (Optional, List) The project configuration version. - Nested schema for **approved_version**: + * `active_draft` - (Optional, List) The project configuration version. + Nested schema for **active_draft**: * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (Required, String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (Required, String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. * `version` - (Required, Integer) The version number of the configuration. - * `check_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **check_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. + * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (Optional, List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `definition` - (Optional, List) The project configuration definition summary. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (Optional, List) The project configuration definition. Nested schema for **definition**: + * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + Nested schema for **authorizations**: + * `api_key` - (Optional, String) The IBM Cloud API Key. + * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. + Nested schema for **trusted_profile**: + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `target_iam_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `compliance_profile` - (Optional, List) The profile required for compliance. + Nested schema for **compliance_profile**: + * `attachment_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_id` - (Optional, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `instance_location` - (Optional, String) The location of the compliance instance. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * `profile_name` - (Optional, String) The name of the compliance profile. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `output` - (Optional, List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (Optional, String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `type` - (Optional, String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `description` - (Optional, String) The description of the project configuration. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `install_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **install_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `installed_version` - (Optional, List) The project configuration version. - Nested schema for **installed_version**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (Required, String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Required, Integer) The version number of the configuration. + * `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `labels` - (Optional, List) A collection of configuration labels. + * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. + * `last_approved` - (Optional, List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (Optional, String) The comment left by the user who approved the configuration. + * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (Required, String) The unique ID of a project. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. + * `name` - (Required, String) The name of the configuration. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `project_id` - (Optional, String) The unique ID. + * `output` - (Optional, List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **output**: + * `description` - (Optional, String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. + * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `project_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + Nested schema for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (Optional, String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `uninstall_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **uninstall_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `type` - (Optional, String) The type of a project configuration manual property. + * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. + * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -125,7 +274,7 @@ Nested schema for **configs**: * Constraints: The default value is `true`. * `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Optional, String) The name of the project. +* `name` - (Required, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. @@ -165,7 +314,7 @@ Nested schema for **definition**: ## Import -You can import the `ibm_project` resource by using `id`. The unique ID. +You can import the `ibm_project` resource by using `id`. The unique ID of a project. # Syntax ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 28da460453..ed003b67e1 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -29,12 +29,17 @@ resource "ibm_project_config" "project_config_instance" { attachment_id = "attachment_id" profile_name = "profile_name" } - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." - input = {"account_id":"$configs[].name["account-stage"].input.account_id","resource_group":"stage","access_tags":["env:stage"],"logdna_name":"Name of the LogDNA stage service instance","sysdig_name":"Name of the SysDig stage service instance"} - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" - name = "env-stage" + input { + name = "name" + value = "anything as a string" + } + locator_id = "locator_id" + name = "name" project_id = ibm_project.project_instance.id - setting = {"IBMCLOUD_TOOLCHAIN_ENDPOINT":"https://api.us-south.devops.dev.cloud.ibm.com"} + setting { + name = "name" + value = "value" + } } ``` @@ -50,79 +55,62 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID. + * `id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID. + * `target_iam_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID. + * `attachment_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID. + * `id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID. + * `instance_id` - (Optional, String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The input variables for the configuration definition. +* `input` - (Optional, List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: + * `name` - (Required, String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. -* `locator_id` - (Optional, String) A dotted value of catalogID.versionID. +* `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `name` - (Optional, String) The name of the configuration. +* `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. +* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: + * `name` - (Required, String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (Required, String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. ## Attribute Reference After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the project_config. -* `check_job` - (List) The action job performed on the project configuration. -Nested schema for **check_job**: +* `active_draft` - (List) The project configuration version. +Nested schema for **active_draft**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. + * `state` - (String) The state of the configuration draft. + * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `version` - (Integer) The version number of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The Schematics template property. +* `definition` - (List) The project configuration definition. Nested schema for **definition**: * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -132,26 +120,30 @@ Nested schema for **definition**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. + * `target_iam_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. + * `attachment_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. + * `id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. + * `instance_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The input variables for the configuration definition. + * `input` - (List) The inputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **input**: + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -166,32 +158,24 @@ Nested schema for **definition**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **setting**: + * `name` - (String) The name of the configuration setting. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) The value of the configuration setting. + * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `install_job` - (List) The action job performed on the project configuration. -Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. + * `user_id` - (String) The unique ID of a project. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. @@ -204,27 +188,14 @@ Nested schema for **output**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. + * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `uninstall_job` - (List) The action job performed on the project configuration. -Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From bf2fc988191336ff45094b11accc914b4df23d27 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 29 Aug 2023 17:07:02 +0200 Subject: [PATCH 087/125] regenerate the terraform code based on latest YAML --- examples/ibm-project/README.md | 14 +- examples/ibm-project/main.tf | 103 +- examples/ibm-project/variables.tf | 16 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 645 ++-------- .../project/data_source_ibm_project_config.go | 1061 ++++++++++++----- ibm/service/project/resource_ibm_project.go | 790 +++--------- .../project/resource_ibm_project_config.go | 996 +++++++++++----- website/docs/d/project.html.markdown | 160 +-- website/docs/d/project_config.html.markdown | 140 ++- website/docs/r/project.html.markdown | 261 +--- website/docs/r/project_config.html.markdown | 147 ++- 13 files changed, 2013 insertions(+), 2326 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 9c23f3287d..05be1c0282 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -40,8 +40,8 @@ project_config resource: resource "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - labels = var.project_config_labels description = var.project_config_description + labels = var.project_config_labels authorizations = var.project_config_authorizations compliance_profile = var.project_config_compliance_profile locator_id = var.project_config_locator_id @@ -95,19 +95,19 @@ data "project_config" "project_config_instance" { | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| name | The name of the project. | `string` | true | +| name | The name of the project. | `string` | false | | description | A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. | `string` | false | | destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | | configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | `list()` | false | | project_id | The unique project ID. | `string` | true | -| name | The name of the configuration. | `string` | true | -| labels | A collection of configuration labels. | `list(string)` | false | +| name | The name of the configuration. | `string` | false | | description | The description of the project configuration. | `string` | false | +| labels | A collection of configuration labels. | `list(string)` | false | | authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | | compliance_profile | The profile required for compliance. | `` | false | -| locator_id | A dotted value of catalogID.versionID. | `string` | true | -| input | The inputs of a Schematics template property. | `list()` | false | -| setting | Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. | `list()` | false | +| locator_id | A dotted value of catalogID.versionID. | `string` | false | +| input | The input variables for the configuration definition. | `` | false | +| setting | Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. | `` | false | | id | The unique project ID. | `string` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index cea26480b9..5747f37e54 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -16,90 +16,33 @@ resource "ibm_project" "project_instance" { is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + approved_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - active_draft { + installed_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" href = "href" } definition { name = "name" - labels = [ "labels" ] description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } + } + check_job { + id = "id" + href = "href" + } + install_job { + id = "id" + href = "href" + } + uninstall_job { + id = "id" + href = "href" } href = "href" } @@ -109,8 +52,8 @@ resource "ibm_project" "project_instance" { resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id name = var.project_config_name - labels = var.project_config_labels description = var.project_config_description + labels = var.project_config_labels authorizations { trusted_profile { id = "id" @@ -128,12 +71,8 @@ resource "ibm_project_config" "project_config_instance" { } locator_id = var.project_config_locator_id input { - name = "name" - value = "anything as a string" } setting { - name = "name" - value = "value" } } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 86b9bf2534..11b08d1c56 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -39,22 +39,22 @@ variable "project_config_project_id" { variable "project_config_name" { description = "The name of the configuration." type = string - default = "name" -} -variable "project_config_labels" { - description = "A collection of configuration labels." - type = list(string) - default = [ "labels" ] + default = "env-stage" } variable "project_config_description" { description = "The description of the project configuration." type = string - default = "description" + default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." +} +variable "project_config_labels" { + description = "A collection of configuration labels." + type = list(string) + default = ["env:stage","governance:test","build:0"] } variable "project_config_locator_id" { description = "A dotted value of catalogID.versionID." type = string - default = "locator_id" + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" } // Data source arguments for project diff --git a/go.mod b/go.mod index b2a48f60a5..2bdab73c54 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/IBM/keyprotect-go-client v0.10.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.42.0 - github.com/IBM/project-go-sdk v0.0.26-54 + github.com/IBM/project-go-sdk v0.0.26-55 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 github.com/IBM/scc-go-sdk/v4 v4.0.2 diff --git a/go.sum b/go.sum index 73ff9e7388..06c4390a8d 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.42.0 h1:2it30wdvjDRqN8Yc/vqUJpJPVIeTNXpkIOSjwG+P/xc= github.com/IBM/platform-services-go-sdk v0.42.0/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4= -github.com/IBM/project-go-sdk v0.0.26-54 h1:dsaocaBpUf0nVB6uJDZ23AEQYjdclFkO15Ehynk30oc= -github.com/IBM/project-go-sdk v0.0.26-54/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-55 h1:Zg/drqvjYVm91rSaT+jUyIubNGrsHHi7EyXaMwpugq0= +github.com/IBM/project-go-sdk v0.0.26-55/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 5dd91af5c6..fe984efecd 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -143,7 +143,7 @@ func DataSourceIbmProject() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "version": &schema.Schema{ Type: schema.TypeInt, @@ -168,242 +168,118 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ + "approved_version": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The last approved metadata of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - "comment": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The comment left by the user who approved the configuration.", + Description: "The state of the configuration.", }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The version number of the configuration.", }, - "user_id": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "A relative URL.", }, }, }, }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - "authorizations": &schema.Schema{ + "installed_version": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ + "needs_attention_state": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "profile_name": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the compliance profile.", + Description: "The state of the configuration.", }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Computed: true, - Description: "The variable name.", + Description: "The version number of the configuration.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "A relative URL.", }, }, }, }, - "setting": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "The project configuration definition summary.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration setting.", + Description: "The name of the configuration.", }, - "value": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The value of the configuration setting.", + Description: "The description of the project configuration.", }, }, }, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A short explanation of the output value.", + Description: "The unique ID.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "A relative URL.", }, }, }, }, - "active_draft": &schema.Schema{ + "install_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration draft.", - }, - "pipeline_state": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The unique ID.", }, "href": &schema.Schema{ Type: schema.TypeString, @@ -413,173 +289,21 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, - "definition": &schema.Schema{ + "uninstall_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, + Description: "The unique ID.", }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, + Description: "A relative URL.", }, }, }, @@ -624,7 +348,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m cumulativeNeedsAttentionView := []map[string]interface{}{} if projectCanonical.CumulativeNeedsAttentionView != nil { - for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { + for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -670,7 +394,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m definition := []map[string]interface{}{} if projectCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) + modelMap, err := dataSourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -682,8 +406,8 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m configs := []map[string]interface{}{} if projectCanonical.Configs != nil { - for _, modelItem := range projectCanonical.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigCanonicalToMap(&modelItem) + for _, modelItem := range projectCanonical.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -714,15 +438,21 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["description"] = model.Description - modelMap["destroy_on_delete"] = model.DestroyOnDelete + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.DestroyOnDelete != nil { + modelMap["destroy_on_delete"] = model.DestroyOnDelete + } return modelMap, nil } -func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -742,266 +472,83 @@ func dataSourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectCon if model.State != nil { modelMap["state"] = model.State } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if model.ApprovedVersion != nil { + approvedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) if err != nil { return modelMap, err } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.InstalledVersion != nil { + installedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if model.Definition != nil { + definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output + modelMap["definition"] = []map[string]interface{}{definitionMap} } - if model.ActiveDraft != nil { - activeDraftMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) + if model.CheckJob != nil { + checkJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) if err != nil { return modelMap, err } - modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} + modelMap["check_job"] = []map[string]interface{}{checkJobMap} } - if model.Definition != nil { - definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionToMap(model.Definition) + if model.InstallJob != nil { + installJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) if err != nil { return modelMap, err } - modelMap["definition"] = []map[string]interface{}{definitionMap} - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment + modelMap["install_job"] = []map[string]interface{}{installJobMap} } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if model.UninstallJob != nil { + uninstallJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) if err != nil { return modelMap, err } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} - } - if model.Method != nil { - modelMap["method"] = model.Method - } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func dataSourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID - } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation - } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID - } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func dataSourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value - return modelMap, nil -} - -func dataSourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Description != nil { modelMap["description"] = model.Description } - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.ID != nil { + modelMap["id"] = model.ID } if model.Href != nil { modelMap["href"] = model.Href } return modelMap, nil } - -func dataSourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - return modelMap, nil -} diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 3e912ccca2..9c08b97a05 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -31,6 +32,119 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the configuration.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "authorizations": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trusted_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The trusted profile for authorizations.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "target_iam_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + }, + }, + }, + "method": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The IBM Cloud API Key.", + }, + }, + }, + }, + "compliance_profile": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The profile required for compliance.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "instance_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "instance_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The location of the compliance instance.", + }, + "attachment_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the compliance profile.", + }, + }, + }, + }, + "locator_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A dotted value of catalogID.versionID.", + }, + "input": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The input variables for the configuration definition.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + }, + }, + }, + "setting": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + }, + }, + }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -59,11 +173,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, "update_available": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -103,7 +212,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "user_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -113,208 +222,428 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - "authorizations": &schema.Schema{ + "cra_logs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The Code Risk Analyzer logs of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, + "cra_version": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID of a project.", - }, - }, - }, + Description: "The version of the Code Risk Analyzer logs of the configuration.", }, - "method": &schema.Schema{ + "schema_version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The schema version of Code Risk Analyzer logs of the configuration.", }, - "api_key": &schema.Schema{ + "status": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The IBM Cloud API Key.", + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, }, }, }, - "compliance_profile": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The profile required for compliance.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "version": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The version of the cost estimate of the configuration.", }, - "instance_id": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The currency of the cost estimate of the configuration.", }, - "instance_location": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The location of the compliance instance.", + Description: "The total hourly cost estimate of the configuration.", }, - "attachment_id": &schema.Schema{ + "total_monthly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The total monthly cost estimate of the configuration.", }, - "profile_name": &schema.Schema{ + "past_total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the compliance profile.", + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", }, }, }, }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The variable name.", + Description: "The unique ID.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "A relative URL.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, }, }, }, }, - "setting": &schema.Schema{ + "install_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration setting.", + Description: "The unique ID.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The value of the configuration setting.", + Description: "A relative URL.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, }, }, }, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ + "uninstall_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The variable name.", + Description: "The unique ID.", }, - "description": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A short explanation of the output value.", + Description: "A relative URL.", }, - "value": &schema.Schema{ - Type: schema.TypeString, + "summary": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, }, }, }, }, - "active_draft": &schema.Schema{ + "output": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - "state": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration draft.", + Description: "The variable name.", }, - "pipeline_state": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "A short explanation of the output value.", }, - "href": &schema.Schema{ + "value": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The name of the configuration.", }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the project configuration.", + }, "labels": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -323,11 +652,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, }, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -343,12 +667,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -375,12 +699,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -390,7 +714,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -408,100 +732,107 @@ func DataSourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, }, }, }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, }, } } -func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - projectClient, err := meta.(conns.ClientSession).ProjectV1() - if err != nil { - return diag.FromErr(err) +func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + projectClient, err := meta.(conns.ClientSession).ProjectV1() + if err != nil { + return diag.FromErr(err) + } + + getConfigOptions := &projectv1.GetConfigOptions{} + + getConfigOptions.SetProjectID(d.Get("project_id").(string)) + getConfigOptions.SetID(d.Get("id").(string)) + + projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + if err != nil { + log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) + + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + + if err = d.Set("description", projectConfigCanonical.Description); err != nil { + return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + } + + + authorizations := []map[string]interface{}{} + if projectConfigCanonical.Authorizations != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) + if err != nil { + return diag.FromErr(err) + } + authorizations = append(authorizations, modelMap) + } + if err = d.Set("authorizations", authorizations); err != nil { + return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) } - getConfigOptions := &projectv1.GetConfigOptions{} + complianceProfile := []map[string]interface{}{} + if projectConfigCanonical.ComplianceProfile != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) + if err != nil { + return diag.FromErr(err) + } + complianceProfile = append(complianceProfile, modelMap) + } + if err = d.Set("compliance_profile", complianceProfile); err != nil { + return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) + } - getConfigOptions.SetProjectID(d.Get("project_id").(string)) - getConfigOptions.SetID(d.Get("id").(string)) + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } - projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) - if err != nil { - log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) + input := []map[string]interface{}{} + if projectConfigCanonical.Input != nil { + modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) + if err != nil { + return diag.FromErr(err) + } + input = append(input, modelMap) + } + if err = d.Set("input", input); err != nil { + return diag.FromErr(fmt.Errorf("Error setting input %s", err)) } - d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) + setting := []map[string]interface{}{} + if projectConfigCanonical.Setting != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) + if err != nil { + return diag.FromErr(err) + } + setting = append(setting, modelMap) + } + if err = d.Set("setting", setting); err != nil { + return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) + } if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) @@ -523,10 +854,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) - } - if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } @@ -555,77 +882,69 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + craLogs := []map[string]interface{}{} + if projectConfigCanonical.CraLogs != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) + if err != nil { + return diag.FromErr(err) + } + craLogs = append(craLogs, modelMap) } - - if err = d.Set("description", projectConfigCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + if err = d.Set("cra_logs", craLogs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) } - authorizations := []map[string]interface{}{} - if projectConfigCanonical.Authorizations != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) + costEstimate := []map[string]interface{}{} + if projectConfigCanonical.CostEstimate != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) if err != nil { return diag.FromErr(err) } - authorizations = append(authorizations, modelMap) + costEstimate = append(costEstimate, modelMap) } - if err = d.Set("authorizations", authorizations); err != nil { - return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) + if err = d.Set("cost_estimate", costEstimate); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) } - complianceProfile := []map[string]interface{}{} - if projectConfigCanonical.ComplianceProfile != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) + checkJob := []map[string]interface{}{} + if projectConfigCanonical.CheckJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) if err != nil { return diag.FromErr(err) } - complianceProfile = append(complianceProfile, modelMap) - } - if err = d.Set("compliance_profile", complianceProfile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) + checkJob = append(checkJob, modelMap) } - - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + if err = d.Set("check_job", checkJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting check_job %s", err)) } - input := []map[string]interface{}{} - if projectConfigCanonical.Input != nil { - for _, modelItem := range projectConfigCanonical.Input { - modelMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, modelMap) + installJob := []map[string]interface{}{} + if projectConfigCanonical.InstallJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) + if err != nil { + return diag.FromErr(err) } + installJob = append(installJob, modelMap) } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input %s", err)) + if err = d.Set("install_job", installJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting install_job %s", err)) } - setting := []map[string]interface{}{} - if projectConfigCanonical.Setting != nil { - for _, modelItem := range projectConfigCanonical.Setting { - modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, modelMap) + uninstallJob := []map[string]interface{}{} + if projectConfigCanonical.UninstallJob != nil { + modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) + if err != nil { + return diag.FromErr(err) } + uninstallJob = append(uninstallJob, modelMap) } - if err = d.Set("setting", setting); err != nil { - return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) - } - - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + if err = d.Set("uninstall_job", uninstallJob); err != nil { + return diag.FromErr(fmt.Errorf("Error setting uninstall_job %s", err)) } output := []map[string]interface{}{} if projectConfigCanonical.Output != nil { - for _, modelItem := range projectConfigCanonical.Output { + for _, modelItem := range projectConfigCanonical.Output { modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -637,21 +956,13 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting output %s", err)) } - activeDraft := []map[string]interface{}{} - if projectConfigCanonical.ActiveDraft != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) - if err != nil { - return diag.FromErr(err) - } - activeDraft = append(activeDraft, modelMap) - } - if err = d.Set("active_draft", activeDraft); err != nil { - return diag.FromErr(fmt.Errorf("Error setting active_draft %s", err)) + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } definition := []map[string]interface{}{} if projectConfigCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) + modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -661,24 +972,9 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) } - if err = d.Set("href", projectConfigCanonical.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) - } - return nil } -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.TrustedProfile != nil { @@ -728,96 +1024,204 @@ func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projec return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } return modelMap, nil } -func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Value != nil { - modelMap["value"] = model.Value + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.ID != nil { + modelMap["id"] = model.ID } if model.Href != nil { modelMap["href"] = model.Href } + if model.Summary != nil { + summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) + if err != nil { + return modelMap, err + } + modelMap["summary"] = []map[string]interface{}{summaryMap} + } return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary } - if model.Description != nil { - modelMap["description"] = model.Description + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["destroy_summary"] = destroySummary } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["message_summary"] = messageSummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := dataSourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + planMessages[k] = string(bytes) } - modelMap["input"] = input + modelMap["plan_messages"] = planMessages } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := dataSourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + applyMessages[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["apply_messages"] = applyMessages } - if model.Type != nil { - modelMap["type"] = model.Type + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) if model.Output != nil { output := []map[string]interface{}{} for _, outputItem := range model.Output { @@ -829,5 +1233,48 @@ func dataSourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.Pro } modelMap["output"] = output } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 31e54a41a5..f3cf41eea5 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -20,34 +20,34 @@ import ( func ResourceIbmProject() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectCreate, - ReadContext: resourceIbmProjectRead, - UpdateContext: resourceIbmProjectUpdate, - DeleteContext: resourceIbmProjectDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectCreate, + ReadContext: resourceIbmProjectRead, + UpdateContext: resourceIbmProjectUpdate, + DeleteContext: resourceIbmProjectDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, @@ -71,7 +71,7 @@ func ResourceIbmProject() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "version": &schema.Schema{ Type: schema.TypeInt, @@ -94,245 +94,119 @@ func ResourceIbmProject() *schema.Resource { Optional: true, Description: "The state of the configuration.", }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ + "approved_version": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The last approved metadata of the configuration.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The comment left by the user who approved the configuration.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "timestamp": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + Description: "The state of the configuration.", }, - "user_id": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Required: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The description of the project configuration.", - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The version number of the configuration.", }, - "api_key": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The IBM Cloud API Key.", + Description: "A relative URL.", }, }, }, }, - "compliance_profile": &schema.Schema{ + "installed_version": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The profile required for compliance.", + Description: "The project configuration version.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "The unique ID of a project.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, }, - "profile_name": &schema.Schema{ + "state": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The name of the compliance profile.", + Required: true, + Description: "The state of the configuration.", }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, + "version": &schema.Schema{ + Type: schema.TypeInt, Required: true, - Description: "The variable name.", + Description: "The version number of the configuration.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "A relative URL.", }, }, }, }, - "setting": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "The project configuration definition summary.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The name of the configuration setting.", + Description: "The name of the configuration.", }, - "value": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", + Optional: true, + Description: "The description of the project configuration.", }, }, }, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The outputs of a Schematics template property.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A short explanation of the output value.", + Description: "The unique ID.", }, - "value": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "A relative URL.", }, }, }, }, - "active_draft": &schema.Schema{ + "install_job": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration version.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The state of the configuration draft.", - }, - "pipeline_state": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The unique ID.", }, "href": &schema.Schema{ Type: schema.TypeString, @@ -342,175 +216,22 @@ func ResourceIbmProject() *schema.Resource { }, }, }, - "definition": &schema.Schema{ + "uninstall_job": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The description of the project configuration.", - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID of a project.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, Optional: true, - Description: "The inputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, + Description: "The unique ID.", }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - "type": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, + Description: "A relative URL.", }, }, }, @@ -585,17 +306,18 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, Description: "The name of the project.", }, "description": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, - Required: true, + Optional: true, + Default: true, Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, }, @@ -630,7 +352,7 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]+$`, MinValueLength: 1, MaxValueLength: 64, @@ -660,7 +382,9 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) createProjectOptions.SetLocation(d.Get("location").(string)) - createProjectOptions.SetName(d.Get("name").(string)) + if _, ok := d.GetOk("name"); ok { + createProjectOptions.SetName(d.Get("name").(string)) + } if _, ok := d.GetOk("description"); ok { createProjectOptions.SetDescription(d.Get("description").(string)) } @@ -668,10 +392,10 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) } if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfig + var configs []projectv1.ProjectConfigTerraform for _, v := range d.Get("configs").([]interface{}) { value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfig(value) + configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) if err != nil { return diag.FromErr(err) } @@ -717,8 +441,10 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if err = d.Set("location", projectCanonical.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if err = d.Set("name", projectCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + if !core.IsNil(projectCanonical.Name) { + if err = d.Set("name", projectCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } } if !core.IsNil(projectCanonical.Description) { if err = d.Set("description", projectCanonical.Description); err != nil { @@ -733,7 +459,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if !core.IsNil(projectCanonical.Configs) { configs := []map[string]interface{}{} for _, configsItem := range projectCanonical.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigCanonicalToMap(&configsItem) + configsItemMap, err := resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&configsItem) if err != nil { return diag.FromErr(err) } @@ -743,11 +469,15 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } - if err = d.Set("crn", projectCanonical.Crn); err != nil { - return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + if !core.IsNil(projectCanonical.Crn) { + if err = d.Set("crn", projectCanonical.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) + } } - if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + if !core.IsNil(projectCanonical.CreatedAt) { + if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) + } } if !core.IsNil(projectCanonical.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} @@ -767,8 +497,10 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if err = d.Set("state", projectCanonical.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + if !core.IsNil(projectCanonical.State) { + if err = d.Set("state", projectCanonical.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } } if !core.IsNil(projectCanonical.EventNotificationsCrn) { if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { @@ -776,7 +508,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met } } if !core.IsNil(projectCanonical.Definition) { - definitionMap, err := resourceIbmProjectProjectDefinitionResponseToMap(projectCanonical.Definition) + definitionMap, err := resourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -812,6 +544,19 @@ func resourceIbmProjectUpdate(context context.Context, d *schema.ResourceData, m updateProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) hasChange = true } + if d.HasChange("configs") { + var configs []projectv1.ProjectConfigTerraform + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + updateProjectOptions.SetConfigs(configs) + hasChange = true + } if hasChange { _, response, err := projectClient.UpdateProjectWithContext(context, updateProjectOptions) @@ -845,9 +590,14 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return nil } -func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*projectv1.ProjectConfig, error) { - model := &projectv1.ProjectConfig{} - model.Name = core.StringPtr(modelMap["name"].(string)) +func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface{}) (*projectv1.ProjectConfigTerraform, error) { + model := &projectv1.ProjectConfigTerraform{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } if modelMap["labels"] != nil { labels := []string{} for _, labelsItem := range modelMap["labels"].([]interface{}) { @@ -855,9 +605,6 @@ func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*pro } model.Labels = labels } - if modelMap["description"] != nil && modelMap["description"].(string) != "" { - model.Description = core.StringPtr(modelMap["description"].(string)) - } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -872,28 +619,22 @@ func resourceIbmProjectMapToProjectConfig(modelMap map[string]interface{}) (*pro } model.ComplianceProfile = ComplianceProfileModel } - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) - if modelMap["input"] != nil { - input := []projectv1.ProjectConfigInputVariable{} - for _, inputItem := range modelMap["input"].([]interface{}) { - inputItemModel, err := resourceIbmProjectMapToProjectConfigInputVariable(inputItem.(map[string]interface{})) - if err != nil { - return model, err - } - input = append(input, *inputItemModel) + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { + InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err } - model.Input = input + model.Input = InputModel } - if modelMap["setting"] != nil { - setting := []projectv1.ProjectConfigSettingCollection{} - for _, settingItem := range modelMap["setting"].([]interface{}) { - settingItemModel, err := resourceIbmProjectMapToProjectConfigSettingCollection(settingItem.(map[string]interface{})) - if err != nil { - return model, err - } - setting = append(setting, *settingItemModel) + if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { + SettingModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err } - model.Setting = setting + model.Setting = SettingModel } return model, nil } @@ -947,23 +688,17 @@ func resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap map[string]i return model, nil } -func resourceIbmProjectMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { - model := &projectv1.ProjectConfigInputVariable{} - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["value"] != nil { - model.Value = modelMap["value"].(string) - } +func resourceIbmProjectMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { + model := &projectv1.InputVariable{} return model, nil } -func resourceIbmProjectMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { - model := &projectv1.ProjectConfigSettingCollection{} - model.Name = core.StringPtr(modelMap["name"].(string)) - model.Value = core.StringPtr(modelMap["value"].(string)) +func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { + model := &projectv1.ProjectConfigSetting{} return model, nil } -func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfigCanonical) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -983,200 +718,80 @@ func resourceIbmProjectProjectConfigCanonicalToMap(model *projectv1.ProjectConfi if model.State != nil { modelMap["state"] = model.State } - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState - } - if model.UpdateAvailable != nil { - modelMap["update_available"] = model.UpdateAvailable - } - if model.CreatedAt != nil { - modelMap["created_at"] = model.CreatedAt.String() - } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() - } - if model.LastApproved != nil { - lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if model.ApprovedVersion != nil { + approvedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) if err != nil { return modelMap, err } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) + if model.InstalledVersion != nil { + installedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if model.Definition != nil { + definitionMap, err := resourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) if err != nil { return modelMap, err } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output + modelMap["definition"] = []map[string]interface{}{definitionMap} } - if model.ActiveDraft != nil { - activeDraftMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ActiveDraft) + if model.CheckJob != nil { + checkJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) if err != nil { return modelMap, err } - modelMap["active_draft"] = []map[string]interface{}{activeDraftMap} + modelMap["check_job"] = []map[string]interface{}{checkJobMap} } - if model.Definition != nil { - definitionMap, err := resourceIbmProjectProjectConfigDefinitionToMap(model.Definition) + if model.InstallJob != nil { + installJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) if err != nil { return modelMap, err } - modelMap["definition"] = []map[string]interface{}{definitionMap} - } - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["install_job"] = []map[string]interface{}{installJobMap} } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func resourceIbmProjectProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) + if model.UninstallJob != nil { + uninstallJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) if err != nil { return modelMap, err } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} } - if model.Method != nil { - modelMap["method"] = model.Method - } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func resourceIbmProjectProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID - } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation - } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID - } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href } return modelMap, nil } -func resourceIbmProjectProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value - return modelMap, nil -} - -func resourceIbmProjectOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Description != nil { modelMap["description"] = model.Description } - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func resourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.ID != nil { + modelMap["id"] = model.ID } if model.Href != nil { modelMap["href"] = model.Href @@ -1184,69 +799,6 @@ func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.Project return modelMap, nil } -func resourceIbmProjectProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return modelMap, err - } - input = append(input, inputItemMap) - } - modelMap["input"] = input - } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return modelMap, err - } - setting = append(setting, settingItemMap) - } - modelMap["setting"] = setting - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - return modelMap, nil -} - func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.CumulativeNeedsAttention) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Event != nil { @@ -1264,10 +816,16 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative return modelMap, nil } -func resourceIbmProjectProjectDefinitionResponseToMap(model *projectv1.ProjectDefinitionResponse) (map[string]interface{}, error) { +func resourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["description"] = model.Description - modelMap["destroy_on_delete"] = model.DestroyOnDelete + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.DestroyOnDelete != nil { + modelMap["destroy_on_delete"] = model.DestroyOnDelete + } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f85c08695f..56f377c60f 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -20,25 +20,31 @@ import ( func ResourceIbmProjectConfig() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectConfigCreate, - ReadContext: resourceIbmProjectConfigRead, - UpdateContext: resourceIbmProjectConfigUpdate, - DeleteContext: resourceIbmProjectConfigDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectConfigCreate, + ReadContext: resourceIbmProjectConfigRead, + UpdateContext: resourceIbmProjectConfigUpdate, + DeleteContext: resourceIbmProjectConfigDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), - Description: "The unique project ID.", + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The name of the configuration.", + Description: "The name of the configuration.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -46,12 +52,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "A collection of configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", - }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -69,12 +69,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -102,12 +102,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -117,7 +117,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -128,46 +128,28 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, }, }, }, @@ -192,11 +174,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "pipeline_state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", - }, "update_available": &schema.Schema{ Type: schema.TypeBool, Computed: true, @@ -236,7 +213,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "user_id": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -246,86 +223,393 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "type": &schema.Schema{ - Type: schema.TypeString, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The type of a project configuration manual property.", + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, }, - "output": &schema.Schema{ + "cost_estimate": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The outputs of a Schematics template property.", + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "version": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The variable name.", + Optional: true, + Description: "The version of the cost estimate of the configuration.", }, - "description": &schema.Schema{ + "currency": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "A short explanation of the output value.", + Description: "The currency of the cost estimate of the configuration.", }, - "value": &schema.Schema{ + "total_hourly_cost": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", }, }, }, }, - "active_draft": &schema.Schema{ + "check_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The action job performed on the project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", }, - "state": &schema.Schema{ + "href": &schema.Schema{ Type: schema.TypeString, - Required: true, - Description: "The state of the configuration draft.", + Optional: true, + Description: "A relative URL.", }, - "pipeline_state": &schema.Schema{ + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + "install_job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The pipeline state of the configuration. It only exists after the first configuration validation.", + Description: "The unique ID.", }, "href": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "A relative URL.", }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, - "definition": &schema.Schema{ + "uninstall_job": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration definition.", + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "The name of the configuration.", + Description: "The variable name.", }, - "labels": &schema.Schema{ + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "output": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The type of a project configuration manual property.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the configuration.", }, "description": &schema.Schema{ Type: schema.TypeString, Optional: true, Description: "The description of the project configuration.", }, + "labels": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Description: "A collection of configuration labels.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -343,12 +627,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "target_iam_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, }, }, @@ -376,12 +660,12 @@ func ResourceIbmProjectConfig() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "instance_location": &schema.Schema{ Type: schema.TypeString, @@ -391,7 +675,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "attachment_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID of a project.", + Description: "The unique ID.", }, "profile_name": &schema.Schema{ Type: schema.TypeString, @@ -403,84 +687,32 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The inputs of a Schematics template property.", + Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, }, }, }, "setting": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration setting.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The value of the configuration setting.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The type of a project configuration manual property.", - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, + Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ }, }, }, }, }, }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, "project_config_canonical_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -505,7 +737,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$`, MinValueLength: 1, MaxValueLength: 64, @@ -523,7 +755,7 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Identifier: "locator_id", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Required: true, + Optional: true, Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, MinValueLength: 1, MaxValueLength: 512, @@ -543,8 +775,12 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions := &projectv1.CreateConfigOptions{} createConfigOptions.SetProjectID(d.Get("project_id").(string)) - createConfigOptions.SetName(d.Get("name").(string)) - createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + if _, ok := d.GetOk("name"); ok { + createConfigOptions.SetName(d.Get("name").(string)) + } + if _, ok := d.GetOk("description"); ok { + createConfigOptions.SetDescription(d.Get("description").(string)) + } if _, ok := d.GetOk("labels"); ok { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -553,9 +789,6 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetLabels(labels) } - if _, ok := d.GetOk("description"); ok { - createConfigOptions.SetDescription(d.Get("description").(string)) - } if _, ok := d.GetOk("authorizations"); ok { authorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -570,29 +803,22 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD } createConfigOptions.SetComplianceProfile(complianceProfileModel) } + if _, ok := d.GetOk("locator_id"); ok { + createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + } if _, ok := d.GetOk("input"); ok { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) + inputModel, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - createConfigOptions.SetInput(input) + createConfigOptions.SetInput(inputModel) } if _, ok := d.GetOk("setting"); ok { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) + settingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - createConfigOptions.SetSetting(setting) + createConfigOptions.SetSetting(settingModel) } projectConfigCanonical, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) @@ -635,12 +861,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("project_id", projectConfigCanonical.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if !core.IsNil(projectConfigCanonical.Labels) { - if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { - return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) + if !core.IsNil(projectConfigCanonical.Name) { + if err = d.Set("name", projectConfigCanonical.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } } if !core.IsNil(projectConfigCanonical.Description) { @@ -648,6 +871,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } } + if !core.IsNil(projectConfigCanonical.Labels) { + if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { + return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) + } + } if !core.IsNil(projectConfigCanonical.Authorizations) { authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) if err != nil { @@ -666,32 +894,26 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) } } - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + if !core.IsNil(projectConfigCanonical.LocatorID) { + if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) + } } if !core.IsNil(projectConfigCanonical.Input) { - input := []map[string]interface{}{} - for _, inputItem := range projectConfigCanonical.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) - if err != nil { - return diag.FromErr(err) - } - input = append(input, inputItemMap) + inputMap, err := resourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("input", input); err != nil { + if err = d.Set("input", []map[string]interface{}{inputMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) } } if !core.IsNil(projectConfigCanonical.Setting) { - setting := []map[string]interface{}{} - for _, settingItem := range projectConfigCanonical.Setting { - settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, settingItemMap) + settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("setting", setting); err != nil { + if err = d.Set("setting", []map[string]interface{}{settingMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) } } @@ -719,11 +941,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } } - if !core.IsNil(projectConfigCanonical.PipelineState) { - if err = d.Set("pipeline_state", projectConfigCanonical.PipelineState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting pipeline_state: %s", err)) - } - } if !core.IsNil(projectConfigCanonical.UpdateAvailable) { if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) @@ -753,9 +970,49 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Type) { - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + if !core.IsNil(projectConfigCanonical.CraLogs) { + craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.CostEstimate) { + costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.CheckJob) { + checkJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("check_job", []map[string]interface{}{checkJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting check_job: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.InstallJob) { + installJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("install_job", []map[string]interface{}{installJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting install_job: %s", err)) + } + } + if !core.IsNil(projectConfigCanonical.UninstallJob) { + uninstallJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("uninstall_job", []map[string]interface{}{uninstallJobMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting uninstall_job: %s", err)) } } if !core.IsNil(projectConfigCanonical.Output) { @@ -771,17 +1028,13 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) } } - if !core.IsNil(projectConfigCanonical.ActiveDraft) { - activeDraftMap, err := resourceIbmProjectConfigProjectConfigVersionSummaryToMap(projectConfigCanonical.ActiveDraft) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("active_draft", []map[string]interface{}{activeDraftMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting active_draft: %s", err)) + if !core.IsNil(projectConfigCanonical.Type) { + if err = d.Set("type", projectConfigCanonical.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } } if !core.IsNil(projectConfigCanonical.Definition) { - definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionToMap(projectConfigCanonical.Definition) + definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) if err != nil { return diag.FromErr(err) } @@ -789,11 +1042,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Href) { - if err = d.Set("href", projectConfigCanonical.Href); err != nil { - return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) - } - } if !core.IsNil(projectConfigCanonical.ID) { if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) @@ -822,43 +1070,17 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false 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("locator_id") { - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true - } - if d.HasChange("input") { - var input []projectv1.ProjectConfigInputVariable - for _, v := range d.Get("input").([]interface{}) { - value := v.(map[string]interface{}) - inputItem, err := resourceIbmProjectConfigMapToProjectConfigInputVariable(value) - if err != nil { - return diag.FromErr(err) - } - input = append(input, *inputItem) - } - updateConfigOptions.SetInput(input) - hasChange = true - } - if d.HasChange("setting") { - var setting []projectv1.ProjectConfigSettingCollection - for _, v := range d.Get("setting").([]interface{}) { - value := v.(map[string]interface{}) - settingItem, err := resourceIbmProjectConfigMapToProjectConfigSettingCollection(value) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, *settingItem) - } - updateConfigOptions.SetSetting(setting) - hasChange = true + 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") { updateConfigOptions.SetName(d.Get("name").(string)) hasChange = true } + if d.HasChange("description") { + updateConfigOptions.SetDescription(d.Get("description").(string)) + hasChange = true + } if d.HasChange("labels") { var labels []string for _, v := range d.Get("labels").([]interface{}) { @@ -868,10 +1090,6 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetLabels(labels) hasChange = true } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } if d.HasChange("authorizations") { authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) if err != nil { @@ -888,6 +1106,26 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD updateConfigOptions.SetComplianceProfile(complianceProfile) hasChange = true } + if d.HasChange("locator_id") { + updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) + hasChange = true + } + if d.HasChange("input") { + input, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetInput(input) + hasChange = true + } + if d.HasChange("setting") { + setting, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + updateConfigOptions.SetSetting(setting) + hasChange = true + } if hasChange { _, response, err := projectClient.UpdateConfigWithContext(context, updateConfigOptions) @@ -976,19 +1214,13 @@ func resourceIbmProjectConfigMapToProjectConfigComplianceProfile(modelMap map[st return model, nil } -func resourceIbmProjectConfigMapToProjectConfigInputVariable(modelMap map[string]interface{}) (*projectv1.ProjectConfigInputVariable, error) { - model := &projectv1.ProjectConfigInputVariable{} - model.Name = core.StringPtr(modelMap["name"].(string)) - if modelMap["value"] != nil { - model.Value = modelMap["value"].(string) - } +func resourceIbmProjectConfigMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { + model := &projectv1.InputVariable{} return model, nil } -func resourceIbmProjectConfigMapToProjectConfigSettingCollection(modelMap map[string]interface{}) (*projectv1.ProjectConfigSettingCollection, error) { - model := &projectv1.ProjectConfigSettingCollection{} - model.Name = core.StringPtr(modelMap["name"].(string)) - model.Value = core.StringPtr(modelMap["value"].(string)) +func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { + model := &projectv1.ProjectConfigSetting{} return model, nil } @@ -1041,19 +1273,13 @@ func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv return modelMap, nil } -func resourceIbmProjectConfigProjectConfigInputVariableToMap(model *projectv1.ProjectConfigInputVariable) (map[string]interface{}, error) { +func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigSettingCollectionToMap(model *projectv1.ProjectConfigSettingCollection) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - modelMap["value"] = model.Value return modelMap, nil } @@ -1068,80 +1294,183 @@ func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *proje return modelMap, nil } -func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion } - if model.Value != nil { - modelMap["value"] = model.Value + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["version"] = flex.IntValue(model.Version) - modelMap["state"] = model.State - if model.PipelineState != nil { - modelMap["pipeline_state"] = model.PipelineState + if model.Version != nil { + modelMap["version"] = model.Version } - if model.Href != nil { - modelMap["href"] = model.Href + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID } return modelMap, nil } -func resourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.ProjectConfigDefinition) (map[string]interface{}, error) { +func resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Labels != nil { - modelMap["labels"] = model.Labels + if model.ID != nil { + modelMap["id"] = model.ID } - if model.Description != nil { - modelMap["description"] = model.Description + if model.Href != nil { + modelMap["href"] = model.Href } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if model.Summary != nil { + summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + modelMap["summary"] = []map[string]interface{}{summaryMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + return modelMap, nil +} + +func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + modelMap["plan_summary"] = planSummary } - modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - input := []map[string]interface{}{} - for _, inputItem := range model.Input { - inputItemMap, err := resourceIbmProjectConfigProjectConfigInputVariableToMap(&inputItem) + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - input = append(input, inputItemMap) + applySummary[k] = string(bytes) } - modelMap["input"] = input + modelMap["apply_summary"] = applySummary } - if model.Setting != nil { - setting := []map[string]interface{}{} - for _, settingItem := range model.Setting { - settingItemMap, err := resourceIbmProjectConfigProjectConfigSettingCollectionToMap(&settingItem) + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - setting = append(setting, settingItemMap) + destroySummary[k] = string(bytes) } - modelMap["setting"] = setting + modelMap["destroy_summary"] = destroySummary } - if model.Type != nil { - modelMap["type"] = model.Type + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) if model.Output != nil { output := []map[string]interface{}{} for _, outputItem := range model.Output { @@ -1153,5 +1482,48 @@ func resourceIbmProjectConfigProjectConfigDefinitionToMap(model *projectv1.Proje } modelMap["output"] = output } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.Input != nil { + inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } return modelMap, nil } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 28eb4e68ae..7e5b78c9d7 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -33,151 +33,59 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `active_draft` - (List) The project configuration version. - Nested schema for **active_draft**: + * `approved_version` - (List) The project configuration version. + Nested schema for **approved_version**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `version` - (Integer) The version number of the configuration. - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `check_job` - (List) The action job performed on the project configuration. + Nested schema for **check_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `definition` - (List) The project configuration definition. + * `definition` - (List) The project configuration definition summary. Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `install_job` - (List) The action job performed on the project configuration. + Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `installed_version` - (List) The project configuration version. + Nested schema for **installed_version**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Integer) The version number of the configuration. + * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (String) The unique ID of a project. + * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `uninstall_job` - (List) The action job performed on the project configuration. + Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index ab0c368f20..8f3da95577 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -33,16 +33,6 @@ 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 project_config. -* `active_draft` - (List) The project configuration version. -Nested schema for **active_draft**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Integer) The version number of the configuration. - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. @@ -51,27 +41,65 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. + * `target_iam_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `check_job` - (List) The action job performed on the project configuration. +Nested schema for **check_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. + * `attachment_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `instance_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The project configuration definition. +* `definition` - (List) The Schematics template property. Nested schema for **definition**: * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -81,30 +109,26 @@ Nested schema for **definition**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. + * `target_iam_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. + * `attachment_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `instance_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -119,28 +143,32 @@ Nested schema for **definition**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - -* `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + +* `install_job` - (List) The action job performed on the project configuration. +Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. @@ -152,7 +180,7 @@ Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -175,19 +203,11 @@ Nested schema for **output**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. -* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. @@ -195,6 +215,22 @@ Nested schema for **setting**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `uninstall_job` - (List) The action job performed on the project configuration. +Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index f16f557f82..ae09fcff3a 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -21,90 +21,33 @@ resource "ibm_project" "project_instance" { is_draft = true needs_attention_state = [ "anything as a string" ] state = "approved" - pipeline_state = "pipeline_failed" - update_available = true - created_at = "2021-01-31T09:44:12Z" - updated_at = "2021-01-31T09:44:12Z" - last_approved { - is_forced = true - comment = "comment" - timestamp = "2021-01-31T09:44:12Z" - user_id = "user_id" - } - last_save = "2021-01-31T09:44:12Z" - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" + approved_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" + version = 1 + href = "href" } - active_draft { + installed_version { + needs_attention_state = [ "anything as a string" ] + state = "approved" version = 1 - state = "discarded" - pipeline_state = "pipeline_failed" href = "href" } definition { name = "name" - labels = [ "labels" ] description = "description" - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } + } + check_job { + id = "id" + href = "href" + } + install_job { + id = "id" + href = "href" + } + uninstall_job { + id = "id" + href = "href" } href = "href" } @@ -122,151 +65,59 @@ You can specify the following arguments for this resource. * `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `active_draft` - (Optional, List) The project configuration version. - Nested schema for **active_draft**: + * `approved_version` - (Optional, List) The project configuration version. + Nested schema for **approved_version**: * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (Required, String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (Required, String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `version` - (Required, Integer) The version number of the configuration. - * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. + * `check_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **check_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `created_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `definition` - (Optional, List) The project configuration definition. + * `definition` - (Optional, List) The project configuration definition summary. Nested schema for **definition**: - * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. - Nested schema for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (Optional, List) The profile required for compliance. - Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `type` - (Optional, String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `description` - (Optional, String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `href` - (Optional, String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (Optional, List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (Optional, String) The comment left by the user who approved the configuration. - * `is_forced` - (Required, Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (Required, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (Required, String) The unique ID of a project. + * `install_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **install_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_save` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (Required, String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `installed_version` - (Optional, List) The project configuration version. + Nested schema for **installed_version**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `state` - (Required, String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. + * `version` - (Required, Integer) The version number of the configuration. + * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `pipeline_state` - (Optional, String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `project_id` - (Optional, String) The unique ID of a project. + * `project_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `state` - (Optional, String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `type` - (Optional, String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - * `update_available` - (Optional, Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (Optional, String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `uninstall_job` - (Optional, List) The action job performed on the project configuration. + Nested schema for **uninstall_job**: + * `href` - (Optional, String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (Optional, String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `version` - (Optional, Integer) The version of the configuration. * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -274,7 +125,7 @@ Nested schema for **configs**: * Constraints: The default value is `true`. * `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Required, String) The name of the project. +* `name` - (Optional, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. @@ -314,7 +165,7 @@ Nested schema for **definition**: ## Import -You can import the `ibm_project` resource by using `id`. The unique ID of a project. +You can import the `ibm_project` resource by using `id`. The unique ID. # Syntax ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index ed003b67e1..28da460453 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -29,17 +29,12 @@ resource "ibm_project_config" "project_config_instance" { attachment_id = "attachment_id" profile_name = "profile_name" } - input { - name = "name" - value = "anything as a string" - } - locator_id = "locator_id" - name = "name" + description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + input = {"account_id":"$configs[].name["account-stage"].input.account_id","resource_group":"stage","access_tags":["env:stage"],"logdna_name":"Name of the LogDNA stage service instance","sysdig_name":"Name of the SysDig stage service instance"} + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" + name = "env-stage" project_id = ibm_project.project_instance.id - setting { - name = "name" - value = "value" - } + setting = {"IBMCLOUD_TOOLCHAIN_ENDPOINT":"https://api.us-south.devops.dev.cloud.ibm.com"} } ``` @@ -55,62 +50,79 @@ Nested schema for **authorizations**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (Optional, List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID of a project. + * `target_iam_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID of a project. + * `attachment_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID of a project. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID of a project. + * `instance_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `input` - (Optional, List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `labels` - (Optional, List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. -* `locator_id` - (Required, String) A dotted value of catalogID.versionID. +* `locator_id` - (Optional, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `name` - (Required, String) The name of the configuration. +* `name` - (Optional, String) The name of the configuration. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (Required, String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Required, String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. ## Attribute Reference After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the project_config. -* `active_draft` - (List) The project configuration version. -Nested schema for **active_draft**: +* `check_job` - (List) The action job performed on the project configuration. +Nested schema for **check_job**: * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. - * `state` - (String) The state of the configuration draft. - * Constraints: Allowable values are: `discarded`, `merged`, `active`. - * `version` - (Integer) The version number of the configuration. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. +Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. +* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. +Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The project configuration definition. +* `definition` - (List) The Schematics template property. Nested schema for **definition**: * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -120,30 +132,26 @@ Nested schema for **definition**: * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `trusted_profile` - (List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID of a project. + * `target_iam_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID of a project. + * `attachment_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID of a project. + * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID of a project. + * `instance_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `instance_location` - (String) The location of the compliance instance. - * Constraints: The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. + * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the project configuration. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The inputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `labels` - (List) A collection of configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. @@ -158,24 +166,32 @@ Nested schema for **definition**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `name` - (String) The name of the configuration setting. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) The value of the configuration setting. - * Constraints: The maximum length is `1024` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. +* `install_job` - (List) The action job performed on the project configuration. +Nested schema for **install_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID of a project. + * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. @@ -188,14 +204,27 @@ Nested schema for **output**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. -* `pipeline_state` - (String) The pipeline state of the configuration. It only exists after the first configuration validation. - * Constraints: Allowable values are: `pipeline_failed`, `pipeline_running`, `pipeline_succeeded`. * `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. +* `uninstall_job` - (List) The action job performed on the project configuration. +Nested schema for **uninstall_job**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From 570ed67b2a025d082fae20b0a28c96d6a6cf9fb8 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 29 Aug 2023 17:21:11 +0200 Subject: [PATCH 088/125] regenerate the terraform code based on latest YAML --- .../project/data_source_ibm_project.go | 4 +- .../project/data_source_ibm_project_config.go | 15 +-- ibm/service/project/resource_ibm_project.go | 28 +++--- .../project/resource_ibm_project_config.go | 93 +++++++++---------- 4 files changed, 66 insertions(+), 74 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index fe984efecd..de12c422a6 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -348,7 +348,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m cumulativeNeedsAttentionView := []map[string]interface{}{} if projectCanonical.CumulativeNeedsAttentionView != nil { - for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { + for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -406,7 +406,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m configs := []map[string]interface{}{} if projectCanonical.Configs != nil { - for _, modelItem := range projectCanonical.Configs { + for _, modelItem := range projectCanonical.Configs { modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&modelItem) if err != nil { return diag.FromErr(err) diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 9c08b97a05..7dc1672fbd 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -132,8 +132,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -141,8 +140,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "project_config_canonical_id": &schema.Schema{ @@ -734,8 +732,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -743,8 +740,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, }, @@ -781,7 +777,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) } - authorizations := []map[string]interface{}{} if projectConfigCanonical.Authorizations != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) @@ -944,7 +939,7 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD output := []map[string]interface{}{} if projectConfigCanonical.Output != nil { - for _, modelItem := range projectConfigCanonical.Output { + for _, modelItem := range projectConfigCanonical.Output { modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) if err != nil { return diag.FromErr(err) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index f3cf41eea5..bd1e38f21d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -20,34 +20,34 @@ import ( func ResourceIbmProject() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectCreate, - ReadContext: resourceIbmProjectRead, - UpdateContext: resourceIbmProjectUpdate, - DeleteContext: resourceIbmProjectDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectCreate, + ReadContext: resourceIbmProjectRead, + UpdateContext: resourceIbmProjectUpdate, + DeleteContext: resourceIbmProjectDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", + Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 56f377c60f..f938bdb91c 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -20,29 +21,29 @@ import ( func ResourceIbmProjectConfig() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIbmProjectConfigCreate, - ReadContext: resourceIbmProjectConfigRead, - UpdateContext: resourceIbmProjectConfigUpdate, - DeleteContext: resourceIbmProjectConfigDelete, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceIbmProjectConfigCreate, + ReadContext: resourceIbmProjectConfigRead, + UpdateContext: resourceIbmProjectConfigUpdate, + DeleteContext: resourceIbmProjectConfigDelete, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), - Description: "The unique project ID.", + Description: "The unique project ID.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The name of the configuration.", + Description: "The name of the configuration.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), Description: "The description of the project configuration.", }, @@ -128,8 +129,8 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), Description: "A dotted value of catalogID.versionID.", }, @@ -139,8 +140,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -149,8 +149,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "version": &schema.Schema{ @@ -248,7 +247,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "timestamp": &schema.Schema{ Type: schema.TypeString, @@ -344,43 +343,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -415,43 +414,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -486,43 +485,43 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeMap, Optional: true, Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "message_summary": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "plan_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "apply_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, "destroy_messages": &schema.Schema{ Type: schema.TypeMap, Optional: true, Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -696,8 +695,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "The input variables for the configuration definition.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, "setting": &schema.Schema{ @@ -706,8 +704,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - }, + Schema: map[string]*schema.Schema{}, }, }, }, @@ -1070,8 +1067,8 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false 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")) + 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") { updateConfigOptions.SetName(d.Get("name").(string)) From 113d46f9a0e5c56c20db60626063cf3b115fa166 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 30 Aug 2023 17:56:03 +0200 Subject: [PATCH 089/125] update doc --- examples/ibm-project/README.md | 4 +- examples/ibm-project/main.tf | 58 +------------------ examples/ibm-project/outputs.tf | 9 ++- examples/ibm-project/variables.tf | 42 +++----------- examples/ibm-project/versions.tf | 8 +-- ibm/service/project/README.md | 6 +- ibm/service/project/resource_ibm_project.go | 24 ++++---- .../project/resource_ibm_project_config.go | 16 ++--- website/docs/d/project_config.html.markdown | 2 +- 9 files changed, 42 insertions(+), 127 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 05be1c0282..5f0a79aa4a 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -64,7 +64,7 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfigCanonical_id + id = ibm_project_config.project_config_instance.project_config_canonical_id } ``` @@ -118,5 +118,3 @@ data "project_config" "project_config_instance" { |------|-------------| | project | project object | | project_config | project_config object | -| project | project object | -| project_config | project_config object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 5747f37e54..8c947412fe 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -9,43 +9,6 @@ resource "ibm_project" "project_instance" { name = var.project_name description = var.project_description destroy_on_delete = var.project_destroy_on_delete - configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - approved_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" - } - installed_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" - } - definition { - name = "name" - description = "description" - } - check_job { - id = "id" - href = "href" - } - install_job { - id = "id" - href = "href" - } - uninstall_job { - id = "id" - href = "href" - } - href = "href" - } } // Provision project_config resource instance @@ -55,25 +18,10 @@ resource "ibm_project_config" "project_config_instance" { description = var.project_config_description labels = var.project_config_labels authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + method = "API_KEY" + api_key = var.ibmcloud_api_key } locator_id = var.project_config_locator_id - input { - } - setting { - } } // Create project data source @@ -84,5 +32,5 @@ data "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.projectConfigCanonical_id + id = ibm_project_config.project_config_instance.project_config_canonical_id } diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 2ab29c7f63..10a7e3e65e 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -1,12 +1,11 @@ -// This output allows project data to be referenced by other resources and the terraform CLI -// Modify this output if only certain data should be exposed +// This allows project data to be referenced by other resources and the terraform CLI +// Modify this if only certain data should be exposed output "ibm_project" { value = ibm_project.project_instance description = "project resource instance" } -// This output allows project_config data to be referenced by other resources and the terraform CLI -// Modify this output if only certain data should be exposed + output "ibm_project_config" { value = ibm_project_config.project_config_instance - description = "project_config resource instance" + description = "project config instance" } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 11b08d1c56..99929bb5b8 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -15,12 +15,12 @@ variable "project_location" { default = "us-south" } variable "project_name" { - description = "The name of the project." + description = "The project name." type = string default = "acme-microservice" } variable "project_description" { - description = "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description." + description = "A project's descriptive text." type = string default = "A microservice to deploy on top of ACME infrastructure." } @@ -31,47 +31,23 @@ variable "project_destroy_on_delete" { } // Resource arguments for project_config -variable "project_config_project_id" { - description = "The unique project ID." - type = string - default = "project_id" -} variable "project_config_name" { - description = "The name of the configuration." + description = "The configuration name." type = string default = "env-stage" } -variable "project_config_description" { - description = "The description of the project configuration." +variable "project_config_locator_id" { + description = "A dotted value of catalogID.versionID." type = string - default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } variable "project_config_labels" { description = "A collection of configuration labels." type = list(string) default = ["env:stage","governance:test","build:0"] } -variable "project_config_locator_id" { - description = "A dotted value of catalogID.versionID." - type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" -} - -// Data source arguments for project -variable "project_id" { - description = "The unique project ID." - type = string - default = "id" -} - -// Data source arguments for project_config -variable "project_config_project_id" { - description = "The unique project ID." - type = string - default = "project_id" -} -variable "project_config_id" { - description = "The unique config ID." +variable "project_config_description" { + description = "The project configuration description." type = string - default = "id" + default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." } diff --git a/examples/ibm-project/versions.tf b/examples/ibm-project/versions.tf index 54c9d03e8d..d9b6f790b9 100644 --- a/examples/ibm-project/versions.tf +++ b/examples/ibm-project/versions.tf @@ -1,9 +1,3 @@ terraform { - required_version = ">= 1.0" - required_providers { - ibm = { - source = "IBM-Cloud/ibm" - version = "1.52.0-beta0" - } - } + required_version = ">= 0.12" } diff --git a/ibm/service/project/README.md b/ibm/service/project/README.md index f0cba45706..452ed8d034 100644 --- a/ibm/service/project/README.md +++ b/ibm/service/project/README.md @@ -6,6 +6,6 @@ This area is primarily for IBM provider contributors and maintainers. For inform ## Handy Links * [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! * 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/project) -* IBM API Docs: [IBM API Docs for ]() -* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/projectv1) +* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/project_instance) +* IBM API Docs: [IBM API Docs for project](https://test.cloud.ibm.com/apidocs/projects) +* IBM SDK: [IBM SDK for project](https://github.com/IBM/project-go-sdk) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index bd1e38f21d..ac4858c779 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -28,10 +28,10 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), - Description: "The resource group where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ Type: schema.TypeString, @@ -40,16 +40,16 @@ func ResourceIbmProject() *schema.Resource { Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), - Description: "The name of the project.", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f938bdb91c..435499dc22 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -42,10 +42,10 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "The name of the configuration.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -129,10 +129,10 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), - Description: "A dotted value of catalogID.versionID.", + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 8f3da95577..b7261ffc91 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project_config. ```hcl data "ibm_project_config" "project_config" { - id = ibm_project_config.project_config_instance.projectConfigCanonical_id + id = ibm_project_config.project_config_instance.project_config_canonical_id project_id = ibm_project_config.project_config.project_id } ``` From beee11361c13d67ed74c18b71594091334b639b5 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 30 Aug 2023 17:58:50 +0200 Subject: [PATCH 090/125] update doc --- ibm/service/project/resource_ibm_project.go | 24 +++++++++---------- .../project/resource_ibm_project_config.go | 16 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index ac4858c779..bd1e38f21d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -28,10 +28,10 @@ func ResourceIbmProject() *schema.Resource { Schema: map[string]*schema.Schema{ "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), - Description: "The resource group where the project's data and tools are created.", + Type: schema.TypeString, + Required: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), + Description: "The resource group where the project's data and tools are created.", }, "location": &schema.Schema{ Type: schema.TypeString, @@ -40,16 +40,16 @@ func ResourceIbmProject() *schema.Resource { Description: "The location where the project's data and tools are created.", }, "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "name"), - Description: "The name of the project.", + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), + Description: "The name of the project.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "description"), - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 435499dc22..f938bdb91c 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -42,10 +42,10 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "The name of the configuration.", }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), + Description: "The description of the project configuration.", }, "labels": &schema.Schema{ Type: schema.TypeList, @@ -129,10 +129,10 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), - Description: "A dotted value of catalogID.versionID.", + Type: schema.TypeString, + Optional: true, + // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), + Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ Type: schema.TypeList, From f4bcc368ee20961239eb79830b25d7255a5598c1 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 31 Aug 2023 11:11:44 +0200 Subject: [PATCH 091/125] fix test cases --- .../data_source_ibm_project_config_test.go | 25 ++++------------- .../project/data_source_ibm_project_test.go | 28 ++++--------------- .../resource_ibm_project_config_test.go | 8 ------ .../project/resource_ibm_project_test.go | 18 ------------ website/docs/d/project.html.markdown | 2 +- 5 files changed, 12 insertions(+), 69 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index e232e315f1..a62bec0195 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -26,8 +26,9 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.locator_id"), ), }, }, @@ -57,21 +58,15 @@ func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_approved.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "description"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "locator_id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.0.name"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.0.value"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "type"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "active_draft.#"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.description"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.locator_id"), ), }, }, @@ -117,14 +112,6 @@ func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName str api_key = "" } locator_id = "%s" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } } data "ibm_project_config" "project_config_instance" { diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 3f870f9271..d5f3530bdd 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -31,7 +31,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.name"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), ), }, @@ -59,11 +60,10 @@ func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "configs.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.name"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.description"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), ), }, }, @@ -92,24 +92,6 @@ func testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup string name = "%s" description = "%s" destroy_on_delete = %s - configs { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - method = "API_KEY" - api_key = "" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } } data "ibm_project" "project_instance" { diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index f00685538b..ea4b5b0eb1 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -122,14 +122,6 @@ func testAccCheckIbmProjectConfigConfig(name string, description string, locator api_key = "" } locator_id = "%s" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } } `, name, description, locatorID) } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index d0217ccef8..1e17abdf47 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -120,24 +120,6 @@ func testAccCheckIbmProjectConfig(resourceGroup string, location string, name st name = "%s" description = "%s" destroy_on_delete = %s - configs { - name = "name" - labels = [ "labels" ] - description = "description" - authorizations { - method = "API_KEY" - api_key = "" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" - input { - name = "name" - value = "anything as a string" - } - setting { - name = "name" - value = "value" - } - } } `, resourceGroup, location, name, description, destroyOnDelete) } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 7e5b78c9d7..c8910ffbe0 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project. You ca ```hcl data "ibm_project" "project" { - id = ibm_project.project_instance.projectCanonical_id + id = ibm_project.project_instance.id } ``` From ef5db346838d613e8b53c3185811270924a405b3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 09:46:36 +0200 Subject: [PATCH 092/125] commit generated code --- examples/ibm-project/README.md | 62 +- examples/ibm-project/main.tf | 55 +- examples/ibm-project/outputs.tf | 15 +- examples/ibm-project/variables.tf | 49 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 376 ++--- .../project/data_source_ibm_project_config.go | 1006 ++---------- .../data_source_ibm_project_config_test.go | 96 +- .../project/data_source_ibm_project_test.go | 72 +- ibm/service/project/resource_ibm_project.go | 651 +++----- .../project/resource_ibm_project_config.go | 1380 ++++------------- .../resource_ibm_project_config_test.go | 93 +- .../project/resource_ibm_project_test.go | 103 +- website/docs/d/project.html.markdown | 67 +- website/docs/d/project_config.html.markdown | 143 +- website/docs/r/project.html.markdown | 154 +- website/docs/r/project_config.html.markdown | 225 +-- 18 files changed, 1061 insertions(+), 3492 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 5f0a79aa4a..c63042043e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -4,8 +4,8 @@ This example illustrates how to use the ProjectV1 The following types of resources are supported: -* project * project_config +* project ## Usage @@ -22,36 +22,34 @@ Run `terraform destroy` when you don't need these resources. ## ProjectV1 resources +project_config resource: + +```hcl +resource "project_config" "project_config_instance" { + project_id = ibm_project.project_instance.project_id + definition = var.project_config_definition +} +``` project resource: ```hcl resource "project" "project_instance" { resource_group = var.project_resource_group location = var.project_location - name = var.project_name - description = var.project_description - destroy_on_delete = var.project_destroy_on_delete - configs = var.project_configs + definition = var.project_definition } ``` -project_config resource: + +## ProjectV1 data sources + +project_config data source: ```hcl -resource "project_config" "project_config_instance" { +data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - name = var.project_config_name - description = var.project_config_description - labels = var.project_config_labels - authorizations = var.project_config_authorizations - compliance_profile = var.project_config_compliance_profile - locator_id = var.project_config_locator_id - input = var.project_config_input - setting = var.project_config_setting + id = ibm_project_config.project_config_instance.project_config_id } ``` - -## ProjectV1 data sources - project data source: ```hcl @@ -59,14 +57,6 @@ data "project" "project_instance" { id = ibm_project.project_instance.id } ``` -project_config data source: - -```hcl -data "project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_canonical_id -} -``` ## Assumptions @@ -93,28 +83,18 @@ data "project_config" "project_config_instance" { | Name | Description | Type | Required | |------|-------------|------|---------| | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| project_id | The unique project ID. | `string` | true | +| definition | The type and output of a project configuration. | `` | false | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | -| name | The name of the project. | `string` | false | -| description | A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. | `string` | false | -| destroy_on_delete | The policy that indicates whether the resources are destroyed or not when a project is deleted. | `bool` | false | -| configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | `list()` | false | -| project_id | The unique project ID. | `string` | true | -| name | The name of the configuration. | `string` | false | -| description | The description of the project configuration. | `string` | false | -| labels | A collection of configuration labels. | `list(string)` | false | -| authorizations | The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. | `` | false | -| compliance_profile | The profile required for compliance. | `` | false | -| locator_id | A dotted value of catalogID.versionID. | `string` | false | -| input | The input variables for the configuration definition. | `` | false | -| setting | Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. | `` | false | -| id | The unique project ID. | `string` | true | +| definition | The definition of the project. | `` | false | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | +| id | The unique project ID. | `string` | true | ## Outputs | Name | Description | |------|-------------| -| project | project object | | project_config | project_config object | +| project | project object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 8c947412fe..17d936b8e6 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -2,35 +2,52 @@ provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key } +// Provision project_config resource instance +resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.project_id + definition { + name = "name" + description = "description" + labels = [ "labels" ] + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { + id = "id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input = { } + setting = { } + } +} + // Provision project resource instance resource "ibm_project" "project_instance" { resource_group = var.project_resource_group location = var.project_location - name = var.project_name - description = var.project_description - destroy_on_delete = var.project_destroy_on_delete + definition { + name = "name" + description = "description" + destroy_on_delete = true + } } -// Provision project_config resource instance -resource "ibm_project_config" "project_config_instance" { +// Create project_config data source +data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - name = var.project_config_name - description = var.project_config_description - labels = var.project_config_labels - authorizations { - method = "API_KEY" - api_key = var.ibmcloud_api_key - } - locator_id = var.project_config_locator_id + id = ibm_project_config.project_config_instance.project_config_id } // Create project data source data "ibm_project" "project_instance" { id = ibm_project.project_instance.id } - -// Create project_config data source -data "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_canonical_id -} diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 10a7e3e65e..277309cbec 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -1,11 +1,12 @@ -// This allows project data to be referenced by other resources and the terraform CLI -// Modify this if only certain data should be exposed +// This output allows project_config data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_project_config" { + value = ibm_project_config.project_config_instance + description = "project_config resource instance" +} +// This output allows project data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed output "ibm_project" { value = ibm_project.project_instance description = "project resource instance" } - -output "ibm_project_config" { - value = ibm_project_config.project_config_instance - description = "project config instance" -} diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 99929bb5b8..54df2e4e8e 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -3,6 +3,13 @@ variable "ibmcloud_api_key" { type = string } +// Resource arguments for project_config +variable "project_config_project_id" { + description = "The unique project ID." + type = string + default = "project_id" +} + // Resource arguments for project variable "project_resource_group" { description = "The resource group where the project's data and tools are created." @@ -14,40 +21,22 @@ variable "project_location" { type = string default = "us-south" } -variable "project_name" { - description = "The project name." - type = string - default = "acme-microservice" -} -variable "project_description" { - description = "A project's descriptive text." - type = string - default = "A microservice to deploy on top of ACME infrastructure." -} -variable "project_destroy_on_delete" { - description = "The policy that indicates whether the resources are destroyed or not when a project is deleted." - type = bool - default = true -} -// Resource arguments for project_config -variable "project_config_name" { - description = "The configuration name." +// Data source arguments for project_config +variable "project_config_project_id" { + description = "The unique project ID." type = string - default = "env-stage" + default = "project_id" } -variable "project_config_locator_id" { - description = "A dotted value of catalogID.versionID." +variable "project_config_id" { + description = "The unique config ID." type = string - default = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" -} -variable "project_config_labels" { - description = "A collection of configuration labels." - type = list(string) - default = ["env:stage","governance:test","build:0"] + default = "id" } -variable "project_config_description" { - description = "The project configuration description." + +// Data source arguments for project +variable "project_id" { + description = "The unique project ID." type = string - default = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." + default = "id" } diff --git a/go.mod b/go.mod index 0a77a78d04..7d93626158 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.48.1 - github.com/IBM/project-go-sdk v0.0.10 + github.com/IBM/project-go-sdk v0.0.26-79 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.0.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index 647d544466..584664220a 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g= github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8= -github.com/IBM/project-go-sdk v0.0.10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-79 h1:JOhGIkM0jY49QSNvqY1d2qe+AVdr5gW21RqnCCPz1F4= +github.com/IBM/project-go-sdk v0.0.26-79/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.0.2 h1:OUqkzLfJqozp2aqylNurwaJd1SmY8o7KturFse6R2xM= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index de12c422a6..e15e7114d2 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -90,45 +90,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the project.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", - }, - "definition": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The definition of the project.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the project.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", - }, - }, - }, - }, "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -168,150 +129,102 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The state of the configuration.", }, - "approved_version": &schema.Schema{ - Type: schema.TypeList, + "update_available": &schema.Schema{ + Type: schema.TypeBool, Computed: true, - Description: "The project configuration version.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version number of the configuration.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - }, - }, + Description: "The flag that indicates whether a configuration update is available.", }, - "installed_version": &schema.Schema{ + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The project configuration version.", + Description: "The last approved metadata of the configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, + "is_forced": &schema.Schema{ + Type: schema.TypeBool, Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "The flag that indicates whether the approval was forced approved.", }, - "state": &schema.Schema{ + "comment": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The state of the configuration.", + Description: "The comment left by the user who approved the configuration.", }, - "version": &schema.Schema{ - Type: schema.TypeInt, + "timestamp": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The version number of the configuration.", + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "href": &schema.Schema{ + "user_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "The unique ID.", }, }, }, }, - "definition": &schema.Schema{ - Type: schema.TypeList, + "last_save": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The project configuration definition summary.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - }, - }, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "check_job": &schema.Schema{ - Type: schema.TypeList, + "href": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - }, - }, + Description: "A relative URL.", }, - "install_job": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The action job performed on the project configuration.", + Description: "The name and description of a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The unique ID.", + Description: "The configuration name.", }, - "href": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "A project configuration description.", }, }, }, }, - "uninstall_job": &schema.Schema{ - Type: schema.TypeList, + }, + }, + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - }, - }, + Description: "The name of the project.", }, - "href": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + }, + "destroy_on_delete": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, }, }, @@ -330,7 +243,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m getProjectOptions.SetID(d.Get("id").(string)) - projectCanonical, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + project, response, err := projectClient.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)) @@ -338,17 +251,17 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m d.SetId(fmt.Sprintf("%s", *getProjectOptions.ID)) - if err = d.Set("crn", projectCanonical.Crn); err != nil { + if err = d.Set("crn", project.Crn); err != nil { return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { + if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } cumulativeNeedsAttentionView := []map[string]interface{}{} - if projectCanonical.CumulativeNeedsAttentionView != nil { - for _, modelItem := range projectCanonical.CumulativeNeedsAttentionView { + if project.CumulativeNeedsAttentionView != nil { + for _, modelItem := range project.CumulativeNeedsAttentionView { modelMap, err := dataSourceIbmProjectCumulativeNeedsAttentionToMap(&modelItem) if err != nil { return diag.FromErr(err) @@ -360,41 +273,43 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view %s", err)) } - if err = d.Set("cumulative_needs_attention_view_error", projectCanonical.CumulativeNeedsAttentionViewError); err != nil { + if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } - if err = d.Set("location", projectCanonical.Location); err != nil { + if err = d.Set("location", project.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if err = d.Set("resource_group", projectCanonical.ResourceGroup); err != nil { + if err = d.Set("resource_group", project.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if err = d.Set("state", projectCanonical.State); err != nil { + if err = d.Set("state", project.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { + if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } - if err = d.Set("name", projectCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - - if err = d.Set("description", projectCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) + configs := []map[string]interface{}{} + if project.Configs != nil { + for _, modelItem := range project.Configs { + modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, modelMap) + } } - - if err = d.Set("destroy_on_delete", projectCanonical.DestroyOnDelete); err != nil { - return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) } definition := []map[string]interface{}{} - if projectCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) + if project.Definition != nil { + modelMap, err := dataSourceIbmProjectProjectDefinitionPropertiesToMap(project.Definition) if err != nil { return diag.FromErr(err) } @@ -404,20 +319,6 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) } - configs := []map[string]interface{}{} - if projectCanonical.Configs != nil { - for _, modelItem := range projectCanonical.Configs { - modelMap, err := dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&modelItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, modelMap) - } - } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) - } - return nil } @@ -438,117 +339,70 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati return modelMap, nil } -func dataSourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.ProjectConfigCollectionMember) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.DestroyOnDelete != nil { - modelMap["destroy_on_delete"] = model.DestroyOnDelete - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID - } - if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) - } - if model.IsDraft != nil { - modelMap["is_draft"] = model.IsDraft - } + modelMap["id"] = model.ID + modelMap["project_id"] = model.ProjectID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["is_draft"] = model.IsDraft if model.NeedsAttentionState != nil { modelMap["needs_attention_state"] = model.NeedsAttentionState } - if model.State != nil { - modelMap["state"] = model.State - } - if model.ApprovedVersion != nil { - approvedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) - if err != nil { - return modelMap, err - } - modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} - } - if model.InstalledVersion != nil { - installedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) - if err != nil { - return modelMap, err - } - modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} - } - if model.Definition != nil { - definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) - if err != nil { - return modelMap, err - } - modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["state"] = model.State + modelMap["update_available"] = model.UpdateAvailable + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() } - if model.CheckJob != nil { - checkJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) - if err != nil { - return modelMap, err - } - modelMap["check_job"] = []map[string]interface{}{checkJobMap} + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() } - if model.InstallJob != nil { - installJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) + if model.LastApproved != nil { + lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) if err != nil { return modelMap, err } - modelMap["install_job"] = []map[string]interface{}{installJobMap} + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} } - if model.UninstallJob != nil { - uninstallJobMap, err := dataSourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) - if err != nil { - return modelMap, err - } - modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() } - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["href"] = model.Href + definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) + if err != nil { + return modelMap, err } + modelMap["definition"] = []map[string]interface{}{definitionMap} return modelMap, nil } -func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } - modelMap["state"] = model.State - modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID return modelMap, nil } -func dataSourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name + if model.Name != nil { + modelMap["name"] = model.Name + } if model.Description != nil { modelMap["description"] = model.Description } return modelMap, nil } -func dataSourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { +func dataSourceIbmProjectProjectDefinitionPropertiesToMap(model *projectv1.ProjectDefinitionProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Href != nil { - modelMap["href"] = model.Href + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description } + modelMap["destroy_on_delete"] = model.DestroyOnDelete return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 7dc1672fbd..5f5c4ea4e5 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -32,118 +32,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique config ID.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the project configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The input variables for the configuration definition.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "project_config_canonical_id": &schema.Schema{ + "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", @@ -220,432 +109,26 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "check_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "install_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "uninstall_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The Schematics template property.", + Description: "The type and output of a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, "name": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The name of the configuration.", + Description: "The configuration name.", }, "description": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The description of the project configuration.", + Description: "A project configuration description.", }, "labels": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "A collection of configuration labels.", + Description: "The configuration labels.", Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -743,6 +226,38 @@ func DataSourceIbmProjectConfig() *schema.Resource { Schema: map[string]*schema.Schema{}, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The output value object.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, }, }, }, @@ -761,7 +276,7 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD getConfigOptions.SetProjectID(d.Get("project_id").(string)) getConfigOptions.SetID(d.Get("id").(string)) - projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { log.Printf("[DEBUG] GetConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) @@ -769,101 +284,41 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - - if err = d.Set("description", projectConfigCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - - authorizations := []map[string]interface{}{} - if projectConfigCanonical.Authorizations != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) - if err != nil { - return diag.FromErr(err) - } - authorizations = append(authorizations, modelMap) - } - if err = d.Set("authorizations", authorizations); err != nil { - return diag.FromErr(fmt.Errorf("Error setting authorizations %s", err)) - } - - complianceProfile := []map[string]interface{}{} - if projectConfigCanonical.ComplianceProfile != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) - if err != nil { - return diag.FromErr(err) - } - complianceProfile = append(complianceProfile, modelMap) - } - if err = d.Set("compliance_profile", complianceProfile); err != nil { - return diag.FromErr(fmt.Errorf("Error setting compliance_profile %s", err)) - } - - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) - } - - input := []map[string]interface{}{} - if projectConfigCanonical.Input != nil { - modelMap, err := dataSourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) - if err != nil { - return diag.FromErr(err) - } - input = append(input, modelMap) - } - if err = d.Set("input", input); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input %s", err)) - } - - setting := []map[string]interface{}{} - if projectConfigCanonical.Setting != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) - if err != nil { - return diag.FromErr(err) - } - setting = append(setting, modelMap) - } - if err = d.Set("setting", setting); err != nil { - return diag.FromErr(fmt.Errorf("Error setting setting %s", err)) - } - - if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } - if err = d.Set("version", flex.IntValue(projectConfigCanonical.Version)); err != nil { + if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) } - if err = d.Set("is_draft", projectConfigCanonical.IsDraft); err != nil { + if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) } - if err = d.Set("needs_attention_state", projectConfigCanonical.NeedsAttentionState); err != nil { + if err = d.Set("needs_attention_state", projectConfig.NeedsAttentionState); err != nil { return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } - if err = d.Set("state", projectConfigCanonical.State); err != nil { + if err = d.Set("state", projectConfig.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } - if err = d.Set("created_at", flex.DateTimeToString(projectConfigCanonical.CreatedAt)); err != nil { + if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - if err = d.Set("updated_at", flex.DateTimeToString(projectConfigCanonical.UpdatedAt)); err != nil { + if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) } lastApproved := []map[string]interface{}{} - if projectConfigCanonical.LastApproved != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfigCanonical.LastApproved) + if projectConfig.LastApproved != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) if err != nil { return diag.FromErr(err) } @@ -873,101 +328,89 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting last_approved %s", err)) } - if err = d.Set("last_save", flex.DateTimeToString(projectConfigCanonical.LastSave)); err != nil { + if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } - craLogs := []map[string]interface{}{} - if projectConfigCanonical.CraLogs != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) + definition := []map[string]interface{}{} + if projectConfig.Definition != nil { + modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) if err != nil { return diag.FromErr(err) } - craLogs = append(craLogs, modelMap) + definition = append(definition, modelMap) } - if err = d.Set("cra_logs", craLogs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs %s", err)) + if err = d.Set("definition", definition); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) } - costEstimate := []map[string]interface{}{} - if projectConfigCanonical.CostEstimate != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) - if err != nil { - return diag.FromErr(err) - } - costEstimate = append(costEstimate, modelMap) - } - if err = d.Set("cost_estimate", costEstimate); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate %s", err)) + return nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} - checkJob := []map[string]interface{}{} - if projectConfigCanonical.CheckJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) +func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) if err != nil { - return diag.FromErr(err) + return modelMap, err } - checkJob = append(checkJob, modelMap) - } - if err = d.Set("check_job", checkJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting check_job %s", err)) + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - - installJob := []map[string]interface{}{} - if projectConfigCanonical.InstallJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) if err != nil { - return diag.FromErr(err) + return modelMap, err } - installJob = append(installJob, modelMap) + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if err = d.Set("install_job", installJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting install_job %s", err)) + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} } - - uninstallJob := []map[string]interface{}{} - if projectConfigCanonical.UninstallJob != nil { - modelMap, err := dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) + if model.Setting != nil { + settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) if err != nil { - return diag.FromErr(err) + return modelMap, err } - uninstallJob = append(uninstallJob, modelMap) + modelMap["setting"] = []map[string]interface{}{settingMap} } - if err = d.Set("uninstall_job", uninstallJob); err != nil { - return diag.FromErr(fmt.Errorf("Error setting uninstall_job %s", err)) + if model.Type != nil { + modelMap["type"] = model.Type } - - output := []map[string]interface{}{} - if projectConfigCanonical.Output != nil { - for _, modelItem := range projectConfigCanonical.Output { - modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) if err != nil { - return diag.FromErr(err) + return modelMap, err } - output = append(output, modelMap) - } - } - if err = d.Set("output", output); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output %s", err)) - } - - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - - definition := []map[string]interface{}{} - if projectConfigCanonical.Definition != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) - if err != nil { - return diag.FromErr(err) + output = append(output, outputItemMap) } - definition = append(definition, modelMap) - } - if err = d.Set("definition", definition); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition %s", err)) + modelMap["output"] = output } - - return nil + return modelMap, nil } func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { @@ -999,7 +442,7 @@ func dataSourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *proje return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -1029,180 +472,6 @@ func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.Projec return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Summary != nil { - summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name @@ -1210,66 +479,15 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m modelMap["description"] = model.Description } if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) + value := make(map[string]interface{}) + for k, v := range model.Value { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err + value[k] = string(bytes) } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) - if err != nil { - return modelMap, err - } - modelMap["input"] = []map[string]interface{}{inputMap} - } - if model.Setting != nil { - settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} + modelMap["value"] = value } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index a62bec0195..52eb46c2c8 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -7,116 +7,48 @@ import ( "fmt" "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" ) func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { - projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigCanonicalLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalName, projectConfigCanonicalLocatorID), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.locator_id"), - ), - }, - }, - }) -} - -func TestAccIbmProjectConfigDataSourceAllArgs(t *testing.T) { - projectConfigCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectConfigCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectConfigCanonicalLocatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") - resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID), + Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_canonical_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "needs_attention_state.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "last_approved.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "authorizations.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "compliance_profile.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "input.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "setting.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "output.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.description"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.0.locator_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "definition.#"), ), }, }, }) } -func testAccCheckIbmProjectConfigDataSourceConfigBasic(projectConfigCanonicalName string, projectConfigCanonicalLocatorID string) string { - return fmt.Sprintf(` - resource "ibm_project" "project_instance" { - resource_group = "Default" - location = "us-south" - name = "acme-microservice" - } - - resource "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - name = "%s" - locator_id = "%s" - } - - data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_canonical_id - } - `, projectConfigCanonicalName, projectConfigCanonicalLocatorID) -} - -func testAccCheckIbmProjectConfigDataSourceConfig(projectConfigCanonicalName string, projectConfigCanonicalDescription string, projectConfigCanonicalLocatorID string) string { +func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - name = "%s" - labels = [ "labels" ] - description = "%s" - authorizations { - method = "API_KEY" - api_key = "" - } - locator_id = "%s" } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_canonical_id + project_id = ibm_project_config.project_config.project_id + id = ibm_project_config.project_config_instance.projectConfig_id } - `, projectConfigCanonicalName, projectConfigCanonicalDescription, projectConfigCanonicalLocatorID) + `) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index d5f3530bdd..9d20654b59 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -14,88 +14,34 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectCanonicalResourceGroup := fmt.Sprintf("Default") - projectCanonicalLocation := fmt.Sprintf("us-south") - projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName), + Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project", "definition.#"), ), }, }, }) } -func TestAccIbmProjectDataSourceAllArgs(t *testing.T) { - projectCanonicalResourceGroup := fmt.Sprintf("Default") - projectCanonicalLocation := fmt.Sprintf("us-south") - projectCanonicalName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - projectCanonicalDescription := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - projectCanonicalDestroyOnDelete := "true" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.name"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.0.description"), - resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "destroy_on_delete"), - ), - }, - }, - }) -} - -func testAccCheckIbmProjectDataSourceConfigBasic(projectCanonicalResourceGroup string, projectCanonicalLocation string, projectCanonicalName string) string { - return fmt.Sprintf(` - resource "ibm_project" "project_instance" { - resource_group = "%s" - location = "%s" - name = "%s" - } - - data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id - } - `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName) -} - -func testAccCheckIbmProjectDataSourceConfig(projectCanonicalResourceGroup string, projectCanonicalLocation string, projectCanonicalName string, projectCanonicalDescription string, projectCanonicalDestroyOnDelete string) string { +func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, projectLocation string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "%s" location = "%s" - name = "%s" - description = "%s" - destroy_on_delete = %s } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.project_id } - `, projectCanonicalResourceGroup, projectCanonicalLocation, projectCanonicalName, projectCanonicalDescription, projectCanonicalDestroyOnDelete) + `, projectResourceGroup, projectLocation) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index bd1e38f21d..c46e3493af 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -39,207 +39,27 @@ func ResourceIbmProject() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_project", "location"), Description: "The location where the project's data and tools are created.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "name"), - Description: "The name of the project.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "description"), - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", - }, - "destroy_on_delete": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", - }, - "configs": &schema.Schema{ + "definition": &schema.Schema{ Type: schema.TypeList, + MaxItems: 1, Optional: true, - Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", + Description: "The definition of the project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", + Required: true, + Description: "The name of the project.", }, - "project_id": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The unique ID.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Description: "The version of the configuration.", + Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", }, - "is_draft": &schema.Schema{ + "destroy_on_delete": &schema.Schema{ Type: schema.TypeBool, - Optional: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The state of the configuration.", - }, - "approved_version": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The project configuration version.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The state of the configuration.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - }, - }, - }, - "installed_version": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The project configuration version.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The state of the configuration.", - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "The version number of the configuration.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - }, - }, - }, - "definition": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The project configuration definition summary.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The description of the project configuration.", - }, - }, - }, - }, - "check_job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - }, - }, - }, - "install_job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - }, - }, - }, - "uninstall_job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - }, - }, - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", + Required: true, + Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", }, }, }, @@ -298,27 +118,119 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "The CRN of the event notifications instance if one is connected to this project.", }, - "definition": &schema.Schema{ + "configs": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The definition of the project.", + Description: "The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "id": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The name of the project.", + Required: true, + Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", }, - "description": &schema.Schema{ + "project_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description.", + Required: true, + Description: "The unique ID.", }, - "destroy_on_delete": &schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Default: true, - Description: "The policy that indicates whether the resources are destroyed or not when a project is deleted.", + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + // MaxItems: 1, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, + }, + }, + }, + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A relative URL.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The name and description of a project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The configuration name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A project configuration description.", + }, + }, + }, }, }, }, @@ -348,24 +260,6 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { MinValueLength: 0, MaxValueLength: 12, }, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]+$`, - MinValueLength: 1, - MaxValueLength: 64, - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, - }, ) resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project", Schema: validateSchema} @@ -382,20 +276,18 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) createProjectOptions.SetLocation(d.Get("location").(string)) - if _, ok := d.GetOk("name"); ok { - createProjectOptions.SetName(d.Get("name").(string)) - } - if _, ok := d.GetOk("description"); ok { - createProjectOptions.SetDescription(d.Get("description").(string)) - } - if _, ok := d.GetOk("destroy_on_delete"); ok { - createProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) + if _, ok := d.GetOk("definition"); ok { + definitionModel, err := resourceIbmProjectMapToProjectPrototypeDefinition(d.Get("definition.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createProjectOptions.SetDefinition(definitionModel) } if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigTerraform + var configs []projectv1.ProjectConfigPrototype for _, v := range d.Get("configs").([]interface{}) { value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) + configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) if err != nil { return diag.FromErr(err) } @@ -404,13 +296,13 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetConfigs(configs) } - projectCanonical, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) + project, response, err := projectClient.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)) } - d.SetId(*projectCanonical.ID) + d.SetId(*project.ID) return resourceIbmProjectRead(context, d, meta) } @@ -425,7 +317,7 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met getProjectOptions.SetID(d.Id()) - projectCanonical, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) + project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -435,53 +327,34 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } - if err = d.Set("resource_group", projectCanonical.ResourceGroup); err != nil { + if err = d.Set("resource_group", project.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if err = d.Set("location", projectCanonical.Location); err != nil { + if err = d.Set("location", project.Location); err != nil { return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) } - if !core.IsNil(projectCanonical.Name) { - if err = d.Set("name", projectCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - } - if !core.IsNil(projectCanonical.Description) { - if err = d.Set("description", projectCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - } - if !core.IsNil(projectCanonical.DestroyOnDelete) { - if err = d.Set("destroy_on_delete", projectCanonical.DestroyOnDelete); err != nil { - return diag.FromErr(fmt.Errorf("Error setting destroy_on_delete: %s", err)) - } - } - if !core.IsNil(projectCanonical.Configs) { - configs := []map[string]interface{}{} - for _, configsItem := range projectCanonical.Configs { - configsItemMap, err := resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(&configsItem) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, configsItemMap) + if !core.IsNil(project.Definition) { + definitionMap, err := resourceIbmProjectProjectDefinitionPropertiesToMap(project.Definition) + if err != nil { + return diag.FromErr(err) } - if err = d.Set("configs", configs); err != nil { - return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } } - if !core.IsNil(projectCanonical.Crn) { - if err = d.Set("crn", projectCanonical.Crn); err != nil { + if !core.IsNil(project.Crn) { + if err = d.Set("crn", project.Crn); err != nil { return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } } - if !core.IsNil(projectCanonical.CreatedAt) { - if err = d.Set("created_at", flex.DateTimeToString(projectCanonical.CreatedAt)); err != nil { + if !core.IsNil(project.CreatedAt) { + if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } } - if !core.IsNil(projectCanonical.CumulativeNeedsAttentionView) { + if !core.IsNil(project.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} - for _, cumulativeNeedsAttentionViewItem := range projectCanonical.CumulativeNeedsAttentionView { + for _, cumulativeNeedsAttentionViewItem := range project.CumulativeNeedsAttentionView { cumulativeNeedsAttentionViewItemMap, err := resourceIbmProjectCumulativeNeedsAttentionToMap(&cumulativeNeedsAttentionViewItem) if err != nil { return diag.FromErr(err) @@ -492,28 +365,32 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view: %s", err)) } } - if !core.IsNil(projectCanonical.CumulativeNeedsAttentionViewError) { - if err = d.Set("cumulative_needs_attention_view_error", projectCanonical.CumulativeNeedsAttentionViewError); err != nil { + if !core.IsNil(project.CumulativeNeedsAttentionViewError) { + if err = d.Set("cumulative_needs_attention_view_error", project.CumulativeNeedsAttentionViewError); err != nil { return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if !core.IsNil(projectCanonical.State) { - if err = d.Set("state", projectCanonical.State); err != nil { + if !core.IsNil(project.State) { + if err = d.Set("state", project.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } } - if !core.IsNil(projectCanonical.EventNotificationsCrn) { - if err = d.Set("event_notifications_crn", projectCanonical.EventNotificationsCrn); err != nil { + if !core.IsNil(project.EventNotificationsCrn) { + if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) } } - if !core.IsNil(projectCanonical.Definition) { - definitionMap, err := resourceIbmProjectProjectDefinitionTerraformToMap(projectCanonical.Definition) - if err != nil { - return diag.FromErr(err) + if !core.IsNil(project.Configs) { + configs := []map[string]interface{}{} + for _, configsItem := range project.Configs { + configsItemMap, err := resourceIbmProjectProjectConfigCollectionMemberToMap(&configsItem) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, configsItemMap) } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) + if err = d.Set("configs", configs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } @@ -532,29 +409,12 @@ func resourceIbmProjectUpdate(context context.Context, d *schema.ResourceData, m hasChange := false - if d.HasChange("name") { - updateProjectOptions.SetName(d.Get("name").(string)) - hasChange = true - } - if d.HasChange("description") { - updateProjectOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } - if d.HasChange("destroy_on_delete") { - updateProjectOptions.SetDestroyOnDelete(d.Get("destroy_on_delete").(bool)) - hasChange = true - } - if d.HasChange("configs") { - var configs []projectv1.ProjectConfigTerraform - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigTerraform(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) + if d.HasChange("definition") { + definition, err := resourceIbmProjectMapToProjectPrototypePatchDefinitionBlock(d.Get("definition.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } - updateProjectOptions.SetConfigs(configs) + updateProjectOptions.SetDefinition(definition) hasChange = true } @@ -590,11 +450,33 @@ func resourceIbmProjectDelete(context context.Context, d *schema.ResourceData, m return nil } -func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface{}) (*projectv1.ProjectConfigTerraform, error) { - model := &projectv1.ProjectConfigTerraform{} - if modelMap["name"] != nil && modelMap["name"].(string) != "" { - model.Name = core.StringPtr(modelMap["name"].(string)) +func resourceIbmProjectMapToProjectPrototypeDefinition(modelMap map[string]interface{}) (*projectv1.ProjectPrototypeDefinition, error) { + model := &projectv1.ProjectPrototypeDefinition{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["destroy_on_delete"] != nil { + model.DestroyOnDelete = core.BoolPtr(modelMap["destroy_on_delete"].(bool)) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { + model := &projectv1.ProjectConfigPrototype{} + if modelMap["definition"] != nil && len(modelMap["definition"].([]interface{})) > 0 { + DefinitionModel, err := resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap["definition"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Definition = DefinitionModel } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlock, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlock{} + model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["description"] != nil && modelMap["description"].(string) != "" { model.Description = core.StringPtr(modelMap["description"].(string)) } @@ -613,15 +495,13 @@ func resourceIbmProjectMapToProjectConfigTerraform(modelMap map[string]interface model.Authorizations = AuthorizationsModel } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { - ComplianceProfileModel, err := resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } model.ComplianceProfile = ComplianceProfileModel } - if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) - } + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -668,8 +548,8 @@ func resourceIbmProjectMapToProjectConfigAuthTrustedProfile(modelMap map[string] return model, nil } -func resourceIbmProjectMapToProjectConfigComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigComplianceProfile, error) { - model := &projectv1.ProjectConfigComplianceProfile{} +func resourceIbmProjectMapToProjectComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectComplianceProfile, error) { + model := &projectv1.ProjectComplianceProfile{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { model.ID = core.StringPtr(modelMap["id"].(string)) } @@ -698,104 +578,27 @@ func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{} return model, nil } -func resourceIbmProjectProjectConfigCollectionMemberTerraformToMap(model *projectv1.ProjectConfigCollectionMemberTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.ProjectID != nil { - modelMap["project_id"] = model.ProjectID - } - if model.Version != nil { - modelMap["version"] = flex.IntValue(model.Version) - } - if model.IsDraft != nil { - modelMap["is_draft"] = model.IsDraft - } - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } - if model.State != nil { - modelMap["state"] = model.State - } - if model.ApprovedVersion != nil { - approvedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) - if err != nil { - return modelMap, err - } - modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} - } - if model.InstalledVersion != nil { - installedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.InstalledVersion) - if err != nil { - return modelMap, err - } - modelMap["installed_version"] = []map[string]interface{}{installedVersionMap} - } - if model.Definition != nil { - definitionMap, err := resourceIbmProjectProjectConfigDefinitionSummaryToMap(model.Definition) - if err != nil { - return modelMap, err - } - modelMap["definition"] = []map[string]interface{}{definitionMap} - } - if model.CheckJob != nil { - checkJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.CheckJob) - if err != nil { - return modelMap, err - } - modelMap["check_job"] = []map[string]interface{}{checkJobMap} - } - if model.InstallJob != nil { - installJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.InstallJob) - if err != nil { - return modelMap, err - } - modelMap["install_job"] = []map[string]interface{}{installJobMap} - } - if model.UninstallJob != nil { - uninstallJobMap, err := resourceIbmProjectActionJobWithIdAndHrefToMap(model.UninstallJob) - if err != nil { - return modelMap, err - } - modelMap["uninstall_job"] = []map[string]interface{}{uninstallJobMap} +func resourceIbmProjectMapToProjectPrototypePatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectPrototypePatchDefinitionBlock, error) { + model := &projectv1.ProjectPrototypePatchDefinitionBlock{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) } - if model.Href != nil { - modelMap["href"] = model.Href + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState + if modelMap["destroy_on_delete"] != nil { + model.DestroyOnDelete = core.BoolPtr(modelMap["destroy_on_delete"].(bool)) } - modelMap["state"] = model.State - modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil + return model, nil } -func resourceIbmProjectProjectConfigDefinitionSummaryToMap(model *projectv1.ProjectConfigDefinitionSummary) (map[string]interface{}, error) { +func resourceIbmProjectProjectDefinitionPropertiesToMap(model *projectv1.ProjectDefinitionProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Description != nil { modelMap["description"] = model.Description } - return modelMap, nil -} - -func resourceIbmProjectActionJobWithIdAndHrefToMap(model *projectv1.ActionJobWithIdAndHref) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Href != nil { - modelMap["href"] = model.Href - } + modelMap["destroy_on_delete"] = model.DestroyOnDelete return modelMap, nil } @@ -816,7 +619,54 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative return modelMap, nil } -func resourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectDefinitionTerraform) (map[string]interface{}, error) { +func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.ProjectConfigCollectionMember) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["project_id"] = model.ProjectID + modelMap["version"] = flex.IntValue(model.Version) + modelMap["is_draft"] = model.IsDraft + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + modelMap["state"] = model.State + modelMap["update_available"] = model.UpdateAvailable + if model.CreatedAt != nil { + modelMap["created_at"] = model.CreatedAt.String() + } + if model.UpdatedAt != nil { + modelMap["updated_at"] = model.UpdatedAt.String() + } + if model.LastApproved != nil { + lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) + if err != nil { + return modelMap, err + } + modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} + } + if model.LastSave != nil { + modelMap["last_save"] = model.LastSave.String() + } + modelMap["href"] = model.Href + definitionMap, err := resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment + } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID + return modelMap, nil +} + +func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { modelMap["name"] = model.Name @@ -824,8 +674,5 @@ func resourceIbmProjectProjectDefinitionTerraformToMap(model *projectv1.ProjectD if model.Description != nil { modelMap["description"] = model.Description } - if model.DestroyOnDelete != nil { - modelMap["destroy_on_delete"] = model.DestroyOnDelete - } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f938bdb91c..448afc7655 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -35,578 +35,27 @@ func ResourceIbmProjectConfig() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), Description: "The unique project ID.", }, - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_project_config", "name"), - Description: "The name of the configuration.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "description"), - Description: "The description of the project configuration.", - }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "A collection of configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "authorizations": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, - }, - "method": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", - }, - "api_key": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The IBM Cloud API Key.", - }, - }, - }, - }, - "compliance_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The profile required for compliance.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "instance_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "instance_location": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The location of the compliance instance.", - }, - "attachment_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "profile_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The name of the compliance profile.", - }, - }, - }, - }, - "locator_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - // ValidateFunc: validate.InvokeValidator("ibm_project_config", "locator_id"), - Description: "A dotted value of catalogID.versionID.", - }, - "input": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The input variables for the configuration definition.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "setting": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "version": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The version of the configuration.", - }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID.", - }, - }, - }, - }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, - }, - "check_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "install_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "uninstall_job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of a project configuration manual property.", - }, "definition": &schema.Schema{ Type: schema.TypeList, - Computed: true, - Description: "The Schematics template property.", + MaxItems: 1, + Optional: true, + Description: "The type and output of a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "output": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The type of a project configuration manual property.", - }, "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, - Description: "The name of the configuration.", + Required: true, + Description: "The configuration name.", }, "description": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The description of the project configuration.", + Description: "A project configuration description.", }, "labels": &schema.Schema{ Type: schema.TypeList, Optional: true, - Description: "A collection of configuration labels.", + Description: "The configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, "authorizations": &schema.Schema{ @@ -686,7 +135,7 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ @@ -707,10 +156,111 @@ func ResourceIbmProjectConfig() *schema.Resource { Schema: map[string]*schema.Schema{}, }, }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The type of a project configuration manual property.", + }, + "output": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The output value object.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + "version": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The version of the configuration.", + }, + "is_draft": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether the version of the configuration is draft, or active.", + }, + "needs_attention_state": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The needs attention state of a configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "last_approved": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The last approved metadata of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_forced": &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "The flag that indicates whether the approval was forced approved.", + }, + "comment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: "The comment left by the user who approved the configuration.", + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, }, }, }, - "project_config_canonical_id": &schema.Schema{ + "last_save": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", @@ -730,33 +280,6 @@ func ResourceIbmProjectConfigValidator() *validate.ResourceValidator { Regexp: `^[\.\-0-9a-zA-Z]+$`, MaxValueLength: 128, }, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$`, - MinValueLength: 1, - MaxValueLength: 64, - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^$|^(?!\s).*\S$`, - MinValueLength: 0, - MaxValueLength: 1024, - }, - validate.ValidateSchema{ - Identifier: "locator_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^(?!\s)(?!.*\s$)[\.0-9a-z-A-Z_-]+$`, - MinValueLength: 1, - MaxValueLength: 512, - }, ) resourceValidator := validate.ResourceValidator{ResourceName: "ibm_project_config", Schema: validateSchema} @@ -772,59 +295,21 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions := &projectv1.CreateConfigOptions{} createConfigOptions.SetProjectID(d.Get("project_id").(string)) - if _, ok := d.GetOk("name"); ok { - createConfigOptions.SetName(d.Get("name").(string)) - } - if _, ok := d.GetOk("description"); ok { - createConfigOptions.SetDescription(d.Get("description").(string)) - } - if _, ok := d.GetOk("labels"); ok { - var labels []string - for _, v := range d.Get("labels").([]interface{}) { - labelsItem := v.(string) - labels = append(labels, labelsItem) - } - createConfigOptions.SetLabels(labels) - } - if _, ok := d.GetOk("authorizations"); ok { - authorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createConfigOptions.SetAuthorizations(authorizationsModel) - } - if _, ok := d.GetOk("compliance_profile"); ok { - complianceProfileModel, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createConfigOptions.SetComplianceProfile(complianceProfileModel) - } - if _, ok := d.GetOk("locator_id"); ok { - createConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - } - if _, ok := d.GetOk("input"); ok { - inputModel, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createConfigOptions.SetInput(inputModel) - } - if _, ok := d.GetOk("setting"); ok { - settingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if _, ok := d.GetOk("definition"); ok { + definitionModel, err := resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(d.Get("definition.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } - createConfigOptions.SetSetting(settingModel) + createConfigOptions.SetDefinition(definitionModel) } - projectConfigCanonical, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) + projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { log.Printf("[DEBUG] CreateConfigWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("CreateConfigWithContext failed %s\n%s", err, response)) } - d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfigCanonical.ID)) + d.SetId(fmt.Sprintf("%s/%s", *createConfigOptions.ProjectID, *projectConfig.ID)) return resourceIbmProjectConfigRead(context, d, meta) } @@ -845,7 +330,7 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - projectConfigCanonical, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) + projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { if response != nil && response.StatusCode == 404 { d.SetId("") @@ -855,106 +340,51 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) } - if err = d.Set("project_id", projectConfigCanonical.ProjectID); err != nil { + if err = d.Set("project_id", projectConfig.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if !core.IsNil(projectConfigCanonical.Name) { - if err = d.Set("name", projectConfigCanonical.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Description) { - if err = d.Set("description", projectConfigCanonical.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Labels) { - if err = d.Set("labels", projectConfigCanonical.Labels); err != nil { - return diag.FromErr(fmt.Errorf("Error setting labels: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Authorizations) { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(projectConfigCanonical.Authorizations) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("authorizations", []map[string]interface{}{authorizationsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting authorizations: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.ComplianceProfile) { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(projectConfigCanonical.ComplianceProfile) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("compliance_profile", []map[string]interface{}{complianceProfileMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting compliance_profile: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.LocatorID) { - if err = d.Set("locator_id", projectConfigCanonical.LocatorID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting locator_id: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Input) { - inputMap, err := resourceIbmProjectConfigInputVariableToMap(projectConfigCanonical.Input) + if !core.IsNil(projectConfig.Definition) { + definitionMap, err := resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) if err != nil { return diag.FromErr(err) } - if err = d.Set("input", []map[string]interface{}{inputMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting input: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Setting) { - settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(projectConfigCanonical.Setting) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("setting", []map[string]interface{}{settingMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting setting: %s", err)) + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } } - if !core.IsNil(projectConfigCanonical.Version) { - if err = d.Set("version", flex.IntValue(projectConfigCanonical.Version)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) - } + if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) } - if !core.IsNil(projectConfigCanonical.IsDraft) { - if err = d.Set("is_draft", projectConfigCanonical.IsDraft); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) - } + if err = d.Set("is_draft", projectConfig.IsDraft); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) } - if !core.IsNil(projectConfigCanonical.NeedsAttentionState) { + if !core.IsNil(projectConfig.NeedsAttentionState) { needsAttentionState := []interface{}{} - for _, needsAttentionStateItem := range projectConfigCanonical.NeedsAttentionState { + for _, needsAttentionStateItem := range projectConfig.NeedsAttentionState { needsAttentionState = append(needsAttentionState, needsAttentionStateItem) } if err = d.Set("needs_attention_state", needsAttentionState); err != nil { return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } } - if !core.IsNil(projectConfigCanonical.State) { - if err = d.Set("state", projectConfigCanonical.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } + if err = d.Set("state", projectConfig.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if !core.IsNil(projectConfigCanonical.UpdateAvailable) { - if err = d.Set("update_available", projectConfigCanonical.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) - } + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } - if !core.IsNil(projectConfigCanonical.CreatedAt) { - if err = d.Set("created_at", flex.DateTimeToString(projectConfigCanonical.CreatedAt)); err != nil { + if !core.IsNil(projectConfig.CreatedAt) { + if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } } - if !core.IsNil(projectConfigCanonical.UpdatedAt) { - if err = d.Set("updated_at", flex.DateTimeToString(projectConfigCanonical.UpdatedAt)); err != nil { + if !core.IsNil(projectConfig.UpdatedAt) { + if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) } } - if !core.IsNil(projectConfigCanonical.LastApproved) { - lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfigCanonical.LastApproved) + if !core.IsNil(projectConfig.LastApproved) { + lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) if err != nil { return diag.FromErr(err) } @@ -962,87 +392,13 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) } } - if !core.IsNil(projectConfigCanonical.LastSave) { - if err = d.Set("last_save", flex.DateTimeToString(projectConfigCanonical.LastSave)); err != nil { + if !core.IsNil(projectConfig.LastSave) { + if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfigCanonical.CraLogs) { - craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(projectConfigCanonical.CraLogs) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("cra_logs", []map[string]interface{}{craLogsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cra_logs: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.CostEstimate) { - costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(projectConfigCanonical.CostEstimate) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("cost_estimate", []map[string]interface{}{costEstimateMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cost_estimate: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.CheckJob) { - checkJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.CheckJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("check_job", []map[string]interface{}{checkJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting check_job: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.InstallJob) { - installJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.InstallJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("install_job", []map[string]interface{}{installJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting install_job: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.UninstallJob) { - uninstallJobMap, err := resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(projectConfigCanonical.UninstallJob) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("uninstall_job", []map[string]interface{}{uninstallJobMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting uninstall_job: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Output) { - output := []map[string]interface{}{} - for _, outputItem := range projectConfigCanonical.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) - if err != nil { - return diag.FromErr(err) - } - output = append(output, outputItemMap) - } - if err = d.Set("output", output); err != nil { - return diag.FromErr(fmt.Errorf("Error setting output: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Type) { - if err = d.Set("type", projectConfigCanonical.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.Definition) { - definitionMap, err := resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(projectConfigCanonical.Definition) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) - } - } - if !core.IsNil(projectConfigCanonical.ID) { - if err = d.Set("project_config_canonical_id", projectConfigCanonical.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_canonical_id: %s", err)) - } + if err = d.Set("project_config_id", projectConfig.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } return nil @@ -1067,60 +423,15 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false 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") { - updateConfigOptions.SetName(d.Get("name").(string)) - hasChange = true - } - if d.HasChange("description") { - updateConfigOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } - if d.HasChange("labels") { - var labels []string - for _, v := range d.Get("labels").([]interface{}) { - labelsItem := v.(string) - labels = append(labels, labelsItem) - } - updateConfigOptions.SetLabels(labels) - hasChange = true - } - if d.HasChange("authorizations") { - authorizations, err := resourceIbmProjectConfigMapToProjectConfigAuth(d.Get("authorizations.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetAuthorizations(authorizations) - hasChange = true - } - if d.HasChange("compliance_profile") { - complianceProfile, err := resourceIbmProjectConfigMapToProjectConfigComplianceProfile(d.Get("compliance_profile.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetComplianceProfile(complianceProfile) - hasChange = true - } - if d.HasChange("locator_id") { - updateConfigOptions.SetLocatorID(d.Get("locator_id").(string)) - hasChange = true - } - if d.HasChange("input") { - input, err := resourceIbmProjectConfigMapToInputVariable(d.Get("input.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - updateConfigOptions.SetInput(input) - hasChange = true + 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("setting") { - setting, err := resourceIbmProjectConfigMapToProjectConfigSetting(d.Get("setting.0").(map[string]interface{})) + if d.HasChange("definition") { + definition, err := resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(d.Get("definition.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } - updateConfigOptions.SetSetting(setting) + updateConfigOptions.SetDefinition(definition) hasChange = true } @@ -1162,6 +473,51 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return nil } +func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlock, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlock{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["labels"] != nil { + labels := []string{} + for _, labelsItem := range modelMap["labels"].([]interface{}) { + labels = append(labels, labelsItem.(string)) + } + model.Labels = labels + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { + InputModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Input = InputModel + } + if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { + SettingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Setting = SettingModel + } + return model, nil +} + func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { @@ -1191,8 +547,8 @@ func resourceIbmProjectConfigMapToProjectConfigAuthTrustedProfile(modelMap map[s return model, nil } -func resourceIbmProjectConfigMapToProjectConfigComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigComplianceProfile, error) { - model := &projectv1.ProjectConfigComplianceProfile{} +func resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectComplianceProfile, error) { + model := &projectv1.ProjectComplianceProfile{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { model.ID = core.StringPtr(modelMap["id"].(string)) } @@ -1221,6 +577,110 @@ func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]inter return model, nil } +func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypePatchDefinitionBlock, error) { + model := &projectv1.ProjectConfigPrototypePatchDefinitionBlock{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["labels"] != nil { + labels := []string{} + for _, labelsItem := range modelMap["labels"].([]interface{}) { + labels = append(labels, labelsItem.(string)) + } + model.Labels = labels + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { + InputModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Input = InputModel + } + if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { + SettingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Setting = SettingModel + } + return model, nil +} + +func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Labels != nil { + modelMap["labels"] = model.Labels + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + modelMap["locator_id"] = model.LocatorID + if model.Input != nil { + inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) + if err != nil { + return modelMap, err + } + modelMap["input"] = []map[string]interface{}{inputMap} + } + if model.Setting != nil { + settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if err != nil { + return modelMap, err + } + modelMap["setting"] = []map[string]interface{}{settingMap} + } + if model.Type != nil { + modelMap["type"] = model.Type + } + if model.Output != nil { + output := []map[string]interface{}{} + for _, outputItem := range model.Output { + outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + if err != nil { + return modelMap, err + } + output = append(output, outputItemMap) + } + modelMap["output"] = output + } + return modelMap, nil +} + func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.TrustedProfile != nil { @@ -1250,7 +710,7 @@ func resourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *project return modelMap, nil } -func resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model *projectv1.ProjectConfigComplianceProfile) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -1280,180 +740,6 @@ func resourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectC return modelMap, nil } -func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func resourceIbmProjectConfigActionJobWithSummaryAndHrefToMap(model *projectv1.ActionJobWithSummaryAndHref) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Summary != nil { - summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name @@ -1461,66 +747,26 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map modelMap["description"] = model.Description } if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigDefinitionResponseTerraformToMap(model *projectv1.ProjectConfigDefinitionResponseTerraform) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) + value := make(map[string]interface{}) + for k, v := range model.Value { + bytes, err := json.Marshal(v) if err != nil { return modelMap, err } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } - if model.Authorizations != nil { - authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) - if err != nil { - return modelMap, err - } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectConfigProjectConfigComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - if model.LocatorID != nil { - modelMap["locator_id"] = model.LocatorID - } - if model.Input != nil { - inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) - if err != nil { - return modelMap, err + value[k] = string(bytes) } - modelMap["input"] = []map[string]interface{}{inputMap} + modelMap["value"] = value } - if model.Setting != nil { - settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) - if err != nil { - return modelMap, err - } - modelMap["setting"] = []map[string]interface{}{settingMap} + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["is_forced"] = model.IsForced + if model.Comment != nil { + modelMap["comment"] = model.Comment } + modelMap["timestamp"] = model.Timestamp.String() + modelMap["user_id"] = model.UserID return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index ea4b5b0eb1..3928a21bd1 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -7,7 +7,6 @@ import ( "fmt" "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" @@ -18,11 +17,7 @@ import ( ) func TestAccIbmProjectConfigBasic(t *testing.T) { - var conf projectv1.ProjectConfigCanonical - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") + var conf projectv1.ProjectConfig resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -30,57 +25,13 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { CheckDestroy: testAccCheckIbmProjectConfigDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(name, locatorID), + Config: testAccCheckIbmProjectConfigConfigBasic(), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfigBasic(nameUpdate, locatorIDUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorIDUpdate), - ), - }, - }, - }) -} - -func TestAccIbmProjectConfigAllArgs(t *testing.T) { - var conf projectv1.ProjectConfigCanonical - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorID := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - locatorIDUpdate := fmt.Sprintf("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmProjectConfigDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(name, description, locatorID), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", description), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorID), - ), - }, - resource.TestStep{ - Config: testAccCheckIbmProjectConfigConfig(nameUpdate, descriptionUpdate, locatorIDUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project_config.project_config_instance", "locator_id", locatorIDUpdate), - ), - }, - resource.TestStep{ - ResourceName: "ibm_project_config.project_config_instance", + ResourceName: "ibm_project_config.project_config", ImportState: true, ImportStateVerify: true, }, @@ -88,45 +39,19 @@ func TestAccIbmProjectConfigAllArgs(t *testing.T) { }) } -func testAccCheckIbmProjectConfigConfigBasic(name string, locatorID string) string { +func testAccCheckIbmProjectConfigConfigBasic() string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" - name = "acme-microservice" } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - name = "%s" - locator_id = "%s" - } - `, name, locatorID) -} - -func testAccCheckIbmProjectConfigConfig(name string, description string, locatorID string) string { - return fmt.Sprintf(` - - resource "ibm_project" "project_instance" { - resource_group = "Default" - location = "us-south" - name = "acme-microservice" - } - - resource "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - name = "%s" - labels = [ "labels" ] - description = "%s" - authorizations { - method = "API_KEY" - api_key = "" - } - locator_id = "%s" } - `, name, description, locatorID) + `) } -func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigCanonical) resource.TestCheckFunc { +func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -149,12 +74,12 @@ func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfigCan getConfigOptions.SetProjectID(parts[0]) getConfigOptions.SetID(parts[1]) - projectConfigCanonical, _, err := projectClient.GetConfig(getConfigOptions) + projectConfig, _, err := projectClient.GetConfig(getConfigOptions) if err != nil { return err } - obj = *projectConfigCanonical + obj = *projectConfig return nil } } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 1e17abdf47..3818e1160f 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -17,13 +17,11 @@ import ( ) func TestAccIbmProjectBasic(t *testing.T) { - var conf projectv1.ProjectCanonical - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("Default") - locationUpdate := fmt.Sprintf("us-south") - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + var conf projectv1.Project + resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) + locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -31,100 +29,39 @@ func TestAccIbmProjectBasic(t *testing.T) { CheckDestroy: testAccCheckIbmProjectDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location, name), + Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), + testAccCheckIbmProjectExists("ibm_project.project", conf), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project", "location", location), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate, nameUpdate), + Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", nameUpdate), - ), - }, - }, - }) -} - -func TestAccIbmProjectAllArgs(t *testing.T) { - var conf projectv1.ProjectCanonical - resourceGroup := fmt.Sprintf("Default") - location := fmt.Sprintf("us-south") - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - destroyOnDelete := "true" - resourceGroupUpdate := fmt.Sprintf("Default") - locationUpdate := fmt.Sprintf("us-south") - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - destroyOnDeleteUpdate := "true" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmProjectDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIbmProjectConfig(resourceGroup, location, name, description, destroyOnDelete), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", name), - resource.TestCheckResourceAttr("ibm_project.project_instance", "description", description), - resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDelete), + resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), ), }, resource.TestStep{ - Config: testAccCheckIbmProjectConfig(resourceGroupUpdate, locationUpdate, nameUpdate, descriptionUpdate, destroyOnDeleteUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "destroy_on_delete", destroyOnDeleteUpdate), - ), - }, - resource.TestStep{ - ResourceName: "ibm_project.project_instance", - ImportState: true, - ImportStateVerifyIgnore: []string{ - "configs", - }, + ResourceName: "ibm_project.project", + ImportState: true, + ImportStateVerify: true, }, }, }) } -func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string, name string) string { +func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { resource_group = "%s" location = "%s" - name = "%s" - } - `, resourceGroup, location, name) -} - -func testAccCheckIbmProjectConfig(resourceGroup string, location string, name string, description string, destroyOnDelete string) string { - return fmt.Sprintf(` - - resource "ibm_project" "project_instance" { - resource_group = "%s" - location = "%s" - name = "%s" - description = "%s" - destroy_on_delete = %s } - `, resourceGroup, location, name, description, destroyOnDelete) + `, resourceGroup, location) } -func testAccCheckIbmProjectExists(n string, obj projectv1.ProjectCanonical) resource.TestCheckFunc { +func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -141,12 +78,12 @@ func testAccCheckIbmProjectExists(n string, obj projectv1.ProjectCanonical) reso getProjectOptions.SetID(rs.Primary.ID) - projectCanonical, _, err := projectClient.GetProject(getProjectOptions) + project, _, err := projectClient.GetProject(getProjectOptions) if err != nil { return err } - obj = *projectCanonical + obj = *project return nil } } diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index c8910ffbe0..425dea3787 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project. You ca ```hcl data "ibm_project" "project" { - id = ibm_project.project_instance.id + id = ibm_project.project_instance.project_id } ``` @@ -33,59 +33,35 @@ After your data source is created, you can read values from the following attrib * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: - * `approved_version` - (List) The project configuration version. - Nested schema for **approved_version**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Integer) The version number of the configuration. - * `check_job` - (List) The action job performed on the project configuration. - Nested schema for **check_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `definition` - (List) The project configuration definition summary. + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The name and description of a project configuration. Nested schema for **definition**: - * `description` - (String) The description of the project configuration. + * `description` - (String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The name of the configuration. + * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `href` - (String) A relative URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `install_job` - (List) The action job performed on the project configuration. - Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `installed_version` - (List) The project configuration version. - Nested schema for **installed_version**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Integer) The version number of the configuration. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `last_approved` - (List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `uninstall_job` - (List) The action job performed on the project configuration. - Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -115,21 +91,12 @@ Nested schema for **definition**: * `name` - (String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. -* `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - -* `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. - * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `location` - (String) The IBM Cloud location where a resource is deployed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. -* `name` - (String) The name of the project. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. - * `resource_group` - (String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index b7261ffc91..88d59593c8 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project_config. ```hcl data "ibm_project_config" "project_config" { - id = ibm_project_config.project_config_instance.project_config_canonical_id + id = ibm_project_config.project_config_instance.project_config_id project_id = ibm_project_config.project_config.project_id } ``` @@ -33,73 +33,9 @@ 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 project_config. -* `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. -Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - -* `check_job` - (List) The action job performed on the project configuration. -Nested schema for **check_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - -* `compliance_profile` - (List) The profile required for compliance. -Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The Schematics template property. +* `definition` - (List) The type and output of a project configuration. Nested schema for **definition**: * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -125,15 +61,15 @@ Nested schema for **definition**: * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. * `profile_name` - (String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The description of the project configuration. + * `description` - (String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `input` - (List) The input variables for the configuration definition. Nested schema for **input**: - * `labels` - (List) A collection of configuration labels. + * `labels` - (List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. + * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. * `output` - (List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. @@ -142,42 +78,18 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `value` - (Map) The output value object. * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `description` - (String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - -* `input` - (List) The input variables for the configuration definition. -Nested schema for **input**: - -* `install_job` - (List) The action job performed on the project configuration. -Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `labels` - (List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID. @@ -185,51 +97,14 @@ Nested schema for **last_approved**: * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `locator_id` - (String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - -* `name` - (String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -* `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - -* `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. +* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. -Nested schema for **setting**: - * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - -* `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. - -* `uninstall_job` - (List) The action job performed on the project configuration. -Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index ae09fcff3a..5a003ce0ef 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,46 +14,12 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { - configs { - id = "id" - project_id = "project_id" - version = 1 - is_draft = true - needs_attention_state = [ "anything as a string" ] - state = "approved" - approved_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" - } - installed_version { - needs_attention_state = [ "anything as a string" ] - state = "approved" - version = 1 - href = "href" - } - definition { - name = "name" - description = "description" - } - check_job { - id = "id" - href = "href" - } - install_job { - id = "id" - href = "href" - } - uninstall_job { - id = "id" - href = "href" - } - href = "href" + definition { + name = "name" + description = "description" + destroy_on_delete = true } - description = "A microservice to deploy on top of ACME infrastructure." location = "us-south" - name = "acme-microservice" resource_group = "Default" } ``` @@ -62,71 +28,16 @@ resource "ibm_project" "project_instance" { You can specify the following arguments for this resource. -* `configs` - (Optional, List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested schema for **configs**: - * `approved_version` - (Optional, List) The project configuration version. - Nested schema for **approved_version**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (Required, String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Required, Integer) The version number of the configuration. - * `check_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **check_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `definition` - (Optional, List) The project configuration definition summary. - Nested schema for **definition**: - * `description` - (Optional, String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `install_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **install_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `installed_version` - (Optional, List) The project configuration version. - Nested schema for **installed_version**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `state` - (Required, String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `version` - (Required, Integer) The version number of the configuration. - * `is_draft` - (Optional, Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `needs_attention_state` - (Optional, List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - * `project_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `state` - (Optional, String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. - * `uninstall_job` - (Optional, List) The action job performed on the project configuration. - Nested schema for **uninstall_job**: - * `href` - (Optional, String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (Optional, Integer) The version of the configuration. -* `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `destroy_on_delete` - (Optional, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. +* `definition` - (Optional, List) The definition of the project. +Nested schema for **definition**: + * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `destroy_on_delete` - (Required, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. + * Constraints: The default value is `true`. + * `name` - (Required, String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `location` - (Required, String) The location where the project's data and tools are created. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. -* `name` - (Optional, String) The name of the project. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. @@ -135,6 +46,39 @@ Nested schema for **configs**: After your resource is created, you can read values from the listed arguments and the following attributes. * `id` - The unique identifier of the project. +* `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **configs**: + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The name and description of a project configuration. + Nested schema for **definition**: + * `description` - (String) A project configuration description. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The configuration name. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. + * `last_approved` - (List) The last approved metadata of the configuration. + Nested schema for **last_approved**: + * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. + * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `needs_attention_state` - (List) The needs attention state of a configuration. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * `project_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `state` - (String) The state of the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. @@ -149,14 +93,6 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. -* `definition` - (List) The definition of the project. -Nested schema for **definition**: - * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. - * `name` - (String) The name of the project. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 28da460453..2bb1b8db5b 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -14,27 +14,36 @@ Create, update, and delete project_configs with this resource. ```hcl resource "ibm_project_config" "project_config_instance" { - authorizations { - trusted_profile { + definition { + name = "name" + description = "description" + labels = [ "labels" ] + authorizations { + trusted_profile { + id = "id" + target_iam_id = "target_iam_id" + } + method = "method" + api_key = "api_key" + } + compliance_profile { id = "id" - target_iam_id = "target_iam_id" + instance_id = "instance_id" + instance_location = "instance_location" + attachment_id = "attachment_id" + profile_name = "profile_name" + } + locator_id = "locator_id" + input = { } + setting = { } + type = "terraform_template" + output { + name = "name" + description = "description" + value = { "key" = "anything as a string" } } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" } - description = "Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace." - input = {"account_id":"$configs[].name["account-stage"].input.account_id","resource_group":"stage","access_tags":["env:stage"],"logdna_name":"Name of the LogDNA stage service instance","sysdig_name":"Name of the SysDig stage service instance"} - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" - name = "env-stage" project_id = ibm_project.project_instance.id - setting = {"IBMCLOUD_TOOLCHAIN_ENDPOINT":"https://api.us-south.devops.dev.cloud.ibm.com"} } ``` @@ -42,153 +51,68 @@ resource "ibm_project_config" "project_config_instance" { You can specify the following arguments for this resource. -* `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. -Nested schema for **authorizations**: - * `api_key` - (Optional, String) The IBM Cloud API Key. - * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `compliance_profile` - (Optional, List) The profile required for compliance. -Nested schema for **compliance_profile**: - * `attachment_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (Optional, String) The location of the compliance instance. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (Optional, String) The name of the compliance profile. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. -* `description` - (Optional, String) The description of the project configuration. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. -* `input` - (Optional, List) The input variables for the configuration definition. -Nested schema for **input**: -* `labels` - (Optional, List) A collection of configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. -* `locator_id` - (Optional, String) A dotted value of catalogID.versionID. - * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. -* `name` - (Optional, String) The name of the configuration. - * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. -* `project_id` - (Required, Forces new resource, String) The unique project ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. -Nested schema for **setting**: - -## Attribute Reference - -After your resource is created, you can read values from the listed arguments and the following attributes. - -* `id` - The unique identifier of the project_config. -* `check_job` - (List) The action job performed on the project configuration. -Nested schema for **check_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. -* `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. -Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. -* `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. -Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The Schematics template property. +* `definition` - (Optional, List) The type and output of a project configuration. Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: - * `api_key` - (String) The IBM Cloud API Key. + * `api_key` - (Optional, String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. + * `trusted_profile` - (Optional, List) The trusted profile for authorizations. Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. + * `target_iam_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `compliance_profile` - (List) The profile required for compliance. + * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: - * `attachment_id` - (String) The unique ID. + * `attachment_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `id` - (String) The unique ID. + * `id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_id` - (String) The unique ID. + * `instance_id` - (Optional, String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `instance_location` - (String) The location of the compliance instance. + * `instance_location` - (Optional, String) The location of the compliance instance. * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. - * `profile_name` - (String) The name of the compliance profile. + * `profile_name` - (Optional, String) The name of the compliance profile. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `description` - (String) The description of the project configuration. + * `description` - (Optional, String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The input variables for the configuration definition. + * `input` - (Optional, List) The input variables for the configuration definition. Nested schema for **input**: - * `labels` - (List) A collection of configuration labels. + * `labels` - (Optional, List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. + * `locator_id` - (Required, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. - * `name` - (String) The name of the configuration. + * `name` - (Required, String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. + * `output` - (Optional, List) The outputs of a Schematics template property. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **output**: - * `description` - (String) A short explanation of the output value. + * `description` - (Optional, String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. + * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + * `value` - (Optional, Map) The output value object. + * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: - * `type` - (String) The type of a project configuration manual property. + * `type` - (Computed, String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `install_job` - (List) The action job performed on the project configuration. -Nested schema for **install_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. +* `project_id` - (Required, Forces new resource, String) The unique project ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the project_config. +* `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_approved` - (List) The last approved metadata of the configuration. Nested schema for **last_approved**: * `comment` - (String) The comment left by the user who approved the configuration. + * Constraints: The default value is ``. * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID. @@ -196,35 +120,10 @@ Nested schema for **last_approved**: * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -* `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. -Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. -* `project_config_canonical_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. +* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `installed`, `installed_failed`, `installing`, `superceded`, `uninstalling`, `uninstalling_failed`, `validated`, `validating`, `validating_failed`. -* `type` - (String) The type of a project configuration manual property. - * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. -* `uninstall_job` - (List) The action job performed on the project configuration. -Nested schema for **uninstall_job**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From 1068bbff742f3c21e6a44595efbd314cf0b1c8d3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 10:32:03 +0200 Subject: [PATCH 093/125] commit fix --- ibm/service/project/resource_ibm_project_config.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 448afc7655..fa4d7cba23 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -388,8 +388,10 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err != nil { return diag.FromErr(err) } - if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) + if len(lastApprovedMap) > 0 { + if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) + } } } if !core.IsNil(projectConfig.LastSave) { @@ -647,7 +649,9 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project if err != nil { return modelMap, err } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + if len(complianceProfileMap) > 0 { + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } } modelMap["locator_id"] = model.LocatorID if model.Input != nil { @@ -655,7 +659,9 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project if err != nil { return modelMap, err } - modelMap["input"] = []map[string]interface{}{inputMap} + if len(inputMap) > 0 { + modelMap["input"] = []map[string]interface{}{inputMap} + } } if model.Setting != nil { settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) From 12d9964db589c2d7169bd8c312f93f2f5f56b907 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 13:22:25 +0200 Subject: [PATCH 094/125] commit fix --- ibm/service/project/resource_ibm_project_config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index fa4d7cba23..d2f2182e2b 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -389,7 +389,8 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(err) } if len(lastApprovedMap) > 0 { - if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { + // if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { + if err = d.Set("last_approved", []interface{}{lastApprovedMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) } } From 46c3c4b3110b016186ec637a2b0d52e9039af481 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 15:43:26 +0200 Subject: [PATCH 095/125] test cases --- .../data_source_ibm_project_config_test.go | 35 +++++++++++++------ .../project/data_source_ibm_project_test.go | 17 +++++---- .../resource_ibm_project_config_test.go | 19 ++++++++-- .../project/resource_ibm_project_test.go | 26 ++++++++------ 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 52eb46c2c8..0dc3507a97 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -20,15 +20,14 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigDataSourceConfigBasic(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "project_config_id"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "version"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "is_draft"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "update_available"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), ), }, }, @@ -40,15 +39,29 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" + definition { + name = "acme-microservice" + description = "acme-microservice description" + destroy_on_delete = true + } } resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id + definition { + name = "stage-environment" + labels = ["env:stage"] + authorizations { + method = "API_KEY" + api_key = "uJLTE48pX6_kAI_tQZVX1Rp1TbnrE17ybQY0x1YbHl8A" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + } } data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config.project_id - id = ibm_project_config.project_config_instance.projectConfig_id + project_id = ibm_project_config.project_config_instance.project_id + id = ibm_project_config.project_config_instance.project_config_id } `) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 9d20654b59..866986b9e4 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -7,15 +7,14 @@ import ( "fmt" "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" ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - projectLocation := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + projectResourceGroup := fmt.Sprintf("Default") + projectLocation := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -24,9 +23,8 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "id"), - resource.TestCheckResourceAttrSet("data.ibm_project.project", "definition.#"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), ), }, }, @@ -38,10 +36,15 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr resource "ibm_project" "project_instance" { resource_group = "%s" location = "%s" + definition { + name = "acme-microservice" + description = "acme-microservice description" + destroy_on_delete = true + } } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } `, projectResourceGroup, projectLocation) } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 3928a21bd1..4dcfc916bc 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -27,11 +27,11 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigConfigBasic(), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectConfigExists("ibm_project_config.project_config", conf), + testAccCheckIbmProjectConfigExists("ibm_project_config.project_config_instance", conf), ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config", + ResourceName: "ibm_project_config.project_config_instance", ImportState: true, ImportStateVerify: true, }, @@ -44,9 +44,24 @@ func testAccCheckIbmProjectConfigConfigBasic() string { resource "ibm_project" "project_instance" { resource_group = "Default" location = "us-south" + definition { + name = "acme-microservice" + description = "acme-microservice description" + destroy_on_delete = true + } } + resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id + definition { + name = "stage-environment" + labels = ["env:stage"] + authorizations { + method = "API_KEY" + api_key = "uJLTE48pX6_kAI_tQZVX1Rp1TbnrE17ybQY0x1YbHl8A" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + } } `) } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index 3818e1160f..f9f5651f03 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -7,7 +7,6 @@ import ( "fmt" "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" @@ -18,10 +17,10 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - location := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) - resourceGroupUpdate := fmt.Sprintf("tf_resource_group_%d", acctest.RandIntRange(10, 100)) - locationUpdate := fmt.Sprintf("tf_location_%d", acctest.RandIntRange(10, 100)) + resourceGroup := fmt.Sprintf("Default") + location := fmt.Sprintf("us-south") + resourceGroupUpdate := fmt.Sprintf("Default") + locationUpdate := fmt.Sprintf("us-south") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -31,20 +30,20 @@ func TestAccIbmProjectBasic(t *testing.T) { resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmProjectExists("ibm_project.project", conf), - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroup), - resource.TestCheckResourceAttr("ibm_project.project", "location", location), + testAccCheckIbmProjectExists("ibm_project.project_instance", conf), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), ), }, resource.TestStep{ Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), ), }, resource.TestStep{ - ResourceName: "ibm_project.project", + ResourceName: "ibm_project.project_instance", ImportState: true, ImportStateVerify: true, }, @@ -57,6 +56,11 @@ func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string) st resource "ibm_project" "project_instance" { resource_group = "%s" location = "%s" + definition { + name = "acme-microservice" + description = "acme-microservice description" + destroy_on_delete = true + } } `, resourceGroup, location) } From a9a1e4580225cc068d32ab7e0b137781a47eee16 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 15:45:09 +0200 Subject: [PATCH 096/125] test cases --- ibm/service/project/resource_ibm_project_config.go | 3 +++ ibm/service/project/resource_ibm_project_config_test.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index d2f2182e2b..42c9a45136 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -388,12 +388,15 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err != nil { return diag.FromErr(err) } + fmt.Println("**** TEST *****", lastApprovedMap) if len(lastApprovedMap) > 0 { // if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { if err = d.Set("last_approved", []interface{}{lastApprovedMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) } } + } else { + fmt.Println("**** TEST *****", projectConfig.LastApproved) } if !core.IsNil(projectConfig.LastSave) { if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 4dcfc916bc..340cd1b693 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -58,7 +58,7 @@ func testAccCheckIbmProjectConfigConfigBasic() string { labels = ["env:stage"] authorizations { method = "API_KEY" - api_key = "uJLTE48pX6_kAI_tQZVX1Rp1TbnrE17ybQY0x1YbHl8A" + api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } From d61c5c1b01fb456cc3cdabb60b754c0607cd4d95 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 15:45:54 +0200 Subject: [PATCH 097/125] test cases --- ibm/service/project/data_source_ibm_project_config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 0dc3507a97..8d032fcfa1 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -53,7 +53,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { labels = ["env:stage"] authorizations { method = "API_KEY" - api_key = "uJLTE48pX6_kAI_tQZVX1Rp1TbnrE17ybQY0x1YbHl8A" + api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } From 65939961726488dc65ba2a58658dc5eff194d33a Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 19 Sep 2023 15:47:41 +0200 Subject: [PATCH 098/125] test cases --- ibm/service/project/resource_ibm_project_config.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 42c9a45136..14f324d546 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -388,15 +388,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err != nil { return diag.FromErr(err) } - fmt.Println("**** TEST *****", lastApprovedMap) if len(lastApprovedMap) > 0 { - // if err = d.Set("last_approved", []map[string]interface{}{lastApprovedMap}); err != nil { if err = d.Set("last_approved", []interface{}{lastApprovedMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) } } - } else { - fmt.Println("**** TEST *****", projectConfig.LastApproved) } if !core.IsNil(projectConfig.LastSave) { if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { From ca45982d9e2ce0719973807498bc613dad10cbe8 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 20 Sep 2023 09:58:45 +0200 Subject: [PATCH 099/125] updates --- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 622 +++++++++++++++++ .../project/data_source_ibm_project_config.go | 655 +++++++++++++++++- ibm/service/project/resource_ibm_project.go | 589 ++++++++++++++++ .../project/resource_ibm_project_config.go | 608 +++++++++++++++- website/docs/d/project.html.markdown | 77 ++ website/docs/d/project_config.html.markdown | 84 ++- website/docs/r/project.html.markdown | 77 ++ website/docs/r/project_config.html.markdown | 83 ++- 10 files changed, 2765 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 7d93626158..d2d4b43882 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.48.1 - github.com/IBM/project-go-sdk v0.0.26-79 + github.com/IBM/project-go-sdk v0.0.26-80 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.0.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index 584664220a..3978e54800 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g= github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.26-79 h1:JOhGIkM0jY49QSNvqY1d2qe+AVdr5gW21RqnCCPz1F4= -github.com/IBM/project-go-sdk v0.0.26-79/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-80 h1:rVoTP1oWZ0rHPC13N4pxio6aphF3DWcYxkf4y7PDBIE= +github.com/IBM/project-go-sdk v0.0.26-80/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.0.2 h1:OUqkzLfJqozp2aqylNurwaJd1SmY8o7KturFse6R2xM= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index e15e7114d2..79b8cf706d 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -178,6 +179,396 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "last_validated": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + }, + }, + }, + "last_deployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "last_undeployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -366,6 +757,27 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } + if model.LastValidated != nil { + lastValidatedMap, err := dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) + if err != nil { + return modelMap, err + } + modelMap["last_validated"] = []map[string]interface{}{lastValidatedMap} + } + if model.LastDeployed != nil { + lastDeployedMap, err := dataSourceIbmProjectLastActionWithSummaryToMap(model.LastDeployed) + if err != nil { + return modelMap, err + } + modelMap["last_deployed"] = []map[string]interface{}{lastDeployedMap} + } + if model.LastUndeployed != nil { + lastUndeployedMap, err := dataSourceIbmProjectLastActionWithSummaryToMap(model.LastUndeployed) + if err != nil { + return modelMap, err + } + modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} + } modelMap["href"] = model.Href definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -386,6 +798,216 @@ func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1 return modelMap, nil } +func dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.CraLogs != nil { + craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + return modelMap, nil +} + +func dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summaryMap, err := dataSourceIbmProjectActionJobSummaryToMap(model.Summary) + if err != nil { + return modelMap, err + } + modelMap["summary"] = []map[string]interface{}{summaryMap} + } + return modelMap, nil +} + +func dataSourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} + +func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func dataSourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + return modelMap, nil +} + func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 5f5c4ea4e5..46339e6952 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -109,6 +109,396 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "last_validated": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + }, + }, + }, + "last_deployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "last_undeployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -213,7 +603,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "input": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The input variables for the configuration definition.", + Description: "The input variables for configuration definition and environment.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{}, }, @@ -248,12 +638,9 @@ func DataSourceIbmProjectConfig() *schema.Resource { Description: "A short explanation of the output value.", }, "value": &schema.Schema{ - Type: schema.TypeMap, + Type: schema.TypeString, Computed: true, - Description: "The output value object.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, @@ -332,6 +719,42 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } + lastValidated := []map[string]interface{}{} + if projectConfig.LastValidated != nil { + modelMap, err := dataSourceIbmProjectConfigLastValidatedActionWithSummaryToMap(projectConfig.LastValidated) + if err != nil { + return diag.FromErr(err) + } + lastValidated = append(lastValidated, modelMap) + } + if err = d.Set("last_validated", lastValidated); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_validated %s", err)) + } + + lastDeployed := []map[string]interface{}{} + if projectConfig.LastDeployed != nil { + modelMap, err := dataSourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastDeployed) + if err != nil { + return diag.FromErr(err) + } + lastDeployed = append(lastDeployed, modelMap) + } + if err = d.Set("last_deployed", lastDeployed); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_deployed %s", err)) + } + + lastUndeployed := []map[string]interface{}{} + if projectConfig.LastUndeployed != nil { + modelMap, err := dataSourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastUndeployed) + if err != nil { + return diag.FromErr(err) + } + lastUndeployed = append(lastUndeployed, modelMap) + } + if err = d.Set("last_undeployed", lastUndeployed); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_undeployed %s", err)) + } + definition := []map[string]interface{}{} if projectConfig.Definition != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) @@ -358,6 +781,216 @@ func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *pro return modelMap, nil } +func dataSourceIbmProjectConfigLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.CraLogs != nil { + craLogsMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) + if err != nil { + return modelMap, err + } + modelMap["summary"] = []map[string]interface{}{summaryMap} + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + return modelMap, nil +} + func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name @@ -479,15 +1112,7 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m modelMap["description"] = model.Description } if model.Value != nil { - value := make(map[string]interface{}) - for k, v := range model.Value { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - value[k] = string(bytes) - } - modelMap["value"] = value + modelMap["value"] = model.Value } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index c46e3493af..7e431c16e1 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -206,6 +207,363 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "last_validated": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + }, + }, + }, + "last_deployed": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "last_undeployed": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, "href": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -646,6 +1004,27 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } + if model.LastValidated != nil { + lastValidatedMap, err := resourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) + if err != nil { + return modelMap, err + } + modelMap["last_validated"] = []map[string]interface{}{lastValidatedMap} + } + if model.LastDeployed != nil { + lastDeployedMap, err := resourceIbmProjectLastActionWithSummaryToMap(model.LastDeployed) + if err != nil { + return modelMap, err + } + modelMap["last_deployed"] = []map[string]interface{}{lastDeployedMap} + } + if model.LastUndeployed != nil { + lastUndeployedMap, err := resourceIbmProjectLastActionWithSummaryToMap(model.LastUndeployed) + if err != nil { + return modelMap, err + } + modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} + } modelMap["href"] = model.Href definitionMap, err := resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -666,6 +1045,216 @@ func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.P return modelMap, nil } +func resourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.CraLogs != nil { + craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + return modelMap, nil +} + +func resourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summaryMap, err := resourceIbmProjectActionJobSummaryToMap(model.Summary) + if err != nil { + return modelMap, err + } + modelMap["summary"] = []map[string]interface{}{summaryMap} + } + return modelMap, nil +} + +func resourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} + +func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func resourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + return modelMap, nil +} + func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 14f324d546..55b2981d3f 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -142,7 +142,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The input variables for the configuration definition.", + Description: "The input variables for configuration definition and environment.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{}, }, @@ -178,10 +178,9 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "A short explanation of the output value.", }, "value": &schema.Schema{ - Type: schema.TypeMap, + Type: schema.TypeString, Optional: true, - Description: "The output value object.", - Elem: &schema.Schema{Type: schema.TypeString}, + Description: "Can be any value - a string, number, boolean, array, or object.", }, }, }, @@ -260,6 +259,360 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "last_validated": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + "cost_estimate": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the cost estimate of the configuration.", + }, + "currency": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The currency of the cost estimate of the configuration.", + }, + "total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total hourly cost estimate of the configuration.", + }, + "total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The total monthly cost estimate of the configuration.", + }, + "past_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total hourly cost estimate of the configuration.", + }, + "past_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The past total monthly cost estimate of the configuration.", + }, + "diff_total_hourly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total hourly cost estimates of the configuration.", + }, + "diff_total_monthly_cost": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The difference between current and past total monthly cost estimates of the configuration.", + }, + "time_generated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "user_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + }, + }, + }, + "cra_logs": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The Code Risk Analyzer logs of the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cra_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The version of the Code Risk Analyzer logs of the configuration.", + }, + "schema_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The schema version of Code Risk Analyzer logs of the configuration.", + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The status of the Code Risk Analyzer logs of the configuration.", + }, + "summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the Code Risk Analyzer logs of the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "timestamp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + }, + }, + }, + }, + }, + }, + "last_deployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "last_undeployed": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The action job performed on the project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A relative URL.", + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The result of the last action.", + }, + "job": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A brief summary of an action.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The unique ID.", + }, + "summary": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "The summaries of jobs that were performed on the configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "plan_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The summary of the destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message_summary": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The message summaries of jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "plan_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of plan jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "apply_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of apply jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destroy_messages": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The messages of destroy jobs on the configuration.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -399,6 +752,33 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } + if !core.IsNil(projectConfig.LastValidated) { + lastValidatedMap, err := resourceIbmProjectConfigLastValidatedActionWithSummaryToMap(projectConfig.LastValidated) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("last_validated", []map[string]interface{}{lastValidatedMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_validated: %s", err)) + } + } + if !core.IsNil(projectConfig.LastDeployed) { + lastDeployedMap, err := resourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastDeployed) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("last_deployed", []map[string]interface{}{lastDeployedMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_deployed: %s", err)) + } + } + if !core.IsNil(projectConfig.LastUndeployed) { + lastUndeployedMap, err := resourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastUndeployed) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("last_undeployed", []map[string]interface{}{lastUndeployedMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_undeployed: %s", err)) + } + } if err = d.Set("project_config_id", projectConfig.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } @@ -753,15 +1133,7 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map modelMap["description"] = model.Description } if model.Value != nil { - value := make(map[string]interface{}) - for k, v := range model.Value { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - value[k] = string(bytes) - } - modelMap["value"] = value + modelMap["value"] = model.Value } return modelMap, nil } @@ -776,3 +1148,213 @@ func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *proje modelMap["user_id"] = model.UserID return modelMap, nil } + +func resourceIbmProjectConfigLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + if model.CostEstimate != nil { + costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model.CostEstimate) + if err != nil { + return modelMap, err + } + modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} + } + if model.CraLogs != nil { + craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model.CraLogs) + if err != nil { + return modelMap, err + } + modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} + } + return modelMap, nil +} + +func resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) + if err != nil { + return modelMap, err + } + modelMap["summary"] = []map[string]interface{}{summaryMap} + } + return modelMap, nil +} + +func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.PlanSummary != nil { + planSummary := make(map[string]interface{}) + for k, v := range model.PlanSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planSummary[k] = string(bytes) + } + modelMap["plan_summary"] = planSummary + } + if model.ApplySummary != nil { + applySummary := make(map[string]interface{}) + for k, v := range model.ApplySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applySummary[k] = string(bytes) + } + modelMap["apply_summary"] = applySummary + } + if model.DestroySummary != nil { + destroySummary := make(map[string]interface{}) + for k, v := range model.DestroySummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroySummary[k] = string(bytes) + } + modelMap["destroy_summary"] = destroySummary + } + if model.MessageSummary != nil { + messageSummary := make(map[string]interface{}) + for k, v := range model.MessageSummary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + messageSummary[k] = string(bytes) + } + modelMap["message_summary"] = messageSummary + } + if model.PlanMessages != nil { + planMessages := make(map[string]interface{}) + for k, v := range model.PlanMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + planMessages[k] = string(bytes) + } + modelMap["plan_messages"] = planMessages + } + if model.ApplyMessages != nil { + applyMessages := make(map[string]interface{}) + for k, v := range model.ApplyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + applyMessages[k] = string(bytes) + } + modelMap["apply_messages"] = applyMessages + } + if model.DestroyMessages != nil { + destroyMessages := make(map[string]interface{}) + for k, v := range model.DestroyMessages { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + destroyMessages[k] = string(bytes) + } + modelMap["destroy_messages"] = destroyMessages + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Version != nil { + modelMap["version"] = model.Version + } + if model.Currency != nil { + modelMap["currency"] = model.Currency + } + if model.TotalHourlyCost != nil { + modelMap["total_hourly_cost"] = model.TotalHourlyCost + } + if model.TotalMonthlyCost != nil { + modelMap["total_monthly_cost"] = model.TotalMonthlyCost + } + if model.PastTotalHourlyCost != nil { + modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost + } + if model.PastTotalMonthlyCost != nil { + modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost + } + if model.DiffTotalHourlyCost != nil { + modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost + } + if model.DiffTotalMonthlyCost != nil { + modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost + } + if model.TimeGenerated != nil { + modelMap["time_generated"] = model.TimeGenerated.String() + } + if model.UserID != nil { + modelMap["user_id"] = model.UserID + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.CraVersion != nil { + modelMap["cra_version"] = model.CraVersion + } + if model.SchemaVersion != nil { + modelMap["schema_version"] = model.SchemaVersion + } + if model.Status != nil { + modelMap["status"] = model.Status + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + if model.Timestamp != nil { + modelMap["timestamp"] = model.Timestamp.String() + } + return modelMap, nil +} + +func resourceIbmProjectConfigLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Href != nil { + modelMap["href"] = model.Href + } + if model.Result != nil { + modelMap["result"] = model.Result + } + if model.Job != nil { + jobMap, err := resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) + if err != nil { + return modelMap, err + } + modelMap["job"] = []map[string]interface{}{jobMap} + } + return modelMap, nil +} diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 425dea3787..29ccf25ccc 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -53,7 +53,84 @@ Nested schema for **configs**: * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_deployed` - (List) The action job performed on the project configuration. + Nested schema for **last_deployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `last_undeployed` - (List) The action job performed on the project configuration. + Nested schema for **last_undeployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. + * `last_validated` - (List) The action job performed on the project configuration. + Nested schema for **last_validated**: + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 88d59593c8..9d3c7229eb 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -63,7 +63,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (List) The input variables for the configuration definition. + * `input` - (List) The input variables for configuration definition and environment. Nested schema for **input**: * `labels` - (List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. @@ -78,7 +78,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Map) The output value object. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: * `type` - (String) The type of a project configuration manual property. @@ -95,8 +95,88 @@ Nested schema for **last_approved**: * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `last_deployed` - (List) The action job performed on the project configuration. +Nested schema for **last_deployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. + * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `last_undeployed` - (List) The action job performed on the project configuration. +Nested schema for **last_undeployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. + +* `last_validated` - (List) The action job performed on the project configuration. +Nested schema for **last_validated**: + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. + * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 5a003ce0ef..4b67a6d946 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -69,7 +69,84 @@ Nested schema for **configs**: * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `last_deployed` - (List) The action job performed on the project configuration. + Nested schema for **last_deployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `last_undeployed` - (List) The action job performed on the project configuration. + Nested schema for **last_undeployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. + * `last_validated` - (List) The action job performed on the project configuration. + Nested schema for **last_validated**: + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 2bb1b8db5b..8f50ca5fcd 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -40,7 +40,7 @@ resource "ibm_project_config" "project_config_instance" { output { name = "name" description = "description" - value = { "key" = "anything as a string" } + value = "anything as a string" } } project_id = ibm_project.project_instance.id @@ -79,7 +79,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `input` - (Optional, List) The input variables for the configuration definition. + * `input` - (Optional, List) The input variables for configuration definition and environment. Nested schema for **input**: * `labels` - (Optional, List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. @@ -94,7 +94,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (Required, String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, Map) The output value object. + * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. Nested schema for **setting**: * `type` - (Computed, String) The type of a project configuration manual property. @@ -117,7 +117,84 @@ Nested schema for **last_approved**: * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `user_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `last_deployed` - (List) The action job performed on the project configuration. +Nested schema for **last_deployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `last_undeployed` - (List) The action job performed on the project configuration. +Nested schema for **last_undeployed**: + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. +* `last_validated` - (List) The action job performed on the project configuration. +Nested schema for **last_validated**: + * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. + Nested schema for **cost_estimate**: + * `currency` - (String) The currency of the cost estimate of the configuration. + * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. + * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. + * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. + * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. + * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. + * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. + * `user_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `version` - (String) The version of the cost estimate of the configuration. + * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. + Nested schema for **cra_logs**: + * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. + * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. + * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. + * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. + * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `job` - (List) A brief summary of an action. + Nested schema for **job**: + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `summary` - (List) The summaries of jobs that were performed on the configuration. + Nested schema for **summary**: + * `apply_messages` - (Map) The messages of apply jobs on the configuration. + * `apply_summary` - (Map) The summary of the apply jobs on the configuration. + * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. + * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. + * `message_summary` - (Map) The message summaries of jobs on the configuration. + * `plan_messages` - (Map) The messages of plan jobs on the configuration. + * `plan_summary` - (Map) The summary of the plan jobs on the configuration. + * `result` - (String) The result of the last action. + * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. From 66dfb509cd5df6a696837c311225cbc85d9ccb76 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 20 Sep 2023 10:25:19 +0200 Subject: [PATCH 100/125] upgrade to latest go sdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d2d4b43882..cf9f5a733b 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.48.1 - github.com/IBM/project-go-sdk v0.0.26-80 + github.com/IBM/project-go-sdk v0.0.27 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.0.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index 3978e54800..8a31b81c37 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g= github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.26-80 h1:rVoTP1oWZ0rHPC13N4pxio6aphF3DWcYxkf4y7PDBIE= -github.com/IBM/project-go-sdk v0.0.26-80/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.27 h1:inRerLYKRjthL4XswD2UDMGl6IKOx71Wnmc55nmYbPg= +github.com/IBM/project-go-sdk v0.0.27/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.0.2 h1:OUqkzLfJqozp2aqylNurwaJd1SmY8o7KturFse6R2xM= From edd772fefcfdac6207712bced1dc37383b87caf5 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 20 Sep 2023 12:18:11 +0200 Subject: [PATCH 101/125] update generated doc --- examples/ibm-project/README.md | 2 -- examples/ibm-project/main.tf | 38 ++++++++++++++-------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index c63042043e..5f97bf3ad2 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -89,8 +89,6 @@ data "project" "project_instance" { | location | The location where the project's data and tools are created. | `string` | true | | definition | The definition of the project. | `` | false | | project_id | The unique project ID. | `string` | true | -| id | The unique config ID. | `string` | true | -| id | The unique project ID. | `string` | true | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 17d936b8e6..de2c4e4ee7 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -6,37 +6,31 @@ provider "ibm" { resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.project_id definition { - name = "name" - description = "description" - labels = [ "labels" ] + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" + method = "APIKEY" + api_key = "" } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + input { + name = "app_repo_name" + } + setting { + name = "app_repo_name" + value = "static-website-dev-app-repo" } - locator_id = "locator_id" - input = { } - setting = { } } } // Provision project resource instance resource "ibm_project" "project_instance" { - resource_group = var.project_resource_group - location = var.project_location + resource_group = "Default" + location = "us-south" definition { - name = "name" - description = "description" + name = "My static website" + description = "Sample static website test using the IBM catalog deployable architecture" destroy_on_delete = true } } From 075b607857deba054bffaca17a55ff590a8fdbd6 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 20 Sep 2023 17:40:21 +0200 Subject: [PATCH 102/125] update generated code --- ibm/service/project/resource_ibm_project.go | 388 ----------- .../project/resource_ibm_project_config.go | 644 ------------------ 2 files changed, 1032 deletions(-) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 7e431c16e1..87aeeeda6f 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -171,399 +171,11 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - // MaxItems: 1, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "", - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID.", - }, - }, - }, - }, "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_validated": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - }, - }, - }, - "last_deployed": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "last_undeployed": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "href": &schema.Schema{ Type: schema.TypeString, Required: true, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 55b2981d3f..3730b13bd7 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -224,395 +223,11 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "", - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID.", - }, - }, - }, - }, "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_validated": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - }, - }, - }, - "last_deployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "last_undeployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -736,49 +351,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) } } - if !core.IsNil(projectConfig.LastApproved) { - lastApprovedMap, err := resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) - if err != nil { - return diag.FromErr(err) - } - if len(lastApprovedMap) > 0 { - if err = d.Set("last_approved", []interface{}{lastApprovedMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_approved: %s", err)) - } - } - } if !core.IsNil(projectConfig.LastSave) { if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } } - if !core.IsNil(projectConfig.LastValidated) { - lastValidatedMap, err := resourceIbmProjectConfigLastValidatedActionWithSummaryToMap(projectConfig.LastValidated) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("last_validated", []map[string]interface{}{lastValidatedMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_validated: %s", err)) - } - } - if !core.IsNil(projectConfig.LastDeployed) { - lastDeployedMap, err := resourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastDeployed) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("last_deployed", []map[string]interface{}{lastDeployedMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_deployed: %s", err)) - } - } - if !core.IsNil(projectConfig.LastUndeployed) { - lastUndeployedMap, err := resourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastUndeployed) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("last_undeployed", []map[string]interface{}{lastUndeployedMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_undeployed: %s", err)) - } - } if err = d.Set("project_config_id", projectConfig.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } @@ -1137,224 +714,3 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map } return modelMap, nil } - -func resourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func resourceIbmProjectConfigLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.Job != nil { - jobMap, err := resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.CraLogs != nil { - craLogsMap, err := resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - return modelMap, nil -} - -func resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summaryMap, err := resourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func resourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectConfigLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.Job != nil { - jobMap, err := resourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - return modelMap, nil -} From 9b2adca569c08db4280a6db451dd97103e91e4a0 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 20 Sep 2023 18:32:22 +0200 Subject: [PATCH 103/125] updated secrets baseline --- .secrets.baseline | 526 ++++++++-------------------------------------- 1 file changed, 92 insertions(+), 434 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 618f58d428..e22c1e9225 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-14T15:01:09Z", + "generated_at": "2023-09-20T16:31:46Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -547,6 +547,16 @@ "verified_result": null } ], + "examples/ibm-project/main.tf": [ + { + "hashed_secret": "06d988e96c3d9325c9fbc7c0ef3c6c0f2b4eb8e7", + "is_secret": false, + "is_verified": false, + "line_number": 14, + "type": "Secret Keyword", + "verified_result": null + } + ], "examples/ibm-satellite/README.md": [ { "hashed_secret": "91199272d5d6a574a51722ca6f3d1148edb1a0e7", @@ -828,7 +838,7 @@ "hashed_secret": "da8cae6284528565678de15e03d461e23fe22538", "is_secret": false, "is_verified": false, - "line_number": 1714, + "line_number": 1845, "type": "Secret Keyword", "verified_result": null }, @@ -836,7 +846,7 @@ "hashed_secret": "1a0334cfa65f4be58b9d914b8e96e9d9478bfbac", "is_secret": false, "is_verified": false, - "line_number": 3236, + "line_number": 3242, "type": "Secret Keyword", "verified_result": null } @@ -846,7 +856,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1757, + "line_number": 1765, "type": "Secret Keyword", "verified_result": null }, @@ -854,7 +864,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1763, + "line_number": 1771, "type": "Secret Keyword", "verified_result": null } @@ -1288,7 +1298,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 105, + "line_number": 114, "type": "Secret Keyword", "verified_result": null } @@ -1318,7 +1328,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 49, + "line_number": 58, "type": "Secret Keyword", "verified_result": null }, @@ -1326,7 +1336,7 @@ "hashed_secret": "90a487e543acb2a46de4f28f6012de33bb854568", "is_secret": false, "is_verified": false, - "line_number": 283, + "line_number": 307, "type": "Secret Keyword", "verified_result": null } @@ -1346,7 +1356,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 85, + "line_number": 94, "type": "Secret Keyword", "verified_result": null }, @@ -1354,7 +1364,7 @@ "hashed_secret": "505032eaf8a3acf9b094a326dfb1cd0537c75a0d", "is_secret": false, "is_verified": false, - "line_number": 340, + "line_number": 364, "type": "Secret Keyword", "verified_result": null } @@ -1364,7 +1374,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 54, + "line_number": 63, "type": "Secret Keyword", "verified_result": null } @@ -2002,7 +2012,7 @@ "hashed_secret": "884a58e4c2c5d195d3876787bdc63af6c5af2924", "is_secret": false, "is_verified": false, - "line_number": 508, + "line_number": 633, "type": "Secret Keyword", "verified_result": null } @@ -2022,7 +2032,7 @@ "hashed_secret": "b02fa7fd7ca08b5dc86c2548e40f8a21171ef977", "is_secret": false, "is_verified": false, - "line_number": 492, + "line_number": 509, "type": "Secret Keyword", "verified_result": null } @@ -2797,6 +2807,62 @@ "verified_result": null } ], + "ibm/service/project/data_source_ibm_project_config.go": [ + { + "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", + "is_secret": false, + "is_verified": false, + "line_number": 556, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", + "is_secret": false, + "is_verified": false, + "line_number": 1062, + "type": "Secret Keyword", + "verified_result": null + } + ], + "ibm/service/project/data_source_ibm_project_config_test.go": [ + { + "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "is_secret": false, + "is_verified": false, + "line_number": 56, + "type": "Secret Keyword", + "verified_result": null + } + ], + "ibm/service/project/resource_ibm_project_config.go": [ + { + "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", + "is_secret": false, + "is_verified": false, + "line_number": 92, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", + "is_secret": false, + "is_verified": false, + "line_number": 660, + "type": "Secret Keyword", + "verified_result": null + } + ], + "ibm/service/project/resource_ibm_project_config_test.go": [ + { + "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "is_secret": false, + "is_verified": false, + "line_number": 61, + "type": "Secret Keyword", + "verified_result": null + } + ], "ibm/service/pushnotification/resource_ibm_push_notification_chrome.go": [ { "hashed_secret": "8a4036fbf3e13c7a84bac77ddae25de1cdfc4d43", @@ -2885,6 +2951,16 @@ "verified_result": null } ], + "ibm/service/satellite/resource_ibm_satellite_storage_configuration_test.go": [ + { + "hashed_secret": "f32b67c7e26342af42efabc674d441dca0a281c5", + "is_secret": false, + "is_verified": false, + "line_number": 118, + "type": "Secret Keyword", + "verified_result": null + } + ], "ibm/service/scc/data_source_ibm_scc_provider_type_instance_test.go": [ { "hashed_secret": "83747cea2b26d7652ed39218ddcdb1461c570535", @@ -2915,16 +2991,6 @@ "verified_result": null } ], - "ibm/service/satellite/resource_ibm_satellite_storage_configuration_test.go": [ - { - "hashed_secret": "f32b67c7e26342af42efabc674d441dca0a281c5", - "is_secret": false, - "is_verified": false, - "line_number": 118, - "type": "Secret Keyword", - "verified_result": null - } - ], "ibm/service/schematics/data_source_ibm_schematics_action.go": [ { "hashed_secret": "49f3bb8f759241df51c899d3725d877bad58f66e", @@ -3646,7 +3712,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 89080, + "line_number": 92841, "type": "Secret Keyword", "verified_result": null }, @@ -3654,7 +3720,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 111658, + "line_number": 115304, "type": "Secret Keyword", "verified_result": null }, @@ -3662,7 +3728,7 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 141194, + "line_number": 145758, "type": "Secret Keyword", "verified_result": null } @@ -3961,310 +4027,6 @@ "line_number": 19, "type": "Hex High Entropy String", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 83, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 85, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_appconfig.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 102, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 104, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_artifactory.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 105, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 107, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_bitbucketgit.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 127, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 129, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_custom.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 102, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_devopsinsights.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 83, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 85, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_eventnotifications.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_githubconsolidated.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 143, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 145, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_gitlab.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 139, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 141, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_hashicorpvault.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 107, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 109, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_hostedgit.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 132, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 134, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_jenkins.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 96, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_jira.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_keyprotect.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 96, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_nexus.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 101, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 103, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_pagerduty.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_pipeline.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 89, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 91, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cd_toolchain_tool_privateworker.html.markdown": [ @@ -4275,94 +4037,6 @@ "line_number": 21, "type": "Secret Keyword", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_saucelabs.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 91, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 93, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_secretsmanager.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 99, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 101, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_securitycompliance.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 109, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 111, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_slack.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 108, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 110, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cd_toolchain_tool_sonarqube.html.markdown": [ @@ -4373,22 +4047,6 @@ "line_number": 22, "type": "Secret Keyword", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cis_alert.html.markdown": [ From 7b59abf16742703aa7b5926f2835d776df422f99 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 21 Sep 2023 18:43:50 +0200 Subject: [PATCH 104/125] update code to latest API changes --- examples/ibm-project/variables.tf | 10 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 419 ----------- .../project/data_source_ibm_project_config.go | 689 ------------------ ibm/service/project/resource_ibm_project.go | 69 +- .../project/resource_ibm_project_config.go | 27 +- website/docs/d/project.html.markdown | 86 --- website/docs/d/project_config.html.markdown | 89 --- website/docs/r/project.html.markdown | 94 +-- website/docs/r/project_config.html.markdown | 87 +-- 11 files changed, 57 insertions(+), 1519 deletions(-) diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 54df2e4e8e..47a8010f6f 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -11,16 +11,16 @@ variable "project_config_project_id" { } // Resource arguments for project +variable "project_location" { + description = "The IBM Cloud location where a resource is deployed." + type = string + default = "us-south" +} variable "project_resource_group" { description = "The resource group where the project's data and tools are created." type = string default = "Default" } -variable "project_location" { - description = "The location where the project's data and tools are created." - type = string - default = "us-south" -} // Data source arguments for project_config variable "project_config_project_id" { diff --git a/go.mod b/go.mod index cf9f5a733b..c8a5547425 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.48.1 - github.com/IBM/project-go-sdk v0.0.27 + github.com/IBM/project-go-sdk v0.0.26-83 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.0.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index 8a31b81c37..fe7b4dfaf3 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g= github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.27 h1:inRerLYKRjthL4XswD2UDMGl6IKOx71Wnmc55nmYbPg= -github.com/IBM/project-go-sdk v0.0.27/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.26-83 h1:7SvrgKRxcIme0ET5GT+W6MjKrrwHRywAMxMN5rDjjAk= +github.com/IBM/project-go-sdk v0.0.26-83/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.0.2 h1:OUqkzLfJqozp2aqylNurwaJd1SmY8o7KturFse6R2xM= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 79b8cf706d..0662b28741 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -145,430 +145,11 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_validated": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - }, - }, - }, - "last_deployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "last_undeployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 46339e6952..532fa1c707 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -75,430 +74,11 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_approved": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The last approved metadata of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_forced": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the approval was forced approved.", - }, - "comment": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The comment left by the user who approved the configuration.", - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, "last_save": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_validated": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "cost_estimate": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The cost estimate of the configuration.It only exists after the first configuration validation.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the cost estimate of the configuration.", - }, - "currency": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The currency of the cost estimate of the configuration.", - }, - "total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total hourly cost estimate of the configuration.", - }, - "total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The total monthly cost estimate of the configuration.", - }, - "past_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total hourly cost estimate of the configuration.", - }, - "past_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The past total monthly cost estimate of the configuration.", - }, - "diff_total_hourly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total hourly cost estimates of the configuration.", - }, - "diff_total_monthly_cost": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The difference between current and past total monthly cost estimates of the configuration.", - }, - "time_generated": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "user_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, - }, - "cra_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The Code Risk Analyzer logs of the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cra_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The version of the Code Risk Analyzer logs of the configuration.", - }, - "schema_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The schema version of Code Risk Analyzer logs of the configuration.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of the Code Risk Analyzer logs of the configuration.", - }, - "summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the Code Risk Analyzer logs of the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timestamp": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - }, - }, - }, - }, - }, - }, - "last_deployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "last_undeployed": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The action job performed on the project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A relative URL.", - }, - "result": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The result of the last action.", - }, - "job": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A brief summary of an action.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "summary": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The summaries of jobs that were performed on the configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plan_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The summary of the destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "message_summary": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The message summaries of jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "plan_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of plan jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "apply_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of apply jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "destroy_messages": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The messages of destroy jobs on the configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -703,58 +283,10 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) } - lastApproved := []map[string]interface{}{} - if projectConfig.LastApproved != nil { - modelMap, err := dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(projectConfig.LastApproved) - if err != nil { - return diag.FromErr(err) - } - lastApproved = append(lastApproved, modelMap) - } - if err = d.Set("last_approved", lastApproved); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_approved %s", err)) - } - if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } - lastValidated := []map[string]interface{}{} - if projectConfig.LastValidated != nil { - modelMap, err := dataSourceIbmProjectConfigLastValidatedActionWithSummaryToMap(projectConfig.LastValidated) - if err != nil { - return diag.FromErr(err) - } - lastValidated = append(lastValidated, modelMap) - } - if err = d.Set("last_validated", lastValidated); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_validated %s", err)) - } - - lastDeployed := []map[string]interface{}{} - if projectConfig.LastDeployed != nil { - modelMap, err := dataSourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastDeployed) - if err != nil { - return diag.FromErr(err) - } - lastDeployed = append(lastDeployed, modelMap) - } - if err = d.Set("last_deployed", lastDeployed); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_deployed %s", err)) - } - - lastUndeployed := []map[string]interface{}{} - if projectConfig.LastUndeployed != nil { - modelMap, err := dataSourceIbmProjectConfigLastActionWithSummaryToMap(projectConfig.LastUndeployed) - if err != nil { - return diag.FromErr(err) - } - lastUndeployed = append(lastUndeployed, modelMap) - } - if err = d.Set("last_undeployed", lastUndeployed); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_undeployed %s", err)) - } - definition := []map[string]interface{}{} if projectConfig.Definition != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) @@ -770,227 +302,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return nil } -func dataSourceIbmProjectConfigProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func dataSourceIbmProjectConfigLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.Job != nil { - jobMap, err := dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.CraLogs != nil { - craLogsMap, err := dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summaryMap, err := dataSourceIbmProjectConfigActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func dataSourceIbmProjectConfigLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.Job != nil { - jobMap, err := dataSourceIbmProjectConfigActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - return modelMap, nil -} - func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 87aeeeda6f..7ab02f2185 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -28,22 +28,23 @@ func ResourceIbmProject() *schema.Resource { Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ + "location": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_project", "location"), + Description: "The IBM Cloud location where a resource is deployed.", + }, "resource_group": &schema.Schema{ Type: schema.TypeString, Required: true, // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, - "location": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_project", "location"), - Description: "The location where the project's data and tools are created.", - }, "definition": &schema.Schema{ Type: schema.TypeList, + MinItems: 1, MaxItems: 1, - Optional: true, + Required: true, Description: "The definition of the project.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -213,22 +214,22 @@ func ResourceIbmProjectValidator() *validate.ResourceValidator { validateSchema := make([]validate.ValidateSchema, 0) validateSchema = append(validateSchema, validate.ValidateSchema{ - Identifier: "resource_group", + Identifier: "location", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^$|^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]*$`, + Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, MinValueLength: 0, - MaxValueLength: 40, + MaxValueLength: 12, }, validate.ValidateSchema{ - Identifier: "location", + Identifier: "resource_group", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, Required: true, - Regexp: `^$|^(us-south|us-east|eu-gb|eu-de)$`, + Regexp: `^(?!\s)(?!.*\s$)[^'"` + "`" + `<>{}\x00-\x1F]*$`, MinValueLength: 0, - MaxValueLength: 12, + MaxValueLength: 64, }, ) @@ -244,15 +245,13 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions := &projectv1.CreateProjectOptions{} - createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - createProjectOptions.SetLocation(d.Get("location").(string)) - if _, ok := d.GetOk("definition"); ok { - definitionModel, err := resourceIbmProjectMapToProjectPrototypeDefinition(d.Get("definition.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createProjectOptions.SetDefinition(definitionModel) + definitionModel, err := resourceIbmProjectMapToProjectPrototypeDefinition(d.Get("definition.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } + createProjectOptions.SetDefinition(definitionModel) + createProjectOptions.SetLocation(d.Get("location").(string)) + createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) if _, ok := d.GetOk("configs"); ok { var configs []projectv1.ProjectConfigPrototype for _, v := range d.Get("configs").([]interface{}) { @@ -297,20 +296,18 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("GetProjectWithContext failed %s\n%s", err, response)) } + if err = d.Set("location", project.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + } if err = d.Set("resource_group", project.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } - if err = d.Set("location", project.Location); err != nil { - return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + definitionMap, err := resourceIbmProjectProjectDefinitionPropertiesToMap(project.Definition) + if err != nil { + return diag.FromErr(err) } - if !core.IsNil(project.Definition) { - definitionMap, err := resourceIbmProjectProjectDefinitionPropertiesToMap(project.Definition) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) - } + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } if !core.IsNil(project.Crn) { if err = d.Set("crn", project.Crn); err != nil { @@ -434,13 +431,11 @@ func resourceIbmProjectMapToProjectPrototypeDefinition(modelMap map[string]inter func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototype, error) { model := &projectv1.ProjectConfigPrototype{} - if modelMap["definition"] != nil && len(modelMap["definition"].([]interface{})) > 0 { - DefinitionModel, err := resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap["definition"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Definition = DefinitionModel + DefinitionModel, err := resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap["definition"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err } + model.Definition = DefinitionModel return model, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 3730b13bd7..6915eda332 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -36,8 +36,9 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "definition": &schema.Schema{ Type: schema.TypeList, + MinItems: 1, MaxItems: 1, - Optional: true, + Required: true, Description: "The type and output of a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -263,13 +264,11 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD createConfigOptions := &projectv1.CreateConfigOptions{} createConfigOptions.SetProjectID(d.Get("project_id").(string)) - if _, ok := d.GetOk("definition"); ok { - definitionModel, err := resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(d.Get("definition.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createConfigOptions.SetDefinition(definitionModel) + definitionModel, err := resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(d.Get("definition.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } + createConfigOptions.SetDefinition(definitionModel) projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { @@ -311,14 +310,12 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("project_id", projectConfig.ProjectID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) } - if !core.IsNil(projectConfig.Definition) { - definitionMap, err := resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) - } + definitionMap, err := resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting definition: %s", err)) } if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 29ccf25ccc..e84b0793bc 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -45,92 +45,7 @@ Nested schema for **configs**: * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `last_approved` - (List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_deployed` - (List) The action job performed on the project configuration. - Nested schema for **last_deployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `last_undeployed` - (List) The action job performed on the project configuration. - Nested schema for **last_undeployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. - * `last_validated` - (List) The action job performed on the project configuration. - Nested schema for **last_validated**: - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. @@ -164,7 +79,6 @@ Nested schema for **definition**: * `description` - (String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. * `name` - (String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 9d3c7229eb..be1b6351e3 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -86,97 +86,8 @@ Nested schema for **definition**: * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `last_approved` - (List) The last approved metadata of the configuration. -Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - -* `last_deployed` - (List) The action job performed on the project configuration. -Nested schema for **last_deployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `last_undeployed` - (List) The action job performed on the project configuration. -Nested schema for **last_undeployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. - -* `last_validated` - (List) The action job performed on the project configuration. -Nested schema for **last_validated**: - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. - * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 4b67a6d946..54fcd10fa0 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -28,18 +28,17 @@ resource "ibm_project" "project_instance" { You can specify the following arguments for this resource. -* `definition` - (Optional, List) The definition of the project. +* `definition` - (Required, List) The definition of the project. Nested schema for **definition**: * `description` - (Optional, String) A brief explanation of the project's use in the configuration of a deployable architecture. It is possible to create a project without providing a description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `destroy_on_delete` - (Required, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. - * Constraints: The default value is `true`. * `name` - (Required, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. -* `location` - (Required, String) The location where the project's data and tools are created. - * Constraints: The maximum length is `12` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(us-south|us-east|eu-gb|eu-de)$/`. +* `location` - (Required, String) The IBM Cloud location where a resource is deployed. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `resource_group` - (Required, String) The resource group where the project's data and tools are created. - * Constraints: The maximum length is `40` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. ## Attribute Reference @@ -61,92 +60,7 @@ Nested schema for **configs**: * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `last_approved` - (List) The last approved metadata of the configuration. - Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `last_deployed` - (List) The action job performed on the project configuration. - Nested schema for **last_deployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `last_undeployed` - (List) The action job performed on the project configuration. - Nested schema for **last_undeployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. - * `last_validated` - (List) The action job performed on the project configuration. - Nested schema for **last_validated**: - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 8f50ca5fcd..ab11a8f4f3 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -51,7 +51,7 @@ resource "ibm_project_config" "project_config_instance" { You can specify the following arguments for this resource. -* `definition` - (Optional, List) The type and output of a project configuration. +* `definition` - (Required, List) The type and output of a project configuration. Nested schema for **definition**: * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -109,92 +109,7 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the project_config. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `last_approved` - (List) The last approved metadata of the configuration. -Nested schema for **last_approved**: - * `comment` - (String) The comment left by the user who approved the configuration. - * Constraints: The default value is ``. - * `is_forced` - (Boolean) The flag that indicates whether the approval was forced approved. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `last_deployed` - (List) The action job performed on the project configuration. -Nested schema for **last_deployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `last_undeployed` - (List) The action job performed on the project configuration. -Nested schema for **last_undeployed**: - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. -* `last_validated` - (List) The action job performed on the project configuration. -Nested schema for **last_validated**: - * `cost_estimate` - (List) The cost estimate of the configuration.It only exists after the first configuration validation. - Nested schema for **cost_estimate**: - * `currency` - (String) The currency of the cost estimate of the configuration. - * `diff_total_hourly_cost` - (String) The difference between current and past total hourly cost estimates of the configuration. - * `diff_total_monthly_cost` - (String) The difference between current and past total monthly cost estimates of the configuration. - * `past_total_hourly_cost` - (String) The past total hourly cost estimate of the configuration. - * `past_total_monthly_cost` - (String) The past total monthly cost estimate of the configuration. - * `time_generated` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `total_hourly_cost` - (String) The total hourly cost estimate of the configuration. - * `total_monthly_cost` - (String) The total monthly cost estimate of the configuration. - * `user_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `version` - (String) The version of the cost estimate of the configuration. - * `cra_logs` - (List) The Code Risk Analyzer logs of the configuration. - Nested schema for **cra_logs**: - * `cra_version` - (String) The version of the Code Risk Analyzer logs of the configuration. - * `schema_version` - (String) The schema version of Code Risk Analyzer logs of the configuration. - * `status` - (String) The status of the Code Risk Analyzer logs of the configuration. - * `summary` - (Map) The summary of the Code Risk Analyzer logs of the configuration. - * `timestamp` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. - * `job` - (List) A brief summary of an action. - Nested schema for **job**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `summary` - (List) The summaries of jobs that were performed on the configuration. - Nested schema for **summary**: - * `apply_messages` - (Map) The messages of apply jobs on the configuration. - * `apply_summary` - (Map) The summary of the apply jobs on the configuration. - * `destroy_messages` - (Map) The messages of destroy jobs on the configuration. - * `destroy_summary` - (Map) The summary of the destroy jobs on the configuration. - * `message_summary` - (Map) The message summaries of jobs on the configuration. - * `plan_messages` - (Map) The messages of plan jobs on the configuration. - * `plan_summary` - (Map) The summary of the plan jobs on the configuration. - * `result` - (String) The result of the last action. - * Constraints: Allowable values are: `failed`, `passed`. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. From dc327dd7467795f81c390437bf05774603cbc4da Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 21 Sep 2023 18:46:47 +0200 Subject: [PATCH 105/125] secrets --- .secrets.baseline | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index e22c1e9225..4af7ab8dd6 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-20T16:31:46Z", + "generated_at": "2023-09-21T16:45:42Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -2812,7 +2812,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 556, + "line_number": 136, "type": "Secret Keyword", "verified_result": null }, @@ -2820,14 +2820,22 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 1062, + "line_number": 373, "type": "Secret Keyword", "verified_result": null } ], "ibm/service/project/data_source_ibm_project_config_test.go": [ { - "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "hashed_secret": "2c906a6f971c1871a78b88617cc39ea458c007dc", + "is_secret": false, + "is_verified": false, + "line_number": 56, + "type": "Base64 High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "6a5206b1a2d71fc03e74bf790718abcfd5820f2d", "is_secret": false, "is_verified": false, "line_number": 56, @@ -2840,7 +2848,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 92, + "line_number": 93, "type": "Secret Keyword", "verified_result": null }, @@ -2848,14 +2856,22 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 660, + "line_number": 657, "type": "Secret Keyword", "verified_result": null } ], "ibm/service/project/resource_ibm_project_config_test.go": [ { - "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "hashed_secret": "2c906a6f971c1871a78b88617cc39ea458c007dc", + "is_secret": false, + "is_verified": false, + "line_number": 61, + "type": "Base64 High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "6a5206b1a2d71fc03e74bf790718abcfd5820f2d", "is_secret": false, "is_verified": false, "line_number": 61, From 937eaaf3805e42ff107c59c0edbf206da2aa2735 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 21 Sep 2023 18:55:45 +0200 Subject: [PATCH 106/125] fix secrets --- .secrets.baseline | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 4af7ab8dd6..3135e330d0 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-21T16:45:42Z", + "generated_at": "2023-09-21T16:55:24Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -2827,15 +2827,7 @@ ], "ibm/service/project/data_source_ibm_project_config_test.go": [ { - "hashed_secret": "2c906a6f971c1871a78b88617cc39ea458c007dc", - "is_secret": false, - "is_verified": false, - "line_number": 56, - "type": "Base64 High Entropy String", - "verified_result": null - }, - { - "hashed_secret": "6a5206b1a2d71fc03e74bf790718abcfd5820f2d", + "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", "is_secret": false, "is_verified": false, "line_number": 56, @@ -2863,15 +2855,7 @@ ], "ibm/service/project/resource_ibm_project_config_test.go": [ { - "hashed_secret": "2c906a6f971c1871a78b88617cc39ea458c007dc", - "is_secret": false, - "is_verified": false, - "line_number": 61, - "type": "Base64 High Entropy String", - "verified_result": null - }, - { - "hashed_secret": "6a5206b1a2d71fc03e74bf790718abcfd5820f2d", + "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", "is_secret": false, "is_verified": false, "line_number": 61, From cc6c93bb4d9b9593c8b78ce4e89d5b80fdac67c3 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 22 Sep 2023 12:56:39 +0200 Subject: [PATCH 107/125] update samples with real values --- website/docs/r/project.html.markdown | 10 ++--- website/docs/r/project_config.html.markdown | 44 ++++++++------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 54fcd10fa0..70cefa111e 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,13 +14,13 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { + resource_group = "Default" + location = "us-south" definition { - name = "name" - description = "description" - destroy_on_delete = true + name = "My static website" + description = "Sample static website test using the IBM catalog deployable architecture" + destroy_on_delete = true } - location = "us-south" - resource_group = "Default" } ``` diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index ab11a8f4f3..2d6a7fff03 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -14,36 +14,24 @@ Create, update, and delete project_configs with this resource. ```hcl resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.project_id definition { - name = "name" - description = "description" - labels = [ "labels" ] - authorizations { - trusted_profile { - id = "id" - target_iam_id = "target_iam_id" - } - method = "method" - api_key = "api_key" - } - compliance_profile { - id = "id" - instance_id = "instance_id" - instance_location = "instance_location" - attachment_id = "attachment_id" - profile_name = "profile_name" - } - locator_id = "locator_id" - input = { } - setting = { } - type = "terraform_template" - output { - name = "name" - description = "description" - value = "anything as a string" - } + name = "static-website-dev" + labels = [ "env:dev", "billing:internal" ] + description = "Website - development" + authorizations { + method = "APIKEY" + api_key = "" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" + input { + name = "app_repo_name" + } + setting { + name = "app_repo_name" + value = "static-website-dev-app-repo" + } } - project_id = ibm_project.project_instance.id } ``` From dcc3792c94427a2f4e405024763ff0e1b89ffb7b Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 22 Sep 2023 13:06:04 +0200 Subject: [PATCH 108/125] update secrets --- .secrets.baseline | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.secrets.baseline b/.secrets.baseline index 3135e330d0..783a482faa 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-21T16:55:24Z", + "generated_at": "2023-09-22T11:05:35Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -4447,6 +4447,16 @@ "verified_result": null } ], + "website/docs/r/project_config.html.markdown": [ + { + "hashed_secret": "06d988e96c3d9325c9fbc7c0ef3c6c0f2b4eb8e7", + "is_secret": false, + "is_verified": false, + "line_number": 24, + "type": "Secret Keyword", + "verified_result": null + } + ], "website/docs/r/resource_instance.html.markdown": [ { "hashed_secret": "d62552e3d0606ac398b6ee5cbd49e763ac9c3933", From f174da3343f9feb915c325f0fe8f3f414bf8fcdd Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 22 Sep 2023 14:39:05 +0200 Subject: [PATCH 109/125] update secrets --- .secrets.baseline | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 783a482faa..9cc963b4b9 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-22T11:05:35Z", + "generated_at": "2023-09-22T12:38:47Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -752,7 +752,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 353, + "line_number": 355, "type": "Secret Keyword", "verified_result": null }, @@ -760,7 +760,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 359, + "line_number": 361, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1065, + "line_number": 1072, "type": "Base64 High Entropy String", "verified_result": null } @@ -856,7 +856,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1765, + "line_number": 1769, "type": "Secret Keyword", "verified_result": null }, @@ -864,7 +864,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1771, + "line_number": 1775, "type": "Secret Keyword", "verified_result": null } @@ -3733,6 +3733,16 @@ "verified_result": null } ], + "website/docs/d/cd_toolchains.html.markdown": [ + { + "hashed_secret": "8d204a8e6f883c0691207b5eed52ab2889568f71", + "is_secret": false, + "is_verified": false, + "line_number": 18, + "type": "Hex High Entropy String", + "verified_result": null + } + ], "website/docs/d/cis_waf_groups.html.markdown": [ { "hashed_secret": "ece6e4a51cf5a18845f07c95832586a96d5fcf4c", From 9fcb8ec167fd598f9d6546b26d877bd1624cca82 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 3 Oct 2023 11:54:26 +0200 Subject: [PATCH 110/125] update generated code to the latest API definition --- examples/ibm-project/README.md | 5 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 82 +++++++++++++- .../project/data_source_ibm_project_config.go | 40 ++++++- ibm/service/project/resource_ibm_project.go | 103 +++++++++++++++++- .../project/resource_ibm_project_config.go | 50 ++++++++- website/docs/d/project.html.markdown | 6 +- website/docs/d/project_config.html.markdown | 7 +- website/docs/r/project.html.markdown | 6 +- website/docs/r/project_config.html.markdown | 6 +- 11 files changed, 287 insertions(+), 24 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 5f97bf3ad2..159bc89199 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -84,11 +84,14 @@ data "project" "project_instance" { |------|-------------|------|---------| | ibmcloud\_api\_key | IBM Cloud API key | `string` | true | | project_id | The unique project ID. | `string` | true | -| definition | The type and output of a project configuration. | `` | false | +| schematics | A schematics workspace associated to a project configuration. | `` | false | +| definition | The type and output of a project configuration. | `` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | | location | The location where the project's data and tools are created. | `string` | true | | definition | The definition of the project. | `` | false | | project_id | The unique project ID. | `string` | true | +| id | The unique config ID. | `string` | true | +| id | The unique project ID. | `string` | true | ## Outputs diff --git a/go.mod b/go.mod index 234b0f328d..3add490329 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.48.1 - github.com/IBM/project-go-sdk v0.0.26-83 + github.com/IBM/project-go-sdk v0.0.90 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index c4c3a897f6..75be983225 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.48.1 h1:TT+v28xaaFDolswhFLc+2ut6KXukoNyJGhlhuJupV7g= github.com/IBM/platform-services-go-sdk v0.48.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.26-83 h1:7SvrgKRxcIme0ET5GT+W6MjKrrwHRywAMxMN5rDjjAk= -github.com/IBM/project-go-sdk v0.0.26-83/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.90 h1:S+hrSosxrB4R38ZVEcwY22FMWVJuW06twrD9yVTeHC4= +github.com/IBM/project-go-sdk v0.0.90/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.1.2 h1:9axGtNlP3bHhoE9yJgCuc+g5/VdyhYqfhZ5oS3ovCFI= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 0662b28741..a9bd37152f 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -140,7 +140,7 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "updated_at": &schema.Schema{ + "user_modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -150,6 +150,20 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "schematics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A schematics workspace associated to a project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "workspace_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An existing schematics workspace ID.", + }, + }, + }, + }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -325,8 +339,8 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() + if model.UserModifiedAt != nil { + modelMap["user_modified_at"] = model.UserModifiedAt.String() } if model.LastApproved != nil { lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) @@ -359,6 +373,13 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro } modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} } + if model.Schematics != nil { + schematicsMap, err := dataSourceIbmProjectSchematicsWorkspaceToMap(model.Schematics) + if err != nil { + return modelMap, err + } + modelMap["schematics"] = []map[string]interface{}{schematicsMap} + } modelMap["href"] = model.Href definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -387,6 +408,20 @@ func dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.La if model.Result != nil { modelMap["result"] = model.Result } + if model.PreJob != nil { + preJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) + if err != nil { + return modelMap, err + } + modelMap["pre_job"] = []map[string]interface{}{preJobMap} + } + if model.PostJob != nil { + postJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) + if err != nil { + return modelMap, err + } + modelMap["post_job"] = []map[string]interface{}{postJobMap} + } if model.Job != nil { jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) if err != nil { @@ -411,6 +446,25 @@ func dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.La return modelMap, nil } +func dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model *projectv1.PrePostActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + return modelMap, nil +} + func dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { @@ -579,6 +633,20 @@ func dataSourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionW if model.Result != nil { modelMap["result"] = model.Result } + if model.PreJob != nil { + preJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) + if err != nil { + return modelMap, err + } + modelMap["pre_job"] = []map[string]interface{}{preJobMap} + } + if model.PostJob != nil { + postJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) + if err != nil { + return modelMap, err + } + modelMap["post_job"] = []map[string]interface{}{postJobMap} + } if model.Job != nil { jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) if err != nil { @@ -589,6 +657,14 @@ func dataSourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionW return modelMap, nil } +func dataSourceIbmProjectSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.WorkspaceID != nil { + modelMap["workspace_id"] = model.WorkspaceID + } + return modelMap, nil +} + func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 532fa1c707..eaeac93abe 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -69,7 +69,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "updated_at": &schema.Schema{ + "user_modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -79,6 +79,20 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "schematics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "A schematics workspace associated to a project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "workspace_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An existing schematics workspace ID.", + }, + }, + }, + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -279,14 +293,26 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + if err = d.Set("user_modified_at", flex.DateTimeToString(projectConfig.UserModifiedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) } if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) } + schematics := []map[string]interface{}{} + if projectConfig.Schematics != nil { + modelMap, err := dataSourceIbmProjectConfigSchematicsWorkspaceToMap(projectConfig.Schematics) + if err != nil { + return diag.FromErr(err) + } + schematics = append(schematics, modelMap) + } + if err = d.Set("schematics", schematics); err != nil { + return diag.FromErr(fmt.Errorf("Error setting schematics %s", err)) + } + definition := []map[string]interface{}{} if projectConfig.Definition != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) @@ -302,6 +328,14 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return nil } +func dataSourceIbmProjectConfigSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.WorkspaceID != nil { + modelMap["workspace_id"] = model.WorkspaceID + } + return modelMap, nil +} + func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 7ab02f2185..128ce46077 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -37,7 +37,6 @@ func ResourceIbmProject() *schema.Resource { "resource_group": &schema.Schema{ Type: schema.TypeString, Required: true, - // ValidateFunc: validate.InvokeValidator("ibm_project", "resource_group"), Description: "The resource group where the project's data and tools are created.", }, "definition": &schema.Schema{ @@ -167,7 +166,7 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "updated_at": &schema.Schema{ + "user_modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -177,6 +176,21 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "schematics": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A schematics workspace associated to a project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "workspace_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "An existing schematics workspace ID.", + }, + }, + }, + }, "href": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -436,6 +450,13 @@ func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface return model, err } model.Definition = DefinitionModel + if modelMap["schematics"] != nil && len(modelMap["schematics"].([]interface{})) > 0 { + SchematicsModel, err := resourceIbmProjectMapToSchematicsWorkspace(modelMap["schematics"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Schematics = SchematicsModel + } return model, nil } @@ -466,7 +487,9 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s } model.ComplianceProfile = ComplianceProfileModel } - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -543,6 +566,14 @@ func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{} return model, nil } +func resourceIbmProjectMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { + model := &projectv1.SchematicsWorkspace{} + if modelMap["workspace_id"] != nil && modelMap["workspace_id"].(string) != "" { + model.WorkspaceID = core.StringPtr(modelMap["workspace_id"].(string)) + } + return model, nil +} + func resourceIbmProjectMapToProjectPrototypePatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectPrototypePatchDefinitionBlock, error) { model := &projectv1.ProjectPrototypePatchDefinitionBlock{} if modelMap["name"] != nil && modelMap["name"].(string) != "" { @@ -598,8 +629,8 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } - if model.UpdatedAt != nil { - modelMap["updated_at"] = model.UpdatedAt.String() + if model.UserModifiedAt != nil { + modelMap["user_modified_at"] = model.UserModifiedAt.String() } if model.LastApproved != nil { lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) @@ -632,6 +663,13 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje } modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} } + if model.Schematics != nil { + schematicsMap, err := resourceIbmProjectSchematicsWorkspaceToMap(model.Schematics) + if err != nil { + return modelMap, err + } + modelMap["schematics"] = []map[string]interface{}{schematicsMap} + } modelMap["href"] = model.Href definitionMap, err := resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -660,6 +698,20 @@ func resourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.Last if model.Result != nil { modelMap["result"] = model.Result } + if model.PreJob != nil { + preJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) + if err != nil { + return modelMap, err + } + modelMap["pre_job"] = []map[string]interface{}{preJobMap} + } + if model.PostJob != nil { + postJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) + if err != nil { + return modelMap, err + } + modelMap["post_job"] = []map[string]interface{}{postJobMap} + } if model.Job != nil { jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) if err != nil { @@ -684,6 +736,25 @@ func resourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.Last return modelMap, nil } +func resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model *projectv1.PrePostActionJobWithIdAndSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.Summary != nil { + summary := make(map[string]interface{}) + for k, v := range model.Summary { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + summary[k] = string(bytes) + } + modelMap["summary"] = summary + } + return modelMap, nil +} + func resourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { @@ -852,6 +923,20 @@ func resourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWit if model.Result != nil { modelMap["result"] = model.Result } + if model.PreJob != nil { + preJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) + if err != nil { + return modelMap, err + } + modelMap["pre_job"] = []map[string]interface{}{preJobMap} + } + if model.PostJob != nil { + postJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) + if err != nil { + return modelMap, err + } + modelMap["post_job"] = []map[string]interface{}{postJobMap} + } if model.Job != nil { jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) if err != nil { @@ -862,6 +947,14 @@ func resourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWit return modelMap, nil } +func resourceIbmProjectSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.WorkspaceID != nil { + modelMap["workspace_id"] = model.WorkspaceID + } + return modelMap, nil +} + func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 6915eda332..251ab59ee7 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -34,6 +34,21 @@ func ResourceIbmProjectConfig() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_project_config", "project_id"), Description: "The unique project ID.", }, + "schematics": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "A schematics workspace associated to a project configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "workspace_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "An existing schematics workspace ID.", + }, + }, + }, + }, "definition": &schema.Schema{ Type: schema.TypeList, MinItems: 1, @@ -219,7 +234,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "updated_at": &schema.Schema{ + "user_modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -269,6 +284,13 @@ func resourceIbmProjectConfigCreate(context context.Context, d *schema.ResourceD return diag.FromErr(err) } createConfigOptions.SetDefinition(definitionModel) + if _, ok := d.GetOk("schematics"); ok { + schematicsModel, err := resourceIbmProjectConfigMapToSchematicsWorkspace(d.Get("schematics.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createConfigOptions.SetSchematics(schematicsModel) + } projectConfig, response, err := projectClient.CreateConfigWithContext(context, createConfigOptions) if err != nil { @@ -343,9 +365,9 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } } - if !core.IsNil(projectConfig.UpdatedAt) { - if err = d.Set("updated_at", flex.DateTimeToString(projectConfig.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) + if !core.IsNil(projectConfig.UserModifiedAt) { + if err = d.Set("user_modified_at", flex.DateTimeToString(projectConfig.UserModifiedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) } } if !core.IsNil(projectConfig.LastSave) { @@ -456,7 +478,9 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap } model.ComplianceProfile = ComplianceProfileModel } - model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { InputModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -533,6 +557,14 @@ func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]inter return model, nil } +func resourceIbmProjectConfigMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { + model := &projectv1.SchematicsWorkspace{} + if modelMap["workspace_id"] != nil && modelMap["workspace_id"].(string) != "" { + model.WorkspaceID = core.StringPtr(modelMap["workspace_id"].(string)) + } + return model, nil +} + func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypePatchDefinitionBlock, error) { model := &projectv1.ProjectConfigPrototypePatchDefinitionBlock{} if modelMap["name"] != nil && modelMap["name"].(string) != "" { @@ -582,6 +614,14 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(mod return model, nil } +func resourceIbmProjectConfigSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.WorkspaceID != nil { + modelMap["workspace_id"] = model.WorkspaceID + } + return modelMap, nil +} + func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index e84b0793bc..7d0a2e0d4e 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -50,10 +50,14 @@ Nested schema for **configs**: * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `schematics` - (List) A schematics workspace associated to a project configuration. + Nested schema for **schematics**: + * `workspace_id` - (String) An existing schematics workspace ID. + * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index be1b6351e3..2a60ccdf66 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -94,12 +94,17 @@ Nested schema for **definition**: * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `schematics` - (List) A schematics workspace associated to a project configuration. +Nested schema for **schematics**: + * `workspace_id` - (String) An existing schematics workspace ID. + * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. + * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. -* `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 70cefa111e..38a77c1368 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -65,10 +65,14 @@ Nested schema for **configs**: * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `schematics` - (List) A schematics workspace associated to a project configuration. + Nested schema for **schematics**: + * `workspace_id` - (String) An existing schematics workspace ID. + * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. - * `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 2d6a7fff03..d529ed6697 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -89,6 +89,10 @@ Nested schema for **definition**: * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. +* `schematics` - (Optional, List) A schematics workspace associated to a project configuration. +Nested schema for **schematics**: + * `workspace_id` - (Optional, String) An existing schematics workspace ID. + * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. ## Attribute Reference @@ -105,7 +109,7 @@ After your resource is created, you can read values from the listed arguments an * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. -* `updated_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From 2ee7dbaa578df0d832a73242a4254253a7765451 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 3 Oct 2023 12:05:15 +0200 Subject: [PATCH 111/125] update secrets baseline --- .secrets.baseline | 36 ++++++++++----------- ibm/service/project/resource_ibm_project.go | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 9cc963b4b9..861dbef1ee 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-22T12:38:47Z", + "generated_at": "2023-10-03T10:04:19Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -652,7 +652,7 @@ "hashed_secret": "ba02c5a1aad447298fcfbd962a953e7706b8b430", "is_secret": false, "is_verified": false, - "line_number": 25, + "line_number": 27, "type": "Hex High Entropy String", "verified_result": null } @@ -752,7 +752,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 355, + "line_number": 382, "type": "Secret Keyword", "verified_result": null }, @@ -760,7 +760,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 361, + "line_number": 388, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1072, + "line_number": 1099, "type": "Base64 High Entropy String", "verified_result": null } @@ -802,7 +802,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3248, + "line_number": 3250, "type": "Secret Keyword", "verified_result": null }, @@ -810,7 +810,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3261, + "line_number": 3263, "type": "Secret Keyword", "verified_result": null }, @@ -818,7 +818,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3302, + "line_number": 3304, "type": "Secret Keyword", "verified_result": null } @@ -846,7 +846,7 @@ "hashed_secret": "1a0334cfa65f4be58b9d914b8e96e9d9478bfbac", "is_secret": false, "is_verified": false, - "line_number": 3242, + "line_number": 3226, "type": "Secret Keyword", "verified_result": null } @@ -2812,7 +2812,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 136, + "line_number": 150, "type": "Secret Keyword", "verified_result": null }, @@ -2820,7 +2820,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 373, + "line_number": 407, "type": "Secret Keyword", "verified_result": null } @@ -2840,7 +2840,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 93, + "line_number": 108, "type": "Secret Keyword", "verified_result": null }, @@ -2848,7 +2848,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 657, + "line_number": 697, "type": "Secret Keyword", "verified_result": null } @@ -2966,7 +2966,7 @@ "hashed_secret": "83747cea2b26d7652ed39218ddcdb1461c570535", "is_secret": false, "is_verified": false, - "line_number": 80, + "line_number": 79, "type": "Hex High Entropy String", "verified_result": null } @@ -2986,7 +2986,7 @@ "hashed_secret": "83747cea2b26d7652ed39218ddcdb1461c570535", "is_secret": false, "is_verified": false, - "line_number": 95, + "line_number": 94, "type": "Hex High Entropy String", "verified_result": null } @@ -3712,7 +3712,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 92841, + "line_number": 93883, "type": "Secret Keyword", "verified_result": null }, @@ -3720,7 +3720,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 115304, + "line_number": 116309, "type": "Secret Keyword", "verified_result": null }, @@ -3728,7 +3728,7 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 145758, + "line_number": 147225, "type": "Secret Keyword", "verified_result": null } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 128ce46077..ba12229fc9 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -35,8 +35,8 @@ func ResourceIbmProject() *schema.Resource { Description: "The IBM Cloud location where a resource is deployed.", }, "resource_group": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, Description: "The resource group where the project's data and tools are created.", }, "definition": &schema.Schema{ From fe35276e4d0e057e4e0b9c981443e051cc571a2b Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 4 Oct 2023 12:58:48 +0200 Subject: [PATCH 112/125] merge with master --- .secrets.baseline | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 861dbef1ee..63a4d94463 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-03T10:04:19Z", + "generated_at": "2023-10-04T10:58:11Z", "plugins_used": [ { "name": "AWSKeyDetector" diff --git a/go.sum b/go.sum index 1925231db5..11862c817f 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.50.4 h1:YQcdFv5+WW+rH1lideBX4fJbPoS3NauUNqtJdxnnKyI= github.com/IBM/platform-services-go-sdk v0.50.4/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8= -github.com/IBM/project-go-sdk v0.0.10/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.90 h1:S+hrSosxrB4R38ZVEcwY22FMWVJuW06twrD9yVTeHC4= +github.com/IBM/project-go-sdk v0.0.90/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.1.2 h1:9axGtNlP3bHhoE9yJgCuc+g5/VdyhYqfhZ5oS3ovCFI= From 34a294d3a09b1be8a8e4d6a960e3dc58362a0c8d Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 9 Oct 2023 17:11:37 +0200 Subject: [PATCH 113/125] merge with master --- .secrets.baseline | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 63a4d94463..1c637e659f 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-04T10:58:11Z", + "generated_at": "2023-10-09T15:11:13Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -3080,7 +3080,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 177, + "line_number": 185, "type": "Secret Keyword", "verified_result": null }, @@ -3088,7 +3088,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 317, + "line_number": 312, "type": "Secret Keyword", "verified_result": null } @@ -3136,7 +3136,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 189, + "line_number": 197, "type": "Secret Keyword", "verified_result": null }, @@ -3144,7 +3144,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 345, + "line_number": 339, "type": "Secret Keyword", "verified_result": null } @@ -3154,7 +3154,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 227, + "line_number": 235, "type": "Secret Keyword", "verified_result": null }, @@ -3162,7 +3162,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 420, + "line_number": 414, "type": "Secret Keyword", "verified_result": null } @@ -3208,7 +3208,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 292, + "line_number": 299, "type": "Secret Keyword", "verified_result": null }, @@ -3216,7 +3216,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 489, + "line_number": 482, "type": "Secret Keyword", "verified_result": null } @@ -3310,7 +3310,7 @@ "hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3", "is_secret": false, "is_verified": false, - "line_number": 46, + "line_number": 48, "type": "Secret Keyword", "verified_result": null } @@ -3338,7 +3338,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 154, + "line_number": 162, "type": "Secret Keyword", "verified_result": null }, @@ -3346,7 +3346,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 283, + "line_number": 278, "type": "Secret Keyword", "verified_result": null } From 59a343895b8fe98e6bf889d538d4a0ad0cba6758 Mon Sep 17 00:00:00 2001 From: rangelil Date: Fri, 13 Oct 2023 07:45:50 +0200 Subject: [PATCH 114/125] merge with master --- .secrets.baseline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.secrets.baseline b/.secrets.baseline index 1c637e659f..f58c415945 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-09T15:11:13Z", + "generated_at": "2023-10-13T05:45:31Z", "plugins_used": [ { "name": "AWSKeyDetector" From 75ac6cb02b302da28168c553e6268603aa2a9002 Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 16 Oct 2023 14:45:58 +0200 Subject: [PATCH 115/125] update code to the latest SDK level --- .secrets.baseline | 10 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 125 +++++++++++++++ .../project/data_source_ibm_project_config.go | 51 ++---- ibm/service/project/resource_ibm_project.go | 148 ++++++++++++++++-- .../project/resource_ibm_project_config.go | 77 +++------ website/docs/d/project.html.markdown | 17 ++ website/docs/d/project_config.html.markdown | 14 +- website/docs/r/project.html.markdown | 16 ++ website/docs/r/project_config.html.markdown | 14 +- 11 files changed, 347 insertions(+), 131 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index f58c415945..dde8385ec4 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-13T05:45:31Z", + "generated_at": "2023-10-16T12:45:41Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -2812,7 +2812,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 150, + "line_number": 141, "type": "Secret Keyword", "verified_result": null }, @@ -2820,7 +2820,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 407, + "line_number": 397, "type": "Secret Keyword", "verified_result": null } @@ -2840,7 +2840,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 108, + "line_number": 98, "type": "Secret Keyword", "verified_result": null }, @@ -2848,7 +2848,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 697, + "line_number": 677, "type": "Secret Keyword", "verified_result": null } diff --git a/go.mod b/go.mod index d7184976a1..ba0bd4f1ac 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.50.4 - github.com/IBM/project-go-sdk v0.0.90 + github.com/IBM/project-go-sdk v0.0.92 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.2 github.com/IBM/schematics-go-sdk v0.2.1 diff --git a/go.sum b/go.sum index 6478768e4c..813150f79c 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.50.4 h1:YQcdFv5+WW+rH1lideBX4fJbPoS3NauUNqtJdxnnKyI= github.com/IBM/platform-services-go-sdk v0.50.4/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.90 h1:S+hrSosxrB4R38ZVEcwY22FMWVJuW06twrD9yVTeHC4= -github.com/IBM/project-go-sdk v0.0.90/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.92 h1:qnSmk+gEOyt7RWX5dMCNUgZG1w5WeJYBhRMaHKni8PE= +github.com/IBM/project-go-sdk v0.0.92/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/scc-go-sdk/v5 v5.1.2 h1:9axGtNlP3bHhoE9yJgCuc+g5/VdyhYqfhZ5oS3ovCFI= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index a9bd37152f..b19a252fd2 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -191,6 +191,54 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "environments": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project environments. These environments are only included in the response if project environments were created on the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The environment id as a friendly name.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A relative URL.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The environment definition used in the project collection.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the environment.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the environment.", + }, + }, + }, + }, + }, + }, + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -293,6 +341,20 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting configs %s", err)) } + environments := []map[string]interface{}{} + if project.Environments != nil { + for _, modelItem := range project.Environments { + modelMap, err := dataSourceIbmProjectProjectEnvironmentCollectionMemberToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + environments = append(environments, modelMap) + } + } + if err = d.Set("environments", environments); err != nil { + return diag.FromErr(fmt.Errorf("Error setting environments %s", err)) + } + definition := []map[string]interface{}{} if project.Definition != nil { modelMap, err := dataSourceIbmProjectProjectDefinitionPropertiesToMap(project.Definition) @@ -327,6 +389,20 @@ func dataSourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulati func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.ProjectConfigCollectionMember) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.ApprovedVersion != nil { + approvedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) + if err != nil { + return modelMap, err + } + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} + } + if model.DeployedVersion != nil { + deployedVersionMap, err := dataSourceIbmProjectProjectConfigVersionSummaryToMap(model.DeployedVersion) + if err != nil { + return modelMap, err + } + modelMap["deployed_version"] = []map[string]interface{}{deployedVersionMap} + } modelMap["id"] = model.ID modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) @@ -352,6 +428,17 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } + if model.References != nil { + references := make(map[string]interface{}) + for k, v := range model.References { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + references[k] = string(bytes) + } + modelMap["references"] = references + } if model.LastValidated != nil { lastValidatedMap, err := dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) if err != nil { @@ -389,6 +476,19 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro return modelMap, nil } +func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["is_forced"] = model.IsForced @@ -676,6 +776,31 @@ func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *proj return modelMap, nil } +func dataSourceIbmProjectProjectEnvironmentCollectionMemberToMap(model *projectv1.ProjectEnvironmentCollectionMember) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["project_id"] = model.ProjectID + modelMap["created_at"] = model.CreatedAt.String() + modelMap["href"] = model.Href + definitionMap, err := dataSourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + return modelMap, nil +} + +func dataSourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model *projectv1.EnvironmentDefinitionNameDescription) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + return modelMap, nil +} + func dataSourceIbmProjectProjectDefinitionPropertiesToMap(model *projectv1.ProjectDefinitionProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index eaeac93abe..6e3e8d5f57 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -117,35 +117,26 @@ func DataSourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, }, }, + "environment": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The ID of the project environment.", + }, "authorizations": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, + "trusted_profile_id": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, - }, - }, + Description: "The trusted profile ID.", }, "method": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager.", }, "api_key": &schema.Schema{ Type: schema.TypeString, @@ -345,6 +336,9 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje if model.Labels != nil { modelMap["labels"] = model.Labels } + if model.Environment != nil { + modelMap["environment"] = model.Environment + } if model.Authorizations != nil { authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) if err != nil { @@ -393,12 +387,8 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := dataSourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) - if err != nil { - return modelMap, err - } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + if model.TrustedProfileID != nil { + modelMap["trusted_profile_id"] = model.TrustedProfileID } if model.Method != nil { modelMap["method"] = model.Method @@ -409,17 +399,6 @@ func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectCo return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID - } - return modelMap, nil -} - func dataSourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index ba12229fc9..56d904760d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -220,6 +220,56 @@ func ResourceIbmProject() *schema.Resource { }, }, }, + "environments": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project environments. These environments are only included in the response if project environments were created on the project.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The environment id as a friendly name.", + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A relative URL.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The environment definition used in the project collection.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The name of the environment.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The description of the environment.", + }, + }, + }, + }, + }, + }, + }, }, } } @@ -374,6 +424,19 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting configs: %s", err)) } } + if !core.IsNil(project.Environments) { + environments := []map[string]interface{}{} + for _, environmentsItem := range project.Environments { + environmentsItemMap, err := resourceIbmProjectProjectEnvironmentCollectionMemberToMap(&environmentsItem) + if err != nil { + return diag.FromErr(err) + } + environments = append(environments, environmentsItemMap) + } + if err = d.Set("environments", environments); err != nil { + return diag.FromErr(fmt.Errorf("Error setting environments: %s", err)) + } + } return nil } @@ -473,6 +536,9 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s } model.Labels = labels } + if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { + model.Environment = core.StringPtr(modelMap["environment"].(string)) + } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -509,12 +575,8 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s func resourceIbmProjectMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} - if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { - TrustedProfileModel, err := resourceIbmProjectMapToProjectConfigAuthTrustedProfile(modelMap["trusted_profile"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.TrustedProfile = TrustedProfileModel + if modelMap["trusted_profile_id"] != nil && modelMap["trusted_profile_id"].(string) != "" { + model.TrustedProfileID = core.StringPtr(modelMap["trusted_profile_id"].(string)) } if modelMap["method"] != nil && modelMap["method"].(string) != "" { model.Method = core.StringPtr(modelMap["method"].(string)) @@ -525,17 +587,6 @@ func resourceIbmProjectMapToProjectConfigAuth(modelMap map[string]interface{}) ( return model, nil } -func resourceIbmProjectMapToProjectConfigAuthTrustedProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuthTrustedProfile, error) { - model := &projectv1.ProjectConfigAuthTrustedProfile{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } - if modelMap["target_iam_id"] != nil && modelMap["target_iam_id"].(string) != "" { - model.TargetIamID = core.StringPtr(modelMap["target_iam_id"].(string)) - } - return model, nil -} - func resourceIbmProjectMapToProjectComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectComplianceProfile, error) { model := &projectv1.ProjectComplianceProfile{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { @@ -617,6 +668,20 @@ func resourceIbmProjectCumulativeNeedsAttentionToMap(model *projectv1.Cumulative func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.ProjectConfigCollectionMember) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) + if model.ApprovedVersion != nil { + approvedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.ApprovedVersion) + if err != nil { + return modelMap, err + } + modelMap["approved_version"] = []map[string]interface{}{approvedVersionMap} + } + if model.DeployedVersion != nil { + deployedVersionMap, err := resourceIbmProjectProjectConfigVersionSummaryToMap(model.DeployedVersion) + if err != nil { + return modelMap, err + } + modelMap["deployed_version"] = []map[string]interface{}{deployedVersionMap} + } modelMap["id"] = model.ID modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) @@ -642,6 +707,17 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje if model.LastSave != nil { modelMap["last_save"] = model.LastSave.String() } + if model.References != nil { + references := make(map[string]interface{}) + for k, v := range model.References { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + references[k] = string(bytes) + } + modelMap["references"] = references + } if model.LastValidated != nil { lastValidatedMap, err := resourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) if err != nil { @@ -679,6 +755,19 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje return modelMap, nil } +func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.NeedsAttentionState != nil { + modelMap["needs_attention_state"] = model.NeedsAttentionState + } + modelMap["state"] = model.State + modelMap["version"] = flex.IntValue(model.Version) + if model.Href != nil { + modelMap["href"] = model.Href + } + return modelMap, nil +} + func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["is_forced"] = model.IsForced @@ -965,3 +1054,28 @@ func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projec } return modelMap, nil } + +func resourceIbmProjectProjectEnvironmentCollectionMemberToMap(model *projectv1.ProjectEnvironmentCollectionMember) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["project_id"] = model.ProjectID + modelMap["created_at"] = model.CreatedAt.String() + modelMap["href"] = model.Href + definitionMap, err := resourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + return modelMap, nil +} + +func resourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model *projectv1.EnvironmentDefinitionNameDescription) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } + if model.Description != nil { + modelMap["description"] = model.Description + } + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 251ab59ee7..daaaf5c3e7 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -73,37 +73,27 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "The configuration labels.", Elem: &schema.Schema{Type: schema.TypeString}, }, + "environment": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the project environment.", + }, "authorizations": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, - Description: "The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "trusted_profile": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + "trusted_profile_id": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Description: "The trusted profile for authorizations.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - "target_iam_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "The unique ID.", - }, - }, - }, + Description: "The trusted profile ID.", }, "method": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager.", + Description: "The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager.", }, "api_key": &schema.Schema{ Type: schema.TypeString, @@ -464,6 +454,9 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap } model.Labels = labels } + if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { + model.Environment = core.StringPtr(modelMap["environment"].(string)) + } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -500,12 +493,8 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuth, error) { model := &projectv1.ProjectConfigAuth{} - if modelMap["trusted_profile"] != nil && len(modelMap["trusted_profile"].([]interface{})) > 0 { - TrustedProfileModel, err := resourceIbmProjectConfigMapToProjectConfigAuthTrustedProfile(modelMap["trusted_profile"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.TrustedProfile = TrustedProfileModel + if modelMap["trusted_profile_id"] != nil && modelMap["trusted_profile_id"].(string) != "" { + model.TrustedProfileID = core.StringPtr(modelMap["trusted_profile_id"].(string)) } if modelMap["method"] != nil && modelMap["method"].(string) != "" { model.Method = core.StringPtr(modelMap["method"].(string)) @@ -516,17 +505,6 @@ func resourceIbmProjectConfigMapToProjectConfigAuth(modelMap map[string]interfac return model, nil } -func resourceIbmProjectConfigMapToProjectConfigAuthTrustedProfile(modelMap map[string]interface{}) (*projectv1.ProjectConfigAuthTrustedProfile, error) { - model := &projectv1.ProjectConfigAuthTrustedProfile{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } - if modelMap["target_iam_id"] != nil && modelMap["target_iam_id"].(string) != "" { - model.TargetIamID = core.StringPtr(modelMap["target_iam_id"].(string)) - } - return model, nil -} - func resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectComplianceProfile, error) { model := &projectv1.ProjectComplianceProfile{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { @@ -580,6 +558,9 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(mod } model.Labels = labels } + if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { + model.Environment = core.StringPtr(modelMap["environment"].(string)) + } if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -631,6 +612,9 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project if model.Labels != nil { modelMap["labels"] = model.Labels } + if model.Environment != nil { + modelMap["environment"] = model.Environment + } if model.Authorizations != nil { authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) if err != nil { @@ -683,12 +667,8 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.TrustedProfile != nil { - trustedProfileMap, err := resourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model.TrustedProfile) - if err != nil { - return modelMap, err - } - modelMap["trusted_profile"] = []map[string]interface{}{trustedProfileMap} + if model.TrustedProfileID != nil { + modelMap["trusted_profile_id"] = model.TrustedProfileID } if model.Method != nil { modelMap["method"] = model.Method @@ -699,17 +679,6 @@ func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConf return modelMap, nil } -func resourceIbmProjectConfigProjectConfigAuthTrustedProfileToMap(model *projectv1.ProjectConfigAuthTrustedProfile) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.TargetIamID != nil { - modelMap["target_iam_id"] = model.TargetIamID - } - return modelMap, nil -} - func resourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 7d0a2e0d4e..0cda6a2a6a 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -86,6 +86,23 @@ Nested schema for **definition**: * `name` - (String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. +* `environments` - (List) The project environments. These environments are only included in the response if project environments were created on the project. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **environments**: + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The environment definition used in the project collection. + Nested schema for **definition**: + * `description` - (String) The description of the environment. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The name of the environment. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The environment id as a friendly name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `project_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 2a60ccdf66..3113402410 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -37,18 +37,14 @@ After your data source is created, you can read values from the following attrib * `definition` - (List) The type and output of a project configuration. Nested schema for **definition**: - * `authorizations` - (List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + * `authorizations` - (List) The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `trusted_profile_id` - (String) The trusted profile ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. Nested schema for **compliance_profile**: * `attachment_id` - (String) The unique ID. @@ -63,6 +59,8 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `environment` - (String) The ID of the project environment. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (List) The input variables for configuration definition and environment. Nested schema for **input**: * `labels` - (List) The configuration labels. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 38a77c1368..55d7469dd9 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -88,6 +88,22 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. +* `environments` - (List) The project environments. These environments are only included in the response if project environments were created on the project. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **environments**: + * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `definition` - (List) The environment definition used in the project collection. + Nested schema for **definition**: + * `description` - (String) The description of the environment. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The name of the environment. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A relative URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The environment id as a friendly name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `project_id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index d529ed6697..1f748c0dc5 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -41,18 +41,14 @@ You can specify the following arguments for this resource. * `definition` - (Required, List) The type and output of a project configuration. Nested schema for **definition**: - * `authorizations` - (Optional, List) The authorization for a configuration.You can authorize by using a trusted profile or an API key in Secrets Manager. + * `authorizations` - (Optional, List) The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: * `api_key` - (Optional, String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (Optional, String) The authorization for a configuration. You can authorize by using a trusted profile or an API key in Secrets Manager. + * `method` - (Optional, String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. - * `trusted_profile` - (Optional, List) The trusted profile for authorizations. - Nested schema for **trusted_profile**: - * `id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `target_iam_id` - (Optional, String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `trusted_profile_id` - (Optional, String) The trusted profile ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. Nested schema for **compliance_profile**: * `attachment_id` - (Optional, String) The unique ID. @@ -67,6 +63,8 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) A project configuration description. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `environment` - (Optional, String) The ID of the project environment. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `input` - (Optional, List) The input variables for configuration definition and environment. Nested schema for **input**: * `labels` - (Optional, List) The configuration labels. From eba06cb2acabd2e9f9f0c00dfdd13489f60a5ed0 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 18 Oct 2023 17:35:23 +0200 Subject: [PATCH 116/125] address some review comments --- .secrets.baseline | 14 +++++++------- ibm/acctest/acctest.go | 8 ++++++++ .../project/data_source_ibm_project_config_test.go | 4 ++-- .../project/resource_ibm_project_config_test.go | 4 ++-- website/docs/d/project.html.markdown | 2 +- website/docs/d/project_config.html.markdown | 2 +- website/docs/r/project.html.markdown | 2 +- website/docs/r/project_config.html.markdown | 2 +- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index dde8385ec4..3e0757cf66 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-16T12:45:41Z", + "generated_at": "2023-10-18T15:34:16Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -752,7 +752,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 382, + "line_number": 391, "type": "Secret Keyword", "verified_result": null }, @@ -760,7 +760,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 388, + "line_number": 397, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1099, + "line_number": 1108, "type": "Base64 High Entropy String", "verified_result": null } @@ -2827,7 +2827,7 @@ ], "ibm/service/project/data_source_ibm_project_config_test.go": [ { - "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3", "is_secret": false, "is_verified": false, "line_number": 56, @@ -2855,7 +2855,7 @@ ], "ibm/service/project/resource_ibm_project_config_test.go": [ { - "hashed_secret": "d9e9019d9eb455a3d72a3bc252c26927bb148a10", + "hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3", "is_secret": false, "is_verified": false, "line_number": 61, @@ -3682,7 +3682,7 @@ "hashed_secret": "4d55af37dbbb6a42088d917caa1ca25428ec42c9", "is_secret": false, "is_verified": false, - "line_number": 788, + "line_number": 849, "type": "Secret Keyword", "verified_result": null } diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index 54513583d9..5b4f4f249c 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -299,6 +299,9 @@ var ( // for IAM Identity var IamIdentityAssignmentTargetAccountId string +// Projects +var ProjectsConfigApiKey string + func init() { testlogger := os.Getenv("TF_LOG") if testlogger != "" { @@ -307,6 +310,11 @@ func init() { IamIdentityAssignmentTargetAccountId = os.Getenv("IAM_IDENTITY_ASSIGNMENT_TARGET_ACCOUNT") + ProjectsConfigApiKey = os.Getenv("IBM_PROJECTS_CONFIG_APIKEY") + if ProjectsConfigApiKey == "" { + fmt.Println("[WARN] Set the environment variable IBM_PROJECTS_CONFIG_APIKEY for testing IBM Projects Config resources, the tests will fail if this is not set") + } + AppIDTenantID = os.Getenv("IBM_APPID_TENANT_ID") if AppIDTenantID == "" { fmt.Println("[WARN] Set the environment variable IBM_APPID_TENANT_ID for testing AppID resources, AppID tests will fail if this is not set") diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 8d032fcfa1..40e7052d9a 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -53,7 +53,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { labels = ["env:stage"] authorizations { method = "API_KEY" - api_key = "" + api_key = "%s" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } @@ -63,5 +63,5 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { project_id = ibm_project_config.project_config_instance.project_id id = ibm_project_config.project_config_instance.project_config_id } - `) + `, acc.ProjectsConfigApiKey) } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 340cd1b693..61c477d2e9 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -58,12 +58,12 @@ func testAccCheckIbmProjectConfigConfigBasic() string { labels = ["env:stage"] authorizations { method = "API_KEY" - api_key = "" + api_key = "%s" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } } - `) + `, acc.ProjectsConfigApiKey) } func testAccCheckIbmProjectConfigExists(n string, obj projectv1.ProjectConfig) resource.TestCheckFunc { diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 0cda6a2a6a..ba447453d6 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- Get information about project -subcategory: "Projects API" +subcategory: "Projects" --- # ibm_project diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 3113402410..f709e2646c 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_config" description: |- Get information about project_config -subcategory: "Projects API" +subcategory: "Projects" --- # ibm_project_config diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 55d7469dd9..485a049e50 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project" description: |- Manages project. -subcategory: "Projects API" +subcategory: "Projects" --- # ibm_project diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 1f748c0dc5..88a5db9d65 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -3,7 +3,7 @@ layout: "ibm" page_title: "IBM : ibm_project_config" description: |- Manages project_config. -subcategory: "Projects API" +subcategory: "Projects" --- # ibm_project_config From a933dd2dc6b23f570015cd731be8e545df37e4e9 Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 19 Oct 2023 11:05:53 +0200 Subject: [PATCH 117/125] address PR comments --- ibm/service/project/resource_ibm_project.go | 14 ++------------ ibm/service/project/resource_ibm_project_config.go | 5 +---- website/docs/d/project.html.markdown | 4 ++-- website/docs/d/project_config.html.markdown | 2 +- website/docs/r/project.html.markdown | 4 ++-- website/docs/r/project_config.html.markdown | 2 +- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 56d904760d..c458b76e3b 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -31,12 +31,14 @@ func ResourceIbmProject() *schema.Resource { "location": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_project", "location"), Description: "The IBM Cloud location where a resource is deployed.", }, "resource_group": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, Description: "The resource group where the project's data and tools are created.", }, "definition": &schema.Schema{ @@ -316,18 +318,6 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDefinition(definitionModel) createProjectOptions.SetLocation(d.Get("location").(string)) createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) - if _, ok := d.GetOk("configs"); ok { - var configs []projectv1.ProjectConfigPrototype - for _, v := range d.Get("configs").([]interface{}) { - value := v.(map[string]interface{}) - configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) - if err != nil { - return diag.FromErr(err) - } - configs = append(configs, *configsItem) - } - createProjectOptions.SetConfigs(configs) - } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index daaaf5c3e7..04940ec046 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -141,6 +141,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "locator_id": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, Description: "A dotted value of catalogID.versionID.", }, "input": &schema.Schema{ @@ -390,10 +391,6 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false - 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("definition") { definition, err := resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(d.Get("definition.0").(map[string]interface{})) if err != nil { diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index ba447453d6..8dbd525eb6 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -106,10 +106,10 @@ Nested schema for **environments**: * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. -* `location` - (String) The IBM Cloud location where a resource is deployed. +* `location` - (Forces new resource, String) The IBM Cloud location where a resource is deployed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. -* `resource_group` - (String) The resource group where the project's data and tools are created. +* `resource_group` - (Forces new resource, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. * `state` - (String) The project status value. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index f709e2646c..1b63b18296 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -65,7 +65,7 @@ Nested schema for **definition**: Nested schema for **input**: * `labels` - (List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (String) A dotted value of catalogID.versionID. + * `locator_id` - (Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 485a049e50..1fa7b9c2f9 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -35,9 +35,9 @@ Nested schema for **definition**: * `destroy_on_delete` - (Required, Boolean) The policy that indicates whether the resources are destroyed or not when a project is deleted. * `name` - (Required, String) The name of the project. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. -* `location` - (Required, String) The IBM Cloud location where a resource is deployed. +* `location` - (Required, Forces new resource, String) The IBM Cloud location where a resource is deployed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. -* `resource_group` - (Required, String) The resource group where the project's data and tools are created. +* `resource_group` - (Required, Forces new resource, String) The resource group where the project's data and tools are created. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. ## Attribute Reference diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 88a5db9d65..6889710698 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -69,7 +69,7 @@ Nested schema for **definition**: Nested schema for **input**: * `labels` - (Optional, List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. - * `locator_id` - (Required, String) A dotted value of catalogID.versionID. + * `locator_id` - (Required, Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. From 72a819a8de3063f85f8af39d330116d7b65a15de Mon Sep 17 00:00:00 2001 From: rangelil Date: Thu, 19 Oct 2023 11:08:54 +0200 Subject: [PATCH 118/125] address PR comments --- .secrets.baseline | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 3e0757cf66..1bc7b3d043 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-18T15:34:16Z", + "generated_at": "2023-10-19T09:07:51Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -2512,7 +2512,7 @@ "hashed_secret": "b02fa7fd7ca08b5dc86c2548e40f8a21171ef977", "is_secret": false, "is_verified": false, - "line_number": 259, + "line_number": 265, "type": "Secret Keyword", "verified_result": null }, @@ -2520,7 +2520,7 @@ "hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030", "is_secret": false, "is_verified": false, - "line_number": 296, + "line_number": 302, "type": "Secret Keyword", "verified_result": null } @@ -2848,7 +2848,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 677, + "line_number": 674, "type": "Secret Keyword", "verified_result": null } @@ -3006,7 +3006,7 @@ "hashed_secret": "49f3bb8f759241df51c899d3725d877bad58f66e", "is_secret": false, "is_verified": false, - "line_number": 1414, + "line_number": 1405, "type": "Secret Keyword", "verified_result": null }, @@ -3014,7 +3014,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 1417, + "line_number": 1408, "type": "Secret Keyword", "verified_result": null } From f5e7aef86167f24756a57861c98c1118e75cd3cd Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 24 Oct 2023 16:00:24 +0200 Subject: [PATCH 119/125] update to latest sdk level --- examples/ibm-project/README.md | 6 +- examples/ibm-project/main.tf | 6 +- examples/ibm-project/outputs.tf | 1 + go.mod | 2 +- go.sum | 6 +- .../project/data_source_ibm_project.go | 371 ----------------- .../project/data_source_ibm_project_config.go | 164 ++++---- .../data_source_ibm_project_config_test.go | 10 +- .../project/data_source_ibm_project_test.go | 10 +- ibm/service/project/resource_ibm_project.go | 386 +----------------- .../project/resource_ibm_project_config.go | 167 ++++---- .../resource_ibm_project_config_test.go | 10 +- .../project/resource_ibm_project_test.go | 21 +- website/docs/d/project.html.markdown | 11 +- website/docs/d/project_config.html.markdown | 35 +- website/docs/r/project.html.markdown | 11 +- website/docs/r/project_config.html.markdown | 34 +- 17 files changed, 251 insertions(+), 1000 deletions(-) diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 159bc89199..8d7c66c411 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -34,8 +34,8 @@ project resource: ```hcl resource "project" "project_instance" { - resource_group = var.project_resource_group location = var.project_location + resource_group = var.project_resource_group definition = var.project_definition } ``` @@ -86,9 +86,9 @@ data "project" "project_instance" { | project_id | The unique project ID. | `string` | true | | schematics | A schematics workspace associated to a project configuration. | `` | false | | definition | The type and output of a project configuration. | `` | true | +| location | The IBM Cloud location where a resource is deployed. | `string` | true | | resource_group | The resource group where the project's data and tools are created. | `string` | true | -| location | The location where the project's data and tools are created. | `string` | true | -| definition | The definition of the project. | `` | false | +| definition | The definition of the project. | `` | true | | project_id | The unique project ID. | `string` | true | | id | The unique config ID. | `string` | true | | id | The unique project ID. | `string` | true | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index de2c4e4ee7..a9ce85d17f 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -10,7 +10,7 @@ resource "ibm_project_config" "project_config_instance" { labels = [ "env:dev", "billing:internal" ] description = "Website - development" authorizations { - method = "APIKEY" + method = "api_key" api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" @@ -26,8 +26,8 @@ resource "ibm_project_config" "project_config_instance" { // Provision project resource instance resource "ibm_project" "project_instance" { - resource_group = "Default" - location = "us-south" + resource_group = var.project_resource_group + location = var.project_location definition { name = "My static website" description = "Sample static website test using the IBM catalog deployable architecture" diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index 277309cbec..af03b96996 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -3,6 +3,7 @@ output "ibm_project_config" { value = ibm_project_config.project_config_instance description = "project_config resource instance" + sensitive = true } // This output allows project data to be referenced by other resources and the terraform CLI // Modify this output if only certain data should be exposed diff --git a/go.mod b/go.mod index ce5c99b00d..5386e3caaa 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.52.0 - github.com/IBM/project-go-sdk v0.0.92 + github.com/IBM/project-go-sdk v0.0.95 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.2 github.com/IBM/schematics-go-sdk v0.2.2 diff --git a/go.sum b/go.sum index 2be662fab8..2743e6f10d 100644 --- a/go.sum +++ b/go.sum @@ -139,7 +139,6 @@ github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= -github.com/IBM/go-sdk-core/v5 v5.12.1/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.14.1 h1:WR1r0zz+gDW++xzZjF41r9ueY4JyjS2vgZjiYs8lO3c= github.com/IBM/go-sdk-core/v5 v5.14.1/go.mod h1:MUvIr/1mgGh198ZXL+ByKz9Qs1JoEh80v/96x8jPXNY= github.com/IBM/ibm-cos-sdk-go v1.3.1/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY= @@ -158,8 +157,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.52.0 h1:hbf640xE8T0Rwy2IUf5Pu4OATabGS4IDMnEInXUXs4o= github.com/IBM/platform-services-go-sdk v0.52.0/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.92 h1:qnSmk+gEOyt7RWX5dMCNUgZG1w5WeJYBhRMaHKni8PE= -github.com/IBM/project-go-sdk v0.0.92/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.95 h1:rRPch7zsUpxD1/8ObdlclTCBTdslVrvCi6Q1TXFH1Os= +github.com/IBM/project-go-sdk v0.0.95/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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= @@ -1321,7 +1320,6 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl github.com/onsi/gomega v1.18.0/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index b19a252fd2..c610578533 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -112,29 +111,11 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The version of the configuration.", }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "state": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "The state of the configuration.", }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -145,25 +126,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "schematics": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "A schematics workspace associated to a project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "workspace_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "An existing schematics workspace ID.", - }, - }, - }, - }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -406,67 +368,13 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro modelMap["id"] = model.ID modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) - modelMap["is_draft"] = model.IsDraft - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } modelMap["state"] = model.State - modelMap["update_available"] = model.UpdateAvailable if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } if model.UserModifiedAt != nil { modelMap["user_modified_at"] = model.UserModifiedAt.String() } - if model.LastApproved != nil { - lastApprovedMap, err := dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) - if err != nil { - return modelMap, err - } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.References != nil { - references := make(map[string]interface{}) - for k, v := range model.References { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - references[k] = string(bytes) - } - modelMap["references"] = references - } - if model.LastValidated != nil { - lastValidatedMap, err := dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) - if err != nil { - return modelMap, err - } - modelMap["last_validated"] = []map[string]interface{}{lastValidatedMap} - } - if model.LastDeployed != nil { - lastDeployedMap, err := dataSourceIbmProjectLastActionWithSummaryToMap(model.LastDeployed) - if err != nil { - return modelMap, err - } - modelMap["last_deployed"] = []map[string]interface{}{lastDeployedMap} - } - if model.LastUndeployed != nil { - lastUndeployedMap, err := dataSourceIbmProjectLastActionWithSummaryToMap(model.LastUndeployed) - if err != nil { - return modelMap, err - } - modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} - } - if model.Schematics != nil { - schematicsMap, err := dataSourceIbmProjectSchematicsWorkspaceToMap(model.Schematics) - if err != nil { - return modelMap, err - } - modelMap["schematics"] = []map[string]interface{}{schematicsMap} - } modelMap["href"] = model.Href definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -478,9 +386,6 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } modelMap["state"] = model.State modelMap["version"] = flex.IntValue(model.Version) if model.Href != nil { @@ -489,282 +394,6 @@ func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.Proje return modelMap, nil } -func dataSourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func dataSourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.PreJob != nil { - preJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) - if err != nil { - return modelMap, err - } - modelMap["pre_job"] = []map[string]interface{}{preJobMap} - } - if model.PostJob != nil { - postJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) - if err != nil { - return modelMap, err - } - modelMap["post_job"] = []map[string]interface{}{postJobMap} - } - if model.Job != nil { - jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.CraLogs != nil { - craLogsMap, err := dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model *projectv1.PrePostActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - return modelMap, nil -} - -func dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summaryMap, err := dataSourceIbmProjectActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func dataSourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func dataSourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.PreJob != nil { - preJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) - if err != nil { - return modelMap, err - } - modelMap["pre_job"] = []map[string]interface{}{preJobMap} - } - if model.PostJob != nil { - postJobMap, err := dataSourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) - if err != nil { - return modelMap, err - } - modelMap["post_job"] = []map[string]interface{}{postJobMap} - } - if model.Job != nil { - jobMap, err := dataSourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - return modelMap, nil -} - -func dataSourceIbmProjectSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.WorkspaceID != nil { - modelMap["workspace_id"] = model.WorkspaceID - } - return modelMap, nil -} - func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 6e3e8d5f57..878a952437 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -54,16 +54,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, }, }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -74,25 +64,59 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_save": &schema.Schema{ + "last_saved_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "outputs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, "schematics": &schema.Schema{ Type: schema.TypeList, Computed: true, Description: "A schematics workspace associated to a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "workspace_id": &schema.Schema{ + "workspace_crn": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "An existing schematics workspace ID.", + Description: "An existing schematics workspace CRN.", }, }, }, }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -141,6 +165,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "api_key": &schema.Schema{ Type: schema.TypeString, Computed: true, + Sensitive: true, Description: "The IBM Cloud API Key.", }, }, @@ -185,7 +210,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A dotted value of catalogID.versionID.", }, - "input": &schema.Schema{ + "inputs": &schema.Schema{ Type: schema.TypeList, Computed: true, Description: "The input variables for configuration definition and environment.", @@ -193,7 +218,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Schema: map[string]*schema.Schema{}, }, }, - "setting": &schema.Schema{ + "settings": &schema.Schema{ Type: schema.TypeList, Computed: true, Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", @@ -206,30 +231,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The type of a project configuration manual property.", }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, }, }, }, @@ -272,14 +273,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } - if err = d.Set("state", projectConfig.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } - - if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } @@ -288,8 +281,22 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) } - if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + if err = d.Set("last_saved_at", flex.DateTimeToString(projectConfig.LastSavedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_saved_at: %s", err)) + } + + outputs := []map[string]interface{}{} + if projectConfig.Outputs != nil { + for _, modelItem := range projectConfig.Outputs { + modelMap, err := dataSourceIbmProjectConfigOutputValueToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + outputs = append(outputs, modelMap) + } + } + if err = d.Set("outputs", outputs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting outputs %s", err)) } schematics := []map[string]interface{}{} @@ -304,6 +311,14 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting schematics %s", err)) } + if err = d.Set("state", projectConfig.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } + definition := []map[string]interface{}{} if projectConfig.Definition != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) @@ -319,10 +334,22 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return nil } +func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.Value != nil { + modelMap["value"] = model.Value + } + return modelMap, nil +} + func dataSourceIbmProjectConfigSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.WorkspaceID != nil { - modelMap["workspace_id"] = model.WorkspaceID + if model.WorkspaceCrn != nil { + modelMap["workspace_crn"] = model.WorkspaceCrn } return modelMap, nil } @@ -354,34 +381,23 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - inputMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Input) + if model.Inputs != nil { + inputsMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Inputs) if err != nil { return modelMap, err } - modelMap["input"] = []map[string]interface{}{inputMap} + modelMap["inputs"] = []map[string]interface{}{inputsMap} } - if model.Setting != nil { - settingMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if model.Settings != nil { + settingsMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Settings) if err != nil { return modelMap, err } - modelMap["setting"] = []map[string]interface{}{settingMap} + modelMap["settings"] = []map[string]interface{}{settingsMap} } if model.Type != nil { modelMap["type"] = model.Type } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := dataSourceIbmProjectConfigOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } return modelMap, nil } @@ -428,15 +444,3 @@ func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.Projec modelMap := make(map[string]interface{}) return modelMap, nil } - -func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Description != nil { - modelMap["description"] = model.Description - } - if model.Value != nil { - modelMap["value"] = model.Value - } - return modelMap, nil -} diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 40e7052d9a..8463742660 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -37,8 +37,8 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" location = "us-south" + resource_group = "Default" definition { name = "acme-microservice" description = "acme-microservice description" @@ -52,11 +52,17 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { name = "stage-environment" labels = ["env:stage"] authorizations { - method = "API_KEY" + method = "api_key" api_key = "%s" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } + lifecycle { + ignore_changes = [ + definition[0].authorizations[0].api_key, + ] + } + } data "ibm_project_config" "project_config_instance" { diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 866986b9e4..2c739fcfd5 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -13,15 +13,15 @@ import ( ) func TestAccIbmProjectDataSourceBasic(t *testing.T) { - projectResourceGroup := fmt.Sprintf("Default") projectLocation := fmt.Sprintf("us-south") + projectResourceGroup := fmt.Sprintf("Default") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup, projectLocation), + Config: testAccCheckIbmProjectDataSourceConfigBasic(projectLocation, projectResourceGroup), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), @@ -31,11 +31,11 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { }) } -func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, projectLocation string) string { +func testAccCheckIbmProjectDataSourceConfigBasic(projectLocation string, projectResourceGroup string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "%s" location = "%s" + resource_group = "%s" definition { name = "acme-microservice" description = "acme-microservice description" @@ -46,5 +46,5 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectResourceGroup string, pr data "ibm_project" "project_instance" { id = ibm_project.project_instance.id } - `, projectResourceGroup, projectLocation) + `, projectLocation, projectResourceGroup) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index c458b76e3b..c8efec424b 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -142,27 +141,11 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The version of the configuration.", }, - "is_draft": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether the version of the configuration is draft, or active.", - }, - "needs_attention_state": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, "state": &schema.Schema{ Type: schema.TypeString, Required: true, Description: "The state of the configuration.", }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Required: true, - Description: "The flag that indicates whether a configuration update is available.", - }, "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -173,26 +156,6 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_save": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", - }, - "schematics": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "A schematics workspace associated to a project configuration.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "workspace_id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "An existing schematics workspace ID.", - }, - }, - }, - }, "href": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -546,19 +509,19 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { - InputModel, err := resourceIbmProjectMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { + InputsModel, err := resourceIbmProjectMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Input = InputModel + model.Inputs = InputsModel } - if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { - SettingModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { + SettingsModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Setting = SettingModel + model.Settings = SettingsModel } return model, nil } @@ -609,8 +572,8 @@ func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{} func resourceIbmProjectMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} - if modelMap["workspace_id"] != nil && modelMap["workspace_id"].(string) != "" { - model.WorkspaceID = core.StringPtr(modelMap["workspace_id"].(string)) + if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { + model.WorkspaceCrn = core.StringPtr(modelMap["workspace_crn"].(string)) } return model, nil } @@ -675,67 +638,13 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje modelMap["id"] = model.ID modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) - modelMap["is_draft"] = model.IsDraft - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } modelMap["state"] = model.State - modelMap["update_available"] = model.UpdateAvailable if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } if model.UserModifiedAt != nil { modelMap["user_modified_at"] = model.UserModifiedAt.String() } - if model.LastApproved != nil { - lastApprovedMap, err := resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model.LastApproved) - if err != nil { - return modelMap, err - } - modelMap["last_approved"] = []map[string]interface{}{lastApprovedMap} - } - if model.LastSave != nil { - modelMap["last_save"] = model.LastSave.String() - } - if model.References != nil { - references := make(map[string]interface{}) - for k, v := range model.References { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - references[k] = string(bytes) - } - modelMap["references"] = references - } - if model.LastValidated != nil { - lastValidatedMap, err := resourceIbmProjectLastValidatedActionWithSummaryToMap(model.LastValidated) - if err != nil { - return modelMap, err - } - modelMap["last_validated"] = []map[string]interface{}{lastValidatedMap} - } - if model.LastDeployed != nil { - lastDeployedMap, err := resourceIbmProjectLastActionWithSummaryToMap(model.LastDeployed) - if err != nil { - return modelMap, err - } - modelMap["last_deployed"] = []map[string]interface{}{lastDeployedMap} - } - if model.LastUndeployed != nil { - lastUndeployedMap, err := resourceIbmProjectLastActionWithSummaryToMap(model.LastUndeployed) - if err != nil { - return modelMap, err - } - modelMap["last_undeployed"] = []map[string]interface{}{lastUndeployedMap} - } - if model.Schematics != nil { - schematicsMap, err := resourceIbmProjectSchematicsWorkspaceToMap(model.Schematics) - if err != nil { - return modelMap, err - } - modelMap["schematics"] = []map[string]interface{}{schematicsMap} - } modelMap["href"] = model.Href definitionMap, err := resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) if err != nil { @@ -747,9 +656,6 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.ProjectConfigVersionSummary) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.NeedsAttentionState != nil { - modelMap["needs_attention_state"] = model.NeedsAttentionState - } modelMap["state"] = model.State modelMap["version"] = flex.IntValue(model.Version) if model.Href != nil { @@ -758,282 +664,6 @@ func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.Project return modelMap, nil } -func resourceIbmProjectProjectConfigMetadataLastApprovedToMap(model *projectv1.ProjectConfigMetadataLastApproved) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["is_forced"] = model.IsForced - if model.Comment != nil { - modelMap["comment"] = model.Comment - } - modelMap["timestamp"] = model.Timestamp.String() - modelMap["user_id"] = model.UserID - return modelMap, nil -} - -func resourceIbmProjectLastValidatedActionWithSummaryToMap(model *projectv1.LastValidatedActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.PreJob != nil { - preJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) - if err != nil { - return modelMap, err - } - modelMap["pre_job"] = []map[string]interface{}{preJobMap} - } - if model.PostJob != nil { - postJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) - if err != nil { - return modelMap, err - } - modelMap["post_job"] = []map[string]interface{}{postJobMap} - } - if model.Job != nil { - jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - if model.CostEstimate != nil { - costEstimateMap, err := resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model.CostEstimate) - if err != nil { - return modelMap, err - } - modelMap["cost_estimate"] = []map[string]interface{}{costEstimateMap} - } - if model.CraLogs != nil { - craLogsMap, err := resourceIbmProjectProjectConfigMetadataCraLogsToMap(model.CraLogs) - if err != nil { - return modelMap, err - } - modelMap["cra_logs"] = []map[string]interface{}{craLogsMap} - } - return modelMap, nil -} - -func resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model *projectv1.PrePostActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - return modelMap, nil -} - -func resourceIbmProjectActionJobWithIdAndSummaryToMap(model *projectv1.ActionJobWithIdAndSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Summary != nil { - summaryMap, err := resourceIbmProjectActionJobSummaryToMap(model.Summary) - if err != nil { - return modelMap, err - } - modelMap["summary"] = []map[string]interface{}{summaryMap} - } - return modelMap, nil -} - -func resourceIbmProjectActionJobSummaryToMap(model *projectv1.ActionJobSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.PlanSummary != nil { - planSummary := make(map[string]interface{}) - for k, v := range model.PlanSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planSummary[k] = string(bytes) - } - modelMap["plan_summary"] = planSummary - } - if model.ApplySummary != nil { - applySummary := make(map[string]interface{}) - for k, v := range model.ApplySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applySummary[k] = string(bytes) - } - modelMap["apply_summary"] = applySummary - } - if model.DestroySummary != nil { - destroySummary := make(map[string]interface{}) - for k, v := range model.DestroySummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroySummary[k] = string(bytes) - } - modelMap["destroy_summary"] = destroySummary - } - if model.MessageSummary != nil { - messageSummary := make(map[string]interface{}) - for k, v := range model.MessageSummary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - messageSummary[k] = string(bytes) - } - modelMap["message_summary"] = messageSummary - } - if model.PlanMessages != nil { - planMessages := make(map[string]interface{}) - for k, v := range model.PlanMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - planMessages[k] = string(bytes) - } - modelMap["plan_messages"] = planMessages - } - if model.ApplyMessages != nil { - applyMessages := make(map[string]interface{}) - for k, v := range model.ApplyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - applyMessages[k] = string(bytes) - } - modelMap["apply_messages"] = applyMessages - } - if model.DestroyMessages != nil { - destroyMessages := make(map[string]interface{}) - for k, v := range model.DestroyMessages { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - destroyMessages[k] = string(bytes) - } - modelMap["destroy_messages"] = destroyMessages - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataCostEstimateToMap(model *projectv1.ProjectConfigMetadataCostEstimate) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Version != nil { - modelMap["version"] = model.Version - } - if model.Currency != nil { - modelMap["currency"] = model.Currency - } - if model.TotalHourlyCost != nil { - modelMap["total_hourly_cost"] = model.TotalHourlyCost - } - if model.TotalMonthlyCost != nil { - modelMap["total_monthly_cost"] = model.TotalMonthlyCost - } - if model.PastTotalHourlyCost != nil { - modelMap["past_total_hourly_cost"] = model.PastTotalHourlyCost - } - if model.PastTotalMonthlyCost != nil { - modelMap["past_total_monthly_cost"] = model.PastTotalMonthlyCost - } - if model.DiffTotalHourlyCost != nil { - modelMap["diff_total_hourly_cost"] = model.DiffTotalHourlyCost - } - if model.DiffTotalMonthlyCost != nil { - modelMap["diff_total_monthly_cost"] = model.DiffTotalMonthlyCost - } - if model.TimeGenerated != nil { - modelMap["time_generated"] = model.TimeGenerated.String() - } - if model.UserID != nil { - modelMap["user_id"] = model.UserID - } - return modelMap, nil -} - -func resourceIbmProjectProjectConfigMetadataCraLogsToMap(model *projectv1.ProjectConfigMetadataCraLogs) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.CraVersion != nil { - modelMap["cra_version"] = model.CraVersion - } - if model.SchemaVersion != nil { - modelMap["schema_version"] = model.SchemaVersion - } - if model.Status != nil { - modelMap["status"] = model.Status - } - if model.Summary != nil { - summary := make(map[string]interface{}) - for k, v := range model.Summary { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - summary[k] = string(bytes) - } - modelMap["summary"] = summary - } - if model.Timestamp != nil { - modelMap["timestamp"] = model.Timestamp.String() - } - return modelMap, nil -} - -func resourceIbmProjectLastActionWithSummaryToMap(model *projectv1.LastActionWithSummary) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Href != nil { - modelMap["href"] = model.Href - } - if model.Result != nil { - modelMap["result"] = model.Result - } - if model.PreJob != nil { - preJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PreJob) - if err != nil { - return modelMap, err - } - modelMap["pre_job"] = []map[string]interface{}{preJobMap} - } - if model.PostJob != nil { - postJobMap, err := resourceIbmProjectPrePostActionJobWithIdAndSummaryToMap(model.PostJob) - if err != nil { - return modelMap, err - } - modelMap["post_job"] = []map[string]interface{}{postJobMap} - } - if model.Job != nil { - jobMap, err := resourceIbmProjectActionJobWithIdAndSummaryToMap(model.Job) - if err != nil { - return modelMap, err - } - modelMap["job"] = []map[string]interface{}{jobMap} - } - return modelMap, nil -} - -func resourceIbmProjectSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.WorkspaceID != nil { - modelMap["workspace_id"] = model.WorkspaceID - } - return modelMap, nil -} - func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projectv1.ProjectConfigDefinitionNameDescription) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 04940ec046..361e4f15b7 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -41,10 +41,10 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "A schematics workspace associated to a project configuration.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "workspace_id": &schema.Schema{ + "workspace_crn": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "An existing schematics workspace ID.", + Description: "An existing schematics workspace CRN.", }, }, }, @@ -98,6 +98,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "api_key": &schema.Schema{ Type: schema.TypeString, Optional: true, + Sensitive: true, Description: "The IBM Cloud API Key.", }, }, @@ -144,7 +145,7 @@ func ResourceIbmProjectConfig() *schema.Resource { ForceNew: true, Description: "A dotted value of catalogID.versionID.", }, - "input": &schema.Schema{ + "inputs": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -153,7 +154,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Schema: map[string]*schema.Schema{}, }, }, - "setting": &schema.Schema{ + "settings": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -167,30 +168,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The type of a project configuration manual property.", }, - "output": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The outputs of a Schematics template property.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The variable name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "A short explanation of the output value.", - }, - "value": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Can be any value - a string, number, boolean, array, or object.", - }, - }, - }, - }, }, }, }, @@ -210,16 +187,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "The needs attention state of a configuration.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "state": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The state of the configuration.", - }, - "update_available": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "The flag that indicates whether a configuration update is available.", - }, "created_at": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -230,11 +197,45 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "last_save": &schema.Schema{ + "last_saved_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "outputs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The outputs of a Schematics template property.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The variable name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "A short explanation of the output value.", + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Can be any value - a string, number, boolean, array, or object.", + }, + }, + }, + }, + "state": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The state of the configuration.", + }, + "update_available": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "The flag that indicates whether a configuration update is available.", + }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -345,12 +346,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } } - if err = d.Set("state", projectConfig.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } - if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) - } if !core.IsNil(projectConfig.CreatedAt) { if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) @@ -361,11 +356,30 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) } } - if !core.IsNil(projectConfig.LastSave) { - if err = d.Set("last_save", flex.DateTimeToString(projectConfig.LastSave)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_save: %s", err)) + if !core.IsNil(projectConfig.LastSavedAt) { + if err = d.Set("last_saved_at", flex.DateTimeToString(projectConfig.LastSavedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting last_saved_at: %s", err)) } } + if !core.IsNil(projectConfig.Outputs) { + outputs := []map[string]interface{}{} + for _, outputsItem := range projectConfig.Outputs { + outputsItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputsItem) + if err != nil { + return diag.FromErr(err) + } + outputs = append(outputs, outputsItemMap) + } + if err = d.Set("outputs", outputs); err != nil { + return diag.FromErr(fmt.Errorf("Error setting outputs: %s", err)) + } + } + if err = d.Set("state", projectConfig.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) + } + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } if err = d.Set("project_config_id", projectConfig.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) } @@ -471,19 +485,19 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { - InputModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { + InputsModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Input = InputModel + model.Inputs = InputsModel } - if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { - SettingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { + SettingsModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Setting = SettingModel + model.Settings = SettingsModel } return model, nil } @@ -534,8 +548,8 @@ func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]inter func resourceIbmProjectConfigMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} - if modelMap["workspace_id"] != nil && modelMap["workspace_id"].(string) != "" { - model.WorkspaceID = core.StringPtr(modelMap["workspace_id"].(string)) + if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { + model.WorkspaceCrn = core.StringPtr(modelMap["workspace_crn"].(string)) } return model, nil } @@ -575,27 +589,27 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(mod if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["input"] != nil && len(modelMap["input"].([]interface{})) > 0 { - InputModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["input"].([]interface{})[0].(map[string]interface{})) + if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { + InputsModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Input = InputModel + model.Inputs = InputsModel } - if modelMap["setting"] != nil && len(modelMap["setting"].([]interface{})) > 0 { - SettingModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["setting"].([]interface{})[0].(map[string]interface{})) + if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { + SettingsModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } - model.Setting = SettingModel + model.Settings = SettingsModel } return model, nil } func resourceIbmProjectConfigSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.WorkspaceID != nil { - modelMap["workspace_id"] = model.WorkspaceID + if model.WorkspaceCrn != nil { + modelMap["workspace_crn"] = model.WorkspaceCrn } return modelMap, nil } @@ -629,36 +643,25 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project } } modelMap["locator_id"] = model.LocatorID - if model.Input != nil { - inputMap, err := resourceIbmProjectConfigInputVariableToMap(model.Input) + if model.Inputs != nil { + inputsMap, err := resourceIbmProjectConfigInputVariableToMap(model.Inputs) if err != nil { return modelMap, err } - if len(inputMap) > 0 { - modelMap["input"] = []map[string]interface{}{inputMap} + if len(inputsMap) > 0 { + modelMap["inputs"] = []map[string]interface{}{inputsMap} } } - if model.Setting != nil { - settingMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Setting) + if model.Settings != nil { + settingsMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Settings) if err != nil { return modelMap, err } - modelMap["setting"] = []map[string]interface{}{settingMap} + modelMap["settings"] = []map[string]interface{}{settingsMap} } if model.Type != nil { modelMap["type"] = model.Type } - if model.Output != nil { - output := []map[string]interface{}{} - for _, outputItem := range model.Output { - outputItemMap, err := resourceIbmProjectConfigOutputValueToMap(&outputItem) - if err != nil { - return modelMap, err - } - output = append(output, outputItemMap) - } - modelMap["output"] = output - } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 61c477d2e9..88998500a9 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -42,8 +42,8 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { func testAccCheckIbmProjectConfigConfigBasic() string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "Default" location = "us-south" + resource_group = "Default" definition { name = "acme-microservice" description = "acme-microservice description" @@ -57,11 +57,17 @@ func testAccCheckIbmProjectConfigConfigBasic() string { name = "stage-environment" labels = ["env:stage"] authorizations { - method = "API_KEY" + method = "api_key" api_key = "%s" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } + lifecycle { + ignore_changes = [ + definition[0].authorizations[0].api_key, + ] + } + } `, acc.ProjectsConfigApiKey) } diff --git a/ibm/service/project/resource_ibm_project_test.go b/ibm/service/project/resource_ibm_project_test.go index f9f5651f03..20174656ec 100644 --- a/ibm/service/project/resource_ibm_project_test.go +++ b/ibm/service/project/resource_ibm_project_test.go @@ -17,10 +17,8 @@ import ( func TestAccIbmProjectBasic(t *testing.T) { var conf projectv1.Project - resourceGroup := fmt.Sprintf("Default") location := fmt.Sprintf("us-south") - resourceGroupUpdate := fmt.Sprintf("Default") - locationUpdate := fmt.Sprintf("us-south") + resourceGroup := fmt.Sprintf("Default") resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -28,18 +26,11 @@ func TestAccIbmProjectBasic(t *testing.T) { CheckDestroy: testAccCheckIbmProjectDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIbmProjectConfigBasic(resourceGroup, location), + Config: testAccCheckIbmProjectConfigBasic(location, resourceGroup), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIbmProjectExists("ibm_project.project_instance", conf), - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), resource.TestCheckResourceAttr("ibm_project.project_instance", "location", location), - ), - }, - resource.TestStep{ - Config: testAccCheckIbmProjectConfigBasic(resourceGroupUpdate, locationUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroupUpdate), - resource.TestCheckResourceAttr("ibm_project.project_instance", "location", locationUpdate), + resource.TestCheckResourceAttr("ibm_project.project_instance", "resource_group", resourceGroup), ), }, resource.TestStep{ @@ -51,18 +42,18 @@ func TestAccIbmProjectBasic(t *testing.T) { }) } -func testAccCheckIbmProjectConfigBasic(resourceGroup string, location string) string { +func testAccCheckIbmProjectConfigBasic(location string, resourceGroup string) string { return fmt.Sprintf(` resource "ibm_project" "project_instance" { - resource_group = "%s" location = "%s" + resource_group = "%s" definition { name = "acme-microservice" description = "acme-microservice description" destroy_on_delete = true } } - `, resourceGroup, location) + `, location, resourceGroup) } func testAccCheckIbmProjectExists(n string, obj projectv1.Project) resource.TestCheckFunc { diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 8dbd525eb6..b8111471f1 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -44,19 +44,10 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `schematics` - (List) A schematics workspace associated to a project configuration. - Nested schema for **schematics**: - * `workspace_id` - (String) An existing schematics workspace ID. - * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 1b63b18296..8cd5e8724f 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -42,7 +42,7 @@ Nested schema for **definition**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: Allowable values are: `api_key`, `trusted_profile`. * `trusted_profile_id` - (String) The trusted profile ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (List) The profile required for compliance. @@ -61,44 +61,45 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `environment` - (String) The ID of the project environment. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (List) The input variables for configuration definition and environment. - Nested schema for **input**: + * `inputs` - (List) The input variables for configuration definition and environment. + Nested schema for **inputs**: * `labels` - (List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **setting**: + * `settings` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + Nested schema for **settings**: * `type` - (String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `outputs` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **outputs**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `schematics` - (List) A schematics workspace associated to a project configuration. Nested schema for **schematics**: - * `workspace_id` - (String) An existing schematics workspace ID. - * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. + * `workspace_crn` - (String) An existing schematics workspace CRN. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 1fa7b9c2f9..f606990308 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -59,19 +59,10 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. - * `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. * `project_id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `schematics` - (List) A schematics workspace associated to a project configuration. - Nested schema for **schematics**: - * `workspace_id` - (String) An existing schematics workspace ID. - * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. - * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 6889710698..4b549e287c 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -46,7 +46,7 @@ Nested schema for **definition**: * `api_key` - (Optional, String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `method` - (Optional, String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. - * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. + * Constraints: Allowable values are: `api_key`, `trusted_profile`. * `trusted_profile_id` - (Optional, String) The trusted profile ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `compliance_profile` - (Optional, List) The profile required for compliance. @@ -65,32 +65,24 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `environment` - (Optional, String) The ID of the project environment. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `input` - (Optional, List) The input variables for configuration definition and environment. - Nested schema for **input**: + * `inputs` - (Optional, List) The input variables for configuration definition and environment. + Nested schema for **inputs**: * `labels` - (Optional, List) The configuration labels. * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Required, Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `output` - (Optional, List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. - Nested schema for **output**: - * `description` - (Optional, String) A short explanation of the output value. - * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. - * `name` - (Required, String) The variable name. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (Optional, String) Can be any value - a string, number, boolean, array, or object. - * `setting` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **setting**: + * `settings` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. + Nested schema for **settings**: * `type` - (Computed, String) The type of a project configuration manual property. * Constraints: Allowable values are: `terraform_template`, `schematics_blueprint`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `schematics` - (Optional, List) A schematics workspace associated to a project configuration. Nested schema for **schematics**: - * `workspace_id` - (Optional, String) An existing schematics workspace ID. - * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9.-]+$/`. + * `workspace_crn` - (Optional, String) An existing schematics workspace CRN. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. ## Attribute Reference @@ -99,13 +91,21 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the project_config. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. -* `last_save` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +* `outputs` - (List) The outputs of a Schematics template property. + * Constraints: The maximum length is `10000` items. The minimum length is `0` items. +Nested schema for **outputs**: + * `description` - (String) A short explanation of the output value. + * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. + * `name` - (String) The variable name. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. + * `value` - (String) Can be any value - a string, number, boolean, array, or object. * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superceded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. From ec3266a75a5ce03f8a8f70af664f393c689d3104 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 24 Oct 2023 16:12:53 +0200 Subject: [PATCH 120/125] update to latest sdk level --- .secrets.baseline | 30 +++++++++---------- .../project/data_source_ibm_project_config.go | 1 - .../project/resource_ibm_project_config.go | 1 - 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 1bc7b3d043..bc3da79c3b 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-19T09:07:51Z", + "generated_at": "2023-10-24T14:12:37Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -752,7 +752,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 391, + "line_number": 401, "type": "Secret Keyword", "verified_result": null }, @@ -760,7 +760,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 397, + "line_number": 407, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1108, + "line_number": 1118, "type": "Base64 High Entropy String", "verified_result": null } @@ -778,7 +778,7 @@ "hashed_secret": "9184b0c38101bf24d78b2bb0d044deb1d33696fc", "is_secret": false, "is_verified": false, - "line_number": 130, + "line_number": 131, "type": "Secret Keyword", "verified_result": null }, @@ -786,7 +786,7 @@ "hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790", "is_secret": false, "is_verified": false, - "line_number": 1427, + "line_number": 1438, "type": "Base64 High Entropy String", "verified_result": null }, @@ -794,7 +794,7 @@ "hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018", "is_secret": false, "is_verified": false, - "line_number": 1494, + "line_number": 1505, "type": "Secret Keyword", "verified_result": null }, @@ -802,7 +802,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3250, + "line_number": 3298, "type": "Secret Keyword", "verified_result": null }, @@ -810,7 +810,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3263, + "line_number": 3311, "type": "Secret Keyword", "verified_result": null }, @@ -818,7 +818,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3304, + "line_number": 3352, "type": "Secret Keyword", "verified_result": null } @@ -856,7 +856,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1769, + "line_number": 1779, "type": "Secret Keyword", "verified_result": null }, @@ -864,7 +864,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1775, + "line_number": 1785, "type": "Secret Keyword", "verified_result": null } @@ -2812,7 +2812,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 141, + "line_number": 165, "type": "Secret Keyword", "verified_result": null }, @@ -2820,7 +2820,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 397, + "line_number": 412, "type": "Secret Keyword", "verified_result": null } @@ -2848,7 +2848,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 674, + "line_number": 676, "type": "Secret Keyword", "verified_result": null } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 878a952437..29f7c5a152 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -165,7 +165,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { "api_key": &schema.Schema{ Type: schema.TypeString, Computed: true, - Sensitive: true, Description: "The IBM Cloud API Key.", }, }, diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 361e4f15b7..c8e828d223 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -98,7 +98,6 @@ func ResourceIbmProjectConfig() *schema.Resource { "api_key": &schema.Schema{ Type: schema.TypeString, Optional: true, - Sensitive: true, Description: "The IBM Cloud API Key.", }, }, From 47e8b412603ed752a0480a751effc8eeefda6cf8 Mon Sep 17 00:00:00 2001 From: rangelil Date: Tue, 24 Oct 2023 16:15:17 +0200 Subject: [PATCH 121/125] update to latest sdk level --- examples/ibm-project/outputs.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/ibm-project/outputs.tf b/examples/ibm-project/outputs.tf index af03b96996..277309cbec 100644 --- a/examples/ibm-project/outputs.tf +++ b/examples/ibm-project/outputs.tf @@ -3,7 +3,6 @@ output "ibm_project_config" { value = ibm_project_config.project_config_instance description = "project_config resource instance" - sensitive = true } // This output allows project data to be referenced by other resources and the terraform CLI // Modify this output if only certain data should be exposed From 5e0abd5d7610372d55451f7827567340865e4d43 Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 25 Oct 2023 06:40:09 +0200 Subject: [PATCH 122/125] merge with master --- .secrets.baseline | 50 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index bc3da79c3b..e464b6f61e 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-24T14:12:37Z", + "generated_at": "2023-10-25T04:39:42Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -662,7 +662,7 @@ "hashed_secret": "5ffafdbd72224c86c3601bacfa0b6f04f308b9f6", "is_secret": false, "is_verified": false, - "line_number": 62, + "line_number": 67, "type": "Secret Keyword", "verified_result": null } @@ -856,7 +856,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1779, + "line_number": 1800, "type": "Secret Keyword", "verified_result": null }, @@ -864,7 +864,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1785, + "line_number": 1806, "type": "Secret Keyword", "verified_result": null } @@ -2782,7 +2782,17 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 373, + "line_number": 402, + "type": "Secret Keyword", + "verified_result": null + } + ], + "ibm/service/kubernetes/resource_ibm_container_ingress_secret_opaque_test.go": [ + { + "hashed_secret": "5df29b80b97dab81130058ac9af4a9b9d1c091b4", + "is_secret": false, + "is_verified": false, + "line_number": 276, "type": "Secret Keyword", "verified_result": null } @@ -2792,7 +2802,17 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 267, + "line_number": 291, + "type": "Secret Keyword", + "verified_result": null + } + ], + "ibm/service/kubernetes/resource_ibm_container_ingress_secret_tls_test.go": [ + { + "hashed_secret": "5df29b80b97dab81130058ac9af4a9b9d1c091b4", + "is_secret": false, + "is_verified": false, + "line_number": 239, "type": "Secret Keyword", "verified_result": null } @@ -4259,24 +4279,6 @@ "verified_result": null } ], - "website/docs/r/en_destination_huawei.html.markdown": [ - { - "hashed_secret": "167a06dbc64c344aeb0bd749d1962d2ef9731f06", - "is_secret": false, - "is_verified": false, - "line_number": 24, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "69d7a780b792608707bd8579c295cb5028505f0b", - "is_secret": false, - "is_verified": false, - "line_number": 24, - "type": "Box Credentials", - "verified_result": null - } - ], "website/docs/r/en_destination_ios.html.markdown": [ { "hashed_secret": "e1e03a31507ee39abca8fc86cf37b8347dc32002", From 48c4ada9035a1220844ab43c9135afe59325df9e Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 25 Oct 2023 10:34:21 +0200 Subject: [PATCH 123/125] update to the latest sdk level --- .secrets.baseline | 14 +- examples/ibm-project/main.tf | 2 +- go.mod | 11 +- go.sum | 22 +-- .../project/data_source_ibm_project.go | 121 ++++++++++++++-- .../project/data_source_ibm_project_config.go | 69 ++++++++++ ibm/service/project/resource_ibm_project.go | 129 ++++++++++++++++-- .../project/resource_ibm_project_config.go | 69 +++++++++- .../resource_ibm_project_config_test.go | 8 +- website/docs/d/project.html.markdown | 38 ++++-- website/docs/d/project_config.html.markdown | 15 +- website/docs/r/project.html.markdown | 40 ++++-- website/docs/r/project_config.html.markdown | 16 ++- 13 files changed, 457 insertions(+), 97 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index e464b6f61e..e5e7ba5047 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-25T04:39:42Z", + "generated_at": "2023-10-25T08:33:40Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -2832,7 +2832,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 165, + "line_number": 203, "type": "Secret Keyword", "verified_result": null }, @@ -2840,7 +2840,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 412, + "line_number": 481, "type": "Secret Keyword", "verified_result": null } @@ -2868,7 +2868,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 676, + "line_number": 720, "type": "Secret Keyword", "verified_result": null } @@ -3732,7 +3732,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 93883, + "line_number": 96417, "type": "Secret Keyword", "verified_result": null }, @@ -3740,7 +3740,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 116309, + "line_number": 119435, "type": "Secret Keyword", "verified_result": null }, @@ -3748,7 +3748,7 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 147225, + "line_number": 151680, "type": "Secret Keyword", "verified_result": null } diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index a9ce85d17f..61be0f6786 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -26,8 +26,8 @@ resource "ibm_project_config" "project_config_instance" { // Provision project resource instance resource "ibm_project" "project_instance" { - resource_group = var.project_resource_group location = var.project_location + resource_group = var.project_resource_group definition { name = "My static website" description = "Sample static website test using the IBM catalog deployable architecture" diff --git a/go.mod b/go.mod index 34c57686c4..9a02539d65 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.52.0 - github.com/IBM/project-go-sdk v0.0.95 + github.com/IBM/project-go-sdk v0.0.96 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.2 github.com/IBM/schematics-go-sdk v0.2.2 @@ -70,7 +70,6 @@ require ( require ( cloud.google.com/go/kms v1.10.1 // indirect cloud.google.com/go/monitoring v1.13.0 // indirect - github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/agext/levenshtein v1.2.2 // indirect @@ -87,7 +86,6 @@ require ( github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect - github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect @@ -119,7 +117,6 @@ require ( github.com/google/gnostic v0.6.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -160,7 +157,6 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kardianos/govendor v1.0.9 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect github.com/leodido/go-urn v1.2.3 // indirect @@ -172,8 +168,6 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/gox v1.0.1 // indirect - github.com/mitchellh/iochan v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/moby/spdystream v0.2.0 // indirect @@ -214,9 +208,6 @@ require ( golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.12.0 // indirect - golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect - golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect diff --git a/go.sum b/go.sum index 891aba3c21..103170f0ce 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,6 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 h1:xGHheKK44eC6K0u5X+DZW/fRaR1LnDdqPHMZMWx5fv8= -github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75/go.mod h1:4/6eNcqZ09BZ9wLK3tZOjBA1nDj+B0728nlX5YRlSmQ= 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/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -129,8 +127,6 @@ github.com/IBM/continuous-delivery-go-sdk v1.2.0 h1:FcgB5EvVrZLUnyR4S/mBocHHo9gJ github.com/IBM/continuous-delivery-go-sdk v1.2.0/go.mod h1:oW51tS5/MDCcEM7lUvjK1H9GFC/oKsRbyYfmvGyMGmw= github.com/IBM/event-notifications-go-admin-sdk v0.2.7 h1:Y6YPiXZO3/oAhs7rY6ekowJAsf9J05g2UFq3wjFkuCs= github.com/IBM/event-notifications-go-admin-sdk v0.2.7/go.mod h1:iI6/TJt4GQBDsl8NYzoIYGnsNjMG0kOVIEl7mcM5v1E= -github.com/IBM/eventstreams-go-sdk v1.2.0 h1:eP0afHArMGjwhGqvZAhhu/3EDKRch2JehpveqF1TUjs= -github.com/IBM/eventstreams-go-sdk v1.2.0/go.mod h1:2tuAxaYLctfqfr5jvyqSrxxEQGMwYPm3yJGWSj85YVQ= github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM= github.com/IBM/eventstreams-go-sdk v1.4.0/go.mod h1:2tuAxaYLctfqfr5jvyqSrxxEQGMwYPm3yJGWSj85YVQ= github.com/IBM/go-sdk-core/v3 v3.0.0/go.mod h1:JI5NS2+iCoY/D8Oq3JNEZNA7qO42agu6fnaUmDsRcJA= @@ -161,8 +157,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.52.0 h1:hbf640xE8T0Rwy2IUf5Pu4OATabGS4IDMnEInXUXs4o= github.com/IBM/platform-services-go-sdk v0.52.0/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.95 h1:rRPch7zsUpxD1/8ObdlclTCBTdslVrvCi6Q1TXFH1Os= -github.com/IBM/project-go-sdk v0.0.95/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.96 h1:8iHRmZwKGht1yoy1zqaU+CS20Lh2U81QFmNaYXF1Hmg= +github.com/IBM/project-go-sdk v0.0.96/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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= @@ -364,8 +360,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0= -github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 h1:3T8ZyTDp5QxTx3NU48JVb2u+75xc040fofcBaN+6jPA= -github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185/go.mod h1:cFRxtTwTOJkz2x3rQUNCYKWC93yP1VKjR8NUhqFxZNU= 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/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8= @@ -741,8 +735,6 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe 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/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= 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= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -892,7 +884,6 @@ github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -1077,8 +1068,6 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kardianos/govendor v1.0.9 h1:WOH3FcVI9eOgnIZYg96iwUwrL4eOVx+aQ66oyX2R8Yc= -github.com/kardianos/govendor v1.0.9/go.mod h1:yvmR6q9ZZ7nSF5Wvh40v0wfP+3TwwL8zYQp+itoZSVM= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= @@ -1193,10 +1182,7 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= -github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -2074,10 +2060,6 @@ golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= -golang.org/x/tools/cmd/cover v0.1.0-deprecated h1:Rwy+mWYz6loAF+LnG1jHG/JWMHRMMC2/1XX3Ejkx9lA= -golang.org/x/tools/cmd/cover v0.1.0-deprecated/go.mod h1:hMDiIvlpN1NoVgmjLjUJE9tMHyxHjFX7RuQ+rW12mSA= -golang.org/x/tools/go/vcs v0.1.0-deprecated h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4= -golang.org/x/tools/go/vcs v0.1.0-deprecated/go.mod h1:zUrvATBAvEI9535oC0yWYsLsHIV4Z7g63sNPVMtuBy8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index c610578533..e8379452f2 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -101,11 +101,6 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The unique ID.", - }, "version": &schema.Schema{ Type: schema.TypeInt, Computed: true, @@ -129,7 +124,7 @@ func DataSourceIbmProject() *schema.Resource { "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "A URL.", }, "definition": &schema.Schema{ Type: schema.TypeList, @@ -150,6 +145,44 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "project": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, + }, + }, + }, }, }, }, @@ -164,10 +197,43 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The environment id as a friendly name.", }, - "project_id": &schema.Schema{ - Type: schema.TypeString, + "project": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "The unique ID.", + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, + }, + }, }, "created_at": &schema.Schema{ Type: schema.TypeString, @@ -177,7 +243,7 @@ func DataSourceIbmProject() *schema.Resource { "href": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A relative URL.", + Description: "A URL.", }, "definition": &schema.Schema{ Type: schema.TypeList, @@ -366,7 +432,6 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro modelMap["deployed_version"] = []map[string]interface{}{deployedVersionMap} } modelMap["id"] = model.ID - modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) modelMap["state"] = model.State if model.CreatedAt != nil { @@ -381,6 +446,11 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro return modelMap, err } modelMap["definition"] = []map[string]interface{}{definitionMap} + projectMap, err := dataSourceIbmProjectProjectReferenceToMap(model.Project) + if err != nil { + return modelMap, err + } + modelMap["project"] = []map[string]interface{}{projectMap} return modelMap, nil } @@ -388,9 +458,7 @@ func dataSourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.Proje modelMap := make(map[string]interface{}) modelMap["state"] = model.State modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href - } + modelMap["href"] = model.Href return modelMap, nil } @@ -405,10 +473,33 @@ func dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *proj return modelMap, nil } +func dataSourceIbmProjectProjectReferenceToMap(model *projectv1.ProjectReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + definitionMap, err := dataSourceIbmProjectProjectDefinitionReferenceToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["crn"] = model.Crn + modelMap["href"] = model.Href + return modelMap, nil +} + +func dataSourceIbmProjectProjectDefinitionReferenceToMap(model *projectv1.ProjectDefinitionReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + return modelMap, nil +} + func dataSourceIbmProjectProjectEnvironmentCollectionMemberToMap(model *projectv1.ProjectEnvironmentCollectionMember) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["id"] = model.ID - modelMap["project_id"] = model.ProjectID + projectMap, err := dataSourceIbmProjectProjectReferenceToMap(model.Project) + if err != nil { + return modelMap, err + } + modelMap["project"] = []map[string]interface{}{projectMap} modelMap["created_at"] = model.CreatedAt.String() modelMap["href"] = model.Href definitionMap, err := dataSourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model.Definition) diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 29f7c5a152..b5e7279993 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -93,6 +93,44 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, + "project": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, + }, + }, + }, "schematics": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -298,6 +336,18 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting outputs %s", err)) } + project := []map[string]interface{}{} + if projectConfig.Project != nil { + modelMap, err := dataSourceIbmProjectConfigProjectReferenceToMap(projectConfig.Project) + if err != nil { + return diag.FromErr(err) + } + project = append(project, modelMap) + } + if err = d.Set("project", project); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project %s", err)) + } + schematics := []map[string]interface{}{} if projectConfig.Schematics != nil { modelMap, err := dataSourceIbmProjectConfigSchematicsWorkspaceToMap(projectConfig.Schematics) @@ -345,6 +395,25 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m return modelMap, nil } +func dataSourceIbmProjectConfigProjectReferenceToMap(model *projectv1.ProjectReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + definitionMap, err := dataSourceIbmProjectConfigProjectDefinitionReferenceToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["crn"] = model.Crn + modelMap["href"] = model.Href + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectDefinitionReferenceToMap(model *projectv1.ProjectDefinitionReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + return modelMap, nil +} + func dataSourceIbmProjectConfigSchematicsWorkspaceToMap(model *projectv1.SchematicsWorkspace) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.WorkspaceCrn != nil { diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index c8efec424b..8a55ee0e49 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -131,11 +131,6 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", }, - "project_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The unique ID.", - }, "version": &schema.Schema{ Type: schema.TypeInt, Required: true, @@ -159,7 +154,7 @@ func ResourceIbmProject() *schema.Resource { "href": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "A relative URL.", + Description: "A URL.", }, "definition": &schema.Schema{ Type: schema.TypeList, @@ -182,6 +177,48 @@ func ResourceIbmProject() *schema.Resource { }, }, }, + "project": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A URL.", + }, + }, + }, + }, }, }, }, @@ -196,10 +233,47 @@ func ResourceIbmProject() *schema.Resource { Required: true, Description: "The environment id as a friendly name.", }, - "project_id": &schema.Schema{ - Type: schema.TypeString, + "project": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, Required: true, - Description: "The unique ID.", + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A URL.", + }, + }, + }, }, "created_at": &schema.Schema{ Type: schema.TypeString, @@ -209,7 +283,7 @@ func ResourceIbmProject() *schema.Resource { "href": &schema.Schema{ Type: schema.TypeString, Required: true, - Description: "A relative URL.", + Description: "A URL.", }, "definition": &schema.Schema{ Type: schema.TypeList, @@ -636,7 +710,6 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje modelMap["deployed_version"] = []map[string]interface{}{deployedVersionMap} } modelMap["id"] = model.ID - modelMap["project_id"] = model.ProjectID modelMap["version"] = flex.IntValue(model.Version) modelMap["state"] = model.State if model.CreatedAt != nil { @@ -651,6 +724,11 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje return modelMap, err } modelMap["definition"] = []map[string]interface{}{definitionMap} + projectMap, err := resourceIbmProjectProjectReferenceToMap(model.Project) + if err != nil { + return modelMap, err + } + modelMap["project"] = []map[string]interface{}{projectMap} return modelMap, nil } @@ -658,9 +736,7 @@ func resourceIbmProjectProjectConfigVersionSummaryToMap(model *projectv1.Project modelMap := make(map[string]interface{}) modelMap["state"] = model.State modelMap["version"] = flex.IntValue(model.Version) - if model.Href != nil { - modelMap["href"] = model.Href - } + modelMap["href"] = model.Href return modelMap, nil } @@ -675,10 +751,33 @@ func resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model *projec return modelMap, nil } +func resourceIbmProjectProjectReferenceToMap(model *projectv1.ProjectReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + definitionMap, err := resourceIbmProjectProjectDefinitionReferenceToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["crn"] = model.Crn + modelMap["href"] = model.Href + return modelMap, nil +} + +func resourceIbmProjectProjectDefinitionReferenceToMap(model *projectv1.ProjectDefinitionReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + return modelMap, nil +} + func resourceIbmProjectProjectEnvironmentCollectionMemberToMap(model *projectv1.ProjectEnvironmentCollectionMember) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["id"] = model.ID - modelMap["project_id"] = model.ProjectID + projectMap, err := resourceIbmProjectProjectReferenceToMap(model.Project) + if err != nil { + return modelMap, err + } + modelMap["project"] = []map[string]interface{}{projectMap} modelMap["created_at"] = model.CreatedAt.String() modelMap["href"] = model.Href definitionMap, err := resourceIbmProjectEnvironmentDefinitionNameDescriptionToMap(model.Definition) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index c8e828d223..7d4420a671 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -225,6 +225,46 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, + "project": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The project referenced by this resource.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The unique ID.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, + Description: "The definition of the project reference.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The name of the project.", + }, + }, + }, + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "A URL.", + }, + }, + }, + }, "state": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -320,9 +360,6 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("GetConfigWithContext failed %s\n%s", err, response)) } - if err = d.Set("project_id", projectConfig.ProjectID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_id: %s", err)) - } definitionMap, err := resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) if err != nil { return diag.FromErr(err) @@ -373,6 +410,13 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting outputs: %s", err)) } } + projectMap, err := resourceIbmProjectConfigProjectReferenceToMap(projectConfig.Project) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("project", []map[string]interface{}{projectMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting project: %s", err)) + } if err = d.Set("state", projectConfig.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } @@ -719,3 +763,22 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map } return modelMap, nil } + +func resourceIbmProjectConfigProjectReferenceToMap(model *projectv1.ProjectReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + definitionMap, err := resourceIbmProjectConfigProjectDefinitionReferenceToMap(model.Definition) + if err != nil { + return modelMap, err + } + modelMap["definition"] = []map[string]interface{}{definitionMap} + modelMap["crn"] = model.Crn + modelMap["href"] = model.Href + return modelMap, nil +} + +func resourceIbmProjectConfigProjectDefinitionReferenceToMap(model *projectv1.ProjectDefinitionReference) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["name"] = model.Name + return modelMap, nil +} diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 88998500a9..d32f559a7e 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -31,9 +31,10 @@ func TestAccIbmProjectConfigBasic(t *testing.T) { ), }, resource.TestStep{ - ResourceName: "ibm_project_config.project_config_instance", - ImportState: true, - ImportStateVerify: true, + ResourceName: "ibm_project_config.project_config_instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"project_id"}, }, }, }) @@ -50,7 +51,6 @@ func testAccCheckIbmProjectConfigConfigBasic() string { destroy_on_delete = true } } - resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id definition { diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index b8111471f1..6238589012 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project. You ca ```hcl data "ibm_project" "project" { - id = ibm_project.project_instance.project_id + id = ibm_project.project_instance.id } ``` @@ -40,12 +40,22 @@ Nested schema for **configs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `project_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `project` - (List) The project referenced by this resource. + Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -87,12 +97,22 @@ Nested schema for **environments**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The name of the environment. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The environment id as a friendly name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `project_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `project` - (List) The project referenced by this resource. + Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 8cd5e8724f..d4392d0e52 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -41,7 +41,7 @@ Nested schema for **definition**: Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. + * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Se~~~~crets Manager. * Constraints: Allowable values are: `api_key`, `trusted_profile`. * `trusted_profile_id` - (String) The trusted profile ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -90,6 +90,19 @@ Nested schema for **outputs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `project` - (List) The project referenced by this resource. +Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index f606990308..be550bf591 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -14,13 +14,13 @@ Create, update, and delete projects with this resource. ```hcl resource "ibm_project" "project_instance" { - resource_group = "Default" - location = "us-south" definition { name = "My static website" description = "Sample static website test using the IBM catalog deployable architecture" destroy_on_delete = true } + location = "us-south" + resource_group = "Default" } ``` @@ -55,12 +55,22 @@ Nested schema for **configs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The configuration name. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `project_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `project` - (List) The project referenced by this resource. + Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -89,12 +99,22 @@ Nested schema for **environments**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. * `name` - (String) The name of the environment. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. - * `href` - (String) A relative URL. - * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The environment id as a friendly name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `project_id` - (String) The unique ID. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `project` - (List) The project referenced by this resource. + Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `state` - (String) The project status value. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 4b549e287c..030692b186 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -14,13 +14,13 @@ Create, update, and delete project_configs with this resource. ```hcl resource "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.project_id + project_id = ibm_project.project_instance.id definition { name = "static-website-dev" labels = [ "env:dev", "billing:internal" ] description = "Website - development" authorizations { - method = "APIKEY" + method = "api_key" api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" @@ -102,6 +102,18 @@ Nested schema for **outputs**: * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. * `value` - (String) Can be any value - a string, number, boolean, array, or object. +* `project` - (List) The project referenced by this resource. +Nested schema for **project**: + * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `definition` - (List) The definition of the project reference. + Nested schema for **definition**: + * `name` - (String) The name of the project. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. + * `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `id` - (String) The unique ID. + * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. From 52d2585ac237938a8232973d9db154432532052f Mon Sep 17 00:00:00 2001 From: rangelil Date: Wed, 25 Oct 2023 10:37:45 +0200 Subject: [PATCH 124/125] format test case --- ibm/service/project/data_source_ibm_project_config_test.go | 1 - ibm/service/project/resource_ibm_project_config_test.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 8463742660..9133b7a4e7 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -62,7 +62,6 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { definition[0].authorizations[0].api_key, ] } - } data "ibm_project_config" "project_config_instance" { diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index d32f559a7e..1663ec3e57 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -51,6 +51,7 @@ func testAccCheckIbmProjectConfigConfigBasic() string { destroy_on_delete = true } } + resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id definition { @@ -67,7 +68,6 @@ func testAccCheckIbmProjectConfigConfigBasic() string { definition[0].authorizations[0].api_key, ] } - } `, acc.ProjectsConfigApiKey) } From 2cb180d9b9dd0e48eeb4d11a8543a7db08c5c2de Mon Sep 17 00:00:00 2001 From: rangelil Date: Mon, 30 Oct 2023 16:57:16 +0100 Subject: [PATCH 125/125] regenerate the code with generator fixes --- .secrets.baseline | 70 +++++++++---------- examples/ibm-project/README.md | 8 +-- examples/ibm-project/main.tf | 7 +- examples/ibm-project/variables.tf | 4 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 10 +-- .../project/data_source_ibm_project_config.go | 30 ++------ .../data_source_ibm_project_config_test.go | 6 +- .../project/data_source_ibm_project_test.go | 8 ++- ibm/service/project/resource_ibm_project.go | 31 +++----- .../project/resource_ibm_project_config.go | 37 ++-------- .../resource_ibm_project_config_test.go | 1 - website/docs/d/project.html.markdown | 13 ++-- website/docs/d/project_config.html.markdown | 21 +++--- website/docs/r/project.html.markdown | 9 +-- website/docs/r/project_config.html.markdown | 10 ++- 17 files changed, 106 insertions(+), 165 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 78d4594379..0d60faf91f 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-10-25T08:33:40Z", + "generated_at": "2023-10-30T15:56:24Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -472,7 +472,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 44, + "line_number": 51, "type": "Secret Keyword", "verified_result": null } @@ -552,7 +552,7 @@ "hashed_secret": "06d988e96c3d9325c9fbc7c0ef3c6c0f2b4eb8e7", "is_secret": false, "is_verified": false, - "line_number": 14, + "line_number": 13, "type": "Secret Keyword", "verified_result": null } @@ -2080,7 +2080,7 @@ "hashed_secret": "deab23f996709b4e3d14e5499d1cc2de677bfaa8", "is_secret": false, "is_verified": false, - "line_number": 1559, + "line_number": 1340, "type": "Secret Keyword", "verified_result": null }, @@ -2088,7 +2088,7 @@ "hashed_secret": "20a25bac21219ffff1904bde871ded4027eca2f8", "is_secret": false, "is_verified": false, - "line_number": 2212, + "line_number": 1927, "type": "Secret Keyword", "verified_result": null }, @@ -2096,7 +2096,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 2231, + "line_number": 1946, "type": "Secret Keyword", "verified_result": null }, @@ -2104,7 +2104,7 @@ "hashed_secret": "1f5e25be9b575e9f5d39c82dfd1d9f4d73f1975c", "is_secret": false, "is_verified": false, - "line_number": 2496, + "line_number": 2186, "type": "Secret Keyword", "verified_result": null } @@ -2114,7 +2114,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 726, + "line_number": 731, "type": "Secret Keyword", "verified_result": null } @@ -2124,7 +2124,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 189, + "line_number": 205, "type": "Secret Keyword", "verified_result": null } @@ -2134,7 +2134,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 779, + "line_number": 823, "type": "Secret Keyword", "verified_result": null } @@ -2154,7 +2154,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 199, + "line_number": 213, "type": "Secret Keyword", "verified_result": null } @@ -2164,7 +2164,7 @@ "hashed_secret": "68ab9ef0953865fef0558010a9f7afcef110d5b8", "is_secret": false, "is_verified": false, - "line_number": 199, + "line_number": 215, "type": "Secret Keyword", "verified_result": null }, @@ -2172,7 +2172,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 257, + "line_number": 280, "type": "Secret Keyword", "verified_result": null } @@ -2182,7 +2182,7 @@ "hashed_secret": "5667b8489a17faa9ef54941db31ed762be280bec", "is_secret": false, "is_verified": false, - "line_number": 141, + "line_number": 157, "type": "Secret Keyword", "verified_result": null }, @@ -2190,7 +2190,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 173, + "line_number": 189, "type": "Secret Keyword", "verified_result": null } @@ -2200,7 +2200,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 200, + "line_number": 214, "type": "Secret Keyword", "verified_result": null } @@ -2210,7 +2210,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 134, + "line_number": 150, "type": "Secret Keyword", "verified_result": null } @@ -2220,7 +2220,7 @@ "hashed_secret": "e407cbe1c64cadb886be6f42907e2dd1c06ca080", "is_secret": false, "is_verified": false, - "line_number": 626, + "line_number": 490, "type": "Secret Keyword", "verified_result": null }, @@ -2228,7 +2228,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 991, + "line_number": 658, "type": "Secret Keyword", "verified_result": null } @@ -2238,7 +2238,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 209, + "line_number": 223, "type": "Secret Keyword", "verified_result": null } @@ -2248,7 +2248,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 251, + "line_number": 272, "type": "Secret Keyword", "verified_result": null } @@ -2842,7 +2842,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 203, + "line_number": 190, "type": "Secret Keyword", "verified_result": null }, @@ -2850,7 +2850,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 481, + "line_number": 461, "type": "Secret Keyword", "verified_result": null } @@ -2860,7 +2860,7 @@ "hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3", "is_secret": false, "is_verified": false, - "line_number": 56, + "line_number": 58, "type": "Secret Keyword", "verified_result": null } @@ -2870,7 +2870,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 98, + "line_number": 92, "type": "Secret Keyword", "verified_result": null }, @@ -2878,7 +2878,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 720, + "line_number": 693, "type": "Secret Keyword", "verified_result": null } @@ -3742,7 +3742,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 96417, + "line_number": 96615, "type": "Secret Keyword", "verified_result": null }, @@ -3750,7 +3750,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 119435, + "line_number": 119404, "type": "Secret Keyword", "verified_result": null }, @@ -3758,7 +3758,7 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 151680, + "line_number": 151612, "type": "Secret Keyword", "verified_result": null } @@ -4028,7 +4028,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 153, + "line_number": 152, "type": "Secret Keyword", "verified_result": null }, @@ -4036,7 +4036,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 155, + "line_number": 154, "type": "Secret Keyword", "verified_result": null } @@ -4238,7 +4238,7 @@ "hashed_secret": "10c28f9cf0668595d45c1090a7b4a2ae98edfa58", "is_secret": false, "is_verified": false, - "line_number": 488, + "line_number": 494, "type": "Secret Keyword", "verified_result": null }, @@ -4246,7 +4246,7 @@ "hashed_secret": "e407cbe1c64cadb886be6f42907e2dd1c06ca080", "is_secret": false, "is_verified": false, - "line_number": 553, + "line_number": 559, "type": "Secret Keyword", "verified_result": null }, @@ -4254,7 +4254,7 @@ "hashed_secret": "91199272d5d6a574a51722ca6f3d1148edb1a0e7", "is_secret": false, "is_verified": false, - "line_number": 577, + "line_number": 583, "type": "Secret Keyword", "verified_result": null } @@ -4474,7 +4474,7 @@ "hashed_secret": "06d988e96c3d9325c9fbc7c0ef3c6c0f2b4eb8e7", "is_secret": false, "is_verified": false, - "line_number": 24, + "line_number": 23, "type": "Secret Keyword", "verified_result": null } diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 8d7c66c411..2c985f19d0 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -47,14 +47,14 @@ project_config data source: ```hcl data "project_config" "project_config_instance" { project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + project_config_id = ibm_project_config.project_config_instance.project_config_id } ``` project data source: ```hcl data "project" "project_instance" { - id = ibm_project.project_instance.id + project_id = ibm_project.project_instance.id } ``` @@ -90,8 +90,8 @@ data "project" "project_instance" { | resource_group | The resource group where the project's data and tools are created. | `string` | true | | definition | The definition of the project. | `` | true | | project_id | The unique project ID. | `string` | true | -| id | The unique config ID. | `string` | true | -| id | The unique project ID. | `string` | true | +| project_config_id | The unique config ID. | `string` | true | +| project_id | The unique project ID. | `string` | true | ## Outputs diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 61be0f6786..79837ee3fb 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -7,7 +7,6 @@ resource "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.project_id definition { name = "static-website-dev" - labels = [ "env:dev", "billing:internal" ] description = "Website - development" authorizations { method = "api_key" @@ -37,11 +36,11 @@ resource "ibm_project" "project_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id - id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config_instance.project_id + project_config_id = ibm_project_config.project_config_instance.project_config_id } // Create project data source data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + project_id = ibm_project.project_instance.id } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 47a8010f6f..b32094d31b 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -31,12 +31,12 @@ variable "project_config_project_id" { variable "project_config_id" { description = "The unique config ID." type = string - default = "id" + default = "project_config_id" } // Data source arguments for project variable "project_id" { description = "The unique project ID." type = string - default = "id" + default = "project_id" } diff --git a/go.mod b/go.mod index b815322039..8cec155f12 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.52.0 - github.com/IBM/project-go-sdk v0.0.96 + github.com/IBM/project-go-sdk v0.0.99 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.3 github.com/IBM/schematics-go-sdk v0.2.2 diff --git a/go.sum b/go.sum index 9550471057..e1f9e3e9ff 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.52.0 h1:hbf640xE8T0Rwy2IUf5Pu4OATabGS4IDMnEInXUXs4o= github.com/IBM/platform-services-go-sdk v0.52.0/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU= -github.com/IBM/project-go-sdk v0.0.96 h1:8iHRmZwKGht1yoy1zqaU+CS20Lh2U81QFmNaYXF1Hmg= -github.com/IBM/project-go-sdk v0.0.96/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.0.99 h1:rQU/uQLW83OsAUfP/d8fFSIjp8ooEQIFjalYQD4i4aY= +github.com/IBM/project-go-sdk v0.0.99/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= 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/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index e8379452f2..277d769e3a 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -21,7 +21,7 @@ func DataSourceIbmProject() *schema.Resource { ReadContext: dataSourceIbmProjectRead, Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ + "project_id": &schema.Schema{ Type: schema.TypeString, Required: true, Description: "The unique project ID.", @@ -116,7 +116,7 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "user_modified_at": &schema.Schema{ + "modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -303,7 +303,7 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m getProjectOptions := &projectv1.GetProjectOptions{} - getProjectOptions.SetID(d.Get("id").(string)) + getProjectOptions.SetID(d.Get("project_id").(string)) project, response, err := projectClient.GetProjectWithContext(context, getProjectOptions) if err != nil { @@ -437,8 +437,8 @@ func dataSourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Pro if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } - if model.UserModifiedAt != nil { - modelMap["user_modified_at"] = model.UserModifiedAt.String() + if model.ModifiedAt != nil { + modelMap["modified_at"] = model.ModifiedAt.String() } modelMap["href"] = model.Href definitionMap, err := dataSourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index b5e7279993..e064294568 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -26,16 +26,11 @@ func DataSourceIbmProjectConfig() *schema.Resource { Required: true, Description: "The unique project ID.", }, - "id": &schema.Schema{ + "project_config_id": &schema.Schema{ Type: schema.TypeString, Required: true, Description: "The unique config ID.", }, - "project_config_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.", - }, "version": &schema.Schema{ Type: schema.TypeInt, Computed: true, @@ -59,7 +54,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "user_modified_at": &schema.Schema{ + "modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -171,14 +166,6 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A project configuration description.", }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The configuration labels.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "environment": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -284,7 +271,7 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD getConfigOptions := &projectv1.GetConfigOptions{} getConfigOptions.SetProjectID(d.Get("project_id").(string)) - getConfigOptions.SetID(d.Get("id").(string)) + getConfigOptions.SetID(d.Get("project_config_id").(string)) projectConfig, response, err := projectClient.GetConfigWithContext(context, getConfigOptions) if err != nil { @@ -294,10 +281,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD d.SetId(fmt.Sprintf("%s/%s", *getConfigOptions.ProjectID, *getConfigOptions.ID)) - if err = d.Set("project_config_id", projectConfig.ID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) - } - if err = d.Set("version", flex.IntValue(projectConfig.Version)); err != nil { return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) } @@ -314,8 +297,8 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - if err = d.Set("user_modified_at", flex.DateTimeToString(projectConfig.UserModifiedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) + if err = d.Set("modified_at", flex.DateTimeToString(projectConfig.ModifiedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting modified_at: %s", err)) } if err = d.Set("last_saved_at", flex.DateTimeToString(projectConfig.LastSavedAt)); err != nil { @@ -428,9 +411,6 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje if model.Description != nil { modelMap["description"] = model.Description } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } if model.Environment != nil { modelMap["environment"] = model.Environment } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 9133b7a4e7..785e6ff684 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -25,6 +25,9 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project_config_id"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "version"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "is_draft"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "modified_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project.#"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), @@ -50,7 +53,6 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { project_id = ibm_project.project_instance.id definition { name = "stage-environment" - labels = ["env:stage"] authorizations { method = "api_key" api_key = "%s" @@ -66,7 +68,7 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { data "ibm_project_config" "project_config_instance" { project_id = ibm_project_config.project_config_instance.project_id - id = ibm_project_config.project_config_instance.project_config_id + project_config_id = ibm_project_config.project_config_instance.project_config_id } `, acc.ProjectsConfigApiKey) } diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index 2c739fcfd5..062bc5fefe 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -24,6 +24,12 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { Config: testAccCheckIbmProjectDataSourceConfigBasic(projectLocation, projectResourceGroup), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "project_id"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), ), }, @@ -44,7 +50,7 @@ func testAccCheckIbmProjectDataSourceConfigBasic(projectLocation string, project } data "ibm_project" "project_instance" { - id = ibm_project.project_instance.id + project_id = ibm_project.project_instance.id } `, projectLocation, projectResourceGroup) } diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 8a55ee0e49..9b5242752d 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -146,7 +146,7 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "user_modified_at": &schema.Schema{ + "modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -400,15 +400,11 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if err = d.Set("definition", []map[string]interface{}{definitionMap}); err != nil { return diag.FromErr(fmt.Errorf("Error setting definition: %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)) - } + if err = d.Set("crn", project.Crn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) } - if !core.IsNil(project.CreatedAt) { - if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } + if err = d.Set("created_at", flex.DateTimeToString(project.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } if !core.IsNil(project.CumulativeNeedsAttentionView) { cumulativeNeedsAttentionView := []map[string]interface{}{} @@ -428,10 +424,8 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met return diag.FromErr(fmt.Errorf("Error setting cumulative_needs_attention_view_error: %s", err)) } } - if !core.IsNil(project.State) { - if err = d.Set("state", project.State); err != nil { - return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) - } + if err = d.Set("state", project.State); err != nil { + return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } if !core.IsNil(project.EventNotificationsCrn) { if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { @@ -556,13 +550,6 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s if modelMap["description"] != nil && modelMap["description"].(string) != "" { model.Description = core.StringPtr(modelMap["description"].(string)) } - if modelMap["labels"] != nil { - labels := []string{} - for _, labelsItem := range modelMap["labels"].([]interface{}) { - labels = append(labels, labelsItem.(string)) - } - model.Labels = labels - } if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { model.Environment = core.StringPtr(modelMap["environment"].(string)) } @@ -715,8 +702,8 @@ func resourceIbmProjectProjectConfigCollectionMemberToMap(model *projectv1.Proje if model.CreatedAt != nil { modelMap["created_at"] = model.CreatedAt.String() } - if model.UserModifiedAt != nil { - modelMap["user_modified_at"] = model.UserModifiedAt.String() + if model.ModifiedAt != nil { + modelMap["modified_at"] = model.ModifiedAt.String() } modelMap["href"] = model.Href definitionMap, err := resourceIbmProjectProjectConfigDefinitionNameDescriptionToMap(model.Definition) diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 7d4420a671..ef7fb404c3 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -67,12 +67,6 @@ func ResourceIbmProjectConfig() *schema.Resource { Optional: true, Description: "A project configuration description.", }, - "labels": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "The configuration labels.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, "environment": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -191,7 +185,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, - "user_modified_at": &schema.Schema{ + "modified_at": &schema.Schema{ Type: schema.TypeString, Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", @@ -382,15 +376,11 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) } } - if !core.IsNil(projectConfig.CreatedAt) { - if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } + if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } - if !core.IsNil(projectConfig.UserModifiedAt) { - if err = d.Set("user_modified_at", flex.DateTimeToString(projectConfig.UserModifiedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting user_modified_at: %s", err)) - } + if err = d.Set("modified_at", flex.DateTimeToString(projectConfig.ModifiedAt)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting modified_at: %s", err)) } if !core.IsNil(projectConfig.LastSavedAt) { if err = d.Set("last_saved_at", flex.DateTimeToString(projectConfig.LastSavedAt)); err != nil { @@ -501,13 +491,6 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap if modelMap["description"] != nil && modelMap["description"].(string) != "" { model.Description = core.StringPtr(modelMap["description"].(string)) } - if modelMap["labels"] != nil { - labels := []string{} - for _, labelsItem := range modelMap["labels"].([]interface{}) { - labels = append(labels, labelsItem.(string)) - } - model.Labels = labels - } if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { model.Environment = core.StringPtr(modelMap["environment"].(string)) } @@ -605,13 +588,6 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypePatchDefinitionBlock(mod if modelMap["description"] != nil && modelMap["description"].(string) != "" { model.Description = core.StringPtr(modelMap["description"].(string)) } - if modelMap["labels"] != nil { - labels := []string{} - for _, labelsItem := range modelMap["labels"].([]interface{}) { - labels = append(labels, labelsItem.(string)) - } - model.Labels = labels - } if modelMap["environment"] != nil && modelMap["environment"].(string) != "" { model.Environment = core.StringPtr(modelMap["environment"].(string)) } @@ -663,9 +639,6 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project if model.Description != nil { modelMap["description"] = model.Description } - if model.Labels != nil { - modelMap["labels"] = model.Labels - } if model.Environment != nil { modelMap["environment"] = model.Environment } diff --git a/ibm/service/project/resource_ibm_project_config_test.go b/ibm/service/project/resource_ibm_project_config_test.go index 1663ec3e57..8a827c81f1 100644 --- a/ibm/service/project/resource_ibm_project_config_test.go +++ b/ibm/service/project/resource_ibm_project_config_test.go @@ -56,7 +56,6 @@ func testAccCheckIbmProjectConfigConfigBasic() string { project_id = ibm_project.project_instance.id definition { name = "stage-environment" - labels = ["env:stage"] authorizations { method = "api_key" api_key = "%s" diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 6238589012..3ac6b811d3 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a project. You ca ```hcl data "ibm_project" "project" { - id = ibm_project.project_instance.id + project_id = ibm_project.project_instance.id } ``` @@ -22,7 +22,7 @@ data "ibm_project" "project" { You can specify the following arguments for this data source. -* `id` - (Required, Forces new resource, String) The unique project ID. +* `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. ## Attribute Reference @@ -31,7 +31,7 @@ After your data source is created, you can read values from the following attrib * `id` - The unique identifier of the project. * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `definition` - (List) The name and description of a project configuration. @@ -44,6 +44,7 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `project` - (List) The project referenced by this resource. Nested schema for **project**: * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. @@ -58,7 +59,6 @@ Nested schema for **configs**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. - * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -67,7 +67,7 @@ Nested schema for **configs**: * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **cumulative_needs_attention_view**: * `config_id` - (String) A unique ID for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -78,6 +78,7 @@ Nested schema for **cumulative_needs_attention_view**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. + * Constraints: The default value is `false`. * `definition` - (List) The definition of the project. Nested schema for **definition**: @@ -88,7 +89,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `environments` - (List) The project environments. These environments are only included in the response if project environments were created on the project. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **environments**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `definition` - (List) The environment definition used in the project collection. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index d4392d0e52..5cfedd0d20 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -14,8 +14,8 @@ Provides a read-only data source to retrieve information about a project_config. ```hcl data "ibm_project_config" "project_config" { - id = ibm_project_config.project_config_instance.project_config_id - project_id = ibm_project_config.project_config.project_id + project_config_id = ibm_project_config.project_config_instance.project_config_id + project_id = ibm_project_config.project_config_instance.project_id } ``` @@ -23,7 +23,7 @@ data "ibm_project_config" "project_config" { You can specify the following arguments for this data source. -* `id` - (Required, Forces new resource, String) The unique config ID. +* `project_config_id` - (Required, Forces new resource, String) The unique config ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -41,7 +41,7 @@ Nested schema for **definition**: Nested schema for **authorizations**: * `api_key` - (String) The IBM Cloud API Key. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. - * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Se~~~~crets Manager. + * `method` - (String) The authorization method. You can authorize by using a trusted profile or an API key in Secrets Manager. * Constraints: Allowable values are: `api_key`, `trusted_profile`. * `trusted_profile_id` - (String) The trusted profile ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -63,8 +63,6 @@ Nested schema for **definition**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `inputs` - (List) The input variables for configuration definition and environment. Nested schema for **inputs**: - * `labels` - (List) The configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. @@ -78,11 +76,13 @@ Nested schema for **definition**: * `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. + * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. * `outputs` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **outputs**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -103,9 +103,6 @@ Nested schema for **project**: * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. -* `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. - * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `schematics` - (List) A schematics workspace associated to a project configuration. Nested schema for **schematics**: * `workspace_crn` - (String) An existing schematics workspace CRN. @@ -116,7 +113,5 @@ Nested schema for **schematics**: * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. -* `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. - * `version` - (Integer) The version of the configuration. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index be550bf591..98926aaffd 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -46,7 +46,7 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the project. * `configs` - (List) The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **configs**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `definition` - (List) The name and description of a project configuration. @@ -59,6 +59,7 @@ Nested schema for **configs**: * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. + * `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `project` - (List) The project referenced by this resource. Nested schema for **project**: * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. @@ -73,13 +74,12 @@ Nested schema for **configs**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. - * `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. * `cumulative_needs_attention_view` - (List) The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **cumulative_needs_attention_view**: * `config_id` - (String) A unique ID for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -89,8 +89,9 @@ Nested schema for **cumulative_needs_attention_view**: * `event_id` - (String) A unique ID for that individual event. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `cumulative_needs_attention_view_error` - (Boolean) True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. + * Constraints: The default value is `false`. * `environments` - (List) The project environments. These environments are only included in the response if project environments were created on the project. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **environments**: * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `definition` - (List) The environment definition used in the project collection. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 030692b186..db20dac197 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -14,7 +14,6 @@ Create, update, and delete project_configs with this resource. ```hcl resource "ibm_project_config" "project_config_instance" { - project_id = ibm_project.project_instance.id definition { name = "static-website-dev" labels = [ "env:dev", "billing:internal" ] @@ -32,6 +31,7 @@ resource "ibm_project_config" "project_config_instance" { value = "static-website-dev-app-repo" } } + project_id = ibm_project.project_instance.id } ``` @@ -67,8 +67,6 @@ Nested schema for **definition**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `inputs` - (Optional, List) The input variables for configuration definition and environment. Nested schema for **inputs**: - * `labels` - (Optional, List) The configuration labels. - * Constraints: The list items must match regular expression `/^[_\\-a-z0-9:\/=]+$/`. The maximum length is `10000` items. The minimum length is `0` items. * `locator_id` - (Required, Forces new resource, String) A dotted value of catalogID.versionID. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. @@ -92,10 +90,11 @@ After your resource is created, you can read values from the listed arguments an * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `needs_attention_state` - (List) The needs attention state of a configuration. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. * `outputs` - (List) The outputs of a Schematics template property. - * Constraints: The maximum length is `10000` items. The minimum length is `0` items. + * Constraints: The default value is `[]`. The maximum length is `10000` items. The minimum length is `0` items. Nested schema for **outputs**: * `description` - (String) A short explanation of the output value. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s).*\\S$/`. @@ -119,7 +118,6 @@ Nested schema for **project**: * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. -* `user_modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `version` - (Integer) The version of the configuration.