Skip to content

Commit

Permalink
update catalog offering instance resource and datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
JonWoodlief authored and hkantare committed Jun 17, 2021
1 parent fd8ff86 commit 3aa905e
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/IBM/ibm-cos-sdk-go-config v1.2.0
github.com/IBM/keyprotect-go-client v0.7.0
github.com/IBM/networking-go-sdk v0.14.0
github.com/IBM/platform-services-go-sdk v0.18.12
github.com/IBM/platform-services-go-sdk v0.18.16
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/schematics-go-sdk v0.0.2
github.com/IBM/secrets-manager-go-sdk v0.1.19
Expand Down
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ github.com/IBM/platform-services-go-sdk v0.18.11 h1:86o1S+LghQJmmjXfOLcmJ+C5bXsa
github.com/IBM/platform-services-go-sdk v0.18.11/go.mod h1:yaE+2oxhno9RhKYyvzeektKCajakHkM2R2/gWSJIqfA=
github.com/IBM/platform-services-go-sdk v0.18.12 h1:Xxh3hmbIStKfz7L9E3C1NbHvic/bdRai/pHSpQwHfp8=
github.com/IBM/platform-services-go-sdk v0.18.12/go.mod h1:awc7TZUeGMlToSeMSaWEz34Knf0lQnuGWumcI4pcuoM=
github.com/IBM/platform-services-go-sdk v0.18.15 h1:Yb1s0l/SwXJ6AhpGL9klVFswm9jAol+ICog97hvsyC0=
github.com/IBM/platform-services-go-sdk v0.18.15/go.mod h1:awc7TZUeGMlToSeMSaWEz34Knf0lQnuGWumcI4pcuoM=
github.com/IBM/platform-services-go-sdk v0.18.16 h1:blYycstPoNtPKtu1uZe240WvzcJENy/Lzx+HMUA8bOo=
github.com/IBM/platform-services-go-sdk v0.18.16/go.mod h1:awc7TZUeGMlToSeMSaWEz34Knf0lQnuGWumcI4pcuoM=
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/schematics-go-sdk v0.0.2 h1:IFdM73VL3xwf/KaTh1IY99hkiTfFRYg5F1JNj69FOEg=
Expand All @@ -159,6 +163,7 @@ github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy86
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
Expand Down Expand Up @@ -320,12 +325,15 @@ github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.1.0 h1:4pl5BV4o7ZG/lterP4S6WzJ6xr49Ba5ET9ygheTYahk=
github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
github.com/go-git/go-git/v5 v5.3.0 h1:8WKMtJR2j8RntEXR/uvTKagfEt4GYlwQ7mntE4+0GWc=
github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -670,6 +678,7 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
Expand Down Expand Up @@ -707,6 +716,7 @@ github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaR
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down Expand Up @@ -900,6 +910,7 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down Expand Up @@ -951,6 +962,7 @@ github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37w
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
Expand Down Expand Up @@ -1357,6 +1369,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
Expand Down
16 changes: 16 additions & 0 deletions ibm/data_source_ibm_cm_offering_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ func dataSourceIBMCmOfferingInstance() *schema.Resource {
Computed: true,
Description: "id of the resource group",
},
"install_plan": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "install plan for the subscription of the operator- can be either Automatic or Manual. Required for operator bundles",
},
"channel": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "channel to target for the operator subscription. Required for operator bundles",
},
},
}
}
Expand Down Expand Up @@ -161,6 +171,12 @@ func dataSourceIBMCmOfferingInstanceRead(context context.Context, d *schema.Reso
if err = d.Set("resource_group_id", offeringInstance.ResourceGroupID); err != nil {
return diag.FromErr(fmt.Errorf("Error setting resource_group_id: %s", err))
}
if err = d.Set("install_plan", offeringInstance.InstallPlan); err != nil {
return diag.FromErr(fmt.Errorf("Error setting install_plan: %s", err))
}
if err = d.Set("channel", offeringInstance.Channel); err != nil {
return diag.FromErr(fmt.Errorf("Error setting channel: %s", err))
}

return nil
}
3 changes: 2 additions & 1 deletion ibm/data_source_ibm_cm_offering_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func testAccCheckIBMCmOfferingInstanceDataSourceConfig(clusterId string, cluster
resource "ibm_cm_version" "cm_version" {
catalog_identifier = ibm_cm_catalog.cm_catalog.id
offering_id = ibm_cm_offering.cm_offering.id
zipurl = "https://raw.githubusercontent.com/operator-framework/community-operators/master/community-operators/flux/0.9.1/manifests/flux.v0.9.1.clusterserviceversion.yaml"
zipurl = "https://raw.githubusercontent.com/operator-framework/community-operators/master/community-operators/cockroachdb/5.0.3/manifests/cockroachdb.clusterserviceversion.yaml"
}
resource "ibm_cm_offering_instance" "cm_offering_instance" {
Expand All @@ -63,6 +63,7 @@ func testAccCheckIBMCmOfferingInstanceDataSourceConfig(clusterId string, cluster
cluster_namespaces = ["tf-cm-data-test"]
cluster_all_namespaces = false
resource_group_id = "%s"
install_plan = "Automatic"
}
data "ibm_cm_offering_instance" "cm_offering_instance_data" {
Expand Down
99 changes: 91 additions & 8 deletions ibm/resource_ibm_cm_offering_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ import (
"fmt"
"log"
"os"
"time"

"github.com/IBM/platform-services-go-sdk/catalogmanagementv1"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

const (
inProgress = "in progress"
failed = "failed"
success = "succeeded"

waitUntilInterval = 10 * time.Second
)

func resourceIBMCmOfferingInstance() *schema.Resource {
return &schema.Resource{
Create: resourceIBMCmOfferingInstanceCreate,
Expand All @@ -21,6 +31,12 @@ func resourceIBMCmOfferingInstance() *schema.Resource {
Exists: resourceIBMCmOfferingInstanceExists,
Importer: &schema.ResourceImporter{},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(4 * time.Minute),
Update: schema.DefaultTimeout(4 * time.Minute),
Delete: schema.DefaultTimeout(4 * time.Minute),
},

Schema: map[string]*schema.Schema{
"url": &schema.Schema{
Type: schema.TypeString,
Expand All @@ -32,11 +48,6 @@ func resourceIBMCmOfferingInstance() *schema.Resource {
Computed: true,
Description: "platform CRN for this instance.",
},
"_rev": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Cloudant Revision for this instance",
},
"label": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -93,6 +104,23 @@ func resourceIBMCmOfferingInstance() *schema.Resource {
Optional: true,
Description: "id of the resource group",
},
"install_plan": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "install plan for the subscription of the operator- can be either automatic or manual. Required for operator bundles",
},
"channel": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "channel to target for the operator subscription. Required for operator bundles",
},
"wait_until_successful": {
Type: schema.TypeBool,
Optional: true,
DiffSuppressFunc: applyOnce,
Default: true,
Description: "Whether to wait until the offering instance successfully provisions, or to return when accepted",
},
},
}
}
Expand Down Expand Up @@ -146,6 +174,12 @@ func resourceIBMCmOfferingInstanceCreate(d *schema.ResourceData, meta interface{
if _, ok := d.GetOk("resource_group_id"); ok {
createOfferingInstanceOptions.SetResourceGroupID(d.Get("resource_group_id").(string))
}
if _, ok := d.GetOk("install_plan"); ok {
createOfferingInstanceOptions.SetInstallPlan(d.Get("install_plan").(string))
}
if _, ok := d.GetOk("channel"); ok {
createOfferingInstanceOptions.SetChannel(d.Get("channel").(string))
}

offeringInstance, response, err := catalogManagementClient.CreateOfferingInstance(createOfferingInstanceOptions)
if err != nil {
Expand All @@ -155,11 +189,46 @@ func resourceIBMCmOfferingInstanceCreate(d *schema.ResourceData, meta interface{

d.SetId(*offeringInstance.ID)

if d.Get("wait_until_successful").(bool) {
if _, err = waitUntilSuccess(d, meta); err != nil {
log.Print(err)
return err
}
}

log.Printf("LOG2 Service version instance of type %q was created on cluster %q", *createOfferingInstanceOptions.KindFormat, *createOfferingInstanceOptions.ClusterID)

return resourceIBMCmOfferingInstanceRead(d, meta)
}

func waitUntilSuccess(d *schema.ResourceData, meta interface{}) (interface{}, error) {
catalogManagementClient, err := meta.(ClientSession).CatalogManagementV1()
if err != nil {
return nil, err
}
getOfferingInstanceOptions := &catalogmanagementv1.GetOfferingInstanceOptions{}

getOfferingInstanceOptions.SetInstanceIdentifier(d.Id())

stateConf := &resource.StateChangeConf{
Pending: []string{inProgress},
Target: []string{success},
Refresh: func() (interface{}, string, error) {
offeringInstance, _, err := catalogManagementClient.GetOfferingInstance(getOfferingInstanceOptions)
if err != nil {
return nil, "", fmt.Errorf("Error retrieving offering instance: %s", err)
}

return offeringInstance, *offeringInstance.LastOperation.State, nil
},
Delay: waitUntilInterval * 2,
MinTimeout: waitUntilInterval,
Timeout: d.Timeout(schema.TimeoutCreate),
}

return stateConf.WaitForState()
}

func resourceIBMCmOfferingInstanceRead(d *schema.ResourceData, meta interface{}) error {
catalogManagementClient, err := meta.(ClientSession).CatalogManagementV1()
if err != nil {
Expand All @@ -186,9 +255,6 @@ func resourceIBMCmOfferingInstanceRead(d *schema.ResourceData, meta interface{})
if err = d.Set("crn", offeringInstance.CRN); err != nil {
return fmt.Errorf("Error setting crn: %s", err)
}
if err = d.Set("_rev", offeringInstance.Rev); err != nil {
return fmt.Errorf("Error setting _rev: %s", err)
}
if err = d.Set("label", offeringInstance.Label); err != nil {
return fmt.Errorf("Error setting label: %s", err)
}
Expand Down Expand Up @@ -221,6 +287,12 @@ func resourceIBMCmOfferingInstanceRead(d *schema.ResourceData, meta interface{})
if err = d.Set("schematics_workspace_id", offeringInstance.SchematicsWorkspaceID); err != nil {
return fmt.Errorf("Error setting schematics_workspace_id: %s", err)
}
if err = d.Set("install_plan", offeringInstance.InstallPlan); err != nil {
return fmt.Errorf("Error setting install_plan: %s", err)
}
if err = d.Set("channel", offeringInstance.Channel); err != nil {
return fmt.Errorf("Error setting channel: %s", err)
}

return nil
}
Expand Down Expand Up @@ -248,6 +320,11 @@ func resourceIBMCmOfferingInstanceUpdate(d *schema.ResourceData, meta interface{

putOfferingInstanceOptions := &catalogmanagementv1.PutOfferingInstanceOptions{}

schemID, isfound := os.LookupEnv("IC_SCHEMATICS_WORKSPACE_ID")
if isfound {
putOfferingInstanceOptions.SetSchematicsWorkspaceID(schemID)
}

putOfferingInstanceOptions.SetInstanceIdentifier(d.Id())
putOfferingInstanceOptions.SetID(d.Id())
putOfferingInstanceOptions.SetXAuthRefreshToken(rsConClient.Config.IAMRefreshToken)
Expand Down Expand Up @@ -283,6 +360,12 @@ func resourceIBMCmOfferingInstanceUpdate(d *schema.ResourceData, meta interface{
if _, ok := d.GetOk("resource_group_id"); ok {
putOfferingInstanceOptions.SetResourceGroupID(d.Get("resource_group_id").(string))
}
if _, ok := d.GetOk("install_plan"); ok {
putOfferingInstanceOptions.SetInstallPlan(d.Get("install_plan").(string))
}
if _, ok := d.GetOk("channel"); ok {
putOfferingInstanceOptions.SetChannel(d.Get("channel").(string))
}

_, response, err = catalogManagementClient.PutOfferingInstance(putOfferingInstanceOptions)
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions ibm/resource_ibm_cm_offering_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ func TestAccIBMCmOfferingInstance(t *testing.T) {
),
},
resource.TestStep{
ResourceName: "ibm_cm_offering_instance.cm_offering_instance",
ImportState: true,
ImportStateVerify: true,
ResourceName: "ibm_cm_offering_instance.cm_offering_instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"wait_until_successful"},
},
},
})
Expand All @@ -54,7 +55,7 @@ func testAccCheckIBMCmOfferingInstanceConfig(clusterId string, clusterRegion str
resource "ibm_cm_version" "cm_version" {
catalog_identifier = ibm_cm_catalog.cm_catalog.id
offering_id = ibm_cm_offering.cm_offering.id
zipurl = "https://raw.githubusercontent.com/operator-framework/community-operators/master/community-operators/cockroachdb/5.0.3/manifests/cockroachdb.clusterserviceversion.yaml"
zipurl = "https://raw.githubusercontent.com/operator-framework/community-operators/master/community-operators/flux/0.14.2/manifests/flux.v0.14.2.clusterserviceversion.yaml"
}
resource "ibm_cm_offering_instance" "cm_offering_instance" {
Expand All @@ -67,6 +68,7 @@ func testAccCheckIBMCmOfferingInstanceConfig(clusterId string, clusterRegion str
cluster_region = "%s"
cluster_namespaces = ["tf-cm-test"]
cluster_all_namespaces = false
install_plan = "Automatic"
}
`, clusterId, clusterRegion)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/cm_offering_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ Review the argument reference that you can specify for your data source.
In addition to the argument reference list, you can access the following attribute references after your data source is created.

- `catalog_id` - (String) The catalog ID the instance that is created from.
- `channel` - (String) Channel to target for the operator subscription. Required for operator bundles
- `cluster_id` - (String) The cluster ID.
- `cluster_region` - (String) The cluster region for example, `us-south`.
- `cluster_namespaces` - (String) The list of target namespaces to install.
- `cluster_all_namespaces` - (String) Designate to install into all namespaces.
- `crn` - (String) The platform CRN for an instance.
- `_rev` - (string) The cloudant revisionn of this object
- `id` - (String) The unique identifier of the `cm_offering_instance`.
- `install_plan` - (String) Install plan for the subscription of the operator- can be either Automatic or Manual. Required for operator bundles
- `kind_format` - (String) The format this instance has such as `helm`, `operator`.
- `label` - (String) The label for an instance.
- `offering_id` - (String) The offering ID the instance that is created from.
Expand Down
Loading

0 comments on commit 3aa905e

Please sign in to comment.