Skip to content

Commit

Permalink
Merge branch 'master' into gen3
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm committed Jun 18, 2024
2 parents f3b00ca + e3c9600 commit 993bbf3
Show file tree
Hide file tree
Showing 67 changed files with 2,787 additions and 464 deletions.
2 changes: 2 additions & 0 deletions examples/ibm-is-ng/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ resource "ibm_is_instance" "instance8" {
}
catalog_offering {
version_crn = data.ibm_is_images.imageslist.images.0.catalog_offering.0.version.0.crn
plan_crn = "crn:v1:bluemix:public:globalcatalog-collection:global:a/123456:51c9e0db-2911-45a6-adb0-ac5332d27cf2:plan:sw.51c9e0db-2911-45a6-adb0-ac5332d27cf2.772c0dbe-aa62-482e-adbe-a3fc20101e0e"
}
vpc = ibm_is_vpc.vpc2.id
zone = "us-south-2"
Expand All @@ -777,6 +778,7 @@ resource "ibm_is_instance_template" "instancetemplate3" {
name = "instancetemplate-3"
catalog_offering {
version_crn = data.ibm_is_images.imageslist.images.0.catalog_offering.0.version.0.crn
plan_crn = "crn:v1:bluemix:public:globalcatalog-collection:global:a/123456:51c9e0db-2911-45a6-adb0-ac5332d27cf2:plan:sw.51c9e0db-2911-45a6-adb0-ac5332d27cf2.772c0dbe-aa62-482e-adbe-a3fc20101e0e"
}
profile = var.profile

Expand Down
313 changes: 0 additions & 313 deletions go.sum

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,25 @@ func DataSourceIBMISInstance() *schema.Resource {
Computed: true,
Description: "Identifies a version of a catalog offering by a unique CRN property",
},
isInstanceCatalogOfferingPlanCrn: {
Type: schema.TypeString,
Computed: true,
Description: "The CRN for this catalog offering version's billing plan",
},
"deleted": {
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates the referenced resource has been deleted and provides some supplementary information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"more_info": {
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about deleted resources.",
},
},
},
},
},
},
},
Expand Down Expand Up @@ -1106,6 +1125,14 @@ func DataSourceIBMISInstance() *schema.Resource {
}
}

func resourceIbmIsInstanceCatalogOfferingVersionPlanReferenceDeletedToMap(catalogOfferingVersionPlanReferenceDeleted vpcv1.CatalogOfferingVersionPlanReferenceDeleted) map[string]interface{} {
catalogOfferingVersionPlanReferenceDeletedMap := map[string]interface{}{}

catalogOfferingVersionPlanReferenceDeletedMap["more_info"] = catalogOfferingVersionPlanReferenceDeleted.MoreInfo

return catalogOfferingVersionPlanReferenceDeletedMap
}

func dataSourceIBMISInstanceRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

