Merge #3288: Disallow Update func when no updates are possible.
This commit is contained in:
commit
6e4b445b58
|
@ -19,7 +19,6 @@ func resourceArtifact() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceArtifactRead,
|
||||
Read: resourceArtifactRead,
|
||||
Update: resourceArtifactRead,
|
||||
Delete: resourceArtifactDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
|
|
@ -15,8 +15,6 @@ func resourceAwsAppCookieStickinessPolicy() *schema.Resource {
|
|||
// There is no concept of "updating" an App Stickiness policy in
|
||||
// the AWS API.
|
||||
Create: resourceAwsAppCookieStickinessPolicyCreate,
|
||||
Update: resourceAwsAppCookieStickinessPolicyCreate,
|
||||
|
||||
Read: resourceAwsAppCookieStickinessPolicyRead,
|
||||
Delete: resourceAwsAppCookieStickinessPolicyDelete,
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ func resourceAwsLBCookieStickinessPolicy() *schema.Resource {
|
|||
// There is no concept of "updating" an LB Stickiness policy in
|
||||
// the AWS API.
|
||||
Create: resourceAwsLBCookieStickinessPolicyCreate,
|
||||
Update: resourceAwsLBCookieStickinessPolicyCreate,
|
||||
|
||||
Read: resourceAwsLBCookieStickinessPolicyRead,
|
||||
Delete: resourceAwsLBCookieStickinessPolicyDelete,
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ func resourceAwsS3BucketObject() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceAwsS3BucketObjectPut,
|
||||
Read: resourceAwsS3BucketObjectRead,
|
||||
Update: resourceAwsS3BucketObjectPut,
|
||||
Delete: resourceAwsS3BucketObjectDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
|
|
@ -17,8 +17,6 @@ func resourceAwsVpnConnectionRoute() *schema.Resource {
|
|||
// You can't update a route. You can just delete one and make
|
||||
// a new one.
|
||||
Create: resourceAwsVpnConnectionRouteCreate,
|
||||
Update: resourceAwsVpnConnectionRouteCreate,
|
||||
|
||||
Read: resourceAwsVpnConnectionRouteRead,
|
||||
Delete: resourceAwsVpnConnectionRouteDelete,
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ func resourceAzureStorageBlob() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceAzureStorageBlobCreate,
|
||||
Read: resourceAzureStorageBlobRead,
|
||||
Update: resourceAzureStorageBlobUpdate,
|
||||
Exists: resourceAzureStorageBlobExists,
|
||||
Delete: resourceAzureStorageBlobDelete,
|
||||
|
||||
|
@ -122,17 +121,6 @@ func resourceAzureStorageBlobRead(d *schema.ResourceData, meta interface{}) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
// resourceAzureStorageBlobUpdate does all the necessary API calls to
|
||||
// update a blob on Azure.
|
||||
func resourceAzureStorageBlobUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
// NOTE: although empty as most parameters have ForceNew set; this is
|
||||
// still required in case of changes to the storage_service_key
|
||||
|
||||
// run the ExistsFunc beforehand to ensure the resource's existence nonetheless:
|
||||
_, err := resourceAzureStorageBlobExists(d, meta)
|
||||
return err
|
||||
}
|
||||
|
||||
// resourceAzureStorageBlobExists does all the necessary API calls to
|
||||
// check for the existence of the blob on Azure.
|
||||
func resourceAzureStorageBlobExists(d *schema.ResourceData, meta interface{}) (bool, error) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
|
@ -13,7 +13,6 @@ func resourceStorageBucketObject() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceStorageBucketObjectCreate,
|
||||
Read: resourceStorageBucketObjectRead,
|
||||
Update: resourceStorageBucketObjectUpdate,
|
||||
Delete: resourceStorageBucketObjectDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -107,12 +106,6 @@ func resourceStorageBucketObjectRead(d *schema.ResourceData, meta interface{}) e
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceStorageBucketObjectUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
// The Cloud storage API doesn't support updating object data contents,
|
||||
// only metadata. So once we implement metadata we'll have work to do here
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceStorageBucketObjectDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ func resource() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceCreate,
|
||||
Read: resourceRead,
|
||||
Update: resourceUpdate,
|
||||
Delete: resourceDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{},
|
||||
|
@ -32,10 +31,6 @@ func resourceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
d.SetId("")
|
||||
return nil
|
||||
|
|
|
@ -244,7 +244,20 @@ func (r *Resource) InternalValidate(topSchemaMap schemaMap) error {
|
|||
return fmt.Errorf(
|
||||
"No Update defined, must set ForceNew on: %#v", nonForceNewAttrs)
|
||||
}
|
||||
} else {
|
||||
nonUpdateableAttrs := make([]string, 0)
|
||||
for k, v := range r.Schema {
|
||||
if v.ForceNew || (v.Computed && !v.Optional) {
|
||||
nonUpdateableAttrs = append(nonUpdateableAttrs, k)
|
||||
}
|
||||
}
|
||||
updateableAttrs := len(r.Schema) - len(nonUpdateableAttrs)
|
||||
if updateableAttrs == 0 {
|
||||
return fmt.Errorf(
|
||||
"All fields are ForceNew or Computed w/out Optional, Update is superfluous")
|
||||
}
|
||||
}
|
||||
|
||||
tsm = schemaMap(r.Schema)
|
||||
}
|
||||
|
||||
|
|
|
@ -335,6 +335,36 @@ func TestResourceInternalValidate(t *testing.T) {
|
|||
},
|
||||
true,
|
||||
},
|
||||
|
||||
// Update undefined for non-ForceNew field
|
||||
{
|
||||
&Resource{
|
||||
Create: func(d *ResourceData, meta interface{}) error { return nil },
|
||||
Schema: map[string]*Schema{
|
||||
"boo": &Schema{
|
||||
Type: TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
||||
// Update defined for ForceNew field
|
||||
{
|
||||
&Resource{
|
||||
Create: func(d *ResourceData, meta interface{}) error { return nil },
|
||||
Update: func(d *ResourceData, meta interface{}) error { return nil },
|
||||
Schema: map[string]*Schema{
|
||||
"goo": &Schema{
|
||||
Type: TypeInt,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue