Address review comments

This commit is contained in:
Harvey Lowndes 2021-03-29 11:04:48 +01:00
parent cb359e8064
commit b9b1cdf75f
3 changed files with 26 additions and 10 deletions

View File

@ -283,6 +283,18 @@ func (c *Config) Prepare(raws ...interface{}) error {
errs, errors.New("'shape' must be specified"))
}
if strings.HasSuffix(c.Shape, "Flex") {
if c.ShapeConfig.Ocpus == nil {
errs = packersdk.MultiErrorAppend(
errs, errors.New("'Ocpus' must be specified when using flexible shapes"))
}
}
if c.ShapeConfig.MemoryInGBs != nil && c.ShapeConfig.Ocpus == nil {
errs = packersdk.MultiErrorAppend(
errs, errors.New("'Ocpus' must be specified if memory_in_gbs is specified"))
}
if (c.SubnetID == "") && (c.CreateVnicDetails.SubnetId == nil) {
errs = packersdk.MultiErrorAppend(
errs, errors.New("'subnet_ocid' must be specified"))

View File

@ -95,11 +95,6 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
FreeformTags: d.cfg.CreateVnicDetails.FreeformTags,
}
LaunchInstanceShapeConfigDetails := core.LaunchInstanceShapeConfigDetails{
Ocpus: d.cfg.ShapeConfig.Ocpus,
MemoryInGBs: d.cfg.ShapeConfig.MemoryInGBs,
}
// Determine base image ID
var imageId *string
if d.cfg.BaseImageID != "" {
@ -159,11 +154,18 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
DisplayName: d.cfg.InstanceName,
FreeformTags: d.cfg.InstanceTags,
Shape: &d.cfg.Shape,
ShapeConfig: &LaunchInstanceShapeConfigDetails,
SourceDetails: InstanceSourceDetails,
Metadata: metadata,
}
if d.cfg.ShapeConfig.Ocpus != nil {
LaunchInstanceShapeConfigDetails := core.LaunchInstanceShapeConfigDetails{
Ocpus: d.cfg.ShapeConfig.Ocpus,
MemoryInGBs: d.cfg.ShapeConfig.MemoryInGBs,
}
instanceDetails.ShapeConfig = &LaunchInstanceShapeConfigDetails
}
instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{
LaunchInstanceDetails: instanceDetails,
RequestMetadata: requestMetadata,

View File

@ -100,10 +100,7 @@ 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.
When using flexible shapes, ocpus must be set.
- `subnet_ocid` (string) - The name of the subnet within which a new instance
is launched and provisioned.
@ -192,6 +189,11 @@ can also be supplied to override the typical auto-generated key:
- `use_private_ip` (boolean) - Use private ip addresses to connect to the
instance via ssh.
- `shape_config` (object) - The shape configuration for an instance. The shape configuration determines the resources
allocated to an instance. Options:
- `ocpus` (required when using flexible shapes or memory_in_gbs is set) (float32) - The total number of OCPUs available to the instance.
- `memory_in_gbs` (optional) (float32) - The total amount of memory, in gigabytes, available to the instance.
<!-- markdown-link-check-disable -->
- `metadata` (map of strings) - Metadata optionally contains custom metadata
key/value pairs provided in the configuration. While this can be used to