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

feat(share-snapshot): Support for File share snapshot #389

Open
wants to merge 21 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
318 changes: 167 additions & 151 deletions examples/ibm-is-ng/main.tf

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.7
github.com/IBM/vmware-go-sdk v0.1.2
github.com/IBM/vpc-beta-go-sdk v0.8.0
github.com/IBM/vpc-go-sdk v0.63.1
github.com/IBM/vpc-go-sdk v0.64.0
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w
github.com/IBM/vmware-go-sdk v0.1.2/go.mod h1:2UGPBJju3jiv5VKKBBm9a5L6bzF/aJdKOKAzJ7HaOjA=
github.com/IBM/vpc-beta-go-sdk v0.8.0 h1:cEPpv4iw3Ba5W2d0AWg3TIbKeJ8y1nPuUuibR5Jt9eE=
github.com/IBM/vpc-beta-go-sdk v0.8.0/go.mod h1:hORgIyTFRzXrZIK9IohaWmCRBBlYiDRagsufi7M6akE=
github.com/IBM/vpc-go-sdk v0.63.1 h1:HqQeq2wGI2pF4y0/m18EaPsOEEXFjyml+xwlLC9AiXE=
github.com/IBM/vpc-go-sdk v0.63.1/go.mod h1:VBR6bAznHsNCFA89Ue4JFQpqCcFp8F5neqbCFCyks4Q=
github.com/IBM/vpc-go-sdk v0.64.0 h1:0x2jakapXxXYTTr0EdrwuXa6h0couSK+FTDGxd8jChA=
github.com/IBM/vpc-go-sdk v0.64.0/go.mod h1:VBR6bAznHsNCFA89Ue4JFQpqCcFp8F5neqbCFCyks4Q=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
Expand Down
4 changes: 4 additions & 0 deletions ibm/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ func Provider() *schema.Provider {
"ibm_is_share_profiles": vpc.DataSourceIbmIsShareProfiles(),
"ibm_is_share_accessor_bindings": vpc.DataSourceIBMIsShareAccessorBindings(),
"ibm_is_share_accessor_binding": vpc.DataSourceIBMIsShareAccessorBinding(),
"ibm_is_share_snapshot": vpc.DataSourceIBMIsShareSnapshot(),
"ibm_is_share_snapshots": vpc.DataSourceIBMIsShareSnapshots(),
"ibm_is_virtual_network_interface": vpc.DataSourceIBMIsVirtualNetworkInterface(),
"ibm_is_virtual_network_interfaces": vpc.DataSourceIBMIsVirtualNetworkInterfaces(),

Expand Down Expand Up @@ -1255,6 +1257,7 @@ func Provider() *schema.Provider {
"ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperations(),
"ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTarget(),
"ibm_is_share_delete_accessor_binding": vpc.ResourceIbmIsShareDeleteAccessorBinding(),
"ibm_is_share_snapshot": vpc.ResourceIBMIsShareSnapshot(),
"ibm_is_subnet": vpc.ResourceIBMISSubnet(),
"ibm_is_reservation": vpc.ResourceIBMISReservation(),
"ibm_is_reservation_activate": vpc.ResourceIBMISReservationActivate(),
Expand Down Expand Up @@ -1951,6 +1954,7 @@ func Validator() validate.ValidatorDict {
"ibm_is_share": vpc.ResourceIbmIsShareValidator(),
"ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperationsValidator(),
"ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTargetValidator(),
"ibm_is_share_snapshot": vpc.ResourceIBMIsShareSnapshotValidator(),
"ibm_is_snapshot": vpc.ResourceIBMISSnapshotValidator(),
"ibm_is_snapshot_consistency_group": vpc.ResourceIBMIsSnapshotConsistencyGroupValidator(),
"ibm_is_ssh_key": vpc.ResourceIBMISSHKeyValidator(),
Expand Down
110 changes: 106 additions & 4 deletions ibm/service/vpc/data_source_ibm_is_backup_policy_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,49 @@ func DataSourceIBMIsBackupPolicyJob() *schema.Resource {
},
},
},
"source_share": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "The source share this backup was created from (may be[deleted](https://cloud.ibm.com/apidocs/vpc#deleted-resources)).",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"crn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The CRN for this volume.",
},
"deleted": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates the referenced resource has been deleted and providessome supplementary information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"more_info": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about deleted resources.",
},
},
},
},
"href": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The URL for this volume.",
},
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The unique identifier for this volume.",
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The unique user-defined name for this volume.",
},
},
},
},
"status": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -307,6 +350,53 @@ func DataSourceIBMIsBackupPolicyJob() *schema.Resource {
Computed: true,
Description: "The user-defined name for this snapshot.",
},
"remote": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates that the resource associated with this referenceis remote and therefore may not be directly retrievable.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates that the referenced resource is remote to thisaccount, and identifies the owning account.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The unique identifier for this account.",
},
"resource_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The resource type.",
},
},
},
},
"region": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates that the referenced resource is remote to thisregion, and identifies the native region.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"href": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The URL for this region.",
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The globally unique name for this region.",
},
},
},
},
},
},
},
"resource_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -384,9 +474,21 @@ func dataSourceIBMIsBackupPolicyJobRead(context context.Context, d *schema.Resou
return diag.FromErr(fmt.Errorf("Error setting source_instance %s", err))
}
}
case "*vpcv1.BackupPolicyJobSourceShareReference":
{
jobSource := backupPolicyJob.Source.(*vpcv1.BackupPolicyJobSourceShareReference)
sourceShareList := []map[string]interface{}{}
sourceShareMap := dataShareBackupPolicyJobSourceShareReferenceToMap(jobSource)
sourceShareList = append(sourceShareList, sourceShareMap)
err = d.Set("source_share", sourceShareList)
if err != nil {
return diag.FromErr(fmt.Errorf("Error setting source_share %s", err))
}
}
}

}

if err = d.Set("status", backupPolicyJob.Status); err != nil {
return diag.FromErr(fmt.Errorf("Error setting status: %s", err))
}
Expand Down Expand Up @@ -612,19 +714,19 @@ func dataSourceBackupPolicyJobStatusReasonsToMap(statusReasonsItem vpcv1.BackupP
return statusReasonsMap
}

func dataSourceBackupPolicyJobFlattenTargetSnapshot(result []vpcv1.SnapshotReference) (finalList []map[string]interface{}) {
func dataSourceBackupPolicyJobFlattenTargetSnapshot(result []vpcv1.BackupPolicyTargetSnapshotIntf) (finalList []map[string]interface{}) {
finalList = []map[string]interface{}{}
for _, snapshotReferenceItem := range result {
finalMap := dataSourceBackupPolicyJobTargetSnapshotToMap(snapshotReferenceItem)
finalMap := dataSourceBackupPolicyJobCollectionJobsTargetSnapshotToMap(snapshotReferenceItem)
finalList = append(finalList, finalMap)
}

return finalList
}

func dataSourceBackupPolicyJobTargetSnapshotToMap(targetSnapshotItem vpcv1.SnapshotReference) (targetSnapshotMap map[string]interface{}) {
func dataSourceBackupPolicyJobTargetSnapshotToMap(targetSnapshotItemIntf vpcv1.BackupPolicyTargetSnapshotIntf) (targetSnapshotMap map[string]interface{}) {
targetSnapshotMap = map[string]interface{}{}

targetSnapshotItem := targetSnapshotItemIntf.(*vpcv1.BackupPolicyTargetSnapshot)
if targetSnapshotItem.CRN != nil {
targetSnapshotMap["crn"] = targetSnapshotItem.CRN
}
Expand Down
Loading
Loading