Skip to content

Commit d12adfd

Browse files
r/storage_blob: validation for append blobs
1 parent af6abe4 commit d12adfd

File tree

1 file changed

+12
-7
lines changed
  • azurerm/internal/services/storage

1 file changed

+12
-7
lines changed

azurerm/internal/services/storage/blobs.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ type BlobUpload struct {
3636
}
3737

3838
func (sbu BlobUpload) Create(ctx context.Context) error {
39-
// TODO: should we move this into the Block and Page blocks?
40-
if sbu.SourceUri != "" {
41-
return sbu.copy(ctx)
42-
}
43-
4439
blobType := strings.ToLower(sbu.BlobType)
4540

4641
if blobType == "append" {
47-
// TODO: if Source/SourceContent are set return an error
42+
if sbu.Source != "" || sbu.SourceContent != "" || sbu.SourceUri != "" {
43+
return fmt.Errorf("A source cannot be specified for an Append blob")
44+
}
45+
4846
return sbu.createEmptyAppendBlob(ctx)
4947
}
5048

5149
if blobType == "block" {
50+
if sbu.SourceUri != "" {
51+
return sbu.copy(ctx)
52+
}
53+
5254
if sbu.SourceContent != "" {
5355
return sbu.uploadBlockBlobFromContent(ctx)
5456
}
@@ -60,6 +62,10 @@ func (sbu BlobUpload) Create(ctx context.Context) error {
6062
}
6163

6264
if blobType == "page" {
65+
if sbu.SourceUri != "" {
66+
return sbu.copy(ctx)
67+
}
68+
6369
if sbu.SourceContent != "" {
6470
return sbu.uploadPageBlobFromContent(ctx)
6571
}
@@ -203,7 +209,6 @@ func (sbu BlobUpload) uploadPageBlob(ctx context.Context) error {
203209
ContentType: utils.String(sbu.ContentType),
204210
MetaData: sbu.MetaData,
205211
}
206-
// TODO: access tiers?
207212
if _, err := sbu.Client.PutPageBlob(ctx, sbu.AccountName, sbu.ContainerName, sbu.BlobName, input); err != nil {
208213
return fmt.Errorf("Error PutPageBlob: %s", err)
209214
}

0 commit comments

Comments
 (0)