backend/remote-state/gcs: Enable versioning on automatically created buckets.

This commit is contained in:
Florian Forster 2017-09-13 11:36:36 +02:00 committed by James Bardin
parent 52e6159219
commit 37dc95158d
1 changed files with 5 additions and 1 deletions

View File

@ -121,5 +121,9 @@ func (b *gcsBackend) ensureBucketExists() error {
return fmt.Errorf("bucket %q does not exist; specify the \"project\" option or create the bucket manually using `gsutil mb gs://%s`", b.bucketName, b.bucketName)
}
return b.storageClient.Bucket(b.bucketName).Create(b.storageContext, b.projectID, nil)
attrs := &storage.BucketAttrs{
VersioningEnabled: true,
}
return b.storageClient.Bucket(b.bucketName).Create(b.storageContext, b.projectID, attrs)
}