本文整理汇总了Golang中github.com/pearkes/digitalocean.Droplet.NetworkingType方法的典型用法代码示例。如果您正苦于以下问题:Golang Droplet.NetworkingType方法的具体用法?Golang Droplet.NetworkingType怎么用?Golang Droplet.NetworkingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pearkes/digitalocean.Droplet
的用法示例。
在下文中一共展示了Droplet.NetworkingType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
}