Skip to content

Commit

Permalink
Merge pull request #64 from niuzhenguo/fix-sfs
Browse files Browse the repository at this point in the history
Suppress sfs system metadata
  • Loading branch information
niuzhenguo authored Dec 27, 2018
2 parents f2a2e3b + 4b03a3b commit bf8974c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion huaweicloud/resource_huaweicloud_sfs_file_system_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package huaweicloud
import (
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/terraform/helper/resource"
Expand Down Expand Up @@ -207,14 +208,31 @@ func resourceSFSFileSystemV2Read(d *schema.ResourceData, meta interface{}) error
d.Set("share_type", n.ShareType)
d.Set("volume_type", n.VolumeType)
d.Set("is_public", n.IsPublic)
d.Set("metadata", n.Metadata)
d.Set("availability_zone", n.AvailabilityZone)
d.Set("region", GetRegion(d, config))
d.Set("export_location", n.ExportLocation)
d.Set("export_locations", n.ExportLocations)
d.Set("host", n.Host)
d.Set("links", n.Links)

// NOTE: This tries to remove system metadata.
md := make(map[string]string)
var sys_keys = [2]string{"enterprise_project_id", "share_used"}

OUTER:
for key, val := range n.Metadata {
if strings.HasPrefix(key, "#sfs") {
continue
}
for i := range sys_keys {
if key == sys_keys[i] {
continue OUTER
}
}
md[key] = val
}
d.Set("metadata", md)

if len(rules) > 0 {
rule := rules[0]
d.Set("share_access_id", rule.ID)
Expand Down

0 comments on commit bf8974c

Please sign in to comment.