name := d.Get(isInstanceName).(string)
Expand Down Expand Up @@ -1145,6 +1172,15 @@ func instanceGetByName(d *schema.ResourceData, meta interface{}, name string) er
catalogList := make([]map[string]interface{}, 0)
catalogMap := map[string]interface{}{}
catalogMap[isInstanceCatalogOfferingVersionCrn] = versionCrn
if instance.CatalogOffering.Plan != nil {
if instance.CatalogOffering.Plan.CRN != nil && *instance.CatalogOffering.Plan.CRN != "" {
catalogMap[isInstanceCatalogOfferingPlanCrn] = *instance.CatalogOffering.Plan.CRN
}
if instance.CatalogOffering.Plan.Deleted != nil {
deletedMap := resourceIbmIsInstanceCatalogOfferingVersionPlanReferenceDeletedToMap(*instance.CatalogOffering.Plan.Deleted)
catalogMap["deleted"] = []map[string]interface{}{deletedMap}
}
}
catalogList = append(catalogList, catalogMap)
d.Set(isInstanceCatalogOffering, catalogList)
}
Expand Down
33 changes: 33 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
Computed: true,
Description: "Identifies a version of a catalog offering by a unique CRN property",
},
isInstanceTemplateCatalogOfferingPlanCrn: {
Type: schema.TypeString,
Computed: true,
Description: "The CRN for this catalog offering version's billing plan",
},
},
},
},
Expand Down Expand Up @@ -442,6 +447,11 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
},
},
},
"protocol_state_filtering_mode": {
Type: schema.TypeString,
Computed: true,
Description: "The protocol state filtering mode used for this virtual network interface.",
},
"resource_group": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -630,6 +640,11 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
},
},
},
"protocol_state_filtering_mode": {
Type: schema.TypeString,
Computed: true,
Description: "The protocol state filtering mode used for this virtual network interface.",
},
"resource_group": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -894,6 +909,12 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
version := insTempCatalogOffering.Version.(*vpcv1.CatalogOfferingVersionIdentity)
currentOffering[isInstanceTemplateCatalogOfferingVersionCrn] = *version.CRN
}
if insTempCatalogOffering.Plan != nil {
plan := insTempCatalogOffering.Plan.(*vpcv1.CatalogOfferingVersionPlanIdentity)
if plan.CRN != nil && *plan.CRN != "" {
currentOffering[isInstanceTemplateCatalogOfferingPlanCrn] = *plan.CRN
}
}
catOfferingList = append(catOfferingList, currentOffering)
d.Set(isInstanceTemplateCatalogOffering, catOfferingList)
}
Expand Down Expand Up @@ -1198,6 +1219,12 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso
version := insTempCatalogOffering.Version.(*vpcv1.CatalogOfferingVersionIdentity)
currentOffering[isInstanceTemplateCatalogOfferingVersionCrn] = *version.CRN
}
if insTempCatalogOffering.Plan != nil {
plan := insTempCatalogOffering.Plan.(*vpcv1.CatalogOfferingVersionPlanIdentity)
if plan.CRN != nil && *plan.CRN != "" {
currentOffering[isInstanceTemplateCatalogOfferingPlanCrn] = *plan.CRN
}
}
catOfferingList = append(catOfferingList, currentOffering)
d.Set(isInstanceTemplateCatalogOffering, catOfferingList)
}
Expand Down Expand Up @@ -1802,6 +1829,9 @@ func dataSourceIBMIsInstanceTemplateInstanceNetworkAttachmentPrototypeVirtualNet
}
modelMap["primary_ip"] = []map[string]interface{}{primaryIPMap}
}
if model.ProtocolStateFilteringMode != nil {
modelMap["protocol_state_filtering_mode"] = model.ProtocolStateFilteringMode
}
if model.ResourceGroup != nil {
resourceGroupMap, err := dataSourceIBMIsInstanceTemplateResourceGroupIdentityToMap(model.ResourceGroup)
if err != nil {
Expand Down Expand Up @@ -1873,6 +1903,9 @@ func dataSourceIBMIsInstanceTemplateInstanceNetworkAttachmentPrototypeVirtualNet
}
modelMap["primary_ip"] = []map[string]interface{}{primaryIPMap}
}
if model.ProtocolStateFilteringMode != nil {
modelMap["protocol_state_filtering_mode"] = model.ProtocolStateFilteringMode
}
if model.ResourceGroup != nil {
resourceGroupMap, err := dataSourceIBMIsInstanceTemplateResourceGroupIdentityToMap(model.ResourceGroup)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func TestAccIBMISInstanceTemplate_data_catalog(t *testing.T) {
"data.ibm_is_instance_template.instance_template_data", "catalog_offering.#"),
resource.TestCheckResourceAttrSet(
"data.ibm_is_instance_template.instance_template_data", "catalog_offering.0.version_crn"),
resource.TestCheckResourceAttrSet(
"data.ibm_is_instance_template.instance_template_data", "catalog_offering.0.plan_crn"),
resource.TestCheckNoResourceAttr(
"data.ibm_is_instance_template.instance_template_data", "image"),
),
Expand Down
21 changes: 21 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
Computed: true,
Description: "Identifies a version of a catalog offering by a unique CRN property",
},
isInstanceTemplateCatalogOfferingPlanCrn: {
Type: schema.TypeString,
Computed: true,
Description: "The CRN for this catalog offering version's billing plan",
},
},
},
},
Expand Down Expand Up @@ -395,6 +400,11 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
},
},
},
"protocol_state_filtering_mode": {
Type: schema.TypeString,
Computed: true,
Description: "The protocol state filtering mode used for this virtual network interface.",
},
"resource_group": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -583,6 +593,11 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
},
},
},
"protocol_state_filtering_mode": {
Type: schema.TypeString,
Computed: true,
Description: "The protocol state filtering mode used for this virtual network interface.",
},
"resource_group": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -899,6 +914,12 @@ func dataSourceIBMISInstanceTemplatesRead(d *schema.ResourceData, meta interface
version := insTempCatalogOffering.Version.(*vpcv1.CatalogOfferingVersionIdentity)
currentOffering[isInstanceTemplateCatalogOfferingVersionCrn] = *version.CRN
}
if insTempCatalogOffering.Plan != nil {
plan := insTempCatalogOffering.Plan.(*vpcv1.CatalogOfferingVersionPlanIdentity)
if plan.CRN != nil && *plan.CRN != "" {
currentOffering[isInstanceTemplateCatalogOfferingPlanCrn] = *plan.CRN
}
}
catOfferingList = append(catOfferingList, currentOffering)
template[isInstanceTemplateCatalogOffering] = catOfferingList
}
Expand Down
2 changes: 2 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func TestAccIBMISInstanceTemplates_dataCatalog(t *testing.T) {
"data.ibm_is_instance_templates.instance_templates_data", "templates.0.catalog_offering.#"),
resource.TestCheckResourceAttrSet(
"data.ibm_is_instance_templates.instance_templates_data", "templates.0.catalog_offering.0.version_crn"),
resource.TestCheckResourceAttrSet(
"data.ibm_is_instance_templates.instance_templates_data", "templates.0.catalog_offering.0.plan_crn"),
resource.TestCheckResourceAttr(
"data.ibm_is_instance_templates.instance_templates_data", "templates.0.image", ""),
),
Expand Down
131 changes: 113 additions & 18 deletions ibm/service/vpc/data_source_ibm_is_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,46 +50,101 @@ func TestAccIBMISInstanceDataSource_basic(t *testing.T) {
},
})
}
func TestAccIBMISInstanceDataSource_concom(t *testing.T) {

func TestAccIBMISInstanceDataSourceWithCatalogOffering(t *testing.T) {

vpcname := fmt.Sprintf("tfins-vpc-%d", acctest.RandIntRange(10, 100))
subnetname := fmt.Sprintf("tfins-subnet-%d", acctest.RandIntRange(10, 100))
sshname := fmt.Sprintf("tfins-ssh-%d", acctest.RandIntRange(10, 100))
instanceName := fmt.Sprintf("tfins-name-%d", acctest.RandIntRange(10, 100))
resName := "data.ibm_is_instance.ds_instance"
planCrn := "crn:v1:staging:public:globalcatalog-collection:global::1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc:plan:sw.1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.279a3cee-ba7d-42d5-ae88-6a0ebc56fa4a-global"
versionCrn := "crn:v1:staging:public:globalcatalog-collection:global::1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc:version:4f8466eb-2218-42e3-a755-bf352b559c69-global/6a73aa69-5dd9-4243-a908-3b62f467cbf8-global"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISInstanceDataSourceConfig(vpcname, subnetname, sshname, instanceName),
Config: testAccCheckIBMISInstanceDataSourceConfigWithCatalogOffering(vpcname, subnetname, sshname, instanceName, planCrn, versionCrn),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
resName, "name", instanceName),
resource.TestCheckResourceAttr(
resName, "tags.#", "1"),
resource.TestCheckResourceAttrSet(
resName, "primary_network_interface.0.port_speed"),
resName, "catalog_offering.#"),
resource.TestCheckResourceAttrSet(
resName, "availability_policy_host_failure"),
resName, "catalog_offering.0.plan_crn"),
resource.TestCheckResourceAttrSet(
resName, "lifecycle_state"),
resName, "catalog_offering.0.version_crn"),
),
},
},
})
}


