當前位置: 首頁>>代碼示例>>Golang>>正文


Golang digitalocean.Droplet類代碼示例

本文整理匯總了Golang中github.com/pearkes/digitalocean.Droplet的典型用法代碼示例。如果您正苦於以下問題:Golang Droplet類的具體用法?Golang Droplet怎麽用?Golang Droplet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Droplet類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: testAccCheckDigitalOceanDropletRenamedAndResized

func testAccCheckDigitalOceanDropletRenamedAndResized(droplet *digitalocean.Droplet) resource.TestCheckFunc {
	return func(s *terraform.State) error {

		if droplet.SizeSlug() != "1gb" {
			return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug())
		}

		if droplet.Name != "baz" {
			return fmt.Errorf("Bad name: %s", droplet.Name)
		}

		return nil
	}
}
開發者ID:apriendeau,項目名稱:terraform,代碼行數:14,代碼來源:resource_digitalocean_droplet_test.go

示例2: testAccCheckDigitalOceanDropletAttributes

func testAccCheckDigitalOceanDropletAttributes(droplet *digitalocean.Droplet) resource.TestCheckFunc {
	return func(s *terraform.State) error {

		if droplet.ImageSlug() != "centos-5-8-x32" {
			return fmt.Errorf("Bad image_slug: %s", droplet.ImageSlug())
		}

		if droplet.SizeSlug != "512mb" {
			return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
		}

		if droplet.RegionSlug() != "nyc3" {
			return fmt.Errorf("Bad region_slug: %s", droplet.RegionSlug())
		}

		if droplet.Name != "foo" {
			return fmt.Errorf("Bad name: %s", droplet.Name)
		}
		return nil
	}
}
開發者ID:jrperritt,項目名稱:terraform,代碼行數:21,代碼來源:resource_digitalocean_droplet_test.go

示例3: resource_digitalocean_droplet_update_state

func resource_digitalocean_droplet_update_state(
	s *terraform.ResourceState,
	droplet *digitalocean.Droplet) (*terraform.ResourceState, error) {

	s.Attributes["name"] = droplet.Name
	s.Attributes["region"] = droplet.RegionSlug()

	if droplet.ImageSlug() == "" && droplet.ImageId() != "" {
		s.Attributes["image"] = droplet.ImageId()
	} else {
		s.Attributes["image"] = droplet.ImageSlug()
	}

	if droplet.IPV6Address("public") != "" {
		s.Attributes["ipv6"] = "true"
		s.Attributes["ipv6_address"] = droplet.IPV6Address("public")
		s.Attributes["ipv6_address_private"] = droplet.IPV6Address("private")
	}

	s.Attributes["ipv4_address"] = droplet.IPV4Address("public")
	s.Attributes["locked"] = droplet.IsLocked()

	if droplet.NetworkingType() == "private" {
		s.Attributes["private_networking"] = "true"
		s.Attributes["ipv4_address_private"] = droplet.IPV4Address("private")
	}

	s.Attributes["size"] = droplet.SizeSlug()
	s.Attributes["status"] = droplet.Status

	return s, nil
}
開發者ID:GeorgeErickson,項目名稱:terraform-1,代碼行數:32,代碼來源:resource_digitalocean_droplet.go

示例4: testAccCheckDigitalOceanDropletAttributes_PrivateNetworkingIpv6

func testAccCheckDigitalOceanDropletAttributes_PrivateNetworkingIpv6(droplet *digitalocean.Droplet) resource.TestCheckFunc {
	return func(s *terraform.State) error {

		if droplet.ImageSlug() != "centos-5-8-x32" {
			return fmt.Errorf("Bad image_slug: %s", droplet.ImageSlug())
		}

		if droplet.SizeSlug != "1gb" {
			return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
		}

		if droplet.RegionSlug() != "sgp1" {
			return fmt.Errorf("Bad region_slug: %s", droplet.RegionSlug())
		}

		if droplet.Name != "baz" {
			return fmt.Errorf("Bad name: %s", droplet.Name)
		}

		if droplet.IPV4Address("private") == "" {
			return fmt.Errorf("No ipv4 private: %s", droplet.IPV4Address("private"))
		}

		// if droplet.IPV6Address("private") == "" {
		// 	return fmt.Errorf("No ipv6 private: %s", droplet.IPV6Address("private"))
		// }

		if droplet.NetworkingType() != "private" {
			return fmt.Errorf("Bad networking type: %s", droplet.NetworkingType())
		}

		if droplet.IPV4Address("public") == "" {
			return fmt.Errorf("No ipv4 public: %s", droplet.IPV4Address("public"))
		}

		if droplet.IPV6Address("public") == "" {
			return fmt.Errorf("No ipv6 public: %s", droplet.IPV6Address("public"))
		}

		return nil
	}
}
開發者ID:jrperritt,項目名稱:terraform,代碼行數:42,代碼來源:resource_digitalocean_droplet_test.go


注:本文中的github.com/pearkes/digitalocean.Droplet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。