Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image option insecure source uri #510

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 41 additions & 32 deletions client/v3/v3_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ type ImageVersionResources struct {
ProductVersion *string `json:"product_version" mapstructure:"product_version"`
}

// SourceOptions Options while accessing image source.
type SourceOptions struct {
// Option to ignore the server certificate verification while accessing source_uri (image location).
AllowInsecureConnection *bool `json:"allow_insecure_connection,omitempty" mapstructure:"allow_insecure_connection,omitempty"`
}

// ImageResources describes the image spec resources object.
type ImageResources struct {

Expand All @@ -888,9 +894,12 @@ type ImageResources struct {
// The type of image.
ImageType *string `json:"image_type,omitempty" mapstructure:"image_type,omitempty"`

// The source URI points at the location of a the source image which is used to create/update image.
// The source URI points at the location of a source image which is used to create/update image.
SourceURI *string `json:"source_uri,omitempty" mapstructure:"source_uri,omitempty"`

// SourceOptions Options while accessing image source.
SourceOptions *SourceOptions `json:"source_options,omitempty" mapstructure:"source_options,omitempty"`

// The image version
Version *ImageVersionResources `json:"version,omitempty" mapstructure:"version,omitempty"`

Expand All @@ -901,7 +910,7 @@ type ImageResources struct {
DataSourceReference *Reference `json:"data_source_reference,omitempty" mapstructure:"data_source_reference,omitempty"`
}

// Image An intentful representation of a image spec
// Image An intentful representation of an image spec
type Image struct {

// A description for image.
Expand Down Expand Up @@ -999,7 +1008,7 @@ type ImageResourcesDefStatus struct {
// The size of the image in bytes.
SizeBytes *int64 `json:"size_bytes,omitempty" mapstructure:"size_bytes,omitempty"`

// The source URI points at the location of a the source image which is used to create/update image.
// The source URI points at the location of a source image which is used to create/update image.
SourceURI *string `json:"source_uri,omitempty" mapstructure:"source_uri,omitempty"`

// Cluster reference lists
Expand Down Expand Up @@ -2339,22 +2348,22 @@ type PermissionListResponse struct {
Metadata *ListMetadataOutput `json:"metadata,omitempty"` // All api calls that return a list will have this metadata block
}

//ProtectionRuleResources represents the resources of protection rules
// ProtectionRuleResources represents the resources of protection rules
type ProtectionRuleResources struct {
StartTime string `json:"start_time,omitempty"`
AvailabilityZoneConnectivityList []*AvailabilityZoneConnectivityList `json:"availability_zone_connectivity_list,omitempty"`
OrderedAvailabilityZoneList []*OrderedAvailabilityZoneList `json:"ordered_availability_zone_list,omitempty"`
CategoryFilter *CategoryFilter `json:"category_filter,omitempty"`
}

//AvailabilityZoneConnectivityList represents a object for resource of protection rule
// AvailabilityZoneConnectivityList represents a object for resource of protection rule
type AvailabilityZoneConnectivityList struct {
DestinationAvailabilityZoneIndex *int64 `json:"destination_availability_zone_index,omitempty"`
SourceAvailabilityZoneIndex *int64 `json:"source_availability_zone_index,omitempty"`
SnapshotScheduleList []*SnapshotScheduleList `json:"snapshot_schedule_list,omitempty"`
}

//SnapshotScheduleList represents a object for resource of protection rule
// SnapshotScheduleList represents a object for resource of protection rule
type SnapshotScheduleList struct {
RecoveryPointObjectiveSecs *int64 `json:"recovery_point_objective_secs,omitempty"`
LocalSnapshotRetentionPolicy *SnapshotRetentionPolicy `json:"local_snapshot_retention_policy,omitempty"`
Expand All @@ -2363,25 +2372,25 @@ type SnapshotScheduleList struct {
RemoteSnapshotRetentionPolicy *SnapshotRetentionPolicy `json:"remote_snapshot_retention_policy,omitempty"`
}

//SnapshotRetentionPolicy represents a object for resource of protection rule
// SnapshotRetentionPolicy represents a object for resource of protection rule
type SnapshotRetentionPolicy struct {
NumSnapshots *int64 `json:"num_snapshots,omitempty"`
RollupRetentionPolicy *RollupRetentionPolicy `json:"rollup_retention_policy,omitempty"`
}

//RollupRetentionPolicy represents a object for resource of protection rule
// RollupRetentionPolicy represents a object for resource of protection rule
type RollupRetentionPolicy struct {
Multiple *int64 `json:"multiple,omitempty"`
SnapshotIntervalType string `json:"snapshot_interval_type,omitempty"`
}

//OrderedAvailabilityZoneList represents a object for resource of protection rule
// OrderedAvailabilityZoneList represents a object for resource of protection rule
type OrderedAvailabilityZoneList struct {
ClusterUUID string `json:"cluster_uuid,omitempty"`
AvailabilityZoneURL string `json:"availability_zone_url,omitempty"`
}

//ProtectionRuleStatus represents a status of a protection rule
// ProtectionRuleStatus represents a status of a protection rule
type ProtectionRuleStatus struct {
State string `json:"state,omitempty"`
MessageList []*MessageResource `json:"message_list,omitempty"`
Expand All @@ -2390,68 +2399,68 @@ type ProtectionRuleStatus struct {
ExecutionContext *ExecutionContext `json:"execution_context,omitempty"`
}

//ProtectionRuleSpec represents a spec of protection rules
// ProtectionRuleSpec represents a spec of protection rules
type ProtectionRuleSpec struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Resources *ProtectionRuleResources `json:"resources,omitempty"`
}

//ProtectionRuleResponse represents a response object of a protection rule
// ProtectionRuleResponse represents a response object of a protection rule
type ProtectionRuleResponse struct {
APIVersion string `json:"api_version,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Spec *ProtectionRuleSpec `json:"spec,omitempty"`
Status *ProtectionRuleStatus `json:"status,omitempty"`
}

//ProtectionRulesListResponse represents the response of a list of protection rules
// ProtectionRulesListResponse represents the response of a list of protection rules
type ProtectionRulesListResponse struct {
APIVersion string `json:"api_version,omitempty"`
Entities []*ProtectionRuleResponse `json:"entities,omitempty"`
Metadata *ListMetadataOutput `json:"metadata,omitempty"`
}

//ProtectionRuleInput Represents the request of create protection rule
// ProtectionRuleInput Represents the request of create protection rule
type ProtectionRuleInput struct {
APIVersion string `json:"api_version,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Spec *ProtectionRuleSpec `json:"spec,omitempty"`
}

//RecoveryPlanResources represents the resources of recovery plan
// RecoveryPlanResources represents the resources of recovery plan
type RecoveryPlanResources struct {
StageList []*StageList `json:"stage_list,omitempty"`
Parameters *Parameters `json:"parameters,omitempty"`
}

//Parameters represents a object for resource of recovery plan
// Parameters represents a object for resource of recovery plan
type Parameters struct {
FloatingIPAssignmentList []*FloatingIPAssignmentList `json:"floating_ip_assignment_list,omitempty"`
NetworkMappingList []*NetworkMappingList `json:"network_mapping_list,omitempty"`
}

//FloatingIPAssignmentList represents a object for resource of recovery plan
// FloatingIPAssignmentList represents a object for resource of recovery plan
type FloatingIPAssignmentList struct {
AvailabilityZoneURL string `json:"availability_zone_url,omitempty"`
VMIPAssignmentList []*VMIPAssignmentList `json:"vm_ip_assignment_list,omitempty"`
}

//VMIPAssignmentList represents a object for resource of recovery plan
// VMIPAssignmentList represents a object for resource of recovery plan
type VMIPAssignmentList struct {
TestFloatingIPConfig *FloatingIPConfig `json:"test_floating_ip_config,omitempty"`
RecoveryFloatingIPConfig *FloatingIPConfig `json:"recovery_floating_ip_config,omitempty"`
VMReference *Reference `json:"vm_reference,omitempty"`
VMNICInformation *VMNICInformation `json:"vm_nic_information,omitempty"`
}

//FloatingIPConfig represents a object for resource of recovery plan
// FloatingIPConfig represents a object for resource of recovery plan
type FloatingIPConfig struct {
IP string `json:"ip,omitempty"`
ShouldAllocateDynamically *bool `json:"should_allocate_dynamically,omitempty"`
}

//VMNICInformation represents a object for resource of recovery plan
// VMNICInformation represents a object for resource of recovery plan
type VMNICInformation struct {
IP string `json:"ip,omitempty"`
UUID string `json:"uuid,omitempty"`
Expand All @@ -2463,7 +2472,7 @@ type NetworkMappingList struct {
AreNetworksStretched *bool `json:"are_networks_stretched,omitempty"`
}

//AvailabilityZoneNetworkMappingList represents a object for resource of recovery plan
// AvailabilityZoneNetworkMappingList represents a object for resource of recovery plan
type AvailabilityZoneNetworkMappingList struct {
RecoveryNetwork *Network `json:"recovery_network,omitempty"`
AvailabilityZoneURL string `json:"availability_zone_url,omitempty"`
Expand All @@ -2482,7 +2491,7 @@ type IPConfigList struct {
IPAddress string `json:"ip_address,omitempty"`
}

//Network represents a object for resource of recovery plan
// Network represents a object for resource of recovery plan
type Network struct {
VirtualNetworkReference *Reference `json:"virtual_network_reference,omitempty"`
SubnetList []*SubnetList `json:"subnet_list,omitempty"`
Expand All @@ -2491,31 +2500,31 @@ type Network struct {
UseVPCReference *bool `json:"use_vpc_reference,omitempty"`
}

//SubnetList represents a object for resource of recovery plan
// SubnetList represents a object for resource of recovery plan
type SubnetList struct {
GatewayIP string `json:"gateway_ip,omitempty"`
ExternalConnectivityState string `json:"external_connectivity_state,omitempty"`
PrefixLength *int64 `json:"prefix_length,omitempty"`
}

//StageList represents a object for resource of recovery plan
// StageList represents a object for resource of recovery plan
type StageList struct {
StageWork *StageWork `json:"stage_work,omitempty"`
StageUUID string `json:"stage_uuid,omitempty"`
DelayTimeSecs *int64 `json:"delay_time_secs,omitempty"`
}

//StageWork represents a object for resource of recovery plan
// StageWork represents a object for resource of recovery plan
type StageWork struct {
RecoverEntities *RecoverEntities `json:"recover_entities,omitempty"`
}

//RecoverEntities represents a object for resource of recovery plan
// RecoverEntities represents a object for resource of recovery plan
type RecoverEntities struct {
EntityInfoList []*EntityInfoList `json:"entity_info_list,omitempty"`
}

//EntityInfoList represents a object for resource of recovery plan
// EntityInfoList represents a object for resource of recovery plan
type EntityInfoList struct {
AnyEntityReference *Reference `json:"any_entity_reference,omitempty"`
Categories map[string]string `json:"categories,omitempty"`
Expand All @@ -2527,7 +2536,7 @@ type ScriptList struct {
Timeout *int64 `json:"timeout,omitempty"`
}

//RecoveryPlanStatus represents a status of a recovery plan
// RecoveryPlanStatus represents a status of a recovery plan
type RecoveryPlanStatus struct {
State string `json:"state,omitempty"`
MessageList []*MessageResource `json:"message_list,omitempty"`
Expand All @@ -2536,29 +2545,29 @@ type RecoveryPlanStatus struct {
ExecutionContext *ExecutionContext `json:"execution_context,omitempty"`
}

//RecoveryPlanSpec represents a spec of recovery plans
// RecoveryPlanSpec represents a spec of recovery plans
type RecoveryPlanSpec struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Resources *RecoveryPlanResources `json:"resources,omitempty"`
}

//RecoveryPlanResponse represents a response object of a recovery plan
// RecoveryPlanResponse represents a response object of a recovery plan
type RecoveryPlanResponse struct {
APIVersion string `json:"api_version,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Spec *RecoveryPlanSpec `json:"spec,omitempty"`
Status *RecoveryPlanStatus `json:"status,omitempty"`
}

//RecoveryPlanListResponse represents the response of a list of recovery plans
// RecoveryPlanListResponse represents the response of a list of recovery plans
type RecoveryPlanListResponse struct {
APIVersion string `json:"api_version,omitempty"`
Entities []*RecoveryPlanResponse `json:"entities,omitempty"`
Metadata *ListMetadataOutput `json:"metadata,omitempty"`
}

//RecoveryPlanInput Represents the request of create recovery plan
// RecoveryPlanInput Represents the request of create recovery plan
type RecoveryPlanInput struct {
APIVersion string `json:"api_version,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Expand Down
11 changes: 11 additions & 0 deletions nutanix/resource_nutanix_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ func resourceNutanixImage() *schema.Resource {
Type: schema.TypeString,
},
},
"allow_insecure_source_uri": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"source_uri": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -547,10 +552,16 @@ func getImageResource(d *schema.ResourceData, image *v3.ImageResources) error {
checks := &v3.Checksum{}
su, suok := d.GetOk("source_uri")
sp, spok := d.GetOk("source_path")
ai, aiok := d.GetOk("allow_insecure_source_uri")
var furi string
if suok {
image.SourceURI = utils.StringPtr(su.(string))
furi = su.(string)

if aiok {
sourceOptions := &v3.SourceOptions{AllowInsecureConnection: utils.BoolPtr(ai.(bool))}
image.SourceOptions = sourceOptions
}
}
if spok {
furi = sp.(string)
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/image.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following arguments are supported:
* `source_path`: - (Optional) A local path to upload an image.
* `version`: - (Optional) The image version.
* `data_source_reference` - (Optional) Reference to a data source.
* `allow_insecure_source_uri` - (Optional) Option to ignore the server certificate verification while accessing source_uri.

### Version

Expand Down