Viewed
51 changes: 51 additions & 0 deletions 51
ibm/service/vpc/data_source_ibm_is_instances_test.go
Viewed
Original file line number Original file line Diff line number Diff line change
@@ -63,6 +63,57 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
},
},
})
})
}
}
func TestAccIBMISInstancesDataSource_concom(t *testing.T) {
var instance string
vpcname := fmt.Sprintf("tfins-vpc-%d", acctest.RandIntRange(10, 100))
subnetname := fmt.Sprintf("tfins-subnet-%d", acctest.RandIntRange(10, 100))
publicKey := strings.TrimSpace(`
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
`)
sshname := fmt.Sprintf("tfins-ssh-%d", acctest.RandIntRange(10, 100))
instanceName := fmt.Sprintf("tfins-name-%d", acctest.RandIntRange(10, 100))
resName := "data.ibm_is_instances.ds_instances"
userData := "a"
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISInstanceConfig(vpcname, subnetname, sshname, publicKey, instanceName, userData),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISInstanceExists("ibm_is_instance.testacc_instance", instance),
resource.TestCheckResourceAttr(
resName, "lifecycle_reasons.#", "0"),
resource.TestCheckResourceAttrSet(
resName, "vcpu.#"),
resource.TestCheckResourceAttrSet(
resName, "vcpu.0.manufacturer"),
resource.TestCheckResourceAttrSet(
resName, "confidential_compute_mode"),
resource.TestCheckResourceAttrSet(
resName, "enable_secure_boot"),
"ibm_is_instance.testacc_instance", "name", instanceName),
resource.TestCheckResourceAttr(
"ibm_is_instance.testacc_instance", "zone", acc.ISZoneName),
),
},
{
Config: testAccCheckIBMISInstancesDataSourceConfig(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resName, "instances.0.name"),
resource.TestCheckResourceAttrSet(resName, "instances.0.memory"),
resource.TestCheckResourceAttrSet(resName, "instances.0.status"),
resource.TestCheckResourceAttrSet(resName, "instances.0.resource_group"),
resource.TestCheckResourceAttrSet(resName, "instances.0.vpc"),
resource.TestCheckResourceAttrSet(resName, "instances.0.boot_volume.#"),
resource.TestCheckResourceAttrSet(resName, "instances.0.volume_attachments.#"),
resource.TestCheckResourceAttrSet(resName, "instances.0.primary_network_interface.#"),
resource.TestCheckResourceAttrSet(resName, "instances.0.network_interfaces.#"),
resource.TestCheckResourceAttrSet(resName, "instances.0.profile"),
resource.TestCheckResourceAttrSet(resName, "instances.0.vcpu.#"),
resource.TestCheckResourceAttrSet(resName, "instances.0.zone"),
resource.TestCheckResourceAttrSet(resName, "instances.0.availability_policy_host_failure"),
resource.TestCheckResourceAttrSet(resName, "instances.0.lifecycle_state"),
resource.TestCheckResourceAttr(resName, "instances.0.lifecycle_reasons.#", "0"),
resource.TestCheckResourceAttrSet(resName, "instances.0.vcpu.0.manufacturer"),
resource.TestCheckResourceAttrSet(resName, "instances.0.confidential_compute_mode"),
resource.TestCheckResourceAttrSet(resName, "instances.0.enable_secure_boot"),
),
},
},
})
}

