Skip to content

Commit 2cb121c

Browse files
committed
add additional object metadata
1 parent 8710394 commit 2cb121c

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

metadata/pkg/drivers/azure/azure.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var ObjectList = func(containerURL azblob.ContainerURL, bucketName string) ([]*m
4141
blobResponse, err := containerURL.ListBlobsFlatSegment(context.Background(), azblob.Marker{}, azblob.ListBlobsSegmentOptions{})
4242

4343
if err != nil {
44-
log.Fatal(err)
44+
log.Errorf("unable to list objects. failed with error: %v", err)
4545
}
4646

4747
for _, blob := range blobResponse.Segment.BlobItems {
@@ -59,14 +59,33 @@ var ObjectList = func(containerURL azblob.ContainerURL, bucketName string) ([]*m
5959
obj.RedirectLocation = *blob.Properties.DestinationSnapshot
6060
}
6161

62+
if blob.VersionID != nil {
63+
obj.VersionId = *blob.VersionID
64+
}
65+
66+
tagset := map[string]string{}
67+
68+
if blob.BlobTags != nil {
69+
for _, tag := range blob.BlobTags.BlobTagSet {
70+
tagset[tag.Key] = tag.Value
71+
}
72+
obj.ObjectTags = tagset
73+
}
74+
75+
obj.ExpiresDate = blob.Properties.ExpiresOn
76+
77+
if blob.Properties.EncryptionScope != nil {
78+
obj.ServerSideEncryption = *blob.Properties.EncryptionScope
79+
}
80+
6281
obj.ReplicationStatus = string(blob.Properties.CopyStatus)
6382

6483
if blob.Properties.ContentType != nil {
6584
obj.ObjectType = *blob.Properties.ContentType
6685
}
67-
props, err := blobURL.GetProperties(context.Background(), azblob.BlobAccessConditions{})
86+
props, err := blobURL.GetProperties(context.Background(), azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
6887
if err != nil {
69-
log.Error("get properties failed", err)
88+
log.Error("unable to get properties for object %v. failed with error: %v", obj.ObjectName, err)
7089
}
7190

7291
obj.Metadata = props.NewMetadata()
@@ -101,7 +120,7 @@ func GetBucketMeta(idx int, container azblob.ContainerItem, serviceURL azblob.Se
101120
props, err := containerURL.GetProperties(context.Background(), azblob.LeaseAccessConditions{})
102121

103122
if err != nil {
104-
log.Errorf("failed to get bucket tags. failed wth error: %v", err)
123+
log.Errorf("unable to get bucket tags. failed wth error: %v", err)
105124
} else {
106125
buck.BucketTags = props.NewMetadata()
107126
}
@@ -116,7 +135,7 @@ func GetBucketMeta(idx int, container azblob.ContainerItem, serviceURL azblob.Se
116135
for _, item := range acl.Items {
117136
acc := &model.Access{}
118137
acc.ID = item.ID
119-
acc.Permission = item.AccessPolicy.Permission
138+
acc.Permission = *item.AccessPolicy.Permission
120139
access = append(access, acc)
121140
}
122141
buck.BucketAcl = access

0 commit comments

Comments
 (0)