本文整理匯總了Golang中github.com/hashicorp/terraform/helper/schema.ResourceData.Partial方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResourceData.Partial方法的具體用法?Golang ResourceData.Partial怎麽用?Golang ResourceData.Partial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hashicorp/terraform/helper/schema.ResourceData
的用法示例。
在下文中一共展示了ResourceData.Partial方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: resourceComputeFirewallUpdate
func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
d.Partial(true)
firewall, err := resourceFirewall(d, meta)
if err != nil {
return err
}
op, err := config.clientCompute.Firewalls.Update(
config.Project, d.Id(), firewall).Do()
if err != nil {
return fmt.Errorf("Error updating firewall: %s", err)
}
err = computeOperationWaitGlobal(config, op, "Updating Firewall")
if err != nil {
return err
}
d.Partial(false)
return resourceComputeFirewallRead(d, meta)
}
示例2: resourceAwsAutoscalingGroupUpdate
func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{}) error {
autoscalingconn := meta.(*AWSClient).autoscalingconn
opts := autoscaling.UpdateAutoScalingGroup{
Name: d.Id(),
}
if d.HasChange("desired_capacity") {
opts.DesiredCapacity = d.Get("desired_capacity").(int)
opts.SetDesiredCapacity = true
}
if d.HasChange("min_size") {
opts.MinSize = d.Get("min_size").(int)
opts.SetMinSize = true
}
if d.HasChange("max_size") {
opts.MaxSize = d.Get("max_size").(int)
opts.SetMaxSize = true
}
log.Printf("[DEBUG] AutoScaling Group update configuration: %#v", opts)
_, err := autoscalingconn.UpdateAutoScalingGroup(&opts)
if err != nil {
d.Partial(true)
return fmt.Errorf("Error updating Autoscaling group: %s", err)
}
return resourceAwsAutoscalingGroupRead(d, meta)
}
示例3: resourceMarathonAppCreate
func resourceMarathonAppCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(Config)
client := config.Client
application := mutateResourceToApplication(d)
application, err := client.CreateApplication(application)
if err != nil {
log.Println("[ERROR] creating application", err)
return err
}
d.Partial(true)
d.SetId(application.ID)
setSchemaFieldsForApp(application, d)
for _, deploymentID := range application.DeploymentIDs() {
err = client.WaitOnDeployment(deploymentID.DeploymentID, config.DefaultDeploymentTimeout)
if err != nil {
log.Println("[ERROR] waiting for application for deployment", deploymentID, err)
return err
}
}
d.Partial(false)
return resourceMarathonAppRead(d, meta)
}
示例4: resourceBrightboxDatabaseServerUpdate
func resourceBrightboxDatabaseServerUpdate(
d *schema.ResourceData,
meta interface{},
) error {
client := meta.(*CompositeClient).ApiClient
log.Printf("[DEBUG] Setting Partial")
d.Partial(true)
// Create/Update Database
database_server_opts := getBlankDatabaseServerOpts()
err := addUpdateableDatabaseServerOptions(d, database_server_opts)
if err != nil {
return err
}
if databaseDetailsChanged(d) {
log.Printf("[INFO] Changing database details")
err := removeDatabaseAccessRestrictions(client, d.Id())
if err != nil {
return err
}
err = changeDatabase(d)
if err != nil {
return err
}
assign_string_set_always(d, &database_server_opts.AllowAccess, "allow_access")
} else {
log.Printf("[DEBUG] No change to database details detected")
assign_string_set(d, &database_server_opts.AllowAccess, "allow_access")
}
return updateDatabaseServerAttributes(d, client, database_server_opts)
}
開發者ID:brightbox,項目名稱:terraform-provider-brightbox,代碼行數:30,代碼來源:resource_brightbox_database_server.go
示例5: resourceAwsSubnetUpdate
func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
ec2conn := meta.(*AWSClient).ec2conn
d.Partial(true)
if err := setTags(ec2conn, d); err != nil {
return err
} else {
d.SetPartial("tags")
}
if d.HasChange("map_public_ip_on_launch") {
modifyOpts := &ec2.ModifySubnetAttribute{
SubnetId: d.Id(),
MapPublicIpOnLaunch: true,
}
log.Printf("[DEBUG] Subnet modify attributes: %#v", modifyOpts)
_, err := ec2conn.ModifySubnetAttribute(modifyOpts)
if err != nil {
return err
} else {
d.SetPartial("map_public_ip_on_launch")
}
}
d.Partial(false)
return resourceAwsSubnetRead(d, meta)
}
示例6: resourceAwsRoute53ZoneUpdate
func resourceAwsRoute53ZoneUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).r53conn
d.Partial(true)
if d.HasChange("comment") {
zoneInput := route53.UpdateHostedZoneCommentInput{
Id: aws.String(d.Id()),
Comment: aws.String(d.Get("comment").(string)),
}
_, err := conn.UpdateHostedZoneComment(&zoneInput)
if err != nil {
return err
} else {
d.SetPartial("comment")
}
}
if err := setTagsR53(conn, d, "hostedzone"); err != nil {
return err
} else {
d.SetPartial("tags")
}
d.Partial(false)
return resourceAwsRoute53ZoneRead(d, meta)
}
示例7: resourceAwsProxyProtocolPolicyCreate
func resourceAwsProxyProtocolPolicyCreate(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbconn
elbname := aws.String(d.Get("load_balancer").(string))
input := &elb.CreateLoadBalancerPolicyInput{
LoadBalancerName: elbname,
PolicyAttributes: []*elb.PolicyAttribute{
&elb.PolicyAttribute{
AttributeName: aws.String("ProxyProtocol"),
AttributeValue: aws.String("True"),
},
},
PolicyName: aws.String("TFEnableProxyProtocol"),
PolicyTypeName: aws.String("ProxyProtocolPolicyType"),
}
// Create a policy
log.Printf("[DEBUG] ELB create a policy %s from policy type %s",
*input.PolicyName, *input.PolicyTypeName)
if _, err := elbconn.CreateLoadBalancerPolicy(input); err != nil {
return fmt.Errorf("Error creating a policy %s: %s",
*input.PolicyName, err)
}
// Assign the policy name for use later
d.Partial(true)
d.SetId(fmt.Sprintf("%s:%s", *elbname, *input.PolicyName))
d.SetPartial("load_balancer")
log.Printf("[INFO] ELB PolicyName: %s", *input.PolicyName)
return resourceAwsProxyProtocolPolicyUpdate(d, meta)
}
示例8: resourceComputeForwardingRuleUpdate
func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
region := getOptionalRegion(d, config)
d.Partial(true)
if d.HasChange("target") {
target_name := d.Get("target").(string)
target_ref := &compute.TargetReference{Target: target_name}
op, err := config.clientCompute.ForwardingRules.SetTarget(
config.Project, region, d.Id(), target_ref).Do()
if err != nil {
return fmt.Errorf("Error updating target: %s", err)
}
err = computeOperationWaitRegion(config, op, region, "Updating Forwarding Rule")
if err != nil {
return err
}
d.SetPartial("target")
}
d.Partial(false)
return resourceComputeForwardingRuleRead(d, meta)
}
示例9: resourceAwsDbParameterGroupCreate
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn
createOpts := rds.CreateDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Get("name").(string)),
DBParameterGroupFamily: aws.String(d.Get("family").(string)),
Description: aws.String(d.Get("description").(string)),
}
log.Printf("[DEBUG] Create DB Parameter Group: %#v", createOpts)
_, err := rdsconn.CreateDBParameterGroup(&createOpts)
if err != nil {
return fmt.Errorf("Error creating DB Parameter Group: %s", err)
}
d.Partial(true)
d.SetPartial("name")
d.SetPartial("family")
d.SetPartial("description")
d.Partial(false)
d.SetId(*createOpts.DBParameterGroupName)
log.Printf("[INFO] DB Parameter Group ID: %s", d.Id())
return resourceAwsDbParameterGroupUpdate(d, meta)
}
示例10: resourceAwsSpotFleetRequestUpdate
func resourceAwsSpotFleetRequestUpdate(d *schema.ResourceData, meta interface{}) error {
// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifySpotFleetRequest.html
conn := meta.(*AWSClient).ec2conn
d.Partial(true)
req := &ec2.ModifySpotFleetRequestInput{
SpotFleetRequestId: aws.String(d.Id()),
}
if val, ok := d.GetOk("target_capacity"); ok {
req.TargetCapacity = aws.Int64(int64(val.(int)))
}
if val, ok := d.GetOk("excess_capacity_termination_policy"); ok {
req.ExcessCapacityTerminationPolicy = aws.String(val.(string))
}
resp, err := conn.ModifySpotFleetRequest(req)
if err == nil && aws.BoolValue(resp.Return) {
// TODO: rollback to old values?
}
return nil
}
示例11: instanceProfileSetRoles
func instanceProfileSetRoles(d *schema.ResourceData, iamconn *iam.IAM) error {
oldInterface, newInterface := d.GetChange("roles")
oldRoles := oldInterface.(*schema.Set)
newRoles := newInterface.(*schema.Set)
currentRoles := schema.CopySet(oldRoles)
d.Partial(true)
for _, role := range oldRoles.Difference(newRoles).List() {
err := instanceProfileRemoveRole(iamconn, d.Id(), role.(string))
if err != nil {
return fmt.Errorf("Error removing role %s from IAM instance profile %s: %s", role, d.Id(), err)
}
currentRoles.Remove(role)
d.Set("roles", currentRoles)
d.SetPartial("roles")
}
for _, role := range newRoles.Difference(oldRoles).List() {
err := instanceProfileAddRole(iamconn, d.Id(), role.(string))
if err != nil {
return fmt.Errorf("Error adding role %s to IAM instance profile %s: %s", role, d.Id(), err)
}
currentRoles.Add(role)
d.Set("roles", currentRoles)
d.SetPartial("roles")
}
d.Partial(false)
return nil
}
示例12: resourceChronosJobCreate
func resourceChronosJobCreate(rd *schema.ResourceData, meta interface{}) error {
chronosConfig := meta.(Config)
j := jobFromResource(rd)
jsonBytes, err := json.Marshal(j)
if err != nil {
return err
}
req, err := chronosConfig.CreateRequest("POST", chronosConfig.GetCreateUrl(), "application/json", bytes.NewBuffer(jsonBytes))
if err != nil {
return err
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
if err = checkStatusCodeIsSuccessful(resp.StatusCode); err != nil {
return err
}
rd.Partial(true)
rd.SetId(j.Name)
setSchemaFieldsForJob(j, rd)
rd.Partial(false)
return resourceChronosJobRead(rd, meta)
}
示例13: resourceVultrServerUpdate
func resourceVultrServerUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*lib.Client)
d.Partial(true)
if d.HasChange("name") {
oldName, newName := d.GetChange("name")
err := client.RenameServer(d.Id(), newName.(string))
if err != nil {
return fmt.Errorf("Error renaming server (%s): %s", d.Id(), err)
}
_, err = WaitForServerAttribute(d, newName.(string), []string{"", oldName.(string)}, "name", meta)
if err != nil {
return fmt.Errorf("Error waiting for rename server (%s) to finish: %s", d.Id(), err)
}
d.SetPartial("name")
}
return resourceVultrServerRead(d, meta)
}
示例14: resourceAwsAmiUpdate
func resourceAwsAmiUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*AWSClient).ec2conn
d.Partial(true)
if err := setTags(client, d); err != nil {
return err
} else {
d.SetPartial("tags")
}
if d.Get("description").(string) != "" {
_, err := client.ModifyImageAttribute(&ec2.ModifyImageAttributeInput{
ImageId: aws.String(d.Id()),
Description: &ec2.AttributeValue{
Value: aws.String(d.Get("description").(string)),
},
})
if err != nil {
return err
}
d.SetPartial("description")
}
d.Partial(false)
return resourceAwsAmiRead(d, meta)
}
示例15: resourceAwsElbUpdate
func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbconn
d.Partial(true)
// If we currently have instances, or did have instances,
// we want to figure out what to add and remove from the load
// balancer
if d.HasChange("instances") {
o, n := d.GetChange("instances")
os := o.(*schema.Set)
ns := n.(*schema.Set)
remove := expandStringList(os.Difference(ns).List())
add := expandStringList(ns.Difference(os).List())
if len(add) > 0 {
registerInstancesOpts := elb.RegisterInstancesWithLoadBalancer{
LoadBalancerName: d.Id(),
Instances: add,
}
_, err := elbconn.RegisterInstancesWithLoadBalancer(®isterInstancesOpts)
if err != nil {
return fmt.Errorf("Failure registering instances: %s", err)
}
}
if len(remove) > 0 {
deRegisterInstancesOpts := elb.DeregisterInstancesFromLoadBalancer{
LoadBalancerName: d.Id(),
Instances: remove,
}
_, err := elbconn.DeregisterInstancesFromLoadBalancer(&deRegisterInstancesOpts)
if err != nil {
return fmt.Errorf("Failure deregistering instances: %s", err)
}
}
d.SetPartial("instances")
}
log.Println("[INFO] outside modify attributes")
if d.HasChange("cross_zone_load_balancing") {
log.Println("[INFO] inside modify attributes")
attrs := elb.ModifyLoadBalancerAttributes{
LoadBalancerName: d.Get("name").(string),
LoadBalancerAttributes: elb.LoadBalancerAttributes{
CrossZoneLoadBalancingEnabled: d.Get("cross_zone_load_balancing").(bool),
},
}
_, err := elbconn.ModifyLoadBalancerAttributes(&attrs)
if err != nil {
return fmt.Errorf("Failure configuring health check: %s", err)
}
d.SetPartial("cross_zone_load_balancing")
}
d.Partial(false)
return resourceAwsElbRead(d, meta)
}