From a69e2ac78e5efb5aab6a7d27ee072d2597cc7408 Mon Sep 17 00:00:00 2001 From: Harvey Lowndes Date: Fri, 22 Jun 2018 12:38:25 +0100 Subject: [PATCH] Support instance display name configuration --- builder/oracle/oci/config.go | 4 ++++ builder/oracle/oci/driver_oci.go | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 75fea183b..c82246762 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -44,6 +44,10 @@ type Config struct { BaseImageID string `mapstructure:"base_image_ocid"` Shape string `mapstructure:"shape"` ImageName string `mapstructure:"image_name"` + + // Instance + InstanceName string `mapstructure:"instance_name"` + // UserData and UserDataFile file are both optional and mutually exclusive. UserData string `mapstructure:"user_data"` UserDataFile string `mapstructure:"user_data_file"` diff --git a/builder/oracle/oci/driver_oci.go b/builder/oracle/oci/driver_oci.go index ffb3732c1..43b2d5c88 100644 --- a/builder/oracle/oci/driver_oci.go +++ b/builder/oracle/oci/driver_oci.go @@ -45,14 +45,21 @@ func (d *driverOCI) CreateInstance(publicKey string) (string, error) { metadata["user_data"] = d.cfg.UserData } - instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{LaunchInstanceDetails: core.LaunchInstanceDetails{ + instanceDetails := core.LaunchInstanceDetails{ AvailabilityDomain: &d.cfg.AvailabilityDomain, CompartmentId: &d.cfg.CompartmentID, ImageId: &d.cfg.BaseImageID, Shape: &d.cfg.Shape, SubnetId: &d.cfg.SubnetID, Metadata: metadata, - }}) + } + + // When empty, the default display name is used. + if d.cfg.InstanceName != "" { + instanceDetails.DisplayName = &d.cfg.InstanceName + } + + instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{LaunchInstanceDetails: instanceDetails}) if err != nil { return "", err