From 6e72f58a21761a16e955185caf4f4803ad9fc497 Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Thu, 7 Sep 2023 10:04:03 -0400 Subject: [PATCH 1/6] changed configuration package from vipr / toml to fig --- go.mod | 5 +- go.sum | 8 +++ liquidweb/config.go | 125 +++++++++++++++++++++--------------------- liquidweb/provider.go | 4 +- 4 files changed, 78 insertions(+), 64 deletions(-) diff --git a/go.mod b/go.mod index b0573d4..39e6833 100644 --- a/go.mod +++ b/go.mod @@ -56,6 +56,7 @@ require ( github.com/imdario/mergo v0.3.12 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jstemmer/go-junit-report v0.9.1 // indirect + github.com/kkyr/fig v0.3.2 // indirect github.com/klauspost/compress v1.11.2 // indirect github.com/mattn/go-colorable v0.1.1 // indirect github.com/mattn/go-isatty v0.0.5 // indirect @@ -65,9 +66,10 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.1.2 // indirect + github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/pelletier/go-toml v1.9.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/posener/complete v1.2.1 // indirect github.com/spf13/afero v1.2.2 // indirect @@ -92,6 +94,7 @@ require ( google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect google.golang.org/grpc v1.32.0 // indirect google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) go 1.21 diff --git a/go.sum b/go.sum index 2b71a1a..af9c8b9 100644 --- a/go.sum +++ b/go.sum @@ -241,6 +241,8 @@ github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgy github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkyr/fig v0.3.2 h1:+vMj52FL6RJUxeKOBB6JXIMyyi1/2j1ERDrZXjoBjzM= +github.com/kkyr/fig v0.3.2/go.mod h1:ItUILF8IIzgZOMhx5xpJ1W/bviQsWRKOwKXfE/tqUoA= github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -282,6 +284,8 @@ github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9 github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -290,6 +294,8 @@ github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= +github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -639,6 +645,8 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/liquidweb/config.go b/liquidweb/config.go index d003ed0..a3d6a1c 100644 --- a/liquidweb/config.go +++ b/liquidweb/config.go @@ -1,13 +1,24 @@ package liquidweb import ( + "errors" + "fmt" "log" "os" + "path/filepath" + "strings" - "github.com/BurntSushi/toml" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/kkyr/fig" lwgoapi "github.com/liquidweb/liquidweb-go/client" ) +const lwApiURL = "https://api.liquidweb.com" +const lwApiTimeout = 15 + +var ErrUsernameNotSet = fmt.Errorf("liquidweb username not set") +var ErrSecretNotSet = fmt.Errorf("liquidweb secret not set") + // Config holds all of the metadata for the provider and the Liquidweb API client. type Config struct { LWAPI *lwgoapi.API @@ -33,80 +44,72 @@ func NewConfig(username string, password string, url string, timeout int, nClien } // GetConfig handles mapping configuration between Terraform & Liquid Web's Liquidweb API configuration. -func GetConfig(path string) (interface{}, error) { - log.Printf("config file: %s\n", path) - - type lwapiConfig struct { - Username string `toml:"username"` - Password string `toml:"password"` - URL string `toml:"url"` - Timeout int `toml:"timeout"` +func GetConfig(resourceData *schema.ResourceData) (interface{}, error) { + configPaths := []string{ + "./", + "/", + } + if homedir, err := os.UserHomeDir(); err != nil { + configPaths = append(configPaths, homedir) } - conf := struct { - LWAPI lwapiConfig `toml:"lwapi"` - }{} + configName := "lwapi.toml" - body, err := os.ReadFile(path) - if err != nil { - return nil, err + if optConfigFile, isSet := resourceData.GetOk("config_path"); isSet { + if val, ok := optConfigFile.(string); ok { + log.Printf("included config file: %s\n", val) + configPaths = append([]string{filepath.Dir(val)}, configPaths...) + configName = filepath.Base(val) + } } - log.Printf("conf file contained: %s\n\n", body) - metadata, err := toml.Decode(string(body), &conf) - if err != nil { + var cfg struct { + lwApiCfg struct { + Username string `fig:"username"` + Password string `fig:"password"` + } `fig:"lwapi"` + } + + if err := fig.Load(&cfg, + fig.File(configName), + fig.Dirs(configPaths...), + ); err != nil && !errors.Is(err, fig.ErrFileNotFound) { return nil, err } - _ = metadata - - // config := lwapi.LWAPIConfig{ - // Username: &conf.LWAPI.Username, - // Password: &conf.LWAPI.Password, - // Url: conf.LWAPI.URL, - // } - - // vc := viper.New() - // vc.SetConfigFile(path) - // vc.AutomaticEnv() - // vc.SetConfigType("toml") - - // if err = vc.ReadConfig(bytes.NewBuffer(body)); err != nil { - // return nil, err - // } - - // log.Printf("configuration keys %#v exist\n", vc.AllKeys()) - // for _, k := range vc.AllKeys() { - // log.Printf("setting %s is set to %#v\n", k, vc.Get(k)) - // } - - // username := vc.GetString("lwapi.username") - // password := vc.GetString("lwapi.password") - // url := vc.GetString("lwapi.url") - // timeout := vc.GetInt("lwapi.Timeout") - - // config := lwapi.LWAPIConfig{ - // Username: &username, - // Password: &password, - // Url: url, - // } - - // Initialize original LW go client. - // client, err := lwapi.New(&config) - // if err != nil { - // return nil, err - // } + + for _, e := range os.Environ() { + pair := strings.SplitN(e, "=", 2) + switch pair[0] { + case "LWAPI_USERNAME": + cfg.lwApiCfg.Username = pair[1] + case "LWAPI_PASSWORD": + cfg.lwApiCfg.Password = pair[1] + } + } + + if cfg.lwApiCfg.Username == "" { + return nil, ErrUsernameNotSet + } + + if cfg.lwApiCfg.Password == "" { + return nil, ErrSecretNotSet + } // Initial new LW go client. - lwAPI, err := lwgoapi.NewAPI(conf.LWAPI.Username, conf.LWAPI.Password, conf.LWAPI.URL, conf.LWAPI.Timeout) + lwAPI, err := lwgoapi.NewAPI( + cfg.lwApiCfg.Username, + cfg.lwApiCfg.Password, + lwApiURL, + lwApiTimeout) if err != nil { return nil, err } return NewConfig( - conf.LWAPI.Username, - conf.LWAPI.Password, - conf.LWAPI.URL, - conf.LWAPI.Timeout, + cfg.lwApiCfg.Username, + cfg.lwApiCfg.Password, + lwApiURL, + lwApiTimeout, lwAPI, ) } diff --git a/liquidweb/provider.go b/liquidweb/provider.go index 806f3ab..01a3740 100644 --- a/liquidweb/provider.go +++ b/liquidweb/provider.go @@ -10,7 +10,7 @@ func Provider() *schema.Provider { Schema: map[string]*schema.Schema{ "config_path": { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Path to the LiquidWeb API configuration file.", }, }, @@ -37,5 +37,5 @@ func Provider() *schema.Provider { } func providerConfigure(d *schema.ResourceData) (interface{}, error) { - return GetConfig(d.Get("config_path").(string)) + return GetConfig(d) } From 828f57beafbf5329bcb223df02d282da5170f0d2 Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Thu, 7 Sep 2023 14:04:54 -0400 Subject: [PATCH 2/6] removed all config file reading junk --- liquidweb/config.go | 55 +++++++++---------------------------------- liquidweb/provider.go | 10 ++------ 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/liquidweb/config.go b/liquidweb/config.go index a3d6a1c..4e0d3dc 100644 --- a/liquidweb/config.go +++ b/liquidweb/config.go @@ -1,15 +1,11 @@ package liquidweb import ( - "errors" "fmt" "log" "os" - "path/filepath" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/kkyr/fig" lwgoapi "github.com/liquidweb/liquidweb-go/client" ) @@ -44,61 +40,32 @@ func NewConfig(username string, password string, url string, timeout int, nClien } // GetConfig handles mapping configuration between Terraform & Liquid Web's Liquidweb API configuration. -func GetConfig(resourceData *schema.ResourceData) (interface{}, error) { - configPaths := []string{ - "./", - "/", - } - if homedir, err := os.UserHomeDir(); err != nil { - configPaths = append(configPaths, homedir) - } - - configName := "lwapi.toml" - - if optConfigFile, isSet := resourceData.GetOk("config_path"); isSet { - if val, ok := optConfigFile.(string); ok { - log.Printf("included config file: %s\n", val) - configPaths = append([]string{filepath.Dir(val)}, configPaths...) - configName = filepath.Base(val) - } - } - - var cfg struct { - lwApiCfg struct { - Username string `fig:"username"` - Password string `fig:"password"` - } `fig:"lwapi"` - } - - if err := fig.Load(&cfg, - fig.File(configName), - fig.Dirs(configPaths...), - ); err != nil && !errors.Is(err, fig.ErrFileNotFound) { - return nil, err - } +func GetConfig() (interface{}, error) { + var username, token string for _, e := range os.Environ() { pair := strings.SplitN(e, "=", 2) switch pair[0] { case "LWAPI_USERNAME": - cfg.lwApiCfg.Username = pair[1] + log.Printf("read username %s\n", pair[1]) + username = pair[1] case "LWAPI_PASSWORD": - cfg.lwApiCfg.Password = pair[1] + token = pair[1] } } - if cfg.lwApiCfg.Username == "" { + if username == "" { return nil, ErrUsernameNotSet } - if cfg.lwApiCfg.Password == "" { + if token == "" { return nil, ErrSecretNotSet } // Initial new LW go client. lwAPI, err := lwgoapi.NewAPI( - cfg.lwApiCfg.Username, - cfg.lwApiCfg.Password, + username, + token, lwApiURL, lwApiTimeout) if err != nil { @@ -106,8 +73,8 @@ func GetConfig(resourceData *schema.ResourceData) (interface{}, error) { } return NewConfig( - cfg.lwApiCfg.Username, - cfg.lwApiCfg.Password, + username, + token, lwApiURL, lwApiTimeout, lwAPI, diff --git a/liquidweb/provider.go b/liquidweb/provider.go index 01a3740..b9c1602 100644 --- a/liquidweb/provider.go +++ b/liquidweb/provider.go @@ -7,13 +7,7 @@ import ( // Provider implements the provider definition. func Provider() *schema.Provider { return &schema.Provider{ - Schema: map[string]*schema.Schema{ - "config_path": { - Type: schema.TypeString, - Optional: true, - Description: "Path to the LiquidWeb API configuration file.", - }, - }, + Schema: map[string]*schema.Schema{}, DataSourcesMap: map[string]*schema.Resource{ "liquidweb_network_zone": dataSourceLWNetworkZone(), "liquidweb_cloud_server_config": dataSourceServerConfig(), @@ -37,5 +31,5 @@ func Provider() *schema.Provider { } func providerConfigure(d *schema.ResourceData) (interface{}, error) { - return GetConfig(d) + return GetConfig() } From 5dee0688694a68d36bb73fe327b05d4117d3bd30 Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Thu, 7 Sep 2023 16:01:54 -0400 Subject: [PATCH 3/6] added a gobuild helper for myself --- examples/provider.tf | 4 ++-- gobuild | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100755 gobuild diff --git a/examples/provider.tf b/examples/provider.tf index 79a979f..62f3474 100644 --- a/examples/provider.tf +++ b/examples/provider.tf @@ -5,8 +5,8 @@ variable "liquidweb_config_path" { terraform { required_providers { liquidweb = { - source = "local.providers/liquidweb/liquidweb" - version = "~> 1.5.8" + source = "registry.terraform.io/liquidweb/liquidweb" + version = "~> 1.6.2" } } } diff --git a/gobuild b/gobuild new file mode 100755 index 0000000..7a4aae4 --- /dev/null +++ b/gobuild @@ -0,0 +1,8 @@ +#!/bin/bash + +# Simple bash script to go install this onto your local machine + +new_tag=$(git tag -l|sort -n|tail -n1|awk -F. 'BEGIN{OFS="."};{$NF+=1; print}') + +# shellcheck disable=SC2088 +go build -o "~/terraform.d/plugins/registry.terraform.io/liquidweb/liquidweb/${new_tag}/darwin_amd64/terraform-provider-liquidweb" \ No newline at end of file From 37e2b825831f2b5626e200a1e34046bb4af91112 Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Thu, 7 Sep 2023 16:24:22 -0400 Subject: [PATCH 4/6] moved my cheater script over and increased timeout --- gobuild | 8 -------- liquidweb/config.go | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100755 gobuild diff --git a/gobuild b/gobuild deleted file mode 100755 index 7a4aae4..0000000 --- a/gobuild +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Simple bash script to go install this onto your local machine - -new_tag=$(git tag -l|sort -n|tail -n1|awk -F. 'BEGIN{OFS="."};{$NF+=1; print}') - -# shellcheck disable=SC2088 -go build -o "~/terraform.d/plugins/registry.terraform.io/liquidweb/liquidweb/${new_tag}/darwin_amd64/terraform-provider-liquidweb" \ No newline at end of file diff --git a/liquidweb/config.go b/liquidweb/config.go index 4e0d3dc..cb1dbfd 100644 --- a/liquidweb/config.go +++ b/liquidweb/config.go @@ -10,7 +10,7 @@ import ( ) const lwApiURL = "https://api.liquidweb.com" -const lwApiTimeout = 15 +const lwApiTimeout = 60 var ErrUsernameNotSet = fmt.Errorf("liquidweb username not set") var ErrSecretNotSet = fmt.Errorf("liquidweb secret not set") From a27c0620457339edaeb4d4fd6f25a049f95f9d33 Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Tue, 19 Sep 2023 11:39:54 -0400 Subject: [PATCH 5/6] adding documentation pages for terraform --- docs/data-sources/cloud_server_config.md | 50 +++++++++++++++++++ docs/data-sources/network_zone.md | 29 +++++++++++ docs/index.md | 48 ++++++++++++++++++ docs/resources/cloud_block_storage.md | 44 ++++++++++++++++ docs/resources/cloud_server.md | 44 ++++++++++++++++ docs/resources/network_dns_record.md | 48 ++++++++++++++++++ docs/resources/network_load_balancer.md | 46 +++++++++++++++++ docs/resources/network_vip.md | 31 ++++++++++++ docs/resources/storage_block_volume.md | 44 ++++++++++++++++ go.mod | 3 -- go.sum | 7 --- ....go => data_source_cloud_server_config.go} | 8 +-- terraform-registry-manifest.json | 6 +++ 13 files changed, 394 insertions(+), 14 deletions(-) create mode 100644 docs/data-sources/cloud_server_config.md create mode 100644 docs/data-sources/network_zone.md create mode 100644 docs/index.md create mode 100644 docs/resources/cloud_block_storage.md create mode 100644 docs/resources/cloud_server.md create mode 100644 docs/resources/network_dns_record.md create mode 100644 docs/resources/network_load_balancer.md create mode 100644 docs/resources/network_vip.md create mode 100644 docs/resources/storage_block_volume.md rename liquidweb/{data_source_storm_server_config.go => data_source_cloud_server_config.go} (94%) create mode 100644 terraform-registry-manifest.json diff --git a/docs/data-sources/cloud_server_config.md b/docs/data-sources/cloud_server_config.md new file mode 100644 index 0000000..494efd8 --- /dev/null +++ b/docs/data-sources/cloud_server_config.md @@ -0,0 +1,50 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_cloud_server_config Data Source - terraform-provider-liquidweb" +subcategory: "" +description: |- + +Cloud Server Configs + +--- + +# liquidweb_cloud_server_config (Data Source) + +LiquidWeb Cloud Server Config allows querying of different configs available. +A config ID must be passed to `liquidweb_cloud_server`, this allows querying a config. + + +## Schema + +### Optional + +These optional values allow you to filter returned configs. +The config returned will be the only one that matches the following traits. +If you return more than one, it will be rejected. +If your filters match 0 configs, it will be rejected. + +- `active` (Boolean) - whether the given config is enabled +- `available` (Boolean) - whether the config has available inventory +- `category` (String) - category of the config, see below +- `config_id` (Number) +- `description` (String) +- `disk` (Number) +- `featured` (Boolean) +- `memory` (Number) +- `network_zone` (String) +- `vcpu` (Number) +- `zone_availability` (Map of String) - zones which the config must be in + +### Categories + +Valid categories for configs are: + +- `ssd`` - traditional`SS.VPS`style servers` +- `bare-metal`` - physical servers, no hypervisor +- `gp-compute`` +- `mem-optimized`` +- `cpu-optimized`` + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/data-sources/network_zone.md b/docs/data-sources/network_zone.md new file mode 100644 index 0000000..a65b0da --- /dev/null +++ b/docs/data-sources/network_zone.md @@ -0,0 +1,29 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_network_zone Data Source - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_network_zone (Data Source) + +Allows querying a network zone, as in different regions of infrastructure. + + +## Schema + +### Optional + +- `name` (String) +- `region_id` (Number) +- `region_name` (String) + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) +- `network_zone_id` (String) +- `region` (Map of String) +- `status` (String) +- `valid_source_hvs` (Map of String) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..838d2c2 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,48 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb Provider" +subcategory: "" +description: |- + +LiquidWeb Provider + +--- + +# liquidweb Provider + +Provider is used to interact with LiquidWeb resources. +This provider requires credentials to be used. + +## Example Usage + +Environment variables must also be set: + +- `LWAPI_USERNAME` - the username to connect as +- `LWAPI_PASSWORD` - the password or auth token to use + +```hcl +terraform { + required_providers { + liquidweb = { + source = "liquidweb/liquidweb" + version = "~> 1.7.0" + } + } +} + +# creates a sever +resource "liquidweb_cloud_server" "server" { + config_id = 1757 + zone = 27 + template = "ROCKYLINUX_8_UNMANAGED" + domain = "hostname.example.com" + password = "randomPassword" +} +``` + +## Argument Reference + +- `LWAPI_USERNAME` +- `LWAPI_PASSWORD`` + +These environment variables are used to set your credentials for the provider. diff --git a/docs/resources/cloud_block_storage.md b/docs/resources/cloud_block_storage.md new file mode 100644 index 0000000..a896919 --- /dev/null +++ b/docs/resources/cloud_block_storage.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_cloud_block_storage Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_cloud_block_storage (Resource) + + + + + + +## Schema + +### Required + +- `domain` (String) +- `size` (Number) + +### Optional + +- `attach` (String) +- `cross_attach` (Boolean) +- `region` (Number) + +### Read-Only + +- `attached_to` (List of Object) (see [below for nested schema](#nestedatt--attached_to)) +- `id` (String) The ID of this resource. +- `label` (String) +- `status` (String) +- `zone` (Number) +- `zone_availability` (List of Number) + + +### Nested Schema for `attached_to` + +Read-Only: + +- `device` (String) +- `resource` (String) diff --git a/docs/resources/cloud_server.md b/docs/resources/cloud_server.md new file mode 100644 index 0000000..d8b6e27 --- /dev/null +++ b/docs/resources/cloud_server.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_cloud_server Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_cloud_server (Resource) + + +## Schema + +### Required + +- `config_id` (Number) - config to make, determines resources +- `zone` (Number) - network zone for create server +- `domain` (String) - hostname of server, must be unique + +### Optional + +- `password` (String) - a root password is required +- `public_ssh_key` (String) - single ssh key for root +- `template` (String) - generic template create from +- `image_id` (Number) - server image to create from +- `backup_enabled` (Number) +- `backup_plan` (String) +- `backup_quota` (Number) +- `bandwidth_quota` (String) + +### Read-Only + +- `accnt` (Number) +- `active` (Number) +- `backup_size` (String) +- `config_description` (String) +- `id` (String) The ID of this resource. +- `ip` (String) +- `ip_count` (Number) +- `manage_level` (String) +- `memory` (Number) +- `template_description` (String) +- `type` (String) +- `vcpu` (Number) diff --git a/docs/resources/network_dns_record.md b/docs/resources/network_dns_record.md new file mode 100644 index 0000000..60e750e --- /dev/null +++ b/docs/resources/network_dns_record.md @@ -0,0 +1,48 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_network_dns_record Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_network_dns_record (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) +- `rdata` (String) +- `type` (String) +- `zone` (String) + +### Optional + +- `prio` (Number) +- `refresh_interval` (String) +- `ttl` (Number) + +### Read-Only + +- `admin_email` (String) +- `created` (String) +- `exchange` (String) +- `expiry` (String) +- `full_data` (String) +- `id` (String) The ID of this resource. +- `last_updated` (String) +- `minimum` (String) +- `nameserver` (String) +- `port` (Number) +- `region_overrides` (Map of String) +- `retry` (Number) +- `serial` (String) +- `target` (String) +- `weight` (Number) +- `zone_id` (Number) diff --git a/docs/resources/network_load_balancer.md b/docs/resources/network_load_balancer.md new file mode 100644 index 0000000..351f96a --- /dev/null +++ b/docs/resources/network_load_balancer.md @@ -0,0 +1,46 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_network_load_balancer Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_network_load_balancer (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) +- `service` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--service)) + +### Optional + +- `nodes` (Set of String) +- `region` (Number) +- `session_persistence` (Boolean) +- `ssl_cert` (String) +- `ssl_includes` (Boolean) +- `ssl_int` (String) +- `ssl_key` (String) +- `ssl_termination` (Boolean) +- `strategy` (String) + +### Read-Only + +- `id` (String) The ID of this resource. +- `vip` (String) + + +### Nested Schema for `service` + +Required: + +- `dest_port` (Number) +- `src_port` (Number) diff --git a/docs/resources/network_vip.md b/docs/resources/network_vip.md new file mode 100644 index 0000000..1080d04 --- /dev/null +++ b/docs/resources/network_vip.md @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_network_vip Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_network_vip (Resource) + + + + + + +## Schema + +### Required + +- `domain` (String) +- `zone` (Number) + +### Read-Only + +- `active` (Number) +- `active_status` (String) +- `destroyed` (String) +- `id` (String) The ID of this resource. +- `ip` (String) +- `subaccnt` (String) +- `uniq_id` (String) diff --git a/docs/resources/storage_block_volume.md b/docs/resources/storage_block_volume.md new file mode 100644 index 0000000..12ee155 --- /dev/null +++ b/docs/resources/storage_block_volume.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "liquidweb_storage_block_volume Resource - terraform-provider-liquidweb" +subcategory: "" +description: |- + +--- + +# liquidweb_storage_block_volume (Resource) + + + + + + +## Schema + +### Required + +- `domain` (String) +- `size` (Number) + +### Optional + +- `attach` (String) +- `cross_attach` (Boolean) +- `region` (Number) + +### Read-Only + +- `attached_to` (List of Object) (see [below for nested schema](#nestedatt--attached_to)) +- `id` (String) The ID of this resource. +- `label` (String) +- `status` (String) +- `zone` (Number) +- `zone_availability` (List of Number) + + +### Nested Schema for `attached_to` + +Read-Only: + +- `device` (String) +- `resource` (String) diff --git a/go.mod b/go.mod index 39e6833..038b7c2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/liquidweb/terraform-provider-liquidweb replace git.apache.org/thrift.git => github.com/apache/thrift v0.12.0 require ( - github.com/BurntSushi/toml v0.3.1 github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/liquidweb/liquidweb-go v1.6.0 github.com/opentracing/opentracing-go v1.1.0 @@ -56,7 +55,6 @@ require ( github.com/imdario/mergo v0.3.12 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jstemmer/go-junit-report v0.9.1 // indirect - github.com/kkyr/fig v0.3.2 // indirect github.com/klauspost/compress v1.11.2 // indirect github.com/mattn/go-colorable v0.1.1 // indirect github.com/mattn/go-isatty v0.0.5 // indirect @@ -69,7 +67,6 @@ require ( github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/oklog/run v1.0.0 // indirect - github.com/pelletier/go-toml v1.9.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/posener/complete v1.2.1 // indirect github.com/spf13/afero v1.2.2 // indirect diff --git a/go.sum b/go.sum index af9c8b9..d67d19d 100644 --- a/go.sum +++ b/go.sum @@ -33,7 +33,6 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= @@ -241,8 +240,6 @@ github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgy github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkyr/fig v0.3.2 h1:+vMj52FL6RJUxeKOBB6JXIMyyi1/2j1ERDrZXjoBjzM= -github.com/kkyr/fig v0.3.2/go.mod h1:ItUILF8IIzgZOMhx5xpJ1W/bviQsWRKOwKXfE/tqUoA= github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -282,7 +279,6 @@ github.com/mitchellh/go-testing-interface v1.0.4/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -294,8 +290,6 @@ github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -643,7 +637,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/liquidweb/data_source_storm_server_config.go b/liquidweb/data_source_cloud_server_config.go similarity index 94% rename from liquidweb/data_source_storm_server_config.go rename to liquidweb/data_source_cloud_server_config.go index 6f2acd5..b20cbdd 100644 --- a/liquidweb/data_source_storm_server_config.go +++ b/liquidweb/data_source_cloud_server_config.go @@ -45,7 +45,7 @@ func dataSourceServerConfig() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "disk": { + "disk": { // disk space (in GB) included with VM Type: schema.TypeInt, Optional: true, }, @@ -54,15 +54,15 @@ func dataSourceServerConfig() *schema.Resource { Default: false, Optional: true, }, - "memory": { + "memory": { // memory (in mb) included with vm Type: schema.TypeInt, Optional: true, }, - "vcpu": { + "vcpu": { // CPU threads / vcpus included with vm Type: schema.TypeInt, Optional: true, }, - "zone_availability": { + "zone_availability": { // which zones this config is availble in Type: schema.TypeMap, Optional: true, }, diff --git a/terraform-registry-manifest.json b/terraform-registry-manifest.json new file mode 100644 index 0000000..625ab56 --- /dev/null +++ b/terraform-registry-manifest.json @@ -0,0 +1,6 @@ +{ + "version": 1, + "metadata": { + "protocol_versions": ["5.0"] + } +} \ No newline at end of file From cea725239b6a84fcc899066a22bf8d68d566bfad Mon Sep 17 00:00:00 2001 From: Jack Hayhurst Date: Tue, 19 Sep 2023 14:15:56 -0400 Subject: [PATCH 6/6] setting up github actions and goreleaser --- .github/workflows/release.yml | 41 ++++++++++++++++++++++++ .goreleaser.yml | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3c2b34f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +# Terraform Provider release workflow. +name: Release + +# This GitHub action creates a release when a tag that matches the pattern +# "v*" (e.g. v0.1.0) is created. +on: + push: + tags: + - 'v*' + +# Releases need permissions to read and write the repository contents. +# GitHub considers creating releases and uploading assets as writing contents. +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + # Allow goreleaser to access older tag information. + fetch-depth: 0 + - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + with: + go-version-file: 'go.mod' + cache: true + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 + id: import_gpg + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0 + with: + args: release --clean + env: + # GitHub sets the GITHUB_TOKEN secret automatically. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..0e43eee --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,60 @@ +# Visit https://goreleaser.com for documentation on how to customize this +# behavior. +before: + hooks: + # this is just an example and not a requirement for provider building/publishing + - go mod tidy +builds: +- env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like Terraform Cloud where + # they are unable to install libraries. + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - '386' + - arm + - arm64 + ignore: + - goos: darwin + goarch: '386' + binary: '{{ .ProjectName }}_v{{ .Version }}' +archives: +- format: zip + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' +checksum: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + algorithm: sha256 +signs: + - artifacts: checksum + args: + # if you are using this in a GitHub action or some other automated pipeline, you + # need to pass the batch flag to indicate its not interactive. + - "--batch" + - "--local-user" + - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" +release: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + # If you want to manually examine the release before its live, uncomment this line: + # draft: true +changelog: + skip: true \ No newline at end of file