func TestAccIBMISInstanceDataSource_vni(t *testing.T) {

vpcname := fmt.Sprintf("tfins-vpc-%d", acctest.RandIntRange(10, 100))
Expand Down Expand Up @@ -250,6 +305,46 @@ data "ibm_is_instance" "ds_instance" {
passphrase = ""
}`, vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, sshname, instanceName, acc.IsWinImage, acc.InstanceProfileName, acc.ISZoneName)
}

func testAccCheckIBMISInstanceDataSourceConfigWithCatalogOffering(vpcname, subnetname, sshname, instanceName, planCrn, versionCrn string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc" {
name = "%s"
}
resource "ibm_is_subnet" "testacc_subnet" {
name = "%s"
vpc = ibm_is_vpc.testacc_vpc.id
zone = "%s"
total_ipv4_address_count = 16
}
resource "ibm_is_ssh_key" "testacc_sshkey" {
name = "%s"
public_key = file("./test-fixtures/.ssh/id_rsa.pub")
}
resource "ibm_is_instance" "testacc_instance" {
name = "%s"
profile = "%s"
primary_network_interface {
subnet = ibm_is_subnet.testacc_subnet.id
}
vpc = ibm_is_vpc.testacc_vpc.id
zone = "%s"
keys = [ibm_is_ssh_key.testacc_sshkey.id]
boot_volume {
auto_delete_volume = false
}
catalog_offering {
version_crn = "%s"
plan_crn = "%s"
}
}
data "ibm_is_instance" "ds_instance" {
name = ibm_is_instance.testacc_instance.name
}`, vpcname, subnetname, acc.ISZoneName, sshname, instanceName, acc.InstanceProfileName, acc.ISZoneName, versionCrn, planCrn)
}
func testAccCheckIBMISInstanceVniDataSourceConfig(vpcname, subnetname, sshname, vniname, instanceName string) string {
return fmt.Sprintf(`
resource "ibm_is_vpc" "testacc_vpc" {
Expand Down
Loading

0 comments on commit 993bbf3

Please sign in to comment.