From cb359e80643897f62de8324ea962f43a4e1b9a6f Mon Sep 17 00:00:00 2001 From: Harvey Lowndes Date: Fri, 26 Mar 2021 11:46:15 +0000 Subject: [PATCH] Update OCI docs for flex shapes Update the docs to reflect flex shape additions. Also makes a fix to the mapstructure. --- builder/oracle/oci/config.go | 4 +-- builder/oracle/oci/config.hcl2spec.go | 29 +++++++++++++++++++- website/content/docs/builders/oracle/oci.mdx | 5 ++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 6e369dc97..943bd32fa 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest +//go:generate mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest,FlexShapeConfig package oci @@ -48,7 +48,7 @@ type ListImagesRequest struct { type FlexShapeConfig struct { Ocpus *float32 `mapstructure:"ocpus" required:"false"` - MemoryInGBs *float32 `mapstructure:"ocpus" required:"false"` + MemoryInGBs *float32 `mapstructure:"memory_in_gbs" required:"false"` } type Config struct { diff --git a/builder/oracle/oci/config.hcl2spec.go b/builder/oracle/oci/config.hcl2spec.go index f80dd58fe..c564f1a5a 100644 --- a/builder/oracle/oci/config.hcl2spec.go +++ b/builder/oracle/oci/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest"; DO NOT EDIT. +// Code generated by "mapstructure-to-hcl2 -type Config,CreateVNICDetails,ListImagesRequest,FlexShapeConfig"; DO NOT EDIT. package oci @@ -88,6 +88,7 @@ type FlatConfig struct { InstanceTags map[string]string `mapstructure:"instance_tags" cty:"instance_tags" hcl:"instance_tags"` InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags" cty:"instance_defined_tags" hcl:"instance_defined_tags"` Shape *string `mapstructure:"shape" cty:"shape" hcl:"shape"` + ShapeConfig *FlatFlexShapeConfig `mapstructure:"shape_config" cty:"shape_config" hcl:"shape_config"` BootVolumeSizeInGBs *int64 `mapstructure:"disk_size" cty:"disk_size" hcl:"disk_size"` Metadata map[string]string `mapstructure:"metadata" cty:"metadata" hcl:"metadata"` UserData *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"` @@ -188,6 +189,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "instance_tags": &hcldec.AttrSpec{Name: "instance_tags", Type: cty.Map(cty.String), Required: false}, "instance_defined_tags": &hcldec.AttrSpec{Name: "instance_defined_tags", Type: cty.Map(cty.String), Required: false}, "shape": &hcldec.AttrSpec{Name: "shape", Type: cty.String, Required: false}, + "shape_config": &hcldec.BlockSpec{TypeName: "shape_config", Nested: hcldec.ObjectSpec((*FlatFlexShapeConfig)(nil).HCL2Spec())}, "disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false}, "metadata": &hcldec.AttrSpec{Name: "metadata", Type: cty.Map(cty.String), Required: false}, "user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false}, @@ -239,6 +241,31 @@ func (*FlatCreateVNICDetails) HCL2Spec() map[string]hcldec.Spec { return s } +// FlatFlexShapeConfig is an auto-generated flat version of FlexShapeConfig. +// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. +type FlatFlexShapeConfig struct { + Ocpus *float32 `mapstructure:"ocpus" required:"false" cty:"ocpus" hcl:"ocpus"` + MemoryInGBs *float32 `mapstructure:"memory_in_gbs" required:"false" cty:"memory_in_gbs" hcl:"memory_in_gbs"` +} + +// FlatMapstructure returns a new FlatFlexShapeConfig. +// FlatFlexShapeConfig is an auto-generated flat version of FlexShapeConfig. +// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. +func (*FlexShapeConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { + return new(FlatFlexShapeConfig) +} + +// HCL2Spec returns the hcl spec of a FlexShapeConfig. +// This spec is used by HCL to read the fields of FlexShapeConfig. +// The decoded values from this spec will then be applied to a FlatFlexShapeConfig. +func (*FlatFlexShapeConfig) HCL2Spec() map[string]hcldec.Spec { + s := map[string]hcldec.Spec{ + "ocpus": &hcldec.AttrSpec{Name: "ocpus", Type: cty.Number, Required: false}, + "memory_in_gbs": &hcldec.AttrSpec{Name: "memory_in_gbs", Type: cty.Number, Required: false}, + } + return s +} + // FlatListImagesRequest is an auto-generated flat version of ListImagesRequest. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatListImagesRequest struct { diff --git a/website/content/docs/builders/oracle/oci.mdx b/website/content/docs/builders/oracle/oci.mdx index 167d62737..d9d19f17c 100644 --- a/website/content/docs/builders/oracle/oci.mdx +++ b/website/content/docs/builders/oracle/oci.mdx @@ -100,6 +100,11 @@ can also be supplied to override the typical auto-generated key: [ListShapes](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/iaas/20160918/Shape/ListShapes) operation available in the Core Services API. +- `shape_config` (map of strings) - The shape configuration for an instance. The shape configuration determines the resources + allocated to an instance. Options: + - `ocpus` - The total number of OCPUs available to the instance. + - `memory_in_gbs` - The total amount of memory, in gigabytes, available to the instance. + - `subnet_ocid` (string) - The name of the subnet within which a new instance is launched and provisioned.