Skip to content

Commit ad4a82b

Browse files
r/storage_blob: removing support for defining source_content for Page blobs
In retrospect this doesn't make sense since the content needs to be aligned to a 512-byte boundary As such it's more likely this'll be used for Block Blobs rather than Page Blobs
1 parent 3f75e26 commit ad4a82b

File tree

3 files changed

+4
-64
lines changed

3 files changed

+4
-64
lines changed

azurerm/internal/services/storage/blobs.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ func (sbu BlobUpload) Create(ctx context.Context) error {
6565
if sbu.SourceUri != "" {
6666
return sbu.copy(ctx)
6767
}
68-
6968
if sbu.SourceContent != "" {
70-
return sbu.uploadPageBlobFromContent(ctx)
69+
return fmt.Errorf("`source_content` cannot be specified for a Page blob")
7170
}
7271
if sbu.Source != "" {
7372
return sbu.uploadPageBlob(ctx)
@@ -166,22 +165,6 @@ func (sbu BlobUpload) createEmptyPageBlob(ctx context.Context) error {
166165
return nil
167166
}
168167

169-
func (sbu BlobUpload) uploadPageBlobFromContent(ctx context.Context) error {
170-
tmpFile, err := ioutil.TempFile(os.TempDir(), "upload-")
171-
if err != nil {
172-
return fmt.Errorf("Error creating temporary file: %s", err)
173-
}
174-
defer os.Remove(tmpFile.Name())
175-
176-
if _, err = tmpFile.Write([]byte(sbu.SourceContent)); err != nil {
177-
return fmt.Errorf("Error writing Source Content to Temp File: %s", err)
178-
}
179-
defer tmpFile.Close()
180-
181-
sbu.Source = tmpFile.Name()
182-
return sbu.uploadPageBlob(ctx)
183-
}
184-
185168
func (sbu BlobUpload) uploadPageBlob(ctx context.Context) error {
186169
if sbu.Size != 0 {
187170
return fmt.Errorf("`size` cannot be set for an uploaded page blob")

azurerm/resource_arm_storage_blob_test.go

-43
Original file line numberDiff line numberDiff line change
@@ -509,33 +509,6 @@ func TestAccAzureRMStorageBlob_pageFromExistingBlob(t *testing.T) {
509509
})
510510
}
511511

512-
func TestAccAzureRMStorageBlob_pageFromInlineContent(t *testing.T) {
513-
resourceName := "azurerm_storage_blob.test"
514-
ri := tf.AccRandTimeInt()
515-
rs := strings.ToLower(acctest.RandString(11))
516-
location := testLocation()
517-
518-
resource.ParallelTest(t, resource.TestCase{
519-
PreCheck: func() { testAccPreCheck(t) },
520-
Providers: testAccProviders,
521-
CheckDestroy: testCheckAzureRMStorageBlobDestroy,
522-
Steps: []resource.TestStep{
523-
{
524-
Config: testAccAzureRMStorageBlob_pageFromInlineContent(ri, rs, location),
525-
Check: resource.ComposeTestCheckFunc(
526-
testCheckAzureRMStorageBlobExists(resourceName),
527-
),
528-
},
529-
{
530-
ResourceName: resourceName,
531-
ImportState: true,
532-
ImportStateVerify: true,
533-
ImportStateVerifyIgnore: []string{"attempts", "parallelism", "size", "source_content", "type"},
534-
},
535-
},
536-
})
537-
}
538-
539512
func TestAccAzureRMStorageBlob_pageFromLocalFile(t *testing.T) {
540513
sourceBlob, err := ioutil.TempFile("", "")
541514
if err != nil {
@@ -1136,22 +1109,6 @@ resource "azurerm_storage_blob" "test" {
11361109
`, template)
11371110
}
11381111

1139-
func testAccAzureRMStorageBlob_pageFromInlineContent(rInt int, rString, location string) string {
1140-
template := testAccAzureRMStorageBlob_template(rInt, rString, location, "private")
1141-
return fmt.Sprintf(`
1142-
%s
1143-
1144-
resource "azurerm_storage_blob" "test" {
1145-
name = "rick.morty"
1146-
resource_group_name = "${azurerm_resource_group.test.name}"
1147-
storage_account_name = "${azurerm_storage_account.test.name}"
1148-
storage_container_name = "${azurerm_storage_container.test.name}"
1149-
type = "page"
1150-
source_content = "Wubba Lubba Dub Dub"
1151-
}
1152-
`, template)
1153-
}
1154-
11551112
func testAccAzureRMStorageBlob_pageFromLocalBlob(rInt int, rString, location, fileName string) string {
11561113
template := testAccAzureRMStorageBlob_template(rInt, rString, location, "private")
11571114
return fmt.Sprintf(`

website/docs/r/storage_blob.html.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ The following arguments are supported:
6262

6363
* `content_type` - (Optional) The content type of the storage blob. Cannot be defined if `source_uri` is defined. Defaults to `application/octet-stream`.
6464

65-
* `source` - (Optional) An absolute path to a file on the local system. Cannot be specified if `source_content` or `source_uri` is specified.
65+
* `source` - (Optional) An absolute path to a file on the local system. This field cannot be specified for Append blobs and annot be specified if `source_content` or `source_uri` is specified.
6666

67-
* `source_content` - (Optional) The content for this blob which should be defined inline. Cannot be specified if `source` or `source_uri` is specified.
67+
* `source_content` - (Optional) The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `source_uri` is specified.
6868

6969
* `source_uri` - (Optional) The URI of an existing blob, or a file in the Azure File service, to use as the source contents
70-
for the blob to be created. Changing this forces a new resource to be created. Cannot be specified if `source` or `source_content` is specified.
70+
for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `source_content` is specified.
7171

7272
* `parallelism` - (Optional) The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
7373

0 commit comments

Comments
 (0)