Skip to content

Commit c9b9d7b

Browse files
rcohenmaalexng-canuck
authored andcommitted
making volume group and Identity_provider conform to polymorphic template
1 parent 56bd760 commit c9b9d7b

13 files changed

+321
-250
lines changed

docs/core/volume_attachments.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ The following attributes are exported:
88

99
* `attachment_type` - The type of volume attachment.
1010
* `availability_domain` - The Availability Domain of an instance. Example: `Uocm:PHX-AD-1`
11+
* `chap_secret` - The Challenge-Handshake-Authentication-Protocol (CHAP) secret valid for the associated CHAP user name. (Also called the "CHAP password".) Example: `d6866c0d-298b-48ba-95af-309b4faux45e`
12+
* `chap_username` - The volume's system-generated Challenge-Handshake-Authentication-Protocol (CHAP) user name. Example: `ocid1.volume.oc1.phx.abyhqljrgvttnlx73nmrwfaux7kcvzfs3s66izvxf2h4lgvyndsdsnoiwr5q`
1113
* `compartment_id` - The OCID of the compartment.
1214
* `display_name` - A user-friendly name. Does not have to be unique, and it cannot be changed. Avoid entering confidential information. Example: `My volume attachment`
1315
* `id` - The OCID of the volume attachment.
1416
* `instance_id` - The OCID of the instance the volume is attached to.
17+
* `ipv4` - The volume's iSCSI IP address. Example: `169.254.0.2`
18+
* `iqn` - The target volume's iSCSI Qualified Name in the format defined by RFC 3720. Example: `iqn.2015-12.us.oracle.com:456b0391-17b8-4122-bbf1-f85fc0bb97d9`
1519
* `is_read_only` - Whether the attachment was created in read-only mode.
20+
* `port` - The volume's iSCSI port. Example: `3260`
1621
* `state` - The current state of the volume attachment.
1722
* `time_created` - The date and time the volume was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
1823
* `volume_id` - The OCID of the volume.
1924

20-
The following additional attributes are exported for the iSCSI volume attachment type:
21-
* `use_chap` - Whether to use CHAP authentication for the volume attachment.
22-
* `chap_username` - The volume's system-generated Challenge-Handshake-Authentication-Protocol (CHAP) user name.
23-
* `chap_secret` - The Challenge-Handshake-Authentication-Protocol (CHAP) secret valid for the associated CHAP user name. (Also called the "CHAP password".)
24-
* `ipv4` - The volume's iSCSI IP address.
25-
* `port` - The volume's iSCSI port.
26-
* `iqn` - The target volume's iSCSI Qualified Name in the format defined by RFC 3720.
25+
2726

2827
### Create Operation
2928
Attaches the specified storage volume to the specified instance.

docs/identity/identity_providers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The following attributes are exported:
1212
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
1313
* `id` - The OCID of the `IdentityProvider`.
1414
* `inactive_state` - The detailed status of INACTIVE lifecycleState.
15+
* `metadata_url` - The URL for retrieving the identity provider's metadata, which contains information required for federating.
1516
* `name` - The name you assign to the `IdentityProvider` during creation. The name must be unique across all `IdentityProvider` objects in the tenancy and cannot be changed. This is the name federated users see when choosing which identity provider to use when signing in to the Oracle Cloud Infrastructure Console.
1617
* `product_type` - The identity provider service or product. Supported identity providers are Oracle Identity Cloud Service (IDCS) and Microsoft Active Directory Federation Services (ADFS).
1718

@@ -21,6 +22,8 @@ The following attributes are exported:
2122

2223
Example: `IDCS`
2324
* `protocol` - The protocol used for federation. Allowed value: `SAML2`. Example: `SAML2`
25+
* `redirect_url` - The URL to redirect federated users to for authentication with the identity provider.
26+
* `signing_certificate` - The identity provider's signing certificate used by the IAM Service to validate the SAML2 token.
2427
* `state` - The current state.
2528
* `time_created` - Date and time the `IdentityProvider` was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
2629

oci/core_volume_attachment_resource.go

Lines changed: 86 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ import (
1414
oci_core "github.com/oracle/oci-go-sdk/core"
1515
)
1616

17-
const (
18-
IScsiVolumeAttachmentDiscriminator = "iscsi"
19-
ParavirtualizedVolumeAttachmentDiscriminator = "paravirtualized"
20-
)
21-
2217
func VolumeAttachmentResource() *schema.Resource {
2318
return &schema.Resource{
2419
Importer: &schema.ResourceImporter{
@@ -76,41 +71,39 @@ func VolumeAttachmentResource() *schema.Resource {
7671
Type: schema.TypeString,
7772
Computed: true,
7873
},
79-
"compartment_id": {
74+
"chap_secret": {
8075
Type: schema.TypeString,
8176
Computed: true,
82-
// The legacy provider required this, but the API no longer accepts it. Keep as optional
83-
// to avoid a breaking change. The value will be ignored if defined in the config.
84-
Optional: true,
8577
},
86-
"state": {
78+
"chap_username": {
8779
Type: schema.TypeString,
8880
Computed: true,
8981
},
90-
"time_created": {
82+
"compartment_id": {
9183
Type: schema.TypeString,
9284
Computed: true,
85+
// The legacy provider required this, but the API no longer accepts it. Keep as optional
86+
// to avoid a breaking change. The value will be ignored if defined in the config.
87+
Optional: true,
9388
},
94-
95-
// VolumeAttachment is a polymorphic type itself. The following are only computed if attachment_type == "iscsi".
96-
"chap_secret": {
89+
"ipv4": {
9790
Type: schema.TypeString,
9891
Computed: true,
9992
},
100-
"chap_username": {
93+
"iqn": { // iSCSI Qualified Name per RFC 3720
10194
Type: schema.TypeString,
10295
Computed: true,
10396
},
104-
"ipv4": {
105-
Type: schema.TypeString,
97+
"port": {
98+
Type: schema.TypeInt,
10699
Computed: true,
107100
},
108-
"iqn": { // iSCSI Qualified Name per RFC 3720
101+
"state": {
109102
Type: schema.TypeString,
110103
Computed: true,
111104
},
112-
"port": {
113-
Type: schema.TypeInt,
105+
"time_created": {
106+
Type: schema.TypeString,
114107
Computed: true,
115108
},
116109
},
@@ -226,43 +219,10 @@ func (s *VolumeAttachmentResourceCrud) Delete() error {
226219
}
227220

228221
func (s *VolumeAttachmentResourceCrud) SetData() error {
229-
volumeAttachment := *s.Res
230-
231-
if availabilityDomain := volumeAttachment.GetAvailabilityDomain(); availabilityDomain != nil {
232-
s.D.Set("availability_domain", *availabilityDomain)
233-
}
234-
235-
if compartmentId := volumeAttachment.GetCompartmentId(); compartmentId != nil {
236-
s.D.Set("compartment_id", *compartmentId)
237-
}
238-
239-
if displayName := volumeAttachment.GetDisplayName(); displayName != nil {
240-
s.D.Set("display_name", *displayName)
241-
}
242-
243-
if instanceId := volumeAttachment.GetInstanceId(); instanceId != nil {
244-
s.D.Set("instance_id", *instanceId)
245-
}
246-
247-
if isReadOnly := volumeAttachment.GetIsReadOnly(); isReadOnly != nil {
248-
s.D.Set("is_read_only", *isReadOnly)
249-
}
250-
251-
s.D.Set("state", volumeAttachment.GetLifecycleState())
252-
253-
if timeCreated := volumeAttachment.GetTimeCreated(); timeCreated != nil {
254-
s.D.Set("time_created", timeCreated.String())
255-
}
256-
257-
if volumeId := volumeAttachment.GetVolumeId(); volumeId != nil {
258-
s.D.Set("volume_id", *volumeId)
259-
}
260-
261-
switch v := volumeAttachment.(type) {
222+
switch v := (*s.Res).(type) {
262223
case oci_core.IScsiVolumeAttachment:
263-
s.D.Set("attachment_type", IScsiVolumeAttachmentDiscriminator)
224+
s.D.Set("attachment_type", "iscsi")
264225

265-
// IScsiVolumeAttachment-specific fields:
266226
if v.ChapSecret != nil {
267227
s.D.Set("chap_secret", *v.ChapSecret)
268228
}
@@ -282,12 +242,80 @@ func (s *VolumeAttachmentResourceCrud) SetData() error {
282242
if v.Port != nil {
283243
s.D.Set("port", *v.Port)
284244
}
245+
246+
if v.AvailabilityDomain != nil {
247+
s.D.Set("availability_domain", *v.AvailabilityDomain)
248+
}
249+
250+
if v.CompartmentId != nil {
251+
s.D.Set("compartment_id", *v.CompartmentId)
252+
}
253+
254+
if v.DisplayName != nil {
255+
s.D.Set("display_name", *v.DisplayName)
256+
}
257+
258+
if v.Id != nil {
259+
s.D.Set("id", *v.Id)
260+
}
261+
262+
if v.InstanceId != nil {
263+
s.D.Set("instance_id", *v.InstanceId)
264+
}
265+
266+
if v.IsReadOnly != nil {
267+
s.D.Set("is_read_only", *v.IsReadOnly)
268+
}
269+
270+
s.D.Set("state", v.LifecycleState)
271+
272+
if v.TimeCreated != nil {
273+
s.D.Set("time_created", v.TimeCreated.String())
274+
}
275+
276+
if v.VolumeId != nil {
277+
s.D.Set("volume_id", *v.VolumeId)
278+
}
285279
case oci_core.ParavirtualizedVolumeAttachment:
286-
s.D.Set("attachment_type", ParavirtualizedVolumeAttachmentDiscriminator)
280+
s.D.Set("attachment_type", "paravirtualized")
281+
282+
if v.AvailabilityDomain != nil {
283+
s.D.Set("availability_domain", *v.AvailabilityDomain)
284+
}
285+
286+
if v.CompartmentId != nil {
287+
s.D.Set("compartment_id", *v.CompartmentId)
288+
}
289+
290+
if v.DisplayName != nil {
291+
s.D.Set("display_name", *v.DisplayName)
292+
}
293+
294+
if v.Id != nil {
295+
s.D.Set("id", *v.Id)
296+
}
297+
298+
if v.InstanceId != nil {
299+
s.D.Set("instance_id", *v.InstanceId)
300+
}
301+
302+
if v.IsReadOnly != nil {
303+
s.D.Set("is_read_only", *v.IsReadOnly)
304+
}
305+
306+
s.D.Set("state", v.LifecycleState)
307+
308+
if v.TimeCreated != nil {
309+
s.D.Set("time_created", v.TimeCreated.String())
310+
}
311+
312+
if v.VolumeId != nil {
313+
s.D.Set("volume_id", *v.VolumeId)
314+
}
287315
default:
288-
log.Printf("[WARN] Received volume attachment of unknown type")
316+
log.Printf("[WARN] Received 'attachment_type' of unknown type %v", *s.Res)
317+
return nil
289318
}
290-
291319
return nil
292320
}
293321

0 commit comments

Comments
 (0)