当前位置: 首页>>代码示例>>Golang>>正文


Golang InstanceState.Empty方法代码示例

本文整理汇总了Golang中github.com/xanzy/terraform-api/terraform.InstanceState.Empty方法的典型用法代码示例。如果您正苦于以下问题:Golang InstanceState.Empty方法的具体用法?Golang InstanceState.Empty怎么用?Golang InstanceState.Empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/xanzy/terraform-api/terraform.InstanceState的用法示例。


在下文中一共展示了InstanceState.Empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: resourceComputeInstanceMigrateState

func resourceComputeInstanceMigrateState(
	v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
	if is.Empty() {
		log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
		return is, nil
	}

	switch v {
	case 0:
		log.Println("[INFO] Found Compute Instance State v0; migrating to v1")
		is, err := migrateStateV0toV1(is)
		if err != nil {
			return is, err
		}
		fallthrough
	case 1:
		log.Println("[INFO] Found Compute Instance State v1; migrating to v2")
		is, err := migrateStateV1toV2(is)
		if err != nil {
			return is, err
		}
		return is, nil
	default:
		return is, fmt.Errorf("Unexpected schema version: %d", v)
	}
}
开发者ID:devendraPSL,项目名称:terraform-api,代码行数:26,代码来源:resource_compute_instance_migrate.go

示例2: migrateStateV0toV1

func migrateStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {
	if is.Empty() || is.Attributes == nil {
		log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
		return is, nil
	}

	log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)

	// Delete old count
	delete(is.Attributes, "block_device.#")

	oldBds, err := readV0BlockDevices(is)
	if err != nil {
		return is, err
	}
	// seed count fields for new types
	is.Attributes["ebs_block_device.#"] = "0"
	is.Attributes["ephemeral_block_device.#"] = "0"
	// depending on if state was v0.3.7 or an earlier version, it might have
	// root_block_device defined already
	if _, ok := is.Attributes["root_block_device.#"]; !ok {
		is.Attributes["root_block_device.#"] = "0"
	}
	for _, oldBd := range oldBds {
		if err := writeV1BlockDevice(is, oldBd); err != nil {
			return is, err
		}
	}
	log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes)
	return is, nil
}
开发者ID:devendraPSL,项目名称:terraform-api,代码行数:31,代码来源:resource_aws_instance_migrate.go

示例3: migrateKeyPairStateV0toV1

func migrateKeyPairStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {
	if is.Empty() {
		log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
		return is, nil
	}

	log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)

	// replace public_key with a stripped version, removing `\n` from the end
	// see https://github.com/hashicorp/terraform/issues/3455
	is.Attributes["public_key"] = strings.TrimSpace(is.Attributes["public_key"])

	log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes)
	return is, nil
}
开发者ID:devendraPSL,项目名称:terraform-api,代码行数:15,代码来源:resource_aws_key_pair_migrate.go

示例4: migrateSGRuleStateV0toV1

func migrateSGRuleStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {
	if is.Empty() {
		log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
		return is, nil
	}

	perm, err := migrateExpandIPPerm(is.Attributes)

	if err != nil {
		return nil, fmt.Errorf("[WARN] Error making new IP Permission in Security Group migration")
	}

	log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)
	newID := ipPermissionIDHash(is.Attributes["security_group_id"], is.Attributes["type"], perm)
	is.Attributes["id"] = newID
	is.ID = newID
	log.Printf("[DEBUG] Attributes after migration: %#v, new id: %s", is.Attributes, newID)
	return is, nil
}
开发者ID:devendraPSL,项目名称:terraform-api,代码行数:19,代码来源:resource_aws_security_group_rule_migrate.go


注:本文中的github.com/xanzy/terraform-api/terraform.InstanceState.Empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。