backend/manta: deprecate camelcase attribute name

This change is needed (next to making it consistent as its the only attribute name that uses camelcase) because passing that attribute objectName in the update `terraform_remote_state` resource, ended up giving me this error: https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go#L736
This commit is contained in:
Sander van Harmelen 2018-08-29 20:20:32 +02:00
parent 3e935c846f
commit 77b9fad7f0
4 changed files with 33 additions and 20 deletions

View File

@ -62,9 +62,17 @@ func New() backend.Backend {
},
"objectName": {
Type: schema.TypeString,
Optional: true,
Default: "terraform.tfstate",
Deprecated: "please use the object_name attribute",
},
"object_name": {
Type: schema.TypeString,
Optional: true,
Default: "terraform.tfstate",
// Set this default once the objectName attribute is removed!
// Default: "terraform.tfstate",
},
},
}
@ -116,7 +124,12 @@ func (b *Backend) configure(ctx context.Context) error {
}
b.path = data.Get("path").(string)
b.objectName = data.Get("objectName").(string)
b.objectName = data.Get("object_name").(string)
// If object_name is not set, try the deprecated objectName.
if b.objectName == "" {
b.objectName = data.Get("objectName").(string)
}
var validationError *multierror.Error

View File

@ -31,8 +31,8 @@ func TestBackend(t *testing.T) {
keyName := "testState"
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
createMantaFolder(t, b.storageClient, directory)
@ -48,13 +48,13 @@ func TestBackendLocked(t *testing.T) {
keyName := "testState"
b1 := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
b2 := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
createMantaFolder(t, b1.storageClient, directory)
@ -88,7 +88,6 @@ func deleteMantaFolder(t *testing.T, mantaClient *storage.StorageClient, directo
}
for _, obj := range objs.Entries {
if obj.Type == "directory" {
ojs, err := mantaClient.Dir().List(context.Background(), &storage.ListDirectoryInput{
DirectoryName: path.Join(mantaDefaultRootStore, directoryName, obj.Name),

View File

@ -21,8 +21,8 @@ func TestRemoteClient(t *testing.T) {
keyName := "testState"
b := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
createMantaFolder(t, b.storageClient, directory)
@ -42,13 +42,13 @@ func TestRemoteClientLocks(t *testing.T) {
keyName := "testState"
b1 := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
b2 := backend.TestBackendConfig(t, New(), map[string]interface{}{
"path": directory,
"objectName": keyName,
"path": directory,
"object_name": keyName,
}).(*Backend)
createMantaFolder(t, b1.storageClient, directory)

View File

@ -17,8 +17,8 @@ Stores the state as an artifact in [Manta](https://www.joyent.com/manta).
```hcl
terraform {
backend "manta" {
path = "random/path"
objectName = "terraform.tfstate"
path = "random/path"
object_name = "terraform.tfstate"
}
}
```
@ -32,8 +32,8 @@ Note that for the access credentials we recommend using a
data "terraform_remote_state" "foo" {
backend = "manta"
config {
path = "random/path"
objectName = "terraform.tfstate"
path = "random/path"
object_name = "terraform.tfstate"
}
}
```
@ -49,4 +49,5 @@ The following configuration options are supported:
* `key_id` - (Required) This is the fingerprint of the public key matching the key specified in key_path. It can be obtained via the command ssh-keygen -l -E md5 -f /path/to/key. Can be set via the `SDC_KEY_ID` or `TRITON_KEY_ID` environment variables.
* `insecure_skip_tls_verify` - (Optional) This allows skipping TLS verification of the Triton endpoint. It is useful when connecting to a temporary Triton installation such as Cloud-On-A-Laptop which does not generally use a certificate signed by a trusted root CA. Defaults to `false`.
* `path` - (Required) The path relative to your private storage directory (`/$MANTA_USER/stor`) where the state file will be stored. **Please Note:** If this path does not exist, then the backend will create this folder location as part of backend creation.
* `objectName` - (Optional) The name of the state file (defaults to `terraform.tfstate`)
* `objectName` - (Optional, Deprecated) Use `object_name` instead.
* `object_name` - (Optional) The name of the state file (defaults to `terraform.tfstate`)