diff --git a/civo/acceptance/acceptance.go b/civo/acceptance/acceptance.go new file mode 100644 index 00000000..522fa1d3 --- /dev/null +++ b/civo/acceptance/acceptance.go @@ -0,0 +1,86 @@ +package acceptance + +import ( + "context" + "os" + "strings" + + "testing" + + "github.com/civo/terraform-provider-civo/civo" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +var ( + // TestAccProvider is a global instance of the provider under test. + // It is used in acceptance tests to configure resources. + TestAccProvider *schema.Provider + + // TestAccProviders is a map of provider instances keyed by their name. + // It is used in acceptance tests where multiple providers are in play. + TestAccProviders map[string]*schema.Provider + + // TestAccProviderFactories is a map of functions that return a provider instance and an error. + // It is used in acceptance tests where the provider needs to be configured in a certain way. + TestAccProviderFactories map[string]func() (*schema.Provider, error) +) + +func init() { + TestAccProvider = civo.Provider() + TestAccProviders = map[string]*schema.Provider{ + "civo": TestAccProvider, + } + TestAccProviderFactories = map[string]func() (*schema.Provider, error){ + "civo": func() (*schema.Provider, error) { + return TestAccProvider, nil + }, + } +} + +// TestProvider - Test the provider itself +func TestProvider(t *testing.T) { + if err := civo.Provider().InternalValidate(); err != nil { + t.Fatalf("err: %s", err) + } +} + +// TestProviderImpl is a test function to ensure that the Provider function of the civo package +// returns an instance of the *schema.Provider type. It doesn't test any behavior of the provider itself. +func TestProviderImpl(t *testing.T) { + var _ *schema.Provider = civo.Provider() +} + +// TestToken - Test the provider token +func TestToken(t *testing.T) { + rawProvider := civo.Provider() + raw := map[string]interface{}{ + "token": "123456789", + } + + diags := rawProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw)) + if diags.HasError() { + t.Fatalf("provider configure failed: %s", DiagnosticsToString(diags)) + } +} + +// DiagnosticsToString - Convert diag.Diagnostics to string +func DiagnosticsToString(diags diag.Diagnostics) string { + diagsAsStrings := make([]string, len(diags)) + for i, diag := range diags { + diagsAsStrings[i] = diag.Summary + } + + return strings.Join(diagsAsStrings, "; ") +} + +// TestAccPreCheck - Check if the environment variables are set +func TestAccPreCheck(t *testing.T) { + if v := os.Getenv("CIVO_TOKEN"); v == "" { + t.Fatal("CIVO_TOKEN must be set for acceptance tests") + } + if v := os.Getenv("CIVO_REGION"); v == "" { + t.Fatal("CIVO_REGION must be set for acceptance tests") + } +} diff --git a/civo/acceptance/instances.go b/civo/acceptance/instances.go new file mode 100644 index 00000000..ad80d23b --- /dev/null +++ b/civo/acceptance/instances.go @@ -0,0 +1,51 @@ +package acceptance + +import ( + "fmt" + + "github.com/civo/civogo" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +// CivoInstanceDestroy is used to destroy the instance created during the test +func CivoInstanceDestroy(s *terraform.State) error { + client := TestAccProvider.Meta().(*civogo.Client) + + for _, rs := range s.RootModule().Resources { + if rs.Type != "civo_instance" { + continue + } + + _, err := client.GetInstance(rs.Primary.ID) + if err != nil { + return fmt.Errorf("instance still exists") + } + } + + return nil +} + +// CivoInstanceResourceExists queries the API and retrieves the matching Widget. +func CivoInstanceResourceExists(n string, instance *civogo.Instance) resource.TestCheckFunc { + return func(s *terraform.State) error { + // find the corresponding state object + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("not found: %s", n) + } + + // retrieve the configured client from the test setup + client := TestAccProvider.Meta().(*civogo.Client) + resp, err := client.GetInstance(rs.Primary.ID) + if err != nil { + return fmt.Errorf("instance not found: (%s) %s", rs.Primary.ID, err) + } + + // If no error, assign the response Widget attribute to the widget pointer + *instance = *resp + + // return fmt.Errorf("Domain (%s) not found", rs.Primary.ID) + return nil + } +} diff --git a/civo/acceptance/ip.go b/civo/acceptance/ip.go new file mode 100644 index 00000000..8337ef12 --- /dev/null +++ b/civo/acceptance/ip.go @@ -0,0 +1,31 @@ +package acceptance + +import ( + "fmt" + + "github.com/civo/civogo" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +// CivoReservedIPResourceExists queries the API and retrieves the matching Widget. +func CivoReservedIPResourceExists(n string, ip *civogo.IP) resource.TestCheckFunc { + return func(s *terraform.State) error { + // find the corresponding state object + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("not found: %s", n) + } + + // retrieve the configured client from the test setup + client := TestAccProvider.Meta().(*civogo.Client) + resp, err := client.FindIP(rs.Primary.ID) + if err != nil { + return fmt.Errorf("ip not found: (%s) %s", rs.Primary.ID, err) + } + + *ip = *resp + + return nil + } +} diff --git a/civo/acceptance/kubernetes.go b/civo/acceptance/kubernetes.go new file mode 100644 index 00000000..f4b1fe40 --- /dev/null +++ b/civo/acceptance/kubernetes.go @@ -0,0 +1,26 @@ +package acceptance + +import ( + "fmt" + + "github.com/civo/civogo" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +// CivoKubernetesClusterDestroy is used to destroy the kubernetes cluster created during the test +func CivoKubernetesClusterDestroy(s *terraform.State) error { + client := TestAccProvider.Meta().(*civogo.Client) + + for _, rs := range s.RootModule().Resources { + if rs.Type != "civo_kubernetes_cluster" { + continue + } + + _, err := client.GetKubernetesCluster(rs.Primary.ID) + if err == nil { + return fmt.Errorf("kubernetes Cluster still exists") + } + } + + return nil +} diff --git a/civo/datasource_database.go b/civo/database/datasource_database.go similarity index 96% rename from civo/datasource_database.go rename to civo/database/datasource_database.go index d5e337f7..868d6eb0 100644 --- a/civo/datasource_database.go +++ b/civo/database/datasource_database.go @@ -1,4 +1,4 @@ -package civo +package database import ( "context" @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific Database +// DataSourceDatabase Data source to get from the api a specific Database // using the id or the name -func dataSourceDatabase() *schema.Resource { +func DataSourceDatabase() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information of an Database for use in other resources. This data source provides all of the Database's properties as configured on your Civo account.", diff --git a/civo/datasource_database_test.go b/civo/database/datasource_database_test.go similarity index 71% rename from civo/datasource_database_test.go rename to civo/database/datasource_database_test.go index ea1424a2..dc92d025 100644 --- a/civo/datasource_database_test.go +++ b/civo/database/datasource_database_test.go @@ -1,23 +1,25 @@ -package civo +package database_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) +// TestAccDataSourceCivoDatabase_basic is used to test the data source func TestAccDataSourceCivoDatabase_basic(t *testing.T) { datasourceName := "data.civo_database.foobar" name := acctest.RandomWithPrefix("database") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoDatabaseConfig(name), + Config: DataSourceCivoDatabaseConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttrSet(datasourceName, "size"), @@ -31,7 +33,8 @@ func TestAccDataSourceCivoDatabase_basic(t *testing.T) { }) } -func testAccDataSourceCivoDatabaseConfig(name string) string { +// DataSourceCivoDatabaseConfig is used to configure the data source +func DataSourceCivoDatabaseConfig(name string) string { return fmt.Sprintf(` resource "civo_database" "foobar" { name = "%s" diff --git a/civo/datasource_database_version.go b/civo/database/datasource_database_version.go similarity index 85% rename from civo/datasource_database_version.go rename to civo/database/datasource_database_version.go index 32bba32a..c8b3c156 100644 --- a/civo/datasource_database_version.go +++ b/civo/database/datasource_database_version.go @@ -1,4 +1,4 @@ -package civo +package database import ( "fmt" @@ -7,16 +7,16 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// DatabaseVersion is a temporal struct to save all versions -type DatabaseVersion struct { +// Version is a temporal struct to save all versions +type Version struct { Engine string Version string Default bool } -// Data source to get and filter all database version +// DataDatabaseVersion Data source to get and filter all database version // use to define the engine and version in resourceDatabase -func dataDatabaseVersion() *schema.Resource { +func DataDatabaseVersion() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ Description: "Retrieves information about the database versions that Civo supports, with the ability to filter the results.", RecordSchema: versionSchema(), @@ -37,10 +37,10 @@ func getVersion(m interface{}, _ map[string]interface{}) ([]interface{}, error) return nil, fmt.Errorf("[ERR] error retrieving version: %s", err) } - versionList := []DatabaseVersion{} + versionList := []Version{} for k, v := range partialVersions { for _, version := range v { - versionList = append(versionList, DatabaseVersion{ + versionList = append(versionList, Version{ Engine: k, Version: version.SoftwareVersion, Default: version.Default, @@ -56,7 +56,7 @@ func getVersion(m interface{}, _ map[string]interface{}) ([]interface{}, error) } func flattenVersion(versions, _ interface{}, _ map[string]interface{}) (map[string]interface{}, error) { - s := versions.(DatabaseVersion) + s := versions.(Version) flattenedSize := map[string]interface{}{} flattenedSize["engine"] = s.Engine diff --git a/civo/datasource_database_version_test.go b/civo/database/datasource_database_version_test.go similarity index 60% rename from civo/datasource_database_version_test.go rename to civo/database/datasource_database_version_test.go index 53a40fcb..c90fdfa7 100644 --- a/civo/datasource_database_version_test.go +++ b/civo/database/datasource_database_version_test.go @@ -1,50 +1,54 @@ -package civo +package database_test import ( "fmt" "strconv" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) +// TestAccDataSourceCivoDatabaseVersion_basic - Test the data source for database version func TestAccDataSourceCivoDatabaseVersion_basic(t *testing.T) { datasourceName := "data.civo_database_version.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoDatabaseVersionConfig(), + Config: DataSourceCivoDatabaseVersionConfig(), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckDataSourceDatabaseVersionExist(datasourceName), + DataSourceDatabaseVersionExist(datasourceName), ), }, }, }) } +// TestAccDataSourceCivoDatabaseVersion_WithFilterAndSort - Test the data source for database version with filter and sort func TestAccDataSourceCivoDatabaseVersion_WithFilterAndSort(t *testing.T) { datasourceName := "data.civo_database_version.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoDatabaseVersionWhitFilterAndSort(), + Config: DataSourceCivoDatabaseVersionWhitFilterAndSort(), Check: resource.ComposeTestCheckFunc( - testAccCheckDataSourceDatabaseVersionExist(datasourceName), - testAccCheckDataSourceCivoDatabaseVersionFilteredAndSorted(datasourceName), + DataSourceDatabaseVersionExist(datasourceName), + DataSourceCivoDatabaseVersionFilteredAndSorted(datasourceName), ), }, }, }) } -func testAccCheckDataSourceDatabaseVersionExist(n string) resource.TestCheckFunc { +// DataSourceDatabaseVersionExist - Check if the data source exist +func DataSourceDatabaseVersionExist(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -70,7 +74,8 @@ func testAccCheckDataSourceDatabaseVersionExist(n string) resource.TestCheckFunc } } -func testAccCheckDataSourceCivoDatabaseVersionFilteredAndSorted(n string) resource.TestCheckFunc { +// DataSourceCivoDatabaseVersionFilteredAndSorted - Check if the data source is filtered and sorted +func DataSourceCivoDatabaseVersionFilteredAndSorted(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -104,14 +109,16 @@ func testAccCheckDataSourceCivoDatabaseVersionFilteredAndSorted(n string) resour } } -func testAccDataSourceCivoDatabaseVersionConfig() string { +// DataSourceCivoDatabaseVersionConfig - Config for the data source +func DataSourceCivoDatabaseVersionConfig() string { return ` data "civo_database_version" "foobar" { } ` } -func testAccDataSourceCivoDatabaseVersionWhitFilterAndSort() string { +// DataSourceCivoDatabaseVersionWhitFilterAndSort - Config for the data source with filter and sort +func DataSourceCivoDatabaseVersionWhitFilterAndSort() string { return ` data "civo_database_version" "foobar" { filter { diff --git a/civo/resource_database.go b/civo/database/resource_database.go similarity index 98% rename from civo/resource_database.go rename to civo/database/resource_database.go index def3acca..a4c9ed5f 100644 --- a/civo/resource_database.go +++ b/civo/database/resource_database.go @@ -1,4 +1,4 @@ -package civo +package database import ( "context" @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// The Database resource represents an Database object +// ResourceDatabase The Database resource represents an Database object // and with it you can handle the Database created with Terraform. -func resourceDatabase() *schema.Resource { +func ResourceDatabase() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { diff --git a/civo/resource_database_test.go b/civo/database/resource_database_test.go similarity index 63% rename from civo/resource_database_test.go rename to civo/database/resource_database_test.go index 9968a15a..d51f5ce4 100644 --- a/civo/resource_database_test.go +++ b/civo/database/resource_database_test.go @@ -1,15 +1,17 @@ -package civo +package database_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) +// CivoDatabase_basic is used to test the database resource func TestAccCivoDatabase_basic(t *testing.T) { var database civogo.Database @@ -18,19 +20,19 @@ func TestAccCivoDatabase_basic(t *testing.T) { var databaseName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDatabaseDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDatabaseDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDatabaseConfigBasic(databaseName), + Config: CivoDatabaseConfigBasic(databaseName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoDatabaseResourceExists(resName, &database), + CivoDatabaseResourceExists(resName, &database), // verify remote values - testAccCheckCivoDatabaseValues(&database, databaseName), + CivoDatabaseValues(&database, databaseName), // verify local values resource.TestCheckResourceAttr(resName, "name", databaseName), resource.TestCheckResourceAttrSet(resName, "size"), @@ -44,6 +46,7 @@ func TestAccCivoDatabase_basic(t *testing.T) { }) } +// CivoDatabase_update is used to test the database resource func TestAccCivoDatabase_update(t *testing.T) { var database civogo.Database @@ -52,25 +55,25 @@ func TestAccCivoDatabase_update(t *testing.T) { var databaseName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDatabaseDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDatabaseDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoDatabaseConfigBasic(databaseName), + Config: CivoDatabaseConfigBasic(databaseName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDatabaseResourceExists(resName, &database), - testAccCheckCivoDatabaseValues(&database, databaseName), + CivoDatabaseResourceExists(resName, &database), + CivoDatabaseValues(&database, databaseName), resource.TestCheckResourceAttr(resName, "name", databaseName), resource.TestCheckResourceAttr(resName, "status", "Ready"), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDatabaseConfigUpdates(databaseName), + Config: CivoDatabaseConfigUpdates(databaseName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDatabaseResourceExists(resName, &database), - testAccCheckCivoDatabaseUpdated(&database, databaseName), + CivoDatabaseResourceExists(resName, &database), + CivoDatabaseUpdated(&database, databaseName), resource.TestCheckResourceAttr(resName, "name", databaseName), resource.TestCheckResourceAttr(resName, "status", "Ready"), ), @@ -79,7 +82,8 @@ func TestAccCivoDatabase_update(t *testing.T) { }) } -func testAccCheckCivoDatabaseValues(database *civogo.Database, name string) resource.TestCheckFunc { +// CivoDatabaseConfig is used to configure the database resource +func CivoDatabaseValues(database *civogo.Database, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if database.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, database.Name) @@ -88,8 +92,8 @@ func testAccCheckCivoDatabaseValues(database *civogo.Database, name string) reso } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoDatabaseResourceExists(n string, database *civogo.Database) resource.TestCheckFunc { +// CivoDatabaseResourceExists - Check if the database resource exist +func CivoDatabaseResourceExists(n string, database *civogo.Database) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -98,7 +102,7 @@ func testAccCheckCivoDatabaseResourceExists(n string, database *civogo.Database) } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindDatabase(rs.Primary.ID) if err != nil { return fmt.Errorf("Database not found: (%s) %s", rs.Primary.ID, err) @@ -111,7 +115,8 @@ func testAccCheckCivoDatabaseResourceExists(n string, database *civogo.Database) } } -func testAccCheckCivoDatabaseUpdated(database *civogo.Database, name string) resource.TestCheckFunc { +// CivoDatabaseUpdated - Check if the database resource is updated +func CivoDatabaseUpdated(database *civogo.Database, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if database.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, database.Name) @@ -120,8 +125,9 @@ func testAccCheckCivoDatabaseUpdated(database *civogo.Database, name string) res } } -func testAccCheckCivoDatabaseDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +// CivoDatabaseDestroy is used to destroy the database created during the test +func CivoDatabaseDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_database" { @@ -137,7 +143,8 @@ func testAccCheckCivoDatabaseDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoDatabaseConfigBasic(name string) string { +// CivoDatabaseConfigBasic is used to configure the database resource +func CivoDatabaseConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_database" "foobar" { name = "%s" @@ -148,7 +155,8 @@ resource "civo_database" "foobar" { }`, name) } -func testAccCheckCivoDatabaseConfigUpdates(name string) string { +// CivoDatabaseConfigUpdates is used to configure the database resource +func CivoDatabaseConfigUpdates(name string) string { return fmt.Sprintf(` resource "civo_database" "foobar" { name = "%s" diff --git a/civo/datasource_snapshot.go.disabled b/civo/datasource_snapshot.go.disabled deleted file mode 100644 index 2c6474b1..00000000 --- a/civo/datasource_snapshot.go.disabled +++ /dev/null @@ -1,133 +0,0 @@ -package civo - -import ( - "fmt" - "log" - "time" - - "github.com/civo/civogo" - "github.com/gorhill/cronexpr" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -// Data source to get from the api a specific snapshot -// using the id or the name -func dataSourceSnapshot() *schema.Resource { - return &schema.Resource{ - Description: "Snapshots are saved instances of a block storage volume. Use this data source to retrieve the ID of a Civo snapshot for use in other resources.", - Read: dataSourceSnapshotRead, - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - ExactlyOneOf: []string{"id", "name"}, - }, - "name": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - ExactlyOneOf: []string{"id", "name"}, - Description: "The name of the snapshot", - }, - // Computed resource - "instance_id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the instance from which the snapshot was be taken", - }, - "safe": { - Type: schema.TypeBool, - Computed: true, - Description: "If `true`, the instance will be shut down during the snapshot", - }, - "cron_timing": { - Type: schema.TypeString, - Computed: true, - Description: "A string with the cron format", - }, - "hostname": { - Type: schema.TypeString, - Computed: true, - Description: "The hostname of the instance", - }, - "template_id": { - Type: schema.TypeString, - Computed: true, - Description: "The disk image/template ID", - }, - "region": { - Type: schema.TypeString, - Computed: true, - Description: "The region where the snapshot was taken", - }, - "size_gb": { - Type: schema.TypeInt, - Computed: true, - Description: "The size of the snapshot in GB", - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: "The status of the snapshot", - }, - "next_execution": { - Type: schema.TypeString, - Computed: true, - Description: "If cron was define this date will be the next execution date", - }, - "requested_at": { - Type: schema.TypeString, - Computed: true, - Description: "The date where the snapshot was requested", - }, - "completed_at": { - Type: schema.TypeString, - Computed: true, - Description: "The date where the snapshot was completed", - }, - }, - } -} - -func dataSourceSnapshotRead(d *schema.ResourceData, m interface{}) error { - apiClient := m.(*civogo.Client) - - var searchBy string - - if id, ok := d.GetOk("id"); ok { - log.Printf("[INFO] Getting the snapshot key by id") - searchBy = id.(string) - } else if name, ok := d.GetOk("name"); ok { - log.Printf("[INFO] Getting the snapshot key by label") - searchBy = name.(string) - } - - snapShot, err := apiClient.FindSnapshot(searchBy) - if err != nil { - return fmt.Errorf("[ERR] failed to retrive snapshot: %s", err) - } - - d.SetId(snapShot.ID) - d.Set("name", snapShot.Name) - d.Set("instance_id", snapShot.InstanceID) - d.Set("safe", snapShot.Safe) - d.Set("cron_timing", snapShot.Cron) - d.Set("hostname", snapShot.Hostname) - d.Set("template_id", snapShot.Template) - d.Set("region", snapShot.Region) - d.Set("size_gb", snapShot.SizeGigabytes) - d.Set("state", snapShot.State) - - nextExecution := time.Time{} - if snapShot.Cron != "" { - nextExecution = cronexpr.MustParse(snapShot.Cron).Next(time.Now().UTC()) - } - - d.Set("next_execution", nextExecution.String()) - d.Set("requested_at", snapShot.RequestedAt.UTC().String()) - d.Set("completed_at", snapShot.CompletedAt.UTC().String()) - - return nil -} diff --git a/civo/datasource_snapshot_test.go.disabled b/civo/datasource_snapshot_test.go.disabled deleted file mode 100644 index c5b9f176..00000000 --- a/civo/datasource_snapshot_test.go.disabled +++ /dev/null @@ -1,47 +0,0 @@ -package civo - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccDataSourceCivoSnapshots_basic(t *testing.T) { - datasourceName := "data.civo_snapshot.foobar" - name := acctest.RandomWithPrefix("snapshot-test") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceCivoSnapshotsConfig(name), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(datasourceName, "name", name), - resource.TestCheckResourceAttrSet(datasourceName, "hostname"), - resource.TestCheckResourceAttrSet(datasourceName, "size_gb"), - ), - }, - }, - }) -} - -func testAccDataSourceCivoSnapshotsConfig(name string) string { - return fmt.Sprintf(` -resource "civo_instance" "vm" { - hostname = "instance-%s" -} - -resource "civo_snapshot" "foobar" { - name = "%s" - instance_id = civo_instance.vm.id -} - -data "civo_snapshot" "foobar" { - name = civo_snapshot.foobar.name -} -`, name, name) -} - diff --git a/civo/datasource_template.go.disabled b/civo/datasource_template.go.disabled deleted file mode 100644 index e82db1d3..00000000 --- a/civo/datasource_template.go.disabled +++ /dev/null @@ -1,127 +0,0 @@ -package civo - -import ( - "fmt" - "strings" - - "github.com/civo/civogo" - "github.com/civo/terraform-provider-civo/internal/datalist" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -// TemplateDisk is a temporal struct to get all template in one place -type TemplateDisk struct { - ID string - Name string - Version string - Label string -} - -// Data source to get from the api a specific template -// using the code of the image -func dataSourceTemplate() *schema.Resource { - - dataListConfig := &datalist.ResourceConfig{ - Description: strings.Join([]string{ - "`civo_template` data source is deprecated. Moving forward, please use `civo_disk_image` data source.", - "Get information on an template for use in other resources (e.g. creating a instance) with the ability to filter the results.", - }, "\n\n"), - RecordSchema: templateSchema(), - ExtraQuerySchema: map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Optional: true, - }, - }, - ResultAttributeName: "templates", - FlattenRecord: flattenTemplate, - GetRecords: getTemplates, - } - - sr := datalist.NewResource(dataListConfig) - sr.DeprecationMessage = "\"civo_template\" data source is deprecated. Moving forward, please use \"civo_disk_image\" data source." - return sr -} - -func getTemplates(m interface{}, extra map[string]interface{}) ([]interface{}, error) { - apiClient := m.(*civogo.Client) - - // overwrite the region if is define in the datasource - region, ok := extra["region"].(string) - if !ok { - return nil, fmt.Errorf("unable to find `region` key from query data") - } - - if region != "" { - apiClient.Region = region - } - - templateDiskList := []TemplateDisk{} - - if apiClient.Region == "SVG1" { - templates, err := apiClient.ListTemplates() - if err != nil { - return nil, fmt.Errorf("[ERR] error retrieving all templates: %s", err) - } - - for _, v := range templates { - templateDiskList = append(templateDiskList, TemplateDisk{ID: v.ID, Name: v.Name, Version: v.Code, Label: v.ShortDescription}) - } - } else { - diskImage, err := apiClient.ListDiskImages() - if err != nil { - return nil, fmt.Errorf("[ERR] error retrieving all Disk Images: %s", err) - } - - for _, v := range diskImage { - templateDiskList = append(templateDiskList, TemplateDisk{ID: v.ID, Name: v.Name, Version: v.Version, Label: v.Label}) - } - - } - - templates := []interface{}{} - for _, partialSize := range templateDiskList { - templates = append(templates, partialSize) - } - - return templates, nil -} - -func flattenTemplate(template, m interface{}, extra map[string]interface{}) (map[string]interface{}, error) { - - s := template.(TemplateDisk) - - flattenedTemplate := map[string]interface{}{} - flattenedTemplate["id"] = s.ID - flattenedTemplate["name"] = s.Name - flattenedTemplate["version"] = s.Version - flattenedTemplate["label"] = s.Label - - return flattenedTemplate, nil -} - -func templateSchema() map[string]*schema.Schema { - - return map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "ID of disk image/template", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Name of disk image/template", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "Version of disk image/template", - }, - "label": { - Type: schema.TypeString, - Computed: true, - Description: "Label of disk image/template", - }, - } -} diff --git a/civo/datasource_template_test.go.disabled b/civo/datasource_template_test.go.disabled deleted file mode 100644 index 412249d4..00000000 --- a/civo/datasource_template_test.go.disabled +++ /dev/null @@ -1,128 +0,0 @@ -package civo - -import ( - "fmt" - "strconv" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccDataSourceCivoTemplate_basic(t *testing.T) { - datasourceName := "data.civo_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceCivoTemplatesConfig(), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckDataSourceCivoTemplateExist(datasourceName), - ), - }, - }, - }) -} - -func TestAccDataSourceCivoTemplate_WithFilter(t *testing.T) { - datasourceName := "data.civo_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceCivoTemplatesConfigWhitFilter(), - Check: resource.ComposeTestCheckFunc( - testAccCheckDataSourceCivoTemplateExist(datasourceName), - testAccCheckDataSourceCivoTemplatesFiltered(datasourceName), - ), - }, - }, - }) -} - -func testAccCheckDataSourceCivoTemplateExist(n string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("No Record ID is set") - } - - rawTotal := rs.Primary.Attributes["templates.#"] - total, err := strconv.Atoi(rawTotal) - if err != nil { - return err - } - - if total < 1 { - return fmt.Errorf("No Civo templates retrieved") - } - - return nil - } -} - -func testAccCheckDataSourceCivoTemplatesFiltered(n string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - rawTotal := rs.Primary.Attributes["templates.#"] - total, err := strconv.Atoi(rawTotal) - if err != nil { - return err - } - - stringInSlice := func(value string, slice []string) bool { - for _, item := range slice { - if item == value { - return true - } - } - return false - } - - var prevCode string - for i := 0; i < total; i++ { - code := rs.Primary.Attributes[fmt.Sprintf("templates.%d.code", i)] - if !stringInSlice(code, []string{"debian-stretch", "debian-buster"}) { - return fmt.Errorf("Code is not in expected test filter values") - } - if prevCode != "" && prevCode < code { - return fmt.Errorf("Template is not sorted by code") - } - prevCode = code - } - - return nil - } -} - -func testAccDataSourceCivoTemplatesConfig() string { - return ` -data "civo_template" "foobar" { -} -` -} - -func testAccDataSourceCivoTemplatesConfigWhitFilter() string { - return ` -data "civo_template" "foobar" { - filter { - key = "code" - values = ["debian"] - } -} -` -} diff --git a/civo/datasource_disk_image.go b/civo/disk/datasource_disk_image.go similarity index 95% rename from civo/datasource_disk_image.go rename to civo/disk/datasource_disk_image.go index d3c25540..635d9c15 100644 --- a/civo/datasource_disk_image.go +++ b/civo/disk/datasource_disk_image.go @@ -1,4 +1,4 @@ -package civo +package disk import ( "fmt" @@ -16,9 +16,9 @@ type TemplateDisk struct { Label string } -// Data source to get from the api a specific template +// DataSourceDiskImage Data source to get from the api a specific template // using the code of the image -func dataSourceDiskImage() *schema.Resource { +func DataSourceDiskImage() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ RecordSchema: diskimageSchema(), diff --git a/civo/datasource_dns_domain_name.go b/civo/dns/datasource_dns_domain_name.go similarity index 93% rename from civo/datasource_dns_domain_name.go rename to civo/dns/datasource_dns_domain_name.go index 8b79c9f3..b2d1d734 100644 --- a/civo/datasource_dns_domain_name.go +++ b/civo/dns/datasource_dns_domain_name.go @@ -1,4 +1,4 @@ -package civo +package dns import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// dataSourceDnsDomainName data source to get from the api a specific domain +// DataSourceDNSDomainName data source to get from the api a specific domain // using the id or the name of the domain -func dataSourceDNSDomainName() *schema.Resource { +func DataSourceDNSDomainName() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a domain. This data source provides the name and the id.", diff --git a/civo/datasource_dns_domain_name_test.go b/civo/dns/datasource_dns_domain_name_test.go similarity index 65% rename from civo/datasource_dns_domain_name_test.go rename to civo/dns/datasource_dns_domain_name_test.go index 78e07e57..df9a6859 100644 --- a/civo/datasource_dns_domain_name_test.go +++ b/civo/dns/datasource_dns_domain_name_test.go @@ -1,23 +1,25 @@ -package civo +package dns_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) +// TestAccCivoDNSDomainNameDataSource_basic is a basic test case for a DNS Domain Name data source. func TestAccDataSourceCivoDnsDomainName(t *testing.T) { datasourceName := "data.civo_dns_domain_name.domain" domain := acctest.RandomWithPrefix("domian") + ".com" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoDNSDomainName(domain), + Config: DataSourceCivoDNSDomainName(domain), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", domain), ), @@ -26,7 +28,7 @@ func TestAccDataSourceCivoDnsDomainName(t *testing.T) { }) } -func testAccDataSourceCivoDNSDomainName(domain string) string { +func DataSourceCivoDNSDomainName(domain string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "domain" { name = "%[1]s" diff --git a/civo/datasource_dns_domain_record.go b/civo/dns/datasource_dns_domain_record.go similarity index 95% rename from civo/datasource_dns_domain_record.go rename to civo/dns/datasource_dns_domain_record.go index e0f9a63e..abe35bca 100644 --- a/civo/datasource_dns_domain_record.go +++ b/civo/dns/datasource_dns_domain_record.go @@ -1,4 +1,4 @@ -package civo +package dns import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific domain record +// DataSourceDNSDomainRecord Data source to get from the api a specific domain record // using the id or the name of the domain -func dataSourceDNSDomainRecord() *schema.Resource { +func DataSourceDNSDomainRecord() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a DNS record. This data source provides the name, TTL, and zone file as configured on your Civo account.", diff --git a/civo/datasource_dns_domain_record_test.go b/civo/dns/datasource_dns_domain_record_test.go similarity index 75% rename from civo/datasource_dns_domain_record_test.go rename to civo/dns/datasource_dns_domain_record_test.go index fbaf59cc..0dfc2ad9 100644 --- a/civo/datasource_dns_domain_record_test.go +++ b/civo/dns/datasource_dns_domain_record_test.go @@ -1,23 +1,25 @@ -package civo +package dns_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) +// TestAccDataSourceCivoDNSDomainRecord_basic is a basic test case for a DNS domain record data source. func TestAccDataSourceCivoDNSDomainRecord_basic(t *testing.T) { datasourceName := "data.civo_dns_domain_record.record" domain := acctest.RandomWithPrefix("recordtest") + ".com" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoDNSDomainRecordConfigBasic(domain), + Config: DataSourceCivoDNSDomainRecordConfigBasic(domain), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", "www"), resource.TestCheckResourceAttr(datasourceName, "type", "a"), @@ -31,7 +33,7 @@ func TestAccDataSourceCivoDNSDomainRecord_basic(t *testing.T) { }) } -func testAccDataSourceCivoDNSDomainRecordConfigBasic(domain string) string { +func DataSourceCivoDNSDomainRecordConfigBasic(domain string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "domain" { name = "%[1]s" diff --git a/civo/import_dns_domain_name_test.go b/civo/dns/import_dns_domain_name_test.go similarity index 68% rename from civo/import_dns_domain_name_test.go rename to civo/dns/import_dns_domain_name_test.go index 323722fe..9f3b61bd 100644 --- a/civo/import_dns_domain_name_test.go +++ b/civo/dns/import_dns_domain_name_test.go @@ -1,10 +1,11 @@ -package civo +package dns_test import ( "testing" "fmt" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -14,12 +15,12 @@ func TestAccCivoDNSDomainName_importBasic(t *testing.T) { domainName := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoDNSDomainNameConfigBasic(domainName), + Config: CivoDNSDomainNameConfigBasic(domainName), }, { diff --git a/civo/import_dns_domain_record_test.go b/civo/dns/import_dns_domain_record_test.go similarity index 68% rename from civo/import_dns_domain_record_test.go rename to civo/dns/import_dns_domain_record_test.go index 9eb71d9f..d415bf15 100644 --- a/civo/import_dns_domain_record_test.go +++ b/civo/dns/import_dns_domain_record_test.go @@ -1,9 +1,10 @@ -package civo +package dns_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -15,24 +16,24 @@ func TestAccCivoDNSDomainRecord_importBasic(t *testing.T) { var recordName = acctest.RandomWithPrefix("record") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameRecordDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameRecordDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoDNSDomainNameRecordConfigBasic(domainName, recordName), + Config: CivoDNSDomainNameRecordConfigBasic(domainName, recordName), }, { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateIdFunc: testAccDNSDomainNameRecordImportID(resourceName), + ImportStateIdFunc: DNSDomainNameRecordImportID(resourceName), }, }, }) } -func testAccDNSDomainNameRecordImportID(n string) resource.ImportStateIdFunc { +func DNSDomainNameRecordImportID(n string) resource.ImportStateIdFunc { return func(s *terraform.State) (string, error) { rs, ok := s.RootModule().Resources[n] if !ok { diff --git a/civo/resource_dns_domain_name.go b/civo/dns/resource_dns_domain_name.go similarity index 96% rename from civo/resource_dns_domain_name.go rename to civo/dns/resource_dns_domain_name.go index 87fa0cee..c080a6a8 100644 --- a/civo/resource_dns_domain_name.go +++ b/civo/dns/resource_dns_domain_name.go @@ -1,4 +1,4 @@ -package civo +package dns import ( "context" @@ -10,8 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Dns Domain resource, with this we can create and manage DNS Domain -func resourceDNSDomainName() *schema.Resource { +// ResourceDNSDomainName Dns Domain resource, with this we can create and manage DNS Domain +func ResourceDNSDomainName() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo DNS domain name resource.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_dns_domain_name_test.go b/civo/dns/resource_dns_domain_name_test.go similarity index 65% rename from civo/resource_dns_domain_name_test.go rename to civo/dns/resource_dns_domain_name_test.go index 4a0b881c..fab059e6 100644 --- a/civo/resource_dns_domain_name_test.go +++ b/civo/dns/resource_dns_domain_name_test.go @@ -1,10 +1,11 @@ -package civo +package dns_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,19 +20,19 @@ func TestAccCivoDNSDomainName_basic(t *testing.T) { var domainName = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDNSDomainNameConfigBasic(domainName), + Config: CivoDNSDomainNameConfigBasic(domainName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoDNSDomainNameResourceExists(resName, &domain), + CivoDNSDomainNameResourceExists(resName, &domain), // verify remote values - testAccCheckCivoDNSDomainNameValues(&domain, domainName), + CivoDNSDomainNameValues(&domain, domainName), // verify local values resource.TestCheckResourceAttr(resName, "name", domainName), ), @@ -49,24 +50,24 @@ func TestAccCivoDNSDomainName_update(t *testing.T) { var domainNameUpdate = acctest.RandomWithPrefix("renamed-tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoDNSDomainNameConfigBasic(domainName), + Config: CivoDNSDomainNameConfigBasic(domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDNSDomainNameResourceExists(resName, &domain), - testAccCheckCivoDNSDomainNameValues(&domain, domainName), + CivoDNSDomainNameResourceExists(resName, &domain), + CivoDNSDomainNameValues(&domain, domainName), resource.TestCheckResourceAttr(resName, "name", domainName), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDNSDomainNameConfigUpdates(domainNameUpdate), + Config: CivoDNSDomainNameConfigUpdates(domainNameUpdate), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDNSDomainNameResourceExists(resName, &domain), - testAccCheckCivoDNSDomainNameUpdated(&domain, domainNameUpdate), + CivoDNSDomainNameResourceExists(resName, &domain), + CivoDNSDomainNameUpdated(&domain, domainNameUpdate), resource.TestCheckResourceAttr(resName, "name", domainNameUpdate), ), }, @@ -74,7 +75,7 @@ func TestAccCivoDNSDomainName_update(t *testing.T) { }) } -func testAccCheckCivoDNSDomainNameValues(domain *civogo.DNSDomain, name string) resource.TestCheckFunc { +func CivoDNSDomainNameValues(domain *civogo.DNSDomain, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if domain.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, domain.Name) @@ -83,8 +84,8 @@ func testAccCheckCivoDNSDomainNameValues(domain *civogo.DNSDomain, name string) } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoDNSDomainNameResourceExists(n string, domain *civogo.DNSDomain) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoDNSDomainNameResourceExists(n string, domain *civogo.DNSDomain) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -93,7 +94,7 @@ func testAccCheckCivoDNSDomainNameResourceExists(n string, domain *civogo.DNSDom } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindDNSDomain(rs.Primary.ID) if err != nil { return fmt.Errorf("Domain not found: (%s) %s", rs.Primary.ID, err) @@ -107,7 +108,7 @@ func testAccCheckCivoDNSDomainNameResourceExists(n string, domain *civogo.DNSDom } } -func testAccCheckCivoDNSDomainNameUpdated(domain *civogo.DNSDomain, name string) resource.TestCheckFunc { +func CivoDNSDomainNameUpdated(domain *civogo.DNSDomain, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if domain.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, domain.Name) @@ -116,8 +117,8 @@ func testAccCheckCivoDNSDomainNameUpdated(domain *civogo.DNSDomain, name string) } } -func testAccCheckCivoDNSDomainNameDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoDNSDomainNameDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_dns_domain_name" { @@ -133,14 +134,14 @@ func testAccCheckCivoDNSDomainNameDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoDNSDomainNameConfigBasic(domain string) string { +func CivoDNSDomainNameConfigBasic(domain string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "foobar" { name = "%s" }`, domain) } -func testAccCheckCivoDNSDomainNameConfigUpdates(domain string) string { +func CivoDNSDomainNameConfigUpdates(domain string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "foobar" { name = "%s" diff --git a/civo/resource_dns_domain_record.go b/civo/dns/resource_dns_domain_record.go similarity index 97% rename from civo/resource_dns_domain_record.go rename to civo/dns/resource_dns_domain_record.go index 54bd6cf7..69eb9df2 100644 --- a/civo/resource_dns_domain_record.go +++ b/civo/dns/resource_dns_domain_record.go @@ -1,4 +1,4 @@ -package civo +package dns import ( "context" @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// DNS domain record resource with this we can create and manage DNS Domain -func resourceDNSDomainRecord() *schema.Resource { +// ResourceDNSDomainRecord DNS domain record resource with this we can create and manage DNS Domain +func ResourceDNSDomainRecord() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo DNS domain record resource.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_dns_domain_record_test.go b/civo/dns/resource_dns_domain_record_test.go similarity index 66% rename from civo/resource_dns_domain_record_test.go rename to civo/dns/resource_dns_domain_record_test.go index af3142e2..1290134b 100644 --- a/civo/resource_dns_domain_record_test.go +++ b/civo/dns/resource_dns_domain_record_test.go @@ -1,16 +1,17 @@ -package civo +package dns_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -// example.Widget represents a concrete Go type that represents an API resource +// TestAccCivoDNSDomainNameRecord_basic tests the basic functionality of the domain record resource func TestAccCivoDNSDomainNameRecord_basic(t *testing.T) { var domainRecord civogo.DNSRecord @@ -20,19 +21,19 @@ func TestAccCivoDNSDomainNameRecord_basic(t *testing.T) { var recordName = acctest.RandomWithPrefix("record") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameRecordDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameRecordDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDNSDomainNameRecordConfigBasic(domainName, recordName), + Config: CivoDNSDomainNameRecordConfigBasic(domainName, recordName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoDNSDomainNameRecordResourceExists(resName, &domainRecord), + CivoDNSDomainNameRecordResourceExists(resName, &domainRecord), // verify remote values - testAccCheckCivoDNSDomainNameRecordValues(&domainRecord, recordName), + CivoDNSDomainNameRecordValues(&domainRecord, recordName), // verify local values resource.TestCheckResourceAttr(resName, "name", recordName), ), @@ -51,24 +52,24 @@ func TestAccCivoDNSDomainNameRecord_update(t *testing.T) { var recordNameUpdate = acctest.RandomWithPrefix("renamed-record") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoDNSDomainNameRecordDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoDNSDomainNameRecordDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoDNSDomainNameRecordConfigBasic(domainName, recordName), + Config: CivoDNSDomainNameRecordConfigBasic(domainName, recordName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDNSDomainNameRecordResourceExists(resName, &domainRecord), - testAccCheckCivoDNSDomainNameRecordValues(&domainRecord, recordName), + CivoDNSDomainNameRecordResourceExists(resName, &domainRecord), + CivoDNSDomainNameRecordValues(&domainRecord, recordName), resource.TestCheckResourceAttr(resName, "name", recordName), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoDNSDomainNameRecordConfigUpdates(domainName, recordNameUpdate), + Config: CivoDNSDomainNameRecordConfigUpdates(domainName, recordNameUpdate), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoDNSDomainNameRecordResourceExists(resName, &domainRecord), - testAccCheckCivoDNSDomainNameRecordUpdated(&domainRecord, recordNameUpdate), + CivoDNSDomainNameRecordResourceExists(resName, &domainRecord), + CivoDNSDomainNameRecordUpdated(&domainRecord, recordNameUpdate), resource.TestCheckResourceAttr(resName, "name", recordNameUpdate), ), }, @@ -76,7 +77,7 @@ func TestAccCivoDNSDomainNameRecord_update(t *testing.T) { }) } -func testAccCheckCivoDNSDomainNameRecordValues(domainRecord *civogo.DNSRecord, name string) resource.TestCheckFunc { +func CivoDNSDomainNameRecordValues(domainRecord *civogo.DNSRecord, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if domainRecord.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, domainRecord.Name) @@ -85,7 +86,7 @@ func testAccCheckCivoDNSDomainNameRecordValues(domainRecord *civogo.DNSRecord, n } } -func testAccCheckCivoDNSDomainNameRecordResourceExists(n string, domainRecord *civogo.DNSRecord) resource.TestCheckFunc { +func CivoDNSDomainNameRecordResourceExists(n string, domainRecord *civogo.DNSRecord) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -94,7 +95,7 @@ func testAccCheckCivoDNSDomainNameRecordResourceExists(n string, domainRecord *c } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.GetDNSRecord(rs.Primary.Attributes["domain_id"], rs.Primary.ID) if err != nil { return fmt.Errorf("Domain record not found: (%s) %s", rs.Primary.ID, err) @@ -108,7 +109,7 @@ func testAccCheckCivoDNSDomainNameRecordResourceExists(n string, domainRecord *c } } -func testAccCheckCivoDNSDomainNameRecordUpdated(domainRecord *civogo.DNSRecord, name string) resource.TestCheckFunc { +func CivoDNSDomainNameRecordUpdated(domainRecord *civogo.DNSRecord, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if domainRecord.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, domainRecord.Name) @@ -117,8 +118,8 @@ func testAccCheckCivoDNSDomainNameRecordUpdated(domainRecord *civogo.DNSRecord, } } -func testAccCheckCivoDNSDomainNameRecordDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoDNSDomainNameRecordDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_dns_domain_record" { @@ -134,7 +135,7 @@ func testAccCheckCivoDNSDomainNameRecordDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoDNSDomainNameRecordConfigBasic(domain string, record string) string { +func CivoDNSDomainNameRecordConfigBasic(domain string, record string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "foobar" { name = "%s" @@ -150,7 +151,7 @@ resource "civo_dns_domain_record" "www" { `, domain, record) } -func testAccCheckCivoDNSDomainNameRecordConfigUpdates(domain string, record string) string { +func CivoDNSDomainNameRecordConfigUpdates(domain string, record string) string { return fmt.Sprintf(` resource "civo_dns_domain_name" "foobar" { name = "%s" diff --git a/civo/datasource_firewall.go b/civo/firewall/datasource_firewall.go similarity index 94% rename from civo/datasource_firewall.go rename to civo/firewall/datasource_firewall.go index 1cd997a2..e337e459 100644 --- a/civo/datasource_firewall.go +++ b/civo/firewall/datasource_firewall.go @@ -1,4 +1,4 @@ -package civo +package firewall import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific firewall +// DataSourceFirewall Data source to get from the api a specific firewall // using the id or the label -func dataSourceFirewall() *schema.Resource { +func DataSourceFirewall() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Retrieve information about a firewall for use in other resources.", diff --git a/civo/datasource_firewall_test.go b/civo/firewall/datasource_firewall_test.go similarity index 71% rename from civo/datasource_firewall_test.go rename to civo/firewall/datasource_firewall_test.go index 36ec74cd..f9aae75b 100644 --- a/civo/datasource_firewall_test.go +++ b/civo/firewall/datasource_firewall_test.go @@ -1,9 +1,10 @@ -package civo +package firewall_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoFirewall_basic(t *testing.T) { name := acctest.RandomWithPrefix("net-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoFirewallConfig(name), + Config: DataSourceCivoFirewallConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), ), @@ -26,7 +27,7 @@ func TestAccDataSourceCivoFirewall_basic(t *testing.T) { }) } -func testAccDataSourceCivoFirewallConfig(name string) string { +func DataSourceCivoFirewallConfig(name string) string { return fmt.Sprintf(` resource "civo_firewall" "foobar" { name = "%s" diff --git a/civo/resource_firewall.go b/civo/firewall/resource_firewall.go similarity index 98% rename from civo/resource_firewall.go rename to civo/firewall/resource_firewall.go index 9a157644..ad171854 100644 --- a/civo/resource_firewall.go +++ b/civo/firewall/resource_firewall.go @@ -1,4 +1,4 @@ -package civo +package firewall import ( "context" @@ -10,12 +10,13 @@ import ( "github.com/civo/terraform-provider-civo/internal/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Firewall resource with this we can create and manage all firewall -func resourceFirewall() *schema.Resource { +// ResourceFirewall Firewall resource with this we can create and manage all firewall +func ResourceFirewall() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo firewall resource. This can be used to create, modify, and delete firewalls.", Schema: map[string]*schema.Schema{ @@ -314,7 +315,7 @@ func resourceFirewallDelete(_ context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] deleting the firewall %s", firewallID) - deleteStateConf := &resource.StateChangeConf{ + deleteStateConf := &retry.StateChangeConf{ Pending: []string{"failed"}, Target: []string{"success"}, Refresh: func() (interface{}, string, error) { diff --git a/civo/resource_firewall_test.go b/civo/firewall/resource_firewall_test.go similarity index 71% rename from civo/resource_firewall_test.go rename to civo/firewall/resource_firewall_test.go index 666af75c..22d9e6bc 100644 --- a/civo/resource_firewall_test.go +++ b/civo/firewall/resource_firewall_test.go @@ -1,10 +1,11 @@ -package civo +package firewall_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,19 +20,19 @@ func TestAccCivoFirewall_basic(t *testing.T) { var firewallName = acctest.RandomWithPrefix("tf-fw") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoFirewallDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoFirewallConfigBasic(firewallName), + Config: CivoFirewallConfigBasic(firewallName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoFirewallResourceExists(resName, &firewall), + CivoFirewallResourceExists(resName, &firewall), // verify remote values - testAccCheckCivoFirewallValues(&firewall, firewallName), + CivoFirewallValues(&firewall, firewallName), // verify local values resource.TestCheckResourceAttr(resName, "name", firewallName), resource.TestCheckResourceAttrSet(resName, "ingress_rule.#"), @@ -49,19 +50,19 @@ func TestAccCivoFirewallWithIngressEgress_basic(t *testing.T) { var firewallName = acctest.RandomWithPrefix("tf-fw") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoFirewallDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoFirewallConfigWithIngressEgress(firewallName), + Config: CivoFirewallConfigWithIngressEgress(firewallName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoFirewallResourceExists(resName, &firewall), + CivoFirewallResourceExists(resName, &firewall), // verify remote values - testAccCheckCivoFirewallValues(&firewall, firewallName), + CivoFirewallValues(&firewall, firewallName), // verify local values resource.TestCheckResourceAttr(resName, "name", firewallName), resource.TestCheckResourceAttrSet(resName, "ingress_rule.#"), @@ -87,24 +88,24 @@ func TestAccCivoFirewall_update(t *testing.T) { var firewallNameUpdate = acctest.RandomWithPrefix("rename-fw") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoFirewallDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoFirewallConfigBasic(firewallName), + Config: CivoFirewallConfigBasic(firewallName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoFirewallResourceExists(resName, &firewall), - testAccCheckCivoFirewallValues(&firewall, firewallName), + CivoFirewallResourceExists(resName, &firewall), + CivoFirewallValues(&firewall, firewallName), resource.TestCheckResourceAttr(resName, "name", firewallName), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoFirewallConfigUpdates(firewallNameUpdate), + Config: CivoFirewallConfigUpdates(firewallNameUpdate), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoFirewallResourceExists(resName, &firewall), - testAccCheckCivoFirewallUpdated(&firewall, firewallNameUpdate), + CivoFirewallResourceExists(resName, &firewall), + CivoFirewallUpdated(&firewall, firewallNameUpdate), resource.TestCheckResourceAttr(resName, "name", firewallNameUpdate), ), }, @@ -112,7 +113,7 @@ func TestAccCivoFirewall_update(t *testing.T) { }) } -func testAccCheckCivoFirewallValues(firewall *civogo.Firewall, name string) resource.TestCheckFunc { +func CivoFirewallValues(firewall *civogo.Firewall, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if firewall.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, firewall.Name) @@ -121,8 +122,8 @@ func testAccCheckCivoFirewallValues(firewall *civogo.Firewall, name string) reso } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoFirewallResourceExists(n string, firewall *civogo.Firewall) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoFirewallResourceExists(n string, firewall *civogo.Firewall) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -131,7 +132,7 @@ func testAccCheckCivoFirewallResourceExists(n string, firewall *civogo.Firewall) } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindFirewall(rs.Primary.ID) if err != nil { return fmt.Errorf("Firewall not found: (%s) %s", rs.Primary.ID, err) @@ -145,7 +146,7 @@ func testAccCheckCivoFirewallResourceExists(n string, firewall *civogo.Firewall) } } -func testAccCheckCivoFirewallUpdated(firewall *civogo.Firewall, name string) resource.TestCheckFunc { +func CivoFirewallUpdated(firewall *civogo.Firewall, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if firewall.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, firewall.Name) @@ -154,8 +155,8 @@ func testAccCheckCivoFirewallUpdated(firewall *civogo.Firewall, name string) res } } -func testAccCheckCivoFirewallDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoFirewallDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_firewall" { @@ -171,7 +172,7 @@ func testAccCheckCivoFirewallDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoFirewallConfigBasic(name string) string { +func CivoFirewallConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_firewall" "foobar" { name = "%s" @@ -180,7 +181,7 @@ resource "civo_firewall" "foobar" { }`, name) } -func testAccCheckCivoFirewallConfigWithIngressEgress(name string) string { +func CivoFirewallConfigWithIngressEgress(name string) string { return fmt.Sprintf(` resource "civo_firewall" "foobar" { name = "%s" @@ -205,7 +206,7 @@ resource "civo_firewall" "foobar" { }`, name) } -func testAccCheckCivoFirewallConfigUpdates(name string) string { +func CivoFirewallConfigUpdates(name string) string { return fmt.Sprintf(` resource "civo_firewall" "foobar" { name = "%s" diff --git a/civo/datasource_instance.go b/civo/instances/datasource_instance.go similarity index 97% rename from civo/datasource_instance.go rename to civo/instances/datasource_instance.go index 5d51c458..332412aa 100644 --- a/civo/datasource_instance.go +++ b/civo/instances/datasource_instance.go @@ -1,4 +1,4 @@ -package civo +package instances import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific instance +// DataSourceInstance Data source to get from the api a specific instance // using the id or the hostname -func dataSourceInstance() *schema.Resource { +func DataSourceInstance() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on an instance for use in other resources. This data source provides all of the instance's properties as configured on your Civo account.", diff --git a/civo/datasource_instance_test.go b/civo/instances/datasource_instance_test.go similarity index 82% rename from civo/datasource_instance_test.go rename to civo/instances/datasource_instance_test.go index 907ece73..c08935e2 100644 --- a/civo/datasource_instance_test.go +++ b/civo/instances/datasource_instance_test.go @@ -1,9 +1,10 @@ -package civo +package instances_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoInstance_basic(t *testing.T) { name := acctest.RandomWithPrefix("instance") + ".com" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoInstanceConfig(name), + Config: DataSourceCivoInstanceConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "hostname", name), resource.TestCheckResourceAttrSet(datasourceName, "private_ip"), @@ -33,11 +34,11 @@ func TestAccDataSourceCivoInstanceByID_basic(t *testing.T) { name := acctest.RandomWithPrefix("instance") + ".com" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoInstanceByIDConfig(name), + Config: DataSourceCivoInstanceByIDConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "hostname", name), resource.TestCheckResourceAttrSet(datasourceName, "private_ip"), @@ -48,7 +49,7 @@ func TestAccDataSourceCivoInstanceByID_basic(t *testing.T) { }) } -func testAccDataSourceCivoInstanceConfig(name string) string { +func DataSourceCivoInstanceConfig(name string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { @@ -84,7 +85,7 @@ data "civo_instance" "foobar" { `, name) } -func testAccDataSourceCivoInstanceByIDConfig(name string) string { +func DataSourceCivoInstanceByIDConfig(name string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { diff --git a/civo/datasource_instances.go b/civo/instances/datasource_instances.go similarity index 97% rename from civo/datasource_instances.go rename to civo/instances/datasource_instances.go index 5d7a077f..4703ad40 100644 --- a/civo/datasource_instances.go +++ b/civo/instances/datasource_instances.go @@ -1,4 +1,4 @@ -package civo +package instances import ( "fmt" @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Data source to get and filter all instances with filter -func dataSourceInstances() *schema.Resource { +// DataSourceInstances Data source to get and filter all instances with filter +func DataSourceInstances() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ Description: strings.Join([]string{ "Get information on instances for use in other resources, with the ability to filter and sort the results. If no filters are specified, all instances will be returned.", diff --git a/civo/datasource_instances_test.go b/civo/instances/datasource_instances_test.go similarity index 82% rename from civo/datasource_instances_test.go rename to civo/instances/datasource_instances_test.go index fbfd0c46..57d85a4a 100644 --- a/civo/datasource_instances_test.go +++ b/civo/instances/datasource_instances_test.go @@ -1,9 +1,10 @@ -package civo +package instances_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,14 +14,14 @@ func TestAccDataSourceCivoInstances_basic(t *testing.T) { var instanceHostname2 = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoInstancesConfig(instanceHostname, instanceHostname2), + Config: DataSourceCivoInstancesConfig(instanceHostname, instanceHostname2), }, { - Config: testAccDataSourceCivoInstancesDataConfig(instanceHostname, instanceHostname2), + Config: DataSourceCivoInstancesDataConfig(instanceHostname, instanceHostname2), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.civo_instances.result", "instances.#", "1"), resource.TestCheckResourceAttr("data.civo_instances.result", "instances.0.hostname", instanceHostname), @@ -31,7 +32,7 @@ func TestAccDataSourceCivoInstances_basic(t *testing.T) { }) } -func testAccDataSourceCivoInstancesConfig(name string, name2 string) string { +func DataSourceCivoInstancesConfig(name string, name2 string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { @@ -69,7 +70,7 @@ resource "civo_instance" "bar" { `, name, name2) } -func testAccDataSourceCivoInstancesDataConfig(name string, name2 string) string { +func DataSourceCivoInstancesDataConfig(name string, name2 string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { diff --git a/civo/resource_instance.go b/civo/instances/resource_instance.go similarity index 98% rename from civo/resource_instance.go rename to civo/instances/resource_instance.go index ef8862aa..2c1f4fb1 100644 --- a/civo/resource_instance.go +++ b/civo/instances/resource_instance.go @@ -1,4 +1,4 @@ -package civo +package instances import ( "context" @@ -14,9 +14,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// The instance resource represents an object of type instances +// ResourceInstance The instance resource represents an object of type instances // and with it you can handle the instances created with Terraform -func resourceInstance() *schema.Resource { +func ResourceInstance() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo instance resource. This can be used to create, modify, and delete instances.", Schema: map[string]*schema.Schema{ @@ -86,6 +86,7 @@ func resourceInstance() *schema.Resource { "sshkey_id": { Type: schema.TypeString, Optional: true, + Computed: true, Description: "The ID of an already uploaded SSH public key to use for login to the default user (optional; if one isn't provided a random password will be set and returned in the initial_password field)", }, "firewall_id": { diff --git a/civo/resource_instance_reserved_ip_assignment.go b/civo/instances/resource_instance_reserved_ip_assignment.go similarity index 96% rename from civo/resource_instance_reserved_ip_assignment.go rename to civo/instances/resource_instance_reserved_ip_assignment.go index 35c3bc79..57187dff 100644 --- a/civo/resource_instance_reserved_ip_assignment.go +++ b/civo/instances/resource_instance_reserved_ip_assignment.go @@ -1,4 +1,4 @@ -package civo +package instances import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// The instance reserved ip assignment resource schema definition +// ResourceInstanceReservedIPAssignment The instance reserved ip assignment resource schema definition // represent the instance reserved ip assignment resource -func resourceInstanceReservedIPAssignment() *schema.Resource { +func ResourceInstanceReservedIPAssignment() *schema.Resource { return &schema.Resource{ Description: "The instance reserved ip assignment resource schema definition", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_instance_reserved_ip_assignment_test.go b/civo/instances/resource_instance_reserved_ip_assignment_test.go similarity index 76% rename from civo/resource_instance_reserved_ip_assignment_test.go rename to civo/instances/resource_instance_reserved_ip_assignment_test.go index 61ebccff..8c1a678f 100644 --- a/civo/resource_instance_reserved_ip_assignment_test.go +++ b/civo/instances/resource_instance_reserved_ip_assignment_test.go @@ -1,10 +1,11 @@ -package civo +package instances_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -20,18 +21,18 @@ func TestAccCivoInstanceReservedIPAssignment_basic(t *testing.T) { var AttachmentName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCivoInstanceReservedIPAssignmentDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoInstanceReservedIPAssignmentDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCivoInstanceReservedIPAssignmentConfigBasic(AttachmentName), + Config: CivoInstanceReservedIPAssignmentConfigBasic(AttachmentName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoReservedIPResourceExists("civo_reserved_ip.foo", &ip), - testAccCheckCivoInstanceResourceExists("civo_instance.vm", &instance), + acceptance.CivoReservedIPResourceExists("civo_reserved_ip.foo", &ip), + acceptance.CivoInstanceResourceExists("civo_instance.vm", &instance), // verify local values resource.TestCheckResourceAttrSet(resName, "id"), resource.TestCheckResourceAttrSet(resName, "instance_id"), @@ -42,7 +43,7 @@ func TestAccCivoInstanceReservedIPAssignment_basic(t *testing.T) { }) } -func testAccCivoInstanceReservedIPAssignmentDestroy(s *terraform.State) error { +func CivoInstanceReservedIPAssignmentDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "civo_instance_reserved_ip_assignment" { continue @@ -52,7 +53,7 @@ func testAccCivoInstanceReservedIPAssignmentDestroy(s *terraform.State) error { return nil } -func testAccCivoInstanceReservedIPAssignmentConfigBasic(name string) string { +func CivoInstanceReservedIPAssignmentConfigBasic(name string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { diff --git a/civo/resource_instance_test.go b/civo/instances/resource_instance_test.go similarity index 72% rename from civo/resource_instance_test.go rename to civo/instances/resource_instance_test.go index b1c76b96..74e75ab1 100644 --- a/civo/resource_instance_test.go +++ b/civo/instances/resource_instance_test.go @@ -1,16 +1,17 @@ -package civo +package instances_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -// example.Widget represents a concrete Go type that represents an API resource +// TestAccCivoInstance_basic is a test function that verifies the basic functionality of creating a Civo instance. func TestAccCivoInstance_basic(t *testing.T) { var instance civogo.Instance @@ -19,19 +20,19 @@ func TestAccCivoInstance_basic(t *testing.T) { var instanceHostname = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoInstanceDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoInstanceDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoInstanceConfigBasic(instanceHostname), + Config: CivoInstanceConfigBasic(instanceHostname), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoInstanceResourceExists(resName, &instance), + acceptance.CivoInstanceResourceExists(resName, &instance), // verify remote values - testAccCheckCivoInstanceValues(&instance, instanceHostname), + CivoInstanceValues(&instance, instanceHostname), // verify local values resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), @@ -49,6 +50,7 @@ func TestAccCivoInstance_basic(t *testing.T) { }) } +// TestAccCivoInstanceSize_update is a test function that verifies the update functionality of the CivoInstanceSize resource. func TestAccCivoInstanceSize_update(t *testing.T) { var instance civogo.Instance @@ -57,15 +59,15 @@ func TestAccCivoInstanceSize_update(t *testing.T) { var instanceHostname = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoInstanceDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoInstanceDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoInstanceConfigBasic(instanceHostname), + Config: CivoInstanceConfigBasic(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoInstanceValues(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceValues(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -80,10 +82,10 @@ func TestAccCivoInstanceSize_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoInstanceConfigUpdates(instanceHostname), + Config: CivoInstanceConfigUpdates(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoInstanceUpdated(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceUpdated(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.medium"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -108,15 +110,15 @@ func TestAccCivoInstanceNotes_update(t *testing.T) { var instanceHostname = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoInstanceDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoInstanceDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoInstanceConfigBasic(instanceHostname), + Config: CivoInstanceConfigBasic(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoInstanceValues(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceValues(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -132,10 +134,10 @@ func TestAccCivoInstanceNotes_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoInstanceConfigNotes(instanceHostname), + Config: CivoInstanceConfigNotes(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoInstanceUpdated(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceUpdated(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -155,22 +157,21 @@ func TestAccCivoInstanceNotes_update(t *testing.T) { func TestAccCivoInstanceFirewall_update(t *testing.T) { var instance civogo.Instance - var firewall civogo.Firewall // generate a random name for each test run resName := "civo_instance.foobar" var instanceHostname = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoInstanceDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoInstanceDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoInstanceConfigBasic(instanceHostname), + Config: CivoInstanceConfigBasic(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoInstanceValues(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceValues(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -185,11 +186,10 @@ func TestAccCivoInstanceFirewall_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoInstanceConfigFirewall(instanceHostname), + Config: CivoInstanceConfigFirewall(instanceHostname), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoInstanceResourceExists(resName, &instance), - testAccCheckCivoFirewallResourceExists("civo_firewall.foobar", &firewall), - testAccCheckCivoInstanceUpdated(&instance, instanceHostname), + acceptance.CivoInstanceResourceExists(resName, &instance), + CivoInstanceUpdated(&instance, instanceHostname), resource.TestCheckResourceAttr(resName, "hostname", instanceHostname), resource.TestCheckResourceAttr(resName, "size", "g3.small"), resource.TestCheckResourceAttr(resName, "initial_user", "civo"), @@ -207,7 +207,7 @@ func TestAccCivoInstanceFirewall_update(t *testing.T) { }) } -func testAccCheckCivoInstanceValues(instance *civogo.Instance, name string) resource.TestCheckFunc { +func CivoInstanceValues(instance *civogo.Instance, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if instance.Hostname != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, instance.Hostname) @@ -216,31 +216,7 @@ func testAccCheckCivoInstanceValues(instance *civogo.Instance, name string) reso } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoInstanceResourceExists(n string, instance *civogo.Instance) resource.TestCheckFunc { - return func(s *terraform.State) error { - // find the corresponding state object - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) - resp, err := client.GetInstance(rs.Primary.ID) - if err != nil { - return fmt.Errorf("Instance not found: (%s) %s", rs.Primary.ID, err) - } - - // If no error, assign the response Widget attribute to the widget pointer - *instance = *resp - - // return fmt.Errorf("Domain (%s) not found", rs.Primary.ID) - return nil - } -} - -func testAccCheckCivoInstanceUpdated(instance *civogo.Instance, name string) resource.TestCheckFunc { +func CivoInstanceUpdated(instance *civogo.Instance, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if instance.Hostname != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, instance.Hostname) @@ -249,24 +225,7 @@ func testAccCheckCivoInstanceUpdated(instance *civogo.Instance, name string) res } } -func testAccCheckCivoInstanceDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "civo_instance" { - continue - } - - _, err := client.GetInstance(rs.Primary.ID) - if err != nil { - return fmt.Errorf("Instance still exists") - } - } - - return nil -} - -func testAccCheckCivoInstanceConfigBasic(hostname string) string { +func CivoInstanceConfigBasic(hostname string) string { return fmt.Sprintf(` data "civo_size" "small" { filter { @@ -297,7 +256,7 @@ resource "civo_instance" "foobar" { }`, hostname) } -func testAccCheckCivoInstanceConfigUpdates(hostname string) string { +func CivoInstanceConfigUpdates(hostname string) string { return fmt.Sprintf(` data "civo_size" "medium" { filter { @@ -328,7 +287,7 @@ resource "civo_instance" "foobar" { }`, hostname) } -func testAccCheckCivoInstanceConfigNotes(hostname string) string { +func CivoInstanceConfigNotes(hostname string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { @@ -359,7 +318,7 @@ resource "civo_instance" "foobar" { }`, hostname) } -func testAccCheckCivoInstanceConfigFirewall(hostname string) string { +func CivoInstanceConfigFirewall(hostname string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { diff --git a/civo/datasource_reserved_ip.go b/civo/ip/datasource_reserved_ip.go similarity index 91% rename from civo/datasource_reserved_ip.go rename to civo/ip/datasource_reserved_ip.go index 33a8851d..2add8984 100644 --- a/civo/datasource_reserved_ip.go +++ b/civo/ip/datasource_reserved_ip.go @@ -1,4 +1,4 @@ -package civo +package ip import ( "context" @@ -11,7 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func dataSourceReservedIP() *schema.Resource { +// DataSourceReservedIP function returns a schema.Resource that represents a reserved IP. +// This can be used to query and retrieve details about a specific reserved IP in the infrastructure. +func DataSourceReservedIP() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a reserved IP. This data source provides the region and Instance id as configured on your Civo account.", diff --git a/civo/datasource_reserved_ip_test.go b/civo/ip/datasource_reserved_ip_test.go similarity index 75% rename from civo/datasource_reserved_ip_test.go rename to civo/ip/datasource_reserved_ip_test.go index 130fab40..208ff55f 100644 --- a/civo/datasource_reserved_ip_test.go +++ b/civo/ip/datasource_reserved_ip_test.go @@ -1,9 +1,10 @@ -package civo +package ip_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceReservedIP_basic(t *testing.T) { name := acctest.RandomWithPrefix("ip-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceReservedIPConfig(name), + Config: DataSourceReservedIPConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttrSet(datasourceName, "ip"), @@ -28,7 +29,7 @@ func TestAccDataSourceReservedIP_basic(t *testing.T) { }) } -func testAccDataSourceReservedIPConfig(name string) string { +func DataSourceReservedIPConfig(name string) string { return fmt.Sprintf(` resource "civo_reserved_ip" "newip" { name = "%s" diff --git a/civo/resource_reserved_ip.go b/civo/ip/resource_reserved_ip.go similarity index 94% rename from civo/resource_reserved_ip.go rename to civo/ip/resource_reserved_ip.go index af705337..25ef2f44 100644 --- a/civo/resource_reserved_ip.go +++ b/civo/ip/resource_reserved_ip.go @@ -1,4 +1,4 @@ -package civo +package ip import ( "context" @@ -12,7 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -func resourceReservedIP() *schema.Resource { +// ResourceReservedIP function returns a schema.Resource that represents a reserved IP. +// This can be used to create, read, update, and delete operations for a reserved IP in the infrastructure. +func ResourceReservedIP() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo reserved IP to represent a publicly-accessible static IP addresses that can be mapped to one of your Instancesor Load Balancer.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_reserved_ip_test.go b/civo/ip/resource_reserved_ip_test.go similarity index 54% rename from civo/resource_reserved_ip_test.go rename to civo/ip/resource_reserved_ip_test.go index e6a25e11..164d1813 100644 --- a/civo/resource_reserved_ip_test.go +++ b/civo/ip/resource_reserved_ip_test.go @@ -1,10 +1,11 @@ -package civo +package ip_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -18,19 +19,19 @@ func TestAccCivoReservedIP_basic(t *testing.T) { var nameIP = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoReservedIPDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoReservedIPDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoReservedIPConfigBasic(nameIP), + Config: CivoReservedIPConfigBasic(nameIP), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoReservedIPResourceExists(resName, &ip), + acceptance.CivoReservedIPResourceExists(resName, &ip), // verify remote values - testAccCheckCivoReservedIPValues(&ip, nameIP), + CivoReservedIPValues(&ip, nameIP), // verify local values resource.TestCheckResourceAttr(resName, "name", nameIP), ), @@ -47,24 +48,24 @@ func TestAccCivoReservedIP_update(t *testing.T) { var nameIP = acctest.RandomWithPrefix("rename-tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoReservedIPDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoReservedIPDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoReservedIPConfigUpdates(nameIP), + Config: CivoReservedIPConfigUpdates(nameIP), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoReservedIPResourceExists(resName, &ip), - testAccCheckCivoReservedIPValues(&ip, nameIP), + acceptance.CivoReservedIPResourceExists(resName, &ip), + CivoReservedIPValues(&ip, nameIP), resource.TestCheckResourceAttr(resName, "name", nameIP), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoReservedIPConfigUpdates(nameIP), + Config: CivoReservedIPConfigUpdates(nameIP), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoReservedIPResourceExists(resName, &ip), - testAccCheckCivoReservedIPUpdated(&ip, nameIP), + acceptance.CivoReservedIPResourceExists(resName, &ip), + CivoReservedIPUpdated(&ip, nameIP), resource.TestCheckResourceAttr(resName, "name", nameIP), ), }, @@ -72,7 +73,7 @@ func TestAccCivoReservedIP_update(t *testing.T) { }) } -func testAccCheckCivoReservedIPValues(ip *civogo.IP, name string) resource.TestCheckFunc { +func CivoReservedIPValues(ip *civogo.IP, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if ip.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, ip.Name) @@ -81,29 +82,7 @@ func testAccCheckCivoReservedIPValues(ip *civogo.IP, name string) resource.TestC } } -// testAccCheckCivoReservedIPResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoReservedIPResourceExists(n string, ip *civogo.IP) resource.TestCheckFunc { - return func(s *terraform.State) error { - // find the corresponding state object - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) - resp, err := client.FindIP(rs.Primary.ID) - if err != nil { - return fmt.Errorf("IP not found: (%s) %s", rs.Primary.ID, err) - } - - *ip = *resp - - return nil - } -} - -func testAccCheckCivoReservedIPUpdated(ip *civogo.IP, name string) resource.TestCheckFunc { +func CivoReservedIPUpdated(ip *civogo.IP, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if ip.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, ip.Name) @@ -112,8 +91,8 @@ func testAccCheckCivoReservedIPUpdated(ip *civogo.IP, name string) resource.Test } } -func testAccCheckCivoReservedIPDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoReservedIPDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_reserved_ip" { @@ -129,14 +108,14 @@ func testAccCheckCivoReservedIPDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoReservedIPConfigBasic(label string) string { +func CivoReservedIPConfigBasic(label string) string { return fmt.Sprintf(` resource "civo_reserved_ip" "foobar" { name = "%s" }`, label) } -func testAccCheckCivoReservedIPConfigUpdates(label string) string { +func CivoReservedIPConfigUpdates(label string) string { return fmt.Sprintf(` resource "civo_reserved_ip" "foobar" { name = "%s" diff --git a/civo/datasource_kubernetes_cluster.go b/civo/kubernetes/datasource_kubernetes_cluster.go similarity index 96% rename from civo/datasource_kubernetes_cluster.go rename to civo/kubernetes/datasource_kubernetes_cluster.go index 2390254f..bfc43184 100644 --- a/civo/datasource_kubernetes_cluster.go +++ b/civo/kubernetes/datasource_kubernetes_cluster.go @@ -1,4 +1,4 @@ -package civo +package kubernetes import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific instance -// using the id or the hostname -func dataSourceKubernetesCluster() *schema.Resource { +// DataSourceKubernetesCluster function returns a schema.Resource that represents a Kubernetes cluster. +// This can be used to query and retrieve details about a specific Kubernetes cluster in the infrastructure. +func DataSourceKubernetesCluster() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Provides a Civo Kubernetes cluster data source.", diff --git a/civo/datasource_kubernetes_cluster_test.go b/civo/kubernetes/datasource_kubernetes_cluster_test.go similarity index 83% rename from civo/datasource_kubernetes_cluster_test.go rename to civo/kubernetes/datasource_kubernetes_cluster_test.go index 514a0d71..62eb4a97 100644 --- a/civo/datasource_kubernetes_cluster_test.go +++ b/civo/kubernetes/datasource_kubernetes_cluster_test.go @@ -1,9 +1,10 @@ -package civo +package kubernetes_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoKubernetesCluster_basic(t *testing.T) { name := acctest.RandomWithPrefix("k8s") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoKubernetesClusterConfig(name), + Config: DataSourceCivoKubernetesClusterConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttr(datasourceName, "pools.0.node_count", "2"), @@ -37,11 +38,11 @@ func TestAccDataSourceCivoKubernetesClusterByID_basic(t *testing.T) { name := acctest.RandomWithPrefix("k8s") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoKubernetesClusterByIDConfig(name), + Config: DataSourceCivoKubernetesClusterByIDConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttr(datasourceName, "pools.0.node_count", "2"), @@ -56,7 +57,7 @@ func TestAccDataSourceCivoKubernetesClusterByID_basic(t *testing.T) { }) } -func testAccDataSourceCivoKubernetesClusterConfig(name string) string { +func DataSourceCivoKubernetesClusterConfig(name string) string { return fmt.Sprintf(` data "civo_firewall" "default" { name = "default-default" @@ -78,7 +79,7 @@ data "civo_kubernetes_cluster" "foobar" { `, name) } -func testAccDataSourceCivoKubernetesClusterByIDConfig(name string) string { +func DataSourceCivoKubernetesClusterByIDConfig(name string) string { return fmt.Sprintf(` data "civo_firewall" "default" { name = "default-default" diff --git a/civo/datasource_kubernetes_version.go b/civo/kubernetes/datasource_kubernetes_version.go similarity index 87% rename from civo/datasource_kubernetes_version.go rename to civo/kubernetes/datasource_kubernetes_version.go index 76f5b169..eb08dd00 100644 --- a/civo/datasource_kubernetes_version.go +++ b/civo/kubernetes/datasource_kubernetes_version.go @@ -1,4 +1,4 @@ -package civo +package kubernetes import ( "fmt" @@ -8,10 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Data source to get and filter all kubernetes version -// available in the server, use to define the version at the -// moment of the cluster creation in resourceKubernetesCluster -func dataSourceKubernetesVersion() *schema.Resource { +// DataSourceKubernetesVersion function returns a schema.Resource that represents a Kubernetes version. +// This can be used to query and retrieve details about a specific Kubernetes version in the infrastructure. +func DataSourceKubernetesVersion() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ Description: "Provides access to the available Civo Kubernetes versions, with the ability to filter the results.", RecordSchema: kubernetesVersionSchema(), diff --git a/civo/datasource_kubernetes_version_test.go b/civo/kubernetes/datasource_kubernetes_version_test.go similarity index 70% rename from civo/datasource_kubernetes_version_test.go rename to civo/kubernetes/datasource_kubernetes_version_test.go index ffff18aa..760ec5f9 100644 --- a/civo/datasource_kubernetes_version_test.go +++ b/civo/kubernetes/datasource_kubernetes_version_test.go @@ -1,10 +1,11 @@ -package civo +package kubernetes_test import ( "fmt" "strconv" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -13,13 +14,13 @@ func TestAccDataSourceCivoKubernetesVersion_basic(t *testing.T) { datasourceName := "data.civo_kubernetes_version.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoKubernetesVersionConfig(), + Config: DataSourceCivoKubernetesVersionConfig(), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckDataSourceCivoKubernetesVersionExist(datasourceName), + DataSourceCivoKubernetesVersionExist(datasourceName), ), }, }, @@ -30,21 +31,21 @@ func TestAccDataSourceCivoKubernetesVersion_WithFilter(t *testing.T) { datasourceName := "data.civo_kubernetes_version.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoKubernetesVersionConfigWhitFilter(), + Config: DataSourceCivoKubernetesVersionConfigWhitFilter(), Check: resource.ComposeTestCheckFunc( - testAccCheckDataSourceCivoKubernetesVersionExist(datasourceName), - testAccCheckDataSourceCivoKubernetesVersionFiltered(datasourceName), + DataSourceCivoKubernetesVersionExist(datasourceName), + DataSourceCivoKubernetesVersionFiltered(datasourceName), ), }, }, }) } -func testAccCheckDataSourceCivoKubernetesVersionExist(n string) resource.TestCheckFunc { +func DataSourceCivoKubernetesVersionExist(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -70,7 +71,7 @@ func testAccCheckDataSourceCivoKubernetesVersionExist(n string) resource.TestChe } } -func testAccCheckDataSourceCivoKubernetesVersionFiltered(n string) resource.TestCheckFunc { +func DataSourceCivoKubernetesVersionFiltered(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -105,14 +106,14 @@ func testAccCheckDataSourceCivoKubernetesVersionFiltered(n string) resource.Test } } -func testAccDataSourceCivoKubernetesVersionConfig() string { +func DataSourceCivoKubernetesVersionConfig() string { return ` data "civo_kubernetes_version" "foobar" { } ` } -func testAccDataSourceCivoKubernetesVersionConfigWhitFilter() string { +func DataSourceCivoKubernetesVersionConfigWhitFilter() string { return ` data "civo_kubernetes_version" "foobar" { filter { diff --git a/civo/kubernetes/kubernetes.go b/civo/kubernetes/kubernetes.go new file mode 100644 index 00000000..04ad94e1 --- /dev/null +++ b/civo/kubernetes/kubernetes.go @@ -0,0 +1,162 @@ +package kubernetes + +import ( + "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/internal/utils" + "github.com/google/uuid" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +// nodePoolSchema function to define the node pool schema +func nodePoolSchema(isResource bool) map[string]*schema.Schema { + s := map[string]*schema.Schema{ + "label": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateDiagFunc: utils.ValidateNameOnlyContainsAlphanumericCharacters, + Description: "Node pool label, if you don't provide one, we will generate one for you", + }, + "node_count": { + Type: schema.TypeInt, + Required: true, + Description: "Number of nodes in the nodepool", + ValidateFunc: validation.IntAtLeast(1), + }, + "size": { + Type: schema.TypeString, + Required: true, + Description: "Size of the nodes in the nodepool", + }, + "instance_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: "Instance names in the nodepool", + }, + "public_ip_node_pool": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Node pool belongs to the public ip node pool", + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "taint": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Required: true, + }, + "effect": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "NoSchedule", + "PreferNoSchedule", + "NoExecute", + }, false), + }, + }, + }, + }, + } + + if isResource { + // add the cluster id to the schema + s["cluster_id"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The ID of your cluster", + ValidateFunc: validation.StringIsNotEmpty, + } + } + + return s +} + +// function to flatten all instances inside the cluster +func flattenNodePool(cluster *civogo.KubernetesCluster) []interface{} { + if cluster.Pools == nil { + return nil + } + + flattenedPool := make([]interface{}, 0) + + poolInstanceNames := make([]string, 0) + poolInstanceNames = append(poolInstanceNames, cluster.Pools[0].InstanceNames...) + + rawPool := map[string]interface{}{ + "label": cluster.Pools[0].ID, + "node_count": cluster.Pools[0].Count, + "size": cluster.Pools[0].Size, + "instance_names": poolInstanceNames, + "public_ip_node_pool": cluster.Pools[0].PublicIPNodePool, + } + + flattenedPool = append(flattenedPool, rawPool) + + return flattenedPool +} + +// function to flatten all applications inside the cluster +func flattenInstalledApplication(apps []civogo.KubernetesInstalledApplication) []interface{} { + if apps == nil { + return nil + } + + flattenedInstalledApplication := make([]interface{}, 0) + for _, app := range apps { + rawInstalledApplication := map[string]interface{}{ + "application": app.Name, + "version": app.Version, + "installed": app.Installed, + "category": app.Category, + } + + flattenedInstalledApplication = append(flattenedInstalledApplication, rawInstalledApplication) + } + + return flattenedInstalledApplication +} + +// exapandNodePools function to expand the node pools +func expandNodePools(nodePools []interface{}) []civogo.KubernetesClusterPoolConfig { + expandedNodePools := make([]civogo.KubernetesClusterPoolConfig, 0, len(nodePools)) + for _, rawPool := range nodePools { + pool := rawPool.(map[string]interface{}) + + poolID := uuid.NewString() + if pool["label"].(string) != "" { + poolID = pool["label"].(string) + } + + cr := civogo.KubernetesClusterPoolConfig{ + ID: poolID, + Size: pool["size"].(string), + Count: pool["node_count"].(int), + } + + if pool["public_ip_node_pool"].(bool) { + cr.PublicIPNodePool = pool["public_ip_node_pool"].(bool) + } + + expandedNodePools = append(expandedNodePools, cr) + } + + return expandedNodePools +} diff --git a/civo/resource_kubernetes_cluster.go b/civo/kubernetes/resource_kubernetes_cluster.go similarity index 80% rename from civo/resource_kubernetes_cluster.go rename to civo/kubernetes/resource_kubernetes_cluster.go index cffb0d77..93af4b57 100644 --- a/civo/resource_kubernetes_cluster.go +++ b/civo/kubernetes/resource_kubernetes_cluster.go @@ -1,4 +1,4 @@ -package civo +package kubernetes import ( "context" @@ -8,15 +8,15 @@ import ( "github.com/civo/civogo" "github.com/civo/terraform-provider-civo/internal/utils" - "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Kubernetes Cluster resource, with this you can manage all cluster from terraform -func resourceKubernetesCluster() *schema.Resource { +// ResourceKubernetesCluster function returns a schema.Resource that represents a Kubernetes cluster. +// This can be used to create, read, update, and delete operations for a Kubernetes cluster in the infrastructure. +func ResourceKubernetesCluster() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo Kubernetes cluster resource. This can be used to create, delete, and modify clusters.", Schema: map[string]*schema.Schema{ @@ -97,7 +97,15 @@ func resourceKubernetesCluster() *schema.Resource { }, // Computed resource "installed_applications": applicationSchema(), - "pools": nodePoolSchema(), + "pools": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: nodePoolSchema(false), + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -150,50 +158,6 @@ func resourceKubernetesCluster() *schema.Resource { } } -// schema for the node pool in the cluster -func nodePoolSchema() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "label": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateDiagFunc: utils.ValidateNameOnlyContainsAlphanumericCharacters, - Description: "Node pool label, if you don't provide one, we will generate one for you", - }, - "node_count": { - Type: schema.TypeInt, - Required: true, - Description: "Number of nodes in the nodepool", - ValidateFunc: validation.IntAtLeast(1), - }, - "size": { - Type: schema.TypeString, - Required: true, - Description: "Size of the nodes in the nodepool", - }, - "instance_names": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: "Instance names in the nodepool", - }, - "public_ip_node_pool": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Node pool belongs to the public ip node pool", - }, - }, - }, - } -} - // schema for the application in the cluster func applicationSchema() *schema.Schema { return &schema.Schema{ @@ -488,75 +452,3 @@ func resourceKubernetesClusterDelete(_ context.Context, d *schema.ResourceData, return nil } - -// function to flatten all instances inside the cluster -func flattenNodePool(cluster *civogo.KubernetesCluster) []interface{} { - if cluster.Pools == nil { - return nil - } - - flattenedPool := make([]interface{}, 0) - - poolInstanceNames := make([]string, 0) - poolInstanceNames = append(poolInstanceNames, cluster.Pools[0].InstanceNames...) - - rawPool := map[string]interface{}{ - "label": cluster.Pools[0].ID, - "node_count": cluster.Pools[0].Count, - "size": cluster.Pools[0].Size, - "instance_names": poolInstanceNames, - "public_ip_node_pool": cluster.Pools[0].PublicIPNodePool, - } - - flattenedPool = append(flattenedPool, rawPool) - - return flattenedPool -} - -// function to flatten all applications inside the cluster -func flattenInstalledApplication(apps []civogo.KubernetesInstalledApplication) []interface{} { - if apps == nil { - return nil - } - - flattenedInstalledApplication := make([]interface{}, 0) - for _, app := range apps { - rawInstalledApplication := map[string]interface{}{ - "application": app.Name, - "version": app.Version, - "installed": app.Installed, - "category": app.Category, - } - - flattenedInstalledApplication = append(flattenedInstalledApplication, rawInstalledApplication) - } - - return flattenedInstalledApplication -} - -// exapandNodePools function to expand the node pools -func expandNodePools(nodePools []interface{}) []civogo.KubernetesClusterPoolConfig { - expandedNodePools := make([]civogo.KubernetesClusterPoolConfig, 0, len(nodePools)) - for _, rawPool := range nodePools { - pool := rawPool.(map[string]interface{}) - - poolID := uuid.NewString() - if pool["label"].(string) != "" { - poolID = pool["label"].(string) - } - - cr := civogo.KubernetesClusterPoolConfig{ - ID: poolID, - Size: pool["size"].(string), - Count: pool["node_count"].(int), - } - - if pool["public_ip_node_pool"].(bool) { - cr.PublicIPNodePool = pool["public_ip_node_pool"].(bool) - } - - expandedNodePools = append(expandedNodePools, cr) - } - - return expandedNodePools -} diff --git a/civo/resource_kubernetes_cluster_nodepool.go b/civo/kubernetes/resource_kubernetes_cluster_nodepool.go similarity index 82% rename from civo/resource_kubernetes_cluster_nodepool.go rename to civo/kubernetes/resource_kubernetes_cluster_nodepool.go index 06a6d968..953733b8 100644 --- a/civo/resource_kubernetes_cluster_nodepool.go +++ b/civo/kubernetes/resource_kubernetes_cluster_nodepool.go @@ -1,4 +1,4 @@ -package civo +package kubernetes import ( "context" @@ -16,92 +16,14 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Kubernetes Cluster resource, with this you can manage all cluster from terraform -func resourceKubernetesClusterNodePool() *schema.Resource { +// ResourceKubernetesClusterNodePool function returns a schema.Resource that represents a node pool in a Kubernetes cluster. +// This can be used to create, read, update, and delete operations for a node pool in a Kubernetes cluster from terraform. +func ResourceKubernetesClusterNodePool() *schema.Resource { return &schema.Resource{ - Description: "Provides a Civo Kubernetes node pool resource. While the default node pool must be defined in the `civo_kubernetes_cluster` resource, this resource can be used to add additional ones to a cluster.", - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Required: true, - Description: "The ID of your cluster", - ValidateFunc: validation.StringIsNotEmpty, - }, - "label": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateDiagFunc: utils.ValidateNameOnlyContainsAlphanumericCharacters, - Description: "Node pool label, if you don't provide one, we will generate one for you", - }, - "region": { - Type: schema.TypeString, - Required: true, - Description: "The region of the node pool, has to match that of the cluster", - ValidateFunc: validation.StringIsNotEmpty, - }, - "node_count": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "the number of instances to create (optional, the default at the time of writing is 3)", - }, - "size": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "the size of each node (optional, the default is currently g4s.kube.medium)", - }, - "instance_names": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Description: "Instance names in the nodepool", - }, - "public_ip_node_pool": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Node pool belongs to the public ip node pool", - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "taint": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Required: true, - }, - "value": { - Type: schema.TypeString, - Required: true, - }, - "effect": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - "NoSchedule", - "PreferNoSchedule", - "NoExecute", - }, false), - }, - }, - }, - }, - }, + Description: "Provides a Civo Kubernetes node pool resource. While the default node pool must be defined in the `civo_kubernetes_cluster` resource, this resource can be used to add additional ones to a cluster.", + Schema: nodePoolSchema(true), CreateContext: resourceKubernetesClusterNodePoolCreate, ReadContext: resourceKubernetesClusterNodePoolRead, UpdateContext: resourceKubernetesClusterNodePoolUpdate, diff --git a/civo/resource_kubernetes_cluster_nodepool_test.go b/civo/kubernetes/resource_kubernetes_cluster_nodepool_test.go similarity index 71% rename from civo/resource_kubernetes_cluster_nodepool_test.go rename to civo/kubernetes/resource_kubernetes_cluster_nodepool_test.go index a5c0f797..b4a68d5c 100644 --- a/civo/resource_kubernetes_cluster_nodepool_test.go +++ b/civo/kubernetes/resource_kubernetes_cluster_nodepool_test.go @@ -1,10 +1,11 @@ -package civo +package kubernetes_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -21,28 +22,28 @@ func TestAccCivoKubernetesClusterNodePool_basic(t *testing.T) { var kubernetesClusterName = acctest.RandomWithPrefix("tf-test") + "-example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoKubernetesClusterDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoKubernetesClusterDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoKubernetesClusterConfigBasic(kubernetesClusterName), + Config: CivoKubernetesClusterConfigBasic(kubernetesClusterName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoKubernetesClusterResourceExists(resName, &kubernetes), + CivoKubernetesClusterResourceExists(resName, &kubernetes), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoKubernetesClusterConfigBasic(kubernetesClusterName) + testAccCheckCivoKubernetesClusterNodePoolConfigBasic(), + Config: CivoKubernetesClusterConfigBasic(kubernetesClusterName) + CivoKubernetesClusterNodePoolConfigBasic(), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoKubernetesClusterNodePoolResourceExists(resPoolName, &kubernetes, &kubernetesNodePool), + CivoKubernetesClusterNodePoolResourceExists(resPoolName, &kubernetes, &kubernetesNodePool), // verify remote values - testAccCheckCivoKubernetesClusterNodePoolValues(&kubernetesNodePool, "g4s.kube.small"), + CivoKubernetesClusterNodePoolValues(&kubernetesNodePool, "g4s.kube.small"), // verify local values // resource.TestCheckResourceAttr(resPoolName, "cluster_id", kubernetes.ID), resource.TestCheckResourceAttr(resPoolName, "node_count", "3"), @@ -53,7 +54,7 @@ func TestAccCivoKubernetesClusterNodePool_basic(t *testing.T) { }) } -func testAccCheckCivoKubernetesClusterNodePoolValues(kubernetes *civogo.KubernetesPool, value string) resource.TestCheckFunc { +func CivoKubernetesClusterNodePoolValues(kubernetes *civogo.KubernetesPool, value string) resource.TestCheckFunc { return func(_ *terraform.State) error { if kubernetes.Size != value { return fmt.Errorf("bad name, expected \"%s\", got: %#v", value, kubernetes.Size) @@ -63,7 +64,7 @@ func testAccCheckCivoKubernetesClusterNodePoolValues(kubernetes *civogo.Kubernet } // testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoKubernetesClusterNodePoolResourceExists(n string, kubernetes *civogo.KubernetesCluster, pool *civogo.KubernetesPool) resource.TestCheckFunc { +func CivoKubernetesClusterNodePoolResourceExists(n string, kubernetes *civogo.KubernetesCluster, pool *civogo.KubernetesPool) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -72,7 +73,7 @@ func testAccCheckCivoKubernetesClusterNodePoolResourceExists(n string, kubernete } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.GetKubernetesCluster(kubernetes.ID) if err != nil { return fmt.Errorf("Kuberenetes Cluster not found: (%s) %s", rs.Primary.ID, err) @@ -94,7 +95,7 @@ func testAccCheckCivoKubernetesClusterNodePoolResourceExists(n string, kubernete } } -func testAccCheckCivoKubernetesClusterNodePoolConfigBasic() string { +func CivoKubernetesClusterNodePoolConfigBasic() string { return ` resource "civo_kubernetes_node_pool" "foobar" { cluster_id = civo_kubernetes_cluster.foobar.id diff --git a/civo/resource_kubernetes_cluster_test.go b/civo/kubernetes/resource_kubernetes_cluster_test.go similarity index 70% rename from civo/resource_kubernetes_cluster_test.go rename to civo/kubernetes/resource_kubernetes_cluster_test.go index 468983af..7af1abb5 100644 --- a/civo/resource_kubernetes_cluster_test.go +++ b/civo/kubernetes/resource_kubernetes_cluster_test.go @@ -1,16 +1,16 @@ -package civo +package kubernetes_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -// example.Widget represents a concrete Go type that represents an API resource func TestAccCivoKubernetesCluster_basic(t *testing.T) { var kubernetes civogo.KubernetesCluster @@ -19,19 +19,19 @@ func TestAccCivoKubernetesCluster_basic(t *testing.T) { var kubernetesClusterName = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoKubernetesClusterDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoKubernetesClusterDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoKubernetesClusterConfigBasic(kubernetesClusterName), + Config: CivoKubernetesClusterConfigBasic(kubernetesClusterName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoKubernetesClusterResourceExists(resName, &kubernetes), + CivoKubernetesClusterResourceExists(resName, &kubernetes), // verify remote values - testAccCheckCivoKubernetesClusterValues(&kubernetes, kubernetesClusterName), + CivoKubernetesClusterValues(&kubernetes, kubernetesClusterName), // verify local values resource.TestCheckResourceAttr(resName, "name", kubernetesClusterName), @@ -58,17 +58,17 @@ func TestAccCivoKubernetesClusterCNI(t *testing.T) { var kubernetesClusterName = acctest.RandomWithPrefix("tf-test") + ".example" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoInstanceDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: acceptance.CivoInstanceDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoKubernetesClusterConfigCNI(kubernetesClusterName), + Config: CivoKubernetesClusterConfigCNI(kubernetesClusterName), Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoKubernetesClusterResourceExists(resName, &kubernetes), + CivoKubernetesClusterResourceExists(resName, &kubernetes), // verify remote values - testAccCheckCivoKubernetesClusterValues(&kubernetes, kubernetesClusterName), + CivoKubernetesClusterValues(&kubernetes, kubernetesClusterName), // verify local values resource.TestCheckResourceAttr(resName, "name", kubernetesClusterName), resource.TestCheckResourceAttr(resName, "cni", "cilium"), @@ -86,7 +86,7 @@ func TestAccCivoKubernetesClusterCNI(t *testing.T) { }) } -func testAccCheckCivoKubernetesClusterValues(kubernetes *civogo.KubernetesCluster, name string) resource.TestCheckFunc { +func CivoKubernetesClusterValues(kubernetes *civogo.KubernetesCluster, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if kubernetes.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, kubernetes.Name) @@ -95,8 +95,8 @@ func testAccCheckCivoKubernetesClusterValues(kubernetes *civogo.KubernetesCluste } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoKubernetesClusterResourceExists(n string, kubernetes *civogo.KubernetesCluster) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoKubernetesClusterResourceExists(n string, kubernetes *civogo.KubernetesCluster) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -105,7 +105,7 @@ func testAccCheckCivoKubernetesClusterResourceExists(n string, kubernetes *civog } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.GetKubernetesCluster(rs.Primary.ID) if err != nil { return fmt.Errorf("Kuberenetes Cluster not found: (%s) %s", rs.Primary.ID, err) @@ -119,24 +119,7 @@ func testAccCheckCivoKubernetesClusterResourceExists(n string, kubernetes *civog } } -func testAccCheckCivoKubernetesClusterDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "civo_kubernetes_cluster" { - continue - } - - _, err := client.GetKubernetesCluster(rs.Primary.ID) - if err == nil { - return fmt.Errorf("Kubernetes Cluster still exists") - } - } - - return nil -} - -func testAccCheckCivoKubernetesClusterConfigBasic(name string) string { +func CivoKubernetesClusterConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_firewall" "default" { name = "%s" @@ -154,7 +137,7 @@ resource "civo_kubernetes_cluster" "foobar" { }`, name, name) } -func testAccCheckCivoKubernetesClusterConfigCNI(name string) string { +func CivoKubernetesClusterConfigCNI(name string) string { return fmt.Sprintf(` resource "civo_firewall" "default" { name = "%s" diff --git a/civo/datasource_loadbalancer.go b/civo/loadbalancer/datasource_loadbalancer.go similarity index 95% rename from civo/datasource_loadbalancer.go rename to civo/loadbalancer/datasource_loadbalancer.go index 56bc69f0..63674af9 100644 --- a/civo/datasource_loadbalancer.go +++ b/civo/loadbalancer/datasource_loadbalancer.go @@ -1,4 +1,4 @@ -package civo +package loadbalancer import ( "context" @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Data source to get from the api a specific Load Balancer -// using the id or the hostname of the Load Balancer -func dataSourceLoadBalancer() *schema.Resource { +// DataSourceLoadBalancer function returns a schema.Resource that represents a Load Balancer. +// This can be used to query and retrieve details about a specific Load Balancer in the infrastructure using its id or hostname. +func DataSourceLoadBalancer() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a load balancer for use in other resources. This data source provides all of the load balancers properties as configured on your Civo account.", diff --git a/civo/datasource_loadbalancer_test.go b/civo/loadbalancer/datasource_loadbalancer_test.go similarity index 84% rename from civo/datasource_loadbalancer_test.go rename to civo/loadbalancer/datasource_loadbalancer_test.go index f2a02bbc..0b913ad7 100644 --- a/civo/datasource_loadbalancer_test.go +++ b/civo/loadbalancer/datasource_loadbalancer_test.go @@ -1,4 +1,4 @@ -package civo +package loadbalancer /* import ( @@ -9,16 +9,16 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccDataSourceCivoLoadBalancer_basic(t *testing.T) { +func DataSourceCivoLoadBalancer_basic(t *testing.T) { datasourceName := "data.civo_loadbalancer.foobar" name := acctest.RandomWithPrefix("lb-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() {PreCheck(t) }, + Providers:Providers, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoLoadBalancerConfig(name), + Config:DataSourceCivoLoadBalancerConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "hostname", name), resource.TestCheckResourceAttr(datasourceName, "protocol", "http"), @@ -34,7 +34,7 @@ func TestAccDataSourceCivoLoadBalancer_basic(t *testing.T) { }) } -func testAccDataSourceCivoLoadBalancerConfig(name string) string { +funcDataSourceCivoLoadBalancerConfig(name string) string { return fmt.Sprintf(` resource "civo_instance" "vm" { hostname = "instance-%s" diff --git a/civo/resource_loadbalancer.go.disabled b/civo/loadbalancer/resource_loadbalancer.go.disabled similarity index 100% rename from civo/resource_loadbalancer.go.disabled rename to civo/loadbalancer/resource_loadbalancer.go.disabled diff --git a/civo/resource_loadbalancer_test.go.disabled b/civo/loadbalancer/resource_loadbalancer_test.go.disabled similarity index 79% rename from civo/resource_loadbalancer_test.go.disabled rename to civo/loadbalancer/resource_loadbalancer_test.go.disabled index 7d23d251..2eddc4fb 100644 --- a/civo/resource_loadbalancer_test.go.disabled +++ b/civo/loadbalancer/resource_loadbalancer_test.go.disabled @@ -13,20 +13,20 @@ import ( var domainName = acctest.RandString(10) // example.Widget represents a concrete Go type that represents an API resource -func TestAccCivoLoadBalancer_basic(t *testing.T) { +func CivoLoadBalancer_basic(t *testing.T) { var loadBalancer civogo.LoadBalancer // generate a random name for each test run resName := "civo_loadbalancer.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoLoadBalancerDestroy, + PreCheck: func() {PreCheck(t) }, + Providers: Providers, + CheckDestroy:CheckCivoLoadBalancerDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoLoadBalancerConfigBasic(domainName), + Config:CheckCivoLoadBalancerConfigBasic(domainName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object @@ -46,19 +46,19 @@ func TestAccCivoLoadBalancer_basic(t *testing.T) { }) } -func TestAccCivoLoadBalancer_update(t *testing.T) { +func CivoLoadBalancer_update(t *testing.T) { var loadBalancer civogo.LoadBalancer // generate a random name for each test run resName := "civo_loadbalancer.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallRuleDestroy, + PreCheck: func() {PreCheck(t) }, + Providers: Providers, + CheckDestroy:CheckCivoFirewallRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoLoadBalancerConfigBasic(domainName), + Config:CheckCivoLoadBalancerConfigBasic(domainName), Check: resource.ComposeTestCheckFunc( testAccCheckCivoLoadBalancerResourceExists(resName, &loadBalancer), resource.TestCheckResourceAttr(resName, "protocol", "http"), @@ -71,7 +71,7 @@ func TestAccCivoLoadBalancer_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoLoadBalancerConfigUpdates(domainName), + Config:CheckCivoLoadBalancerConfigUpdates(domainName), Check: resource.ComposeTestCheckFunc( testAccCheckCivoLoadBalancerResourceExists(resName, &loadBalancer), testAccCheckCivoLoadBalancerUpdated(&loadBalancer, domainName), @@ -87,7 +87,7 @@ func TestAccCivoLoadBalancer_update(t *testing.T) { }) } -func testAccCheckCivoLoadBalancerValues(loadBalancer *civogo.LoadBalancer, name string) resource.TestCheckFunc { +funcCheckCivoLoadBalancerValues(loadBalancer *civogo.LoadBalancer, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if loadBalancer.Hostname != name { return fmt.Errorf("bad protocol, expected \"%s\", got: %#v", name, loadBalancer.Hostname) @@ -96,8 +96,8 @@ func testAccCheckCivoLoadBalancerValues(loadBalancer *civogo.LoadBalancer, name } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoLoadBalancerResourceExists(n string, loadBalancer *civogo.LoadBalancer) resource.TestCheckFunc { +//CheckExampleResourceExists queries the API and retrieves the matching Widget. +funcCheckCivoLoadBalancerResourceExists(n string, loadBalancer *civogo.LoadBalancer) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -106,7 +106,7 @@ func testAccCheckCivoLoadBalancerResourceExists(n string, loadBalancer *civogo.L } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client :=Provider.Meta().(*civogo.Client) resp, err := client.FindLoadBalancer(rs.Primary.ID) if err != nil { return fmt.Errorf("LoadBalancer not found: (%s) %s", rs.Primary.ID, err) @@ -120,7 +120,7 @@ func testAccCheckCivoLoadBalancerResourceExists(n string, loadBalancer *civogo.L } } -func testAccCheckCivoLoadBalancerUpdated(loadBalancer *civogo.LoadBalancer, name string) resource.TestCheckFunc { +funcCheckCivoLoadBalancerUpdated(loadBalancer *civogo.LoadBalancer, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if loadBalancer.Hostname != fmt.Sprintf("rename-%s", name) { return fmt.Errorf("bad protocol, expected \"%s\", got: %#v", fmt.Sprintf("rename-%s", name), loadBalancer.Hostname) @@ -129,8 +129,8 @@ func testAccCheckCivoLoadBalancerUpdated(loadBalancer *civogo.LoadBalancer, name } } -func testAccCheckCivoLoadBalancerDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +funcCheckCivoLoadBalancerDestroy(s *terraform.State) error { + client :=Provider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_loadbalancer" { @@ -146,7 +146,7 @@ func testAccCheckCivoLoadBalancerDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoLoadBalancerConfigBasic(name string) string { +funcCheckCivoLoadBalancerConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_instance" "vm" { hostname = "instance-%s" @@ -172,7 +172,7 @@ resource "civo_loadbalancer" "foobar" { `, name, name) } -func testAccCheckCivoLoadBalancerConfigUpdates(name string) string { +funcCheckCivoLoadBalancerConfigUpdates(name string) string { return fmt.Sprintf(` resource "civo_instance" "vm" { hostname = "instance-%s" diff --git a/civo/datasource_network.go b/civo/network/datasource_network.go similarity index 91% rename from civo/datasource_network.go rename to civo/network/datasource_network.go index 0e12c10f..94171bd1 100644 --- a/civo/datasource_network.go +++ b/civo/network/datasource_network.go @@ -1,4 +1,4 @@ -package civo +package network import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific network -// using the id or the label -func dataSourceNetwork() *schema.Resource { +// DataSourceNetwork function returns a schema.Resource that represents a Network. +// This can be used to query and retrieve details about a specific Network in the infrastructure using its id or label. +func DataSourceNetwork() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Retrieve information about a network for use in other resources.", diff --git a/civo/datasource_network_test.go b/civo/network/datasource_network_test.go similarity index 71% rename from civo/datasource_network_test.go rename to civo/network/datasource_network_test.go index f494da29..1766893e 100644 --- a/civo/datasource_network_test.go +++ b/civo/network/datasource_network_test.go @@ -1,9 +1,10 @@ -package civo +package network_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoNetwork_basic(t *testing.T) { name := acctest.RandomWithPrefix("net-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoNetworkConfig(name), + Config: DataSourceCivoNetworkConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "label", name), ), @@ -26,7 +27,7 @@ func TestAccDataSourceCivoNetwork_basic(t *testing.T) { }) } -func testAccDataSourceCivoNetworkConfig(name string) string { +func DataSourceCivoNetworkConfig(name string) string { return fmt.Sprintf(` resource "civo_network" "foobar" { label = "%s" diff --git a/civo/resource_network.go b/civo/network/resource_network.go similarity index 95% rename from civo/resource_network.go rename to civo/network/resource_network.go index 901ccaf6..e4f935b8 100644 --- a/civo/resource_network.go +++ b/civo/network/resource_network.go @@ -1,4 +1,4 @@ -package civo +package network import ( "context" @@ -12,8 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// The resource network represent a network inside the cloud -func resourceNetwork() *schema.Resource { +// ResourceNetwork function returns a schema.Resource that represents a Network. +// This can be used to create, read, update, and delete operations for a Network in the infrastructure. +func ResourceNetwork() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo network resource. This can be used to create, modify, and delete networks.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_network_test.go b/civo/network/resource_network_test.go similarity index 66% rename from civo/resource_network_test.go rename to civo/network/resource_network_test.go index 705f511c..2fb70afa 100644 --- a/civo/resource_network_test.go +++ b/civo/network/resource_network_test.go @@ -1,10 +1,11 @@ -package civo +package network_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,19 +20,19 @@ func TestAccCivoNetwork_basic(t *testing.T) { var networkLabel = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoNetworkDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoNetworkDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoNetworkConfigBasic(networkLabel), + Config: CivoNetworkConfigBasic(networkLabel), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoNetworkResourceExists(resName, &network), + CivoNetworkResourceExists(resName, &network), // verify remote values - testAccCheckCivoNetworkValues(&network, networkLabel), + CivoNetworkValues(&network, networkLabel), // verify local values resource.TestCheckResourceAttr(resName, "label", networkLabel), resource.TestCheckResourceAttr(resName, "default", "false"), @@ -49,24 +50,24 @@ func TestAccCivoNetwork_update(t *testing.T) { var networkLabel = acctest.RandomWithPrefix("rename-tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoNetworkDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoNetworkDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoNetworkConfigUpdates(networkLabel), + Config: CivoNetworkConfigUpdates(networkLabel), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoNetworkResourceExists(resName, &network), - testAccCheckCivoNetworkValues(&network, networkLabel), + CivoNetworkResourceExists(resName, &network), + CivoNetworkValues(&network, networkLabel), resource.TestCheckResourceAttr(resName, "label", networkLabel), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoNetworkConfigUpdates(networkLabel), + Config: CivoNetworkConfigUpdates(networkLabel), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoNetworkResourceExists(resName, &network), - testAccCheckCivoNetworkUpdated(&network, networkLabel), + CivoNetworkResourceExists(resName, &network), + CivoNetworkUpdated(&network, networkLabel), resource.TestCheckResourceAttr(resName, "label", networkLabel), ), }, @@ -74,7 +75,7 @@ func TestAccCivoNetwork_update(t *testing.T) { }) } -func testAccCheckCivoNetworkValues(network *civogo.Network, name string) resource.TestCheckFunc { +func CivoNetworkValues(network *civogo.Network, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if network.Label != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, network.Label) @@ -83,8 +84,8 @@ func testAccCheckCivoNetworkValues(network *civogo.Network, name string) resourc } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoNetworkResourceExists(n string, network *civogo.Network) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoNetworkResourceExists(n string, network *civogo.Network) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -93,7 +94,7 @@ func testAccCheckCivoNetworkResourceExists(n string, network *civogo.Network) re } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindNetwork(rs.Primary.ID) if err != nil { return fmt.Errorf("Network not found: (%s) %s", rs.Primary.ID, err) @@ -107,7 +108,7 @@ func testAccCheckCivoNetworkResourceExists(n string, network *civogo.Network) re } } -func testAccCheckCivoNetworkUpdated(network *civogo.Network, name string) resource.TestCheckFunc { +func CivoNetworkUpdated(network *civogo.Network, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if network.Label != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, network.Label) @@ -116,8 +117,8 @@ func testAccCheckCivoNetworkUpdated(network *civogo.Network, name string) resour } } -func testAccCheckCivoNetworkDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoNetworkDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_network" { @@ -133,14 +134,14 @@ func testAccCheckCivoNetworkDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoNetworkConfigBasic(label string) string { +func CivoNetworkConfigBasic(label string) string { return fmt.Sprintf(` resource "civo_network" "foobar" { label = "%s" }`, label) } -func testAccCheckCivoNetworkConfigUpdates(label string) string { +func CivoNetworkConfigUpdates(label string) string { return fmt.Sprintf(` resource "civo_network" "foobar" { label = "%s" diff --git a/civo/datasource_object_store.go b/civo/objectstorage/datasource_object_store.go similarity index 91% rename from civo/datasource_object_store.go rename to civo/objectstorage/datasource_object_store.go index 0bd59592..f88cb9fe 100644 --- a/civo/datasource_object_store.go +++ b/civo/objectstorage/datasource_object_store.go @@ -1,4 +1,4 @@ -package civo +package objectstorage import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific ObjectStore -// using the id or the name -func dataSourceObjectStore() *schema.Resource { +// DataSourceObjectStore function returns a schema.Resource that represents an Object Store. +// This can be used to query and retrieve details about a specific Object Store in the infrastructure using its id or name. +func DataSourceObjectStore() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information of an Object Store for use in other resources. This data source provides all of the Object Store's properties as configured on your Civo account.", diff --git a/civo/datasource_object_store_credentials.go b/civo/objectstorage/datasource_object_store_credentials.go similarity index 90% rename from civo/datasource_object_store_credentials.go rename to civo/objectstorage/datasource_object_store_credentials.go index 435a6f60..0529fd28 100644 --- a/civo/datasource_object_store_credentials.go +++ b/civo/objectstorage/datasource_object_store_credentials.go @@ -1,4 +1,4 @@ -package civo +package objectstorage import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific ObjectStoreCredential -// using the id or the name -func dataSourceObjectStoreCredential() *schema.Resource { +// DataSourceObjectStoreCredential function returns a schema.Resource that represents an Object Store Credential. +// This can be used to query and retrieve details about a specific Object Store Credential in the infrastructure using its id or name. +func DataSourceObjectStoreCredential() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information of an Object Store Credential for use in other resources. This data source provides all of the Object Store Credential's properties as configured on your Civo account.", diff --git a/civo/datasource_object_store_credentials_test.go b/civo/objectstorage/datasource_object_store_credentials_test.go similarity index 75% rename from civo/datasource_object_store_credentials_test.go rename to civo/objectstorage/datasource_object_store_credentials_test.go index 298a3a83..d2885c2e 100644 --- a/civo/datasource_object_store_credentials_test.go +++ b/civo/objectstorage/datasource_object_store_credentials_test.go @@ -1,9 +1,10 @@ -package civo +package objectstorage_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoObjectStoreCredential_basic(t *testing.T) { name := acctest.RandomWithPrefix("objectstorecredential") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoObjectStoreCredentialConfig(name), + Config: DataSourceCivoObjectStoreCredentialConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttrSet(datasourceName, "access_key_id"), @@ -29,7 +30,7 @@ func TestAccDataSourceCivoObjectStoreCredential_basic(t *testing.T) { }) } -func testAccDataSourceCivoObjectStoreCredentialConfig(name string) string { +func DataSourceCivoObjectStoreCredentialConfig(name string) string { return fmt.Sprintf(` resource "civo_object_store_credential" "foobar" { name = "%s" diff --git a/civo/datasource_object_store_test.go b/civo/objectstorage/datasource_object_store_test.go similarity index 78% rename from civo/datasource_object_store_test.go rename to civo/objectstorage/datasource_object_store_test.go index 7eb6ba6e..0148d52c 100644 --- a/civo/datasource_object_store_test.go +++ b/civo/objectstorage/datasource_object_store_test.go @@ -1,9 +1,10 @@ -package civo +package objectstorage_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoObjectStore_basic(t *testing.T) { name := acctest.RandomWithPrefix("objectstore") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoObjectStoreConfig(name), + Config: DataSourceCivoObjectStoreConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttrSet(datasourceName, "max_size_gb"), @@ -31,7 +32,7 @@ func TestAccDataSourceCivoObjectStore_basic(t *testing.T) { }) } -func testAccDataSourceCivoObjectStoreConfig(name string) string { +func DataSourceCivoObjectStoreConfig(name string) string { return fmt.Sprintf(` resource "civo_object_store" "foobar" { name = "%s" diff --git a/civo/resource_object_store.go b/civo/objectstorage/resource_object_store.go similarity index 95% rename from civo/resource_object_store.go rename to civo/objectstorage/resource_object_store.go index b6310849..a607eb91 100644 --- a/civo/resource_object_store.go +++ b/civo/objectstorage/resource_object_store.go @@ -1,4 +1,4 @@ -package civo +package objectstorage import ( "context" @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// The Object Store resource represents an ObjectStore object -// and with it you can handle the Object Stores created with Terraform. -func resourceObjectStore() *schema.Resource { +// ResourceObjectStore function returns a schema.Resource that represents an Object Store. +// This can be used to create, read, update, and delete operations for an Object Store in the infrastructure. +func ResourceObjectStore() *schema.Resource { return &schema.Resource{ Description: "Provides an Object Store resource. This can be used to create, modify, and delete object stores.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_object_store_credentials.go b/civo/objectstorage/resource_object_store_credentials.go similarity index 95% rename from civo/resource_object_store_credentials.go rename to civo/objectstorage/resource_object_store_credentials.go index 8644c625..d6460a69 100644 --- a/civo/resource_object_store_credentials.go +++ b/civo/objectstorage/resource_object_store_credentials.go @@ -1,4 +1,4 @@ -package civo +package objectstorage import ( "context" @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// The Object Store Credential resource represents an ObjectStoreCredential object -// and with it you can handle the Object Stores Credential created with Terraform. -func resourceObjectStoreCredential() *schema.Resource { +// ResourceObjectStoreCredential function returns a schema.Resource that represents an Object Store Credential. +// This can be used to create, read, update, and delete operations for an Object Store Credential in the infrastructure. +func ResourceObjectStoreCredential() *schema.Resource { return &schema.Resource{ Description: "Provides an Object Store Credential resource. This can be used to create, modify, and delete object stores credential.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_object_store_credentials_test.go b/civo/objectstorage/resource_object_store_credentials_test.go similarity index 67% rename from civo/resource_object_store_credentials_test.go rename to civo/objectstorage/resource_object_store_credentials_test.go index f57f0f9f..cc499ca4 100644 --- a/civo/resource_object_store_credentials_test.go +++ b/civo/objectstorage/resource_object_store_credentials_test.go @@ -1,10 +1,11 @@ -package civo +package objectstorage_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -18,19 +19,19 @@ func TestAccCivoObjectStoreCredential_basic(t *testing.T) { var storeCredentialName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoObjectStoreCredentialDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoObjectStoreCredentialDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoObjectStoreCredentialConfigBasic(storeCredentialName), + Config: CivoObjectStoreCredentialConfigBasic(storeCredentialName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoObjectStoreCredentialResourceExists(resName, &storeCredential), + CivoObjectStoreCredentialResourceExists(resName, &storeCredential), // verify remote values - testAccCheckCivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), + CivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), // verify local values resource.TestCheckResourceAttr(resName, "name", storeCredentialName), resource.TestCheckResourceAttrSet(resName, "access_key_id"), @@ -50,19 +51,19 @@ func TestAccCivoObjectStoreCredentialWhitCustomCredential_basic(t *testing.T) { var storeCredentialName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoObjectStoreCredentialDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoObjectStoreCredentialDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoObjectStoreCredentialWhitCustomCredentialBasic(storeCredentialName), + Config: CivoObjectStoreCredentialWhitCustomCredentialBasic(storeCredentialName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoObjectStoreCredentialResourceExists(resName, &storeCredential), + CivoObjectStoreCredentialResourceExists(resName, &storeCredential), // verify remote values - testAccCheckCivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), + CivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), // verify local values resource.TestCheckResourceAttr(resName, "name", storeCredentialName), resource.TestCheckResourceAttr(resName, "access_key_id", "1234567890"), @@ -82,15 +83,15 @@ func TestAccCivoObjectStoreCredential_update(t *testing.T) { var storeCredentialName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoObjectStoreCredentialDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoObjectStoreCredentialDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoObjectStoreCredentialConfigBasic(storeCredentialName), + Config: CivoObjectStoreCredentialConfigBasic(storeCredentialName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoObjectStoreCredentialResourceExists(resName, &storeCredential), - testAccCheckCivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), + CivoObjectStoreCredentialResourceExists(resName, &storeCredential), + CivoObjectStoreCredentialValues(&storeCredential, storeCredentialName), resource.TestCheckResourceAttr(resName, "name", storeCredentialName), resource.TestCheckResourceAttrSet(resName, "access_key_id"), resource.TestCheckResourceAttrSet(resName, "secret_access_key"), @@ -99,10 +100,10 @@ func TestAccCivoObjectStoreCredential_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoObjectStoreCredentialConfigUpdates(storeCredentialName), + Config: CivoObjectStoreCredentialConfigUpdates(storeCredentialName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoObjectStoreCredentialResourceExists(resName, &storeCredential), - testAccCheckCivoObjectStoreCredentialUpdated(&storeCredential, storeCredentialName), + CivoObjectStoreCredentialResourceExists(resName, &storeCredential), + CivoObjectStoreCredentialUpdated(&storeCredential, storeCredentialName), resource.TestCheckResourceAttr(resName, "name", storeCredentialName), resource.TestCheckResourceAttrSet(resName, "access_key_id"), resource.TestCheckResourceAttr(resName, "secret_access_key", "1234567890"), @@ -113,7 +114,7 @@ func TestAccCivoObjectStoreCredential_update(t *testing.T) { }) } -func testAccCheckCivoObjectStoreCredentialValues(storeCredential *civogo.ObjectStoreCredential, name string) resource.TestCheckFunc { +func CivoObjectStoreCredentialValues(storeCredential *civogo.ObjectStoreCredential, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if storeCredential.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, storeCredential.Name) @@ -122,8 +123,8 @@ func testAccCheckCivoObjectStoreCredentialValues(storeCredential *civogo.ObjectS } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoObjectStoreCredentialResourceExists(n string, storeCredential *civogo.ObjectStoreCredential) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoObjectStoreCredentialResourceExists(n string, storeCredential *civogo.ObjectStoreCredential) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -132,7 +133,7 @@ func testAccCheckCivoObjectStoreCredentialResourceExists(n string, storeCredenti } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindObjectStoreCredential(rs.Primary.ID) if err != nil { return fmt.Errorf("Object Store Credential not found: (%s) %s", rs.Primary.ID, err) @@ -145,7 +146,7 @@ func testAccCheckCivoObjectStoreCredentialResourceExists(n string, storeCredenti } } -func testAccCheckCivoObjectStoreCredentialUpdated(storeCredential *civogo.ObjectStoreCredential, name string) resource.TestCheckFunc { +func CivoObjectStoreCredentialUpdated(storeCredential *civogo.ObjectStoreCredential, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if storeCredential.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, storeCredential.Name) @@ -154,8 +155,8 @@ func testAccCheckCivoObjectStoreCredentialUpdated(storeCredential *civogo.Object } } -func testAccCheckCivoObjectStoreCredentialDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoObjectStoreCredentialDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_object_store_credential" { @@ -171,14 +172,14 @@ func testAccCheckCivoObjectStoreCredentialDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoObjectStoreCredentialConfigBasic(name string) string { +func CivoObjectStoreCredentialConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_object_store_credential" "foobar" { name = "%s" }`, name) } -func testAccCheckCivoObjectStoreCredentialWhitCustomCredentialBasic(name string) string { +func CivoObjectStoreCredentialWhitCustomCredentialBasic(name string) string { return fmt.Sprintf(` resource "civo_object_store_credential" "foobar" { name = "%s" @@ -187,7 +188,7 @@ resource "civo_object_store_credential" "foobar" { }`, name) } -func testAccCheckCivoObjectStoreCredentialConfigUpdates(name string) string { +func CivoObjectStoreCredentialConfigUpdates(name string) string { return fmt.Sprintf(` resource "civo_object_store_credential" "foobar" { name = "%s" diff --git a/civo/resource_object_store_test.go b/civo/objectstorage/resource_object_store_test.go similarity index 69% rename from civo/resource_object_store_test.go rename to civo/objectstorage/resource_object_store_test.go index 656fc50e..15d65de0 100644 --- a/civo/resource_object_store_test.go +++ b/civo/objectstorage/resource_object_store_test.go @@ -1,4 +1,4 @@ -package civo +package objectstorage_test import ( "fmt" @@ -6,6 +6,7 @@ import ( "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -20,19 +21,19 @@ func TestAccCivoObjectStore_basic(t *testing.T) { var storeName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoObjectStoreDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoObjectStoreDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoObjectStoreConfigBasic(storeName), + Config: CivoObjectStoreConfigBasic(storeName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoObjectStoreResourceExists(resName, &store), + CivoObjectStoreResourceExists(resName, &store), // verify remote values - testAccCheckCivoObjectStoreValues(&store, storeName), + CivoObjectStoreValues(&store, storeName), // verify local values resource.TestCheckResourceAttr(resName, "name", storeName), resource.TestCheckResourceAttrSet(resName, "max_size_gb"), @@ -53,15 +54,15 @@ func TestAccCivoObjectStore_update(t *testing.T) { var storeName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoObjectStoreDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoObjectStoreDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoObjectStoreConfigBasic(storeName), + Config: CivoObjectStoreConfigBasic(storeName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoObjectStoreResourceExists(resName, &store), - testAccCheckCivoObjectStoreValues(&store, storeName), + CivoObjectStoreResourceExists(resName, &store), + CivoObjectStoreValues(&store, storeName), resource.TestCheckResourceAttr(resName, "name", storeName), resource.TestCheckResourceAttrSet(resName, "access_key_id"), resource.TestCheckResourceAttr(resName, "max_size_gb", strconv.Itoa(500)), @@ -69,10 +70,10 @@ func TestAccCivoObjectStore_update(t *testing.T) { }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoObjectStoreConfigUpdates(storeName), + Config: CivoObjectStoreConfigUpdates(storeName), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoObjectStoreResourceExists(resName, &store), - testAccCheckCivoObjectStoreUpdated(&store, storeName), + CivoObjectStoreResourceExists(resName, &store), + CivoObjectStoreUpdated(&store, storeName), resource.TestCheckResourceAttr(resName, "name", storeName), resource.TestCheckResourceAttrSet(resName, "access_key_id"), resource.TestCheckResourceAttr(resName, "max_size_gb", strconv.Itoa(1000)), @@ -82,7 +83,7 @@ func TestAccCivoObjectStore_update(t *testing.T) { }) } -func testAccCheckCivoObjectStoreValues(store *civogo.ObjectStore, name string) resource.TestCheckFunc { +func CivoObjectStoreValues(store *civogo.ObjectStore, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if store.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, store.Name) @@ -91,8 +92,8 @@ func testAccCheckCivoObjectStoreValues(store *civogo.ObjectStore, name string) r } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoObjectStoreResourceExists(n string, store *civogo.ObjectStore) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoObjectStoreResourceExists(n string, store *civogo.ObjectStore) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -101,7 +102,7 @@ func testAccCheckCivoObjectStoreResourceExists(n string, store *civogo.ObjectSto } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindObjectStore(rs.Primary.ID) if err != nil { return fmt.Errorf("Object Store not found: (%s) %s", rs.Primary.ID, err) @@ -114,7 +115,7 @@ func testAccCheckCivoObjectStoreResourceExists(n string, store *civogo.ObjectSto } } -func testAccCheckCivoObjectStoreUpdated(store *civogo.ObjectStore, name string) resource.TestCheckFunc { +func CivoObjectStoreUpdated(store *civogo.ObjectStore, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if store.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, store.Name) @@ -123,8 +124,8 @@ func testAccCheckCivoObjectStoreUpdated(store *civogo.ObjectStore, name string) } } -func testAccCheckCivoObjectStoreDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoObjectStoreDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_object_store" { @@ -140,7 +141,7 @@ func testAccCheckCivoObjectStoreDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoObjectStoreConfigBasic(name string) string { +func CivoObjectStoreConfigBasic(name string) string { return fmt.Sprintf(` resource "civo_object_store" "foobar" { name = "%s" @@ -149,7 +150,7 @@ resource "civo_object_store" "foobar" { }`, name) } -func testAccCheckCivoObjectStoreConfigUpdates(name string) string { +func CivoObjectStoreConfigUpdates(name string) string { return fmt.Sprintf(` resource "civo_object_store" "foobar" { name = "%s" diff --git a/civo/provider.go b/civo/provider.go index 71257ac2..7b2a03f1 100644 --- a/civo/provider.go +++ b/civo/provider.go @@ -5,6 +5,20 @@ import ( "log" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/database" + "github.com/civo/terraform-provider-civo/civo/disk" + "github.com/civo/terraform-provider-civo/civo/dns" + "github.com/civo/terraform-provider-civo/civo/firewall" + "github.com/civo/terraform-provider-civo/civo/instances" + "github.com/civo/terraform-provider-civo/civo/ip" + "github.com/civo/terraform-provider-civo/civo/kubernetes" + "github.com/civo/terraform-provider-civo/civo/loadbalancer" + "github.com/civo/terraform-provider-civo/civo/network" + "github.com/civo/terraform-provider-civo/civo/objectstorage" + "github.com/civo/terraform-provider-civo/civo/region" + "github.com/civo/terraform-provider-civo/civo/size" + "github.com/civo/terraform-provider-civo/civo/ssh" + "github.com/civo/terraform-provider-civo/civo/volume" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,48 +55,42 @@ func Provider() *schema.Provider { }, DataSourcesMap: map[string]*schema.Resource{ // "civo_template": dataSourceTemplate(), - "civo_disk_image": dataSourceDiskImage(), - "civo_kubernetes_version": dataSourceKubernetesVersion(), - "civo_kubernetes_cluster": dataSourceKubernetesCluster(), - "civo_size": dataSourceSize(), - "civo_instances": dataSourceInstances(), - "civo_instance": dataSourceInstance(), - "civo_dns_domain_name": dataSourceDNSDomainName(), - "civo_dns_domain_record": dataSourceDNSDomainRecord(), - "civo_network": dataSourceNetwork(), - "civo_volume": dataSourceVolume(), - "civo_firewall": dataSourceFirewall(), - "civo_loadbalancer": dataSourceLoadBalancer(), - "civo_ssh_key": dataSourceSSHKey(), - "civo_object_store": dataSourceObjectStore(), - "civo_object_store_credential": dataSourceObjectStoreCredential(), - "civo_region": dataSourceRegion(), - "civo_reserved_ip": dataSourceReservedIP(), - "civo_database": dataSourceDatabase(), - "civo_database_version": dataDatabaseVersion(), - // "civo_snapshot": dataSourceSnapshot(), + "civo_disk_image": disk.DataSourceDiskImage(), + "civo_kubernetes_version": kubernetes.DataSourceKubernetesVersion(), + "civo_kubernetes_cluster": kubernetes.DataSourceKubernetesCluster(), + "civo_size": size.DataSourceSize(), + "civo_instances": instances.DataSourceInstances(), + "civo_instance": instances.DataSourceInstance(), + "civo_dns_domain_name": dns.DataSourceDNSDomainName(), + "civo_dns_domain_record": dns.DataSourceDNSDomainRecord(), + "civo_network": network.DataSourceNetwork(), + "civo_volume": volume.DataSourceVolume(), + "civo_firewall": firewall.DataSourceFirewall(), + "civo_loadbalancer": loadbalancer.DataSourceLoadBalancer(), + "civo_ssh_key": ssh.DataSourceSSHKey(), + "civo_object_store": objectstorage.DataSourceObjectStore(), + "civo_object_store_credential": objectstorage.DataSourceObjectStoreCredential(), + "civo_region": region.DataSourceRegion(), + "civo_reserved_ip": ip.DataSourceReservedIP(), + "civo_database": database.DataSourceDatabase(), + "civo_database_version": database.DataDatabaseVersion(), }, ResourcesMap: map[string]*schema.Resource{ - "civo_instance": resourceInstance(), - "civo_network": resourceNetwork(), - "civo_volume": resourceVolume(), - "civo_volume_attachment": resourceVolumeAttachment(), - "civo_dns_domain_name": resourceDNSDomainName(), - "civo_dns_domain_record": resourceDNSDomainRecord(), - "civo_firewall": resourceFirewall(), - "civo_firewall_rule": resourceFirewallRule(), - "civo_ssh_key": resourceSSHKey(), - "civo_kubernetes_cluster": resourceKubernetesCluster(), - "civo_kubernetes_node_pool": resourceKubernetesClusterNodePool(), - "civo_reserved_ip": resourceReservedIP(), - "civo_instance_reserved_ip_assignment": resourceInstanceReservedIPAssignment(), - "civo_object_store": resourceObjectStore(), - "civo_object_store_credential": resourceObjectStoreCredential(), - "civo_database": resourceDatabase(), - // "civo_loadbalancer": resourceLoadBalancer(), - // "civo_template": resourceTemplate(), - // "civo_snapshot": resourceSnapshot(), - + "civo_instance": instances.ResourceInstance(), + "civo_instance_reserved_ip_assignment": instances.ResourceInstanceReservedIPAssignment(), + "civo_network": network.ResourceNetwork(), + "civo_volume": volume.ResourceVolume(), + "civo_volume_attachment": volume.ResourceVolumeAttachment(), + "civo_dns_domain_name": dns.ResourceDNSDomainName(), + "civo_dns_domain_record": dns.ResourceDNSDomainRecord(), + "civo_firewall": firewall.ResourceFirewall(), + "civo_ssh_key": ssh.ResourceSSHKey(), + "civo_kubernetes_cluster": kubernetes.ResourceKubernetesCluster(), + "civo_kubernetes_node_pool": kubernetes.ResourceKubernetesClusterNodePool(), + "civo_reserved_ip": ip.ResourceReservedIP(), + "civo_object_store": objectstorage.ResourceObjectStore(), + "civo_object_store_credential": objectstorage.ResourceObjectStoreCredential(), + "civo_database": database.ResourceDatabase(), }, ConfigureFunc: providerConfigure, } diff --git a/civo/provider_test.go b/civo/provider_test.go index bb5ecf03..93585b0b 100644 --- a/civo/provider_test.go +++ b/civo/provider_test.go @@ -2,7 +2,6 @@ package civo import ( "context" - "os" "strings" "testing" @@ -12,32 +11,19 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -var testAccProvider *schema.Provider -var testAccProviders map[string]*schema.Provider -var testAccProviderFactories map[string]func() (*schema.Provider, error) - -func init() { - testAccProvider = Provider() - testAccProviders = map[string]*schema.Provider{ - "civo": testAccProvider, - } - testAccProviderFactories = map[string]func() (*schema.Provider, error){ - "civo": func() (*schema.Provider, error) { - return testAccProvider, nil - }, - } -} - +// TestProvider tests the provider configuration func TestProvider(t *testing.T) { if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) + t.Fatalf("err: %s", err.Error()) } } +// TestProvider_impl tests the provider implementation func TestProvider_impl(t *testing.T) { var _ *schema.Provider = Provider() } +// TestToken tests the token configuration func TestToken(t *testing.T) { rawProvider := Provider() raw := map[string]interface{}{ @@ -58,12 +44,3 @@ func diagnosticsToString(diags diag.Diagnostics) string { return strings.Join(diagsAsStrings, "; ") } - -func testAccPreCheck(t *testing.T) { - if v := os.Getenv("CIVO_TOKEN"); v == "" { - t.Fatal("CIVO_TOKEN must be set for acceptance tests") - } - if v := os.Getenv("CIVO_REGION"); v == "" { - t.Fatal("CIVO_REGION must be set for acceptance tests") - } -} diff --git a/civo/datasource_region.go b/civo/region/datasource_region.go similarity index 84% rename from civo/datasource_region.go rename to civo/region/datasource_region.go index acadfe44..d8b47cd1 100644 --- a/civo/datasource_region.go +++ b/civo/region/datasource_region.go @@ -1,4 +1,4 @@ -package civo +package region import ( "fmt" @@ -8,9 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Data source to get and filter all regions -// use to define the region in the rest of the resource or datasource -func dataSourceRegion() *schema.Resource { +// DataSourceRegion function returns a schema.Resource that represents a Region. +// This can be used to query and retrieve details about a specific Region in the infrastructure. +// The retrieved Region can then be used to define the region for other resources or data sources. +func DataSourceRegion() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ Description: "Retrieves information about the region that Civo supports, with the ability to filter the results.", RecordSchema: map[string]*schema.Schema{ diff --git a/civo/resource_firewall_rule.go b/civo/resource_firewall_rule.go deleted file mode 100644 index f12a1bd9..00000000 --- a/civo/resource_firewall_rule.go +++ /dev/null @@ -1,243 +0,0 @@ -package civo - -import ( - "context" - "log" - - "github.com/civo/civogo" - "github.com/civo/terraform-provider-civo/internal/utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -// Firewall Rule resource represent you can create and manage all firewall rules -// this resource don't have an update option because the backend don't have the -// support for that, so in this case we use ForceNew for all object in the resource -func resourceFirewallRule() *schema.Resource { - return &schema.Resource{ - DeprecationMessage: "This resource is deprecated, please use the `civo_firewall` resource instead", - Description: "Provides a Civo firewall rule resource. This can be used to create, modify, and delete firewalls rules. This resource don't have an update option because Civo backend doesn't support it at this moment. In that case, we use `ForceNew` for all object in the resource.", - Schema: map[string]*schema.Schema{ - "firewall_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: utils.ValidateName, - Description: "The Firewall ID", - }, - "protocol": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: "The protocol choice from `tcp`, `udp` or `icmp` (the default if unspecified is `tcp`)", - ValidateFunc: validation.StringInSlice([]string{ - "tcp", - "udp", - "icmp", - }, false), - }, - "start_port": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: "The start of the port range to configure for this rule (or the single port if required)", - ValidateFunc: validation.NoZeroValues, - }, - "end_port": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: "The end of the port range (this is optional, by default it will only apply to the single port listed in start_port)", - ValidateFunc: validation.NoZeroValues, - }, - "cidr": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - Description: "The CIDR notation of the other end to affect, or a valid network CIDR (e.g. 0.0.0.0/0 to open for everyone or 1.2.3.4/32 to open just for a specific IP address)", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "direction": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The direction of the rule can be ingress or egress", - ValidateFunc: validation.StringInSlice([]string{ - "ingress", "egress", - }, false), - }, - "action": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The action of the rule can be allow or deny. When we set the `action = 'allow'`, this is going to add a rule to allow traffic. Similarly, setting `action = 'deny'` will deny the traffic.", - ValidateFunc: validation.StringInSlice([]string{ - "allow", "deny", - }, false), - }, - "label": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: "A string that will be the displayed name/reference for this rule", - ValidateFunc: validation.StringIsNotEmpty, - }, - "region": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: "The region for this rule", - ValidateFunc: validation.StringIsNotEmpty, - }, - }, - CreateContext: resourceFirewallRuleCreate, - ReadContext: resourceFirewallRuleRead, - DeleteContext: resourceFirewallRuleDelete, - Importer: &schema.ResourceImporter{ - State: resourceFirewallRuleImport, - }, - } -} - -// function to create a new firewall rule -func resourceFirewallRuleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - apiClient := m.(*civogo.Client) - - // overwrite the region if is define in the datasource - if region, ok := d.GetOk("region"); ok { - apiClient.Region = region.(string) - } - - tfCidr := d.Get("cidr").(*schema.Set).List() - cird := make([]string, len(tfCidr)) - for i, tfCird := range tfCidr { - cird[i] = tfCird.(string) - } - - log.Printf("[INFO] configuring a new firewall rule for firewall %s", d.Get("firewall_id").(string)) - config := &civogo.FirewallRuleConfig{ - FirewallID: d.Get("firewall_id").(string), - Protocol: d.Get("protocol").(string), - StartPort: d.Get("start_port").(string), - Direction: d.Get("direction").(string), - Action: d.Get("action").(string), - Cidr: cird, - } - - if attr, ok := d.GetOk("end_port"); ok { - config.EndPort = attr.(string) - } - - if attr, ok := d.GetOk("label"); ok { - config.Label = attr.(string) - } - - log.Printf("[INFO] Creating a new firewall rule for firewall %s with config: %+v", d.Get("firewall_id").(string), config) - firewallRule, err := apiClient.NewFirewallRule(config) - if err != nil { - return diag.Errorf("[ERR] failed to create a new firewall rule: %s", err) - } - - log.Printf("[INFO] Firewall rule created with ID: %s", firewallRule.ID) - - d.SetId(firewallRule.ID) - - return resourceFirewallRuleRead(ctx, d, m) -} - -// function to read a firewall rule -func resourceFirewallRuleRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - apiClient := m.(*civogo.Client) - - // overwrite the region if is define in the datasource - if region, ok := d.GetOk("region"); ok { - apiClient.Region = region.(string) - } - - log.Printf("[INFO] Reading firewall rule %s from firewall %s", d.Id(), d.Get("firewall_id").(string)) - - resp, err := apiClient.FindFirewallRule(d.Get("firewall_id").(string), d.Id()) - if err != nil { - if resp == nil { - d.SetId("") - return nil - } - - return diag.Errorf("[ERR] error retrieving firewall rule: %s", err) - } - - log.Printf("[INFO] Rules response: %+v", resp) - - d.Set("firewall_id", resp.FirewallID) - d.Set("protocol", resp.Protocol) - d.Set("start_port", resp.StartPort) - - if resp.EndPort != "" { - d.Set("end_port", resp.EndPort) - } - - d.Set("cidr", resp.Cidr) - d.Set("direction", resp.Direction) - d.Set("action", resp.Action) - d.Set("label", resp.Label) - - return nil -} - -// function to delete a firewall rule -func resourceFirewallRuleDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - apiClient := m.(*civogo.Client) - - // overwrite the region if is define in the datasource - if region, ok := d.GetOk("region"); ok { - apiClient.Region = region.(string) - } - - log.Printf("[INFO] retriving the firewall rule %s", d.Id()) - _, err := apiClient.DeleteFirewallRule(d.Get("firewall_id").(string), d.Id()) - if err != nil { - return diag.Errorf("[ERR] an error occurred while trying to delete firewall rule %s - %v", d.Id(), err) - } - return nil -} - -// custom import to able to add a firewall rule to the terraform -func resourceFirewallRuleImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - apiClient := m.(*civogo.Client) - - // overwrite the region if is define in the datasource - if region, ok := d.GetOk("region"); ok { - apiClient.Region = region.(string) - } - - firewallID, firewallRuleID, err := utils.ResourceCommonParseID(d.Id()) - if err != nil { - return nil, err - } - - log.Printf("[INFO] retriving the firewall rule %s", firewallRuleID) - resp, err := apiClient.FindFirewallRule(firewallID, firewallRuleID) - if err != nil { - if resp != nil { - return nil, err - } - } - - d.SetId(resp.ID) - d.Set("firewall_id", resp.FirewallID) - d.Set("protocol", resp.Protocol) - d.Set("start_port", resp.StartPort) - d.Set("end_port", resp.EndPort) - d.Set("cidr", resp.Cidr) - d.Set("direction", resp.Direction) - d.Set("action", resp.Action) - d.Set("label", resp.Label) - - return []*schema.ResourceData{d}, nil -} diff --git a/civo/resource_firewall_rule_test.go b/civo/resource_firewall_rule_test.go deleted file mode 100644 index 6be90e6f..00000000 --- a/civo/resource_firewall_rule_test.go +++ /dev/null @@ -1,184 +0,0 @@ -package civo - -import ( - "fmt" - "testing" - - "github.com/civo/civogo" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -// example.Widget represents a concrete Go type that represents an API resource -func TestAccCivoFirewallRule_basic(t *testing.T) { - var firewallRule civogo.FirewallRule - - // generate a random name for each test run - resName := "civo_firewall_rule.testrule" - var firewalName = acctest.RandomWithPrefix("tf-fw-rule") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallRuleDestroy, - Steps: []resource.TestStep{ - { - // use a dynamic configuration with the random name from above - Config: testAccCheckCivoFirewallRuleConfigBasic(firewalName), - // compose a basic test, checking both remote and local values - Check: resource.ComposeTestCheckFunc( - // query the API to retrieve the widget object - testAccCheckCivoFirewallRuleResourceExists(resName, &firewallRule), - // verify remote values - testAccCheckCivoFirewallRuleValues(&firewallRule), - // verify local values - resource.TestCheckResourceAttr(resName, "protocol", "tcp"), - resource.TestCheckResourceAttr(resName, "start_port", "80"), - ), - }, - }, - }) -} - -func TestAccCivoFirewallRule_update(t *testing.T) { - var firewallRule civogo.FirewallRule - - // generate a random name for each test run - resName := "civo_firewall_rule.testrule" - var firewalName = acctest.RandomWithPrefix("tf-fw-rule") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoFirewallRuleDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckCivoFirewallRuleConfigBasic(firewalName), - Check: resource.ComposeTestCheckFunc( - testAccCheckCivoFirewallRuleResourceExists(resName, &firewallRule), - resource.TestCheckResourceAttr(resName, "protocol", "tcp"), - resource.TestCheckResourceAttr(resName, "start_port", "80"), - resource.TestCheckResourceAttr(resName, "label", "web"), - resource.TestCheckResourceAttr(resName, "action", "allow"), - ), - }, - { - // use a dynamic configuration with the random name from above - Config: testAccCheckCivoFirewallRuleConfigUpdates(firewalName), - Check: resource.ComposeTestCheckFunc( - testAccCheckCivoFirewallRuleResourceExists(resName, &firewallRule), - testAccCheckCivoFirewallRuleUpdated(&firewallRule), - resource.TestCheckResourceAttr(resName, "protocol", "tcp"), - resource.TestCheckResourceAttr(resName, "start_port", "443"), - resource.TestCheckResourceAttr(resName, "label", "web_server"), - resource.TestCheckResourceAttr(resName, "action", "allow"), - ), - }, - }, - }) -} - -func testAccCheckCivoFirewallRuleValues(firewall *civogo.FirewallRule) resource.TestCheckFunc { - return func(_ *terraform.State) error { - if firewall.Protocol != "tcp" { - return fmt.Errorf("bad protocol, expected \"%s\", got: %#v", "tcp", firewall.Protocol) - } - if firewall.StartPort != "80" { - return fmt.Errorf("bad port, expected \"%s\", got: %#v", "80", firewall.StartPort) - } - return nil - } -} - -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoFirewallRuleResourceExists(n string, firewall *civogo.FirewallRule) resource.TestCheckFunc { - return func(s *terraform.State) error { - // find the corresponding state object - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) - resp, err := client.FindFirewallRule(rs.Primary.Attributes["firewall_id"], rs.Primary.ID) - if err != nil { - return fmt.Errorf("Firewall rule not found: (%s) %s", rs.Primary.ID, err) - } - - // If no error, assign the response Widget attribute to the widget pointer - *firewall = *resp - - // return fmt.Errorf("Domain (%s) not found", rs.Primary.ID) - return nil - } -} - -func testAccCheckCivoFirewallRuleUpdated(firewall *civogo.FirewallRule) resource.TestCheckFunc { - return func(_ *terraform.State) error { - if firewall.Protocol != "tcp" { - return fmt.Errorf("bad protocol, expected \"%s\", got: %#v", "tcp", firewall.Protocol) - } - if firewall.StartPort != "443" { - return fmt.Errorf("bad port, expected \"%s\", got: %#v", "443", firewall.StartPort) - } - return nil - } -} - -func testAccCheckCivoFirewallRuleDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "civo_firewall_rule" { - continue - } - - _, err := client.FindFirewall(rs.Primary.ID) - if err == nil { - return fmt.Errorf("Firewall rule still exists") - } - } - - return nil -} - -func testAccCheckCivoFirewallRuleConfigBasic(name string) string { - return fmt.Sprintf(` -resource "civo_firewall" "foobar" { - name = "%s" -} - -resource "civo_firewall_rule" "testrule" { - firewall_id = civo_firewall.foobar.id - protocol = "tcp" - start_port = "80" - end_port = "80" - cidr = ["192.168.1.2/32"] - direction = "ingress" - action = "allow" - label = "web" -} - -`, name) -} - -func testAccCheckCivoFirewallRuleConfigUpdates(name string) string { - return fmt.Sprintf(` -resource "civo_firewall" "foobar" { - name = "%s" -} - -resource "civo_firewall_rule" "testrule" { - firewall_id = civo_firewall.foobar.id - protocol = "tcp" - start_port = "443" - end_port = "443" - cidr = ["192.168.1.2/32"] - direction = "ingress" - action = "allow" - label = "web_server" -} -`, name) -} diff --git a/civo/resource_snapshot.go.disabled b/civo/resource_snapshot.go.disabled deleted file mode 100644 index a4e4e67a..00000000 --- a/civo/resource_snapshot.go.disabled +++ /dev/null @@ -1,203 +0,0 @@ -package civo - -import ( - "fmt" - "log" - "time" - - "github.com/civo/civogo" - "github.com/gorhill/cronexpr" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -// Snapshot resource, with this we can create and manage all Snapshot -// this resource dont have update option, we used ForceNew so any change -// in any value will be recreate the resource -func resourceSnapshot() *schema.Resource { - return &schema.Resource{ - Description: "Provides a resource which can be used to create a snapshot from an existing Civo instance.", - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "This is a unqiue, alphanumerical, short, human readable code for the snapshot", - ValidateFunc: validation.StringIsNotEmpty, - }, - "instance_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The ID of the instance to snapshot", - ValidateFunc: validation.StringIsNotEmpty, - }, - "safe": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Default: false, - Description: "If true the instance will be shut down during the snapshot to ensure all files" + - "are in a consistent state (e.g. database tables aren't in the middle of being optimised" + - "and hence risking corruption). The default is false so you experience no interruption" + - "of service, but a small risk of corruption.", - }, - "cron_timing": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "If a valid cron string is passed, the snapshot will be saved as an automated snapshot," + - "continuing to automatically update based on the schedule of the cron sequence provided." + - "The default is nil meaning the snapshot will be saved as a one-off snapshot.", - ValidateFunc: validation.StringIsNotEmpty, - }, - // Computed resource - "hostname": { - Type: schema.TypeString, - Computed: true, - }, - "template_id": { - Type: schema.TypeString, - Computed: true, - }, - "region": { - Type: schema.TypeString, - Computed: true, - }, - "size_gb": { - Type: schema.TypeInt, - Computed: true, - }, - "state": { - Type: schema.TypeString, - Computed: true, - }, - "next_execution": { - Type: schema.TypeString, - Computed: true, - }, - "requested_at": { - Type: schema.TypeString, - Computed: true, - }, - "completed_at": { - Type: schema.TypeString, - Computed: true, - }, - }, - Create: resourceSnapshotCreate, - Read: resourceSnapshotRead, - Delete: resourceSnapshotDelete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - } -} - -// function to create a new snapshot -func resourceSnapshotCreate(d *schema.ResourceData, m interface{}) error { - apiClient := m.(*civogo.Client) - - log.Printf("[INFO] configuring the new snapshot %s", d.Get("name").(string)) - config := &civogo.SnapshotConfig{ - InstanceID: d.Get("instance_id").(string), - } - - if attr, ok := d.GetOk("safe"); ok { - config.Safe = attr.(bool) - } - - if attr, ok := d.GetOk("cron_timing"); ok { - config.Cron = attr.(string) - } - - log.Printf("[INFO] creating the new snapshot %s", d.Get("name").(string)) - resp, err := apiClient.CreateSnapshot(d.Get("name").(string), config) - if err != nil { - return fmt.Errorf("[ERR] failed to create snapshot: %s", err) - } - - d.SetId(resp.ID) - - _, hasCronTiming := d.GetOk("cron_timing") - - if hasCronTiming { - /* - if hasCronTiming is declare them we no need to wait the state from the backend - */ - return resourceSnapshotRead(d, m) - } - /* - if hasCronTiming is not declare them we need to wait the state from the backend - and made a resource retry - */ - return resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - resp, err := apiClient.FindSnapshot(d.Id()) - if err != nil { - return resource.NonRetryableError(fmt.Errorf("error geting snapshot: %s", err)) - } - - if resp.State != "complete" { - return resource.RetryableError(fmt.Errorf("[WARN] expected snapshot to be created but was in state %s", resp.State)) - } - - return resource.NonRetryableError(resourceSnapshotRead(d, m)) - }) - -} - -// function to read the snapshot -func resourceSnapshotRead(d *schema.ResourceData, m interface{}) error { - apiClient := m.(*civogo.Client) - - log.Printf("[INFO] retrieving the snapshot %s", d.Get("name").(string)) - resp, err := apiClient.FindSnapshot(d.Id()) - if err != nil { - if resp == nil { - d.SetId("") - return nil - } - - return fmt.Errorf("[ERR] failed retrieving the snapshot: %s", err) - } - - safeValue := false - nextExecution := time.Time{} - - if resp.Safe == 1 { - safeValue = true - } - - if resp.Cron != "" { - nextExecution = cronexpr.MustParse(resp.Cron).Next(time.Now().UTC()) - } - - d.Set("instance_id", resp.InstanceID) - d.Set("hostname", resp.Hostname) - d.Set("template_id", resp.Template) - d.Set("region", resp.Region) - d.Set("name", resp.Name) - d.Set("safe", safeValue) - d.Set("size_gb", resp.SizeGigabytes) - d.Set("state", resp.State) - d.Set("cron_timing", resp.Cron) - d.Set("next_execution", nextExecution.String()) - d.Set("requested_at", resp.RequestedAt.UTC().String()) - d.Set("completed_at", resp.CompletedAt.UTC().String()) - - return nil -} - -// function to delete snapshot -func resourceSnapshotDelete(d *schema.ResourceData, m interface{}) error { - apiClient := m.(*civogo.Client) - - log.Printf("[INFO] deleting the snapshot %s", d.Id()) - _, err := apiClient.DeleteSnapshot(d.Id()) - if err != nil { - return fmt.Errorf("[ERR] an error occurred while trying to delete the snapshot %s", d.Id()) - } - - return nil -} diff --git a/civo/resource_snapshot_test.go.disabled b/civo/resource_snapshot_test.go.disabled deleted file mode 100644 index 318bc57c..00000000 --- a/civo/resource_snapshot_test.go.disabled +++ /dev/null @@ -1,158 +0,0 @@ -package civo - -import ( - "fmt" - "testing" - - "github.com/civo/civogo" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -// example.Widget represents a concrete Go type that represents an API resource -func TestAccCivoSnapshot_basic(t *testing.T) { - var snapshot civogo.Snapshot - - // generate a random name for each test run - resName := "civo_snapshot.foobar" - var snapshotName = acctest.RandomWithPrefix("tf-test") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoSnapshotDestroy, - Steps: []resource.TestStep{ - { - // use a dynamic configuration with the random name from above - Config: testAccCheckCivoSnapshotConfigBasic(snapshotName), - // compose a basic test, checking both remote and local values - Check: resource.ComposeTestCheckFunc( - // query the API to retrieve the widget object - testAccCheckCivoSnapshotResourceExists(resName, &snapshot), - // verify remote values - testAccCheckCivoSnapshotValues(&snapshot, snapshotName), - // verify local values - resource.TestCheckResourceAttr(resName, "name", snapshotName), - ), - }, - }, - }) -} - -func TestAccCivoSnapshot_update(t *testing.T) { - var snapshot civogo.Snapshot - - // generate a random name for each test run - resName := "civo_snapshot.foobar" - var snapshotName = acctest.RandomWithPrefix("tf-test") - var snapshotNameUpdate = acctest.RandomWithPrefix("rename-tf-test") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoSnapshotDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckCivoSnapshotConfigBasic(snapshotName), - Check: resource.ComposeTestCheckFunc( - testAccCheckCivoSnapshotResourceExists(resName, &snapshot), - testAccCheckCivoSnapshotValues(&snapshot, snapshotName), - resource.TestCheckResourceAttr(resName, "name", snapshotName), - ), - }, - { - // use a dynamic configuration with the random name from above - Config: testAccCheckCivoSnapshotConfigUpdates(snapshotNameUpdate), - Check: resource.ComposeTestCheckFunc( - testAccCheckCivoSnapshotResourceExists(resName, &snapshot), - testAccCheckCivoSnapshotUpdated(&snapshot, snapshotNameUpdate), - resource.TestCheckResourceAttr(resName, "name", snapshotNameUpdate), - ), - }, - }, - }) -} - -func testAccCheckCivoSnapshotValues(snapshot *civogo.Snapshot, name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if snapshot.Name != name { - return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, snapshot.Name) - } - return nil - } -} - -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoSnapshotResourceExists(n string, snapshot *civogo.Snapshot) resource.TestCheckFunc { - return func(s *terraform.State) error { - // find the corresponding state object - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) - resp, err := client.FindSnapshot(rs.Primary.ID) - if err != nil { - return fmt.Errorf("Snapshot not found: (%s) %s", rs.Primary.ID, err) - } - - // If no error, assign the response Widget attribute to the widget pointer - *snapshot = *resp - - // return fmt.Errorf("Domain (%s) not found", rs.Primary.ID) - return nil - } -} - -func testAccCheckCivoSnapshotUpdated(snapshot *civogo.Snapshot, name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - if snapshot.Name != name { - return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, snapshot.Name) - } - return nil - } -} - -func testAccCheckCivoSnapshotDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "civo_snapshot" { - continue - } - - _, err := client.FindSnapshot(rs.Primary.ID) - if err == nil { - return fmt.Errorf("Snapshot still exists") - } - } - - return nil -} - -func testAccCheckCivoSnapshotConfigBasic(name string) string { - return fmt.Sprintf(` -resource "civo_instance" "vm" { - hostname = "instance-%s" -} - -resource "civo_snapshot" "foobar" { - name = "%s" - instance_id = civo_instance.vm.id -}`, name, name) -} - -func testAccCheckCivoSnapshotConfigUpdates(name string) string { - return fmt.Sprintf(` -resource "civo_instance" "vm" { - hostname = "instance-%s" -} - -resource "civo_snapshot" "foobar" { - name = "%s" - instance_id = civo_instance.vm.id -}`, name, name) -} diff --git a/civo/datasource_size.go b/civo/size/datasource_size.go similarity index 90% rename from civo/datasource_size.go rename to civo/size/datasource_size.go index 40f9d9ac..514a0a13 100644 --- a/civo/datasource_size.go +++ b/civo/size/datasource_size.go @@ -1,4 +1,4 @@ -package civo +package size import ( "fmt" @@ -22,9 +22,10 @@ type Size struct { Selectable bool } -// Data source to get and filter all instances size -// use to define the size in resourceInstance -func dataSourceSize() *schema.Resource { +// DataSourceSize function returns a schema.Resource that represents an Instance Size. +// This can be used to query and retrieve details about a specific Instance Size in the infrastructure. +// The retrieved Instance Size can then be used to define the size for other resources or data sources. +func DataSourceSize() *schema.Resource { dataListConfig := &datalist.ResourceConfig{ Description: "Retrieves information about the sizes that Civo supports, with the ability to filter the results.", RecordSchema: sizeSchema(), diff --git a/civo/datasource_size_test.go b/civo/size/datasource_size_test.go similarity index 75% rename from civo/datasource_size_test.go rename to civo/size/datasource_size_test.go index 42ee43f4..7a0d9229 100644 --- a/civo/datasource_size_test.go +++ b/civo/size/datasource_size_test.go @@ -1,10 +1,11 @@ -package civo +package size_test import ( "fmt" "strconv" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -13,13 +14,13 @@ func TestAccDataSourceCivoSize_basic(t *testing.T) { datasourceName := "data.civo_size.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoSizeConfig(), + Config: DataSourceCivoSizeConfig(), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckDataSourceCivoSizeExist(datasourceName), + DataSourceCivoSizeExist(datasourceName), ), }, }, @@ -30,21 +31,21 @@ func TestAccDataSourceCivoSize_WithFilterAndSort(t *testing.T) { datasourceName := "data.civo_size.foobar" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoSizeConfigWhitFilterAndSort(), + Config: DataSourceCivoSizeConfigWhitFilterAndSort(), Check: resource.ComposeTestCheckFunc( - testAccCheckDataSourceCivoSizeExist(datasourceName), - testAccCheckDataSourceCivoSizeFilteredAndSorted(datasourceName), + DataSourceCivoSizeExist(datasourceName), + DataSourceCivoSizeFilteredAndSorted(datasourceName), ), }, }, }) } -func testAccCheckDataSourceCivoSizeExist(n string) resource.TestCheckFunc { +func DataSourceCivoSizeExist(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -70,7 +71,7 @@ func testAccCheckDataSourceCivoSizeExist(n string) resource.TestCheckFunc { } } -func testAccCheckDataSourceCivoSizeFilteredAndSorted(n string) resource.TestCheckFunc { +func DataSourceCivoSizeFilteredAndSorted(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -112,14 +113,14 @@ func testAccCheckDataSourceCivoSizeFilteredAndSorted(n string) resource.TestChec } } -func testAccDataSourceCivoSizeConfig() string { +func DataSourceCivoSizeConfig() string { return ` data "civo_size" "foobar" { } ` } -func testAccDataSourceCivoSizeConfigWhitFilterAndSort() string { +func DataSourceCivoSizeConfigWhitFilterAndSort() string { return ` data "civo_size" "foobar" { filter { diff --git a/civo/datasource_ssh.go b/civo/ssh/datasource_ssh.go similarity index 87% rename from civo/datasource_ssh.go rename to civo/ssh/datasource_ssh.go index b02e7877..ed2a72de 100644 --- a/civo/datasource_ssh.go +++ b/civo/ssh/datasource_ssh.go @@ -1,4 +1,4 @@ -package civo +package ssh import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific ssh key -// using the id or the name -func dataSourceSSHKey() *schema.Resource { +// DataSourceSSHKey function returns a schema.Resource that represents an SSH Key. +// This can be used to query and retrieve details about a specific SSH Key in the infrastructure using its id or name. +func DataSourceSSHKey() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a SSH key. This data source provides the name, and fingerprint as configured on your Civo account.", diff --git a/civo/datasource_ssh_test.go b/civo/ssh/datasource_ssh_test.go similarity index 74% rename from civo/datasource_ssh_test.go rename to civo/ssh/datasource_ssh_test.go index 3d8e6041..95297da8 100644 --- a/civo/datasource_ssh_test.go +++ b/civo/ssh/datasource_ssh_test.go @@ -1,4 +1,4 @@ -package civo +package ssh_test import ( "crypto/rand" @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "golang.org/x/crypto/ssh" @@ -15,18 +16,18 @@ import ( func TestAccDataSourceCivoSSHKey_basic(t *testing.T) { datasourceName := "data.civo_ssh_key.foobar" name := acctest.RandomWithPrefix("sshkey-test") - pubKey, err := testAccGenerateDataSourceCivoSSHKeyPublic() + pubKey, err := GenerateDataSourceCivoSSHKeyPublic() if err != nil { t.Fatalf("Unable to generate public key: %v", err) return } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoSSHKeyConfig(name, pubKey), + Config: DataSourceCivoSSHKeyConfig(name, pubKey), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), ), @@ -35,7 +36,7 @@ func TestAccDataSourceCivoSSHKey_basic(t *testing.T) { }) } -func testAccGenerateDataSourceCivoSSHKeyPublic() (string, error) { +func GenerateDataSourceCivoSSHKeyPublic() (string, error) { privateKey, err := rsa.GenerateKey(rand.Reader, 1024) if err != nil { return "", fmt.Errorf("Unable to generate key: %v", err) @@ -49,7 +50,7 @@ func testAccGenerateDataSourceCivoSSHKeyPublic() (string, error) { return strings.TrimSpace(string(ssh.MarshalAuthorizedKey(publicKey))), nil } -func testAccDataSourceCivoSSHKeyConfig(name string, key string) string { +func DataSourceCivoSSHKeyConfig(name string, key string) string { return fmt.Sprintf(` resource "civo_ssh_key" "foobar" { name = "%s" diff --git a/civo/resource_ssh.go b/civo/ssh/resource_ssh.go similarity index 93% rename from civo/resource_ssh.go rename to civo/ssh/resource_ssh.go index f2db39d7..0898655b 100644 --- a/civo/resource_ssh.go +++ b/civo/ssh/resource_ssh.go @@ -1,4 +1,4 @@ -package civo +package ssh import ( "context" @@ -10,8 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Ssh resource, with this we can create and manage all Snapshot -func resourceSSHKey() *schema.Resource { +// ResourceSSHKey function returns a schema.Resource that represents an SSH Key. +// This can be used to create, read, update, and delete operations for an SSH Key in the infrastructure. +func ResourceSSHKey() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo SSH key resource to allow you to manage SSH keys for instance access. Keys created with this resource can be referenced in your instance configuration via their ID.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_ssh_test.go b/civo/ssh/resource_ssh_test.go similarity index 69% rename from civo/resource_ssh_test.go rename to civo/ssh/resource_ssh_test.go index c21ec0dd..ddfdd098 100644 --- a/civo/resource_ssh_test.go +++ b/civo/ssh/resource_ssh_test.go @@ -1,10 +1,11 @@ -package civo +package ssh_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -23,19 +24,19 @@ func TestAccCivoSSHKey_basic(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoSSHKeyDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoSSHKeyDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoSSHKeyConfigBasic(SSHKeyName, publicKeyMaterial), + Config: CivoSSHKeyConfigBasic(SSHKeyName, publicKeyMaterial), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoSSHKeyResourceExists(resName, &SSHKey), + CivoSSHKeyResourceExists(resName, &SSHKey), // verify remote values - testAccCheckCivoSSHKeyValues(&SSHKey, SSHKeyName), + CivoSSHKeyValues(&SSHKey, SSHKeyName), // verify local values resource.TestCheckResourceAttr(resName, "name", SSHKeyName), resource.TestCheckResourceAttr(resName, "public_key", publicKeyMaterial), @@ -58,25 +59,25 @@ func TestAccCivoSSHKey_update(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoSSHKeyDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoSSHKeyDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckCivoSSHKeyConfigBasic(SSHKeyName, publicKeyMaterial), + Config: CivoSSHKeyConfigBasic(SSHKeyName, publicKeyMaterial), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoSSHKeyResourceExists(resName, &SSHKey), - testAccCheckCivoSSHKeyValues(&SSHKey, SSHKeyName), + CivoSSHKeyResourceExists(resName, &SSHKey), + CivoSSHKeyValues(&SSHKey, SSHKeyName), resource.TestCheckResourceAttr(resName, "name", SSHKeyName), resource.TestCheckResourceAttr(resName, "public_key", publicKeyMaterial), ), }, { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoSSHKeyConfigUpdates(SSHKeyNameUpdate, publicKeyMaterial), + Config: CivoSSHKeyConfigUpdates(SSHKeyNameUpdate, publicKeyMaterial), Check: resource.ComposeTestCheckFunc( - testAccCheckCivoSSHKeyResourceExists(resName, &SSHKey), - testAccCheckCivoSSHKeyUpdated(&SSHKey, SSHKeyNameUpdate), + CivoSSHKeyResourceExists(resName, &SSHKey), + CivoSSHKeyUpdated(&SSHKey, SSHKeyNameUpdate), resource.TestCheckResourceAttr(resName, "name", SSHKeyNameUpdate), resource.TestCheckResourceAttr(resName, "public_key", publicKeyMaterial), ), @@ -85,7 +86,7 @@ func TestAccCivoSSHKey_update(t *testing.T) { }) } -func testAccCheckCivoSSHKeyValues(SSHKey *civogo.SSHKey, name string) resource.TestCheckFunc { +func CivoSSHKeyValues(SSHKey *civogo.SSHKey, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if SSHKey.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, SSHKey.Name) @@ -94,8 +95,8 @@ func testAccCheckCivoSSHKeyValues(SSHKey *civogo.SSHKey, name string) resource.T } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoSSHKeyResourceExists(n string, SSHKey *civogo.SSHKey) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoSSHKeyResourceExists(n string, SSHKey *civogo.SSHKey) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -104,7 +105,7 @@ func testAccCheckCivoSSHKeyResourceExists(n string, SSHKey *civogo.SSHKey) resou } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindSSHKey(rs.Primary.ID) if err != nil { return fmt.Errorf("Ssh key not found: (%s) %s", rs.Primary.ID, err) @@ -118,7 +119,7 @@ func testAccCheckCivoSSHKeyResourceExists(n string, SSHKey *civogo.SSHKey) resou } } -func testAccCheckCivoSSHKeyUpdated(SSHKey *civogo.SSHKey, name string) resource.TestCheckFunc { +func CivoSSHKeyUpdated(SSHKey *civogo.SSHKey, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if SSHKey.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, SSHKey.Name) @@ -127,8 +128,8 @@ func testAccCheckCivoSSHKeyUpdated(SSHKey *civogo.SSHKey, name string) resource. } } -func testAccCheckCivoSSHKeyDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoSSHKeyDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_ssh_key" { @@ -144,7 +145,7 @@ func testAccCheckCivoSSHKeyDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoSSHKeyConfigBasic(name string, key string) string { +func CivoSSHKeyConfigBasic(name string, key string) string { return fmt.Sprintf(` resource "civo_ssh_key" "foobar" { name = "%s" @@ -152,7 +153,7 @@ resource "civo_ssh_key" "foobar" { }`, name, key) } -func testAccCheckCivoSSHKeyConfigUpdates(name string, key string) string { +func CivoSSHKeyConfigUpdates(name string, key string) string { return fmt.Sprintf(` resource "civo_ssh_key" "foobar" { name = "%s" diff --git a/civo/datasource_volume.go b/civo/volume/datasource_volume.go similarity index 91% rename from civo/datasource_volume.go rename to civo/volume/datasource_volume.go index 55ea06dc..f6b539cb 100644 --- a/civo/datasource_volume.go +++ b/civo/volume/datasource_volume.go @@ -1,4 +1,4 @@ -package civo +package volume import ( "context" @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Data source to get from the api a specific domain -// using the id or the name of the domain -func dataSourceVolume() *schema.Resource { +// DataSourceVolume function returns a schema.Resource that represents a Volume. +// This can be used to query and retrieve details about a specific Volume in the infrastructure using its id or name. +func DataSourceVolume() *schema.Resource { return &schema.Resource{ Description: strings.Join([]string{ "Get information on a volume for use in other resources. This data source provides all of the volumes properties as configured on your Civo account.", diff --git a/civo/datasource_volume_test.go b/civo/volume/datasource_volume_test.go similarity index 75% rename from civo/datasource_volume_test.go rename to civo/volume/datasource_volume_test.go index bb6920bc..6cf7cf24 100644 --- a/civo/datasource_volume_test.go +++ b/civo/volume/datasource_volume_test.go @@ -1,9 +1,10 @@ -package civo +package volume_test import ( "fmt" "testing" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -13,11 +14,11 @@ func TestAccDataSourceCivoVolume_basic(t *testing.T) { name := acctest.RandomWithPrefix("ds-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceCivoVolumeConfig(name), + Config: DataSourceCivoVolumeConfig(name), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, "name", name), resource.TestCheckResourceAttrSet(datasourceName, "size_gb"), @@ -27,7 +28,7 @@ func TestAccDataSourceCivoVolume_basic(t *testing.T) { }) } -func testAccDataSourceCivoVolumeConfig(name string) string { +func DataSourceCivoVolumeConfig(name string) string { return fmt.Sprintf(` data "civo_network" "default" { label = "default" diff --git a/civo/resource_volume.go b/civo/volume/resource_volume.go similarity index 96% rename from civo/resource_volume.go rename to civo/volume/resource_volume.go index bb4a7752..1f356129 100644 --- a/civo/resource_volume.go +++ b/civo/volume/resource_volume.go @@ -1,4 +1,4 @@ -package civo +package volume import ( "context" @@ -13,8 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Volume resource, with this we can create and manage all volume -func resourceVolume() *schema.Resource { +// ResourceVolume function returns a schema.Resource that represents a Volume. +// This can be used to create, read, update, and delete operations for a Volume in the infrastructure. +func ResourceVolume() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo volume which can be attached to an instance in order to provide expanded storage.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_volume_attachment.go b/civo/volume/resource_volume_attachment.go similarity index 93% rename from civo/resource_volume_attachment.go rename to civo/volume/resource_volume_attachment.go index 8cd356f0..5449bea6 100644 --- a/civo/resource_volume_attachment.go +++ b/civo/volume/resource_volume_attachment.go @@ -1,4 +1,4 @@ -package civo +package volume import ( "context" @@ -13,8 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -// Volume resource, with this we can create and manage all volume -func resourceVolumeAttachment() *schema.Resource { +// ResourceVolumeAttachment function returns a schema.Resource that represents a Volume Attachment. +// This can be used to create, read, update, and delete operations for a Volume Attachment in the infrastructure. +func ResourceVolumeAttachment() *schema.Resource { return &schema.Resource{ Description: "Manages volume attachment/detachment to an instance.", Schema: map[string]*schema.Schema{ diff --git a/civo/resource_volume_attachment_test.go b/civo/volume/resource_volume_attachment_test.go similarity index 79% rename from civo/resource_volume_attachment_test.go rename to civo/volume/resource_volume_attachment_test.go index d3f90be4..6b309176 100644 --- a/civo/resource_volume_attachment_test.go +++ b/civo/volume/resource_volume_attachment_test.go @@ -1,10 +1,11 @@ -package civo +package volume_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -20,18 +21,18 @@ func TestAccCivoVolumeAttachment_basic(t *testing.T) { var VolumeAttachmentName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoVolumeAttachmentDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoVolumeAttachmentDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoVolumeAttachmentConfigBasic(VolumeAttachmentName), + Config: CivoVolumeAttachmentConfigBasic(VolumeAttachmentName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoVolumeResourceExists("civo_volume.foo", &volume), - testAccCheckCivoInstanceResourceExists("civo_instance.vm", &instance), + CivoVolumeResourceExists("civo_volume.foo", &volume), + acceptance.CivoInstanceResourceExists("civo_instance.vm", &instance), // verify local values resource.TestCheckResourceAttrSet(resName, "id"), resource.TestCheckResourceAttrSet(resName, "instance_id"), @@ -42,7 +43,7 @@ func TestAccCivoVolumeAttachment_basic(t *testing.T) { }) } -func testAccCheckCivoVolumeAttachmentDestroy(s *terraform.State) error { +func CivoVolumeAttachmentDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "civo_volume_attachment" { continue @@ -52,7 +53,7 @@ func testAccCheckCivoVolumeAttachmentDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoVolumeAttachmentConfigBasic(name string) string { +func CivoVolumeAttachmentConfigBasic(name string) string { return fmt.Sprintf(` data "civo_instances_size" "small" { filter { diff --git a/civo/resource_volume_test.go b/civo/volume/resource_volume_test.go similarity index 72% rename from civo/resource_volume_test.go rename to civo/volume/resource_volume_test.go index 5e7f6bd8..1b1a0966 100644 --- a/civo/resource_volume_test.go +++ b/civo/volume/resource_volume_test.go @@ -1,10 +1,11 @@ -package civo +package volume_test import ( "fmt" "testing" "github.com/civo/civogo" + "github.com/civo/terraform-provider-civo/civo/acceptance" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,19 +20,19 @@ func TestAccCivoVolume_basic(t *testing.T) { var VolumeName = acctest.RandomWithPrefix("tf-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckCivoVolumeDestroy, + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + Providers: acceptance.TestAccProviders, + CheckDestroy: CivoVolumeDestroy, Steps: []resource.TestStep{ { // use a dynamic configuration with the random name from above - Config: testAccCheckCivoVolumeConfigBasic(VolumeName), + Config: CivoVolumeConfigBasic(VolumeName), // compose a basic test, checking both remote and local values Check: resource.ComposeTestCheckFunc( // query the API to retrieve the widget object - testAccCheckCivoVolumeResourceExists(resName, &volume), + CivoVolumeResourceExists(resName, &volume), // verify remote values - testAccCheckCivoVolumeValues(&volume, VolumeName), + CivoVolumeValues(&volume, VolumeName), // verify local values resource.TestCheckResourceAttr(resName, "name", VolumeName), resource.TestCheckResourceAttr(resName, "size_gb", "10"), @@ -41,7 +42,7 @@ func TestAccCivoVolume_basic(t *testing.T) { }) } -func testAccCheckCivoVolumeValues(volume *civogo.Volume, name string) resource.TestCheckFunc { +func CivoVolumeValues(volume *civogo.Volume, name string) resource.TestCheckFunc { return func(_ *terraform.State) error { if volume.Name != name { return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, volume.Name) @@ -50,8 +51,8 @@ func testAccCheckCivoVolumeValues(volume *civogo.Volume, name string) resource.T } } -// testAccCheckExampleResourceExists queries the API and retrieves the matching Widget. -func testAccCheckCivoVolumeResourceExists(n string, volume *civogo.Volume) resource.TestCheckFunc { +// CheckExampleResourceExists queries the API and retrieves the matching Widget. +func CivoVolumeResourceExists(n string, volume *civogo.Volume) resource.TestCheckFunc { return func(s *terraform.State) error { // find the corresponding state object rs, ok := s.RootModule().Resources[n] @@ -60,7 +61,7 @@ func testAccCheckCivoVolumeResourceExists(n string, volume *civogo.Volume) resou } // retrieve the configured client from the test setup - client := testAccProvider.Meta().(*civogo.Client) + client := acceptance.TestAccProvider.Meta().(*civogo.Client) resp, err := client.FindVolume(rs.Primary.ID) if err != nil { return fmt.Errorf("Volume not found: (%s) %s", rs.Primary.ID, err) @@ -74,8 +75,8 @@ func testAccCheckCivoVolumeResourceExists(n string, volume *civogo.Volume) resou } } -func testAccCheckCivoVolumeDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*civogo.Client) +func CivoVolumeDestroy(s *terraform.State) error { + client := acceptance.TestAccProvider.Meta().(*civogo.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "civo_volume" { @@ -91,7 +92,7 @@ func testAccCheckCivoVolumeDestroy(s *terraform.State) error { return nil } -func testAccCheckCivoVolumeConfigBasic(name string) string { +func CivoVolumeConfigBasic(name string) string { return fmt.Sprintf(` data "civo_network" "default" { label = "default" diff --git a/examples/resources/civo_kubernetes_cluster/resource-taint-labels.tf b/examples/resources/civo_kubernetes_cluster/resource-taint-labels.tf new file mode 100644 index 00000000..07dd853c --- /dev/null +++ b/examples/resources/civo_kubernetes_cluster/resource-taint-labels.tf @@ -0,0 +1,36 @@ +# Query xsmall instance size +data "civo_size" "xsmall" { + filter { + key = "type" + values = ["kubernetes"] + } + + sort { + key = "ram" + direction = "asc" + } +} + +# Create a cluster with labels and taints +resource "civo_kubernetes_cluster" "my-cluster" { + name = "my-cluster" + applications = "Portainer,Linkerd:Linkerd & Jaeger" + firewall_id = civo_firewall.my-firewall.id + + pools { + size = element(data.civo_size.xsmall.sizes, 0).name + node_count = 3 + + labels = { + service = "backend" + priority = "high" + } + + taint { + key = "workloadKind" + value = "database" + effect = "NoSchedule" + } + } +} + diff --git a/examples/resources/civo_kubernetes_node_pool/resource-taint-labels.tf b/examples/resources/civo_kubernetes_node_pool/resource-taint-labels.tf index b728bf8f..1bbf9c4c 100644 --- a/examples/resources/civo_kubernetes_node_pool/resource-taint-labels.tf +++ b/examples/resources/civo_kubernetes_node_pool/resource-taint-labels.tf @@ -17,7 +17,7 @@ resource "civo_kubernetes_cluster" "my-cluster" { applications = "Portainer,Linkerd:Linkerd & Jaeger" firewall_id = civo_firewall.my-firewall.id - node_pool { + pools { size = element(data.civo_size.xsmall.sizes, 0).name node_count = 3 } diff --git a/examples/resources/civo_kubernetes_node_pool/resource.tf b/examples/resources/civo_kubernetes_node_pool/resource.tf index 1897acd6..fa036d89 100644 --- a/examples/resources/civo_kubernetes_node_pool/resource.tf +++ b/examples/resources/civo_kubernetes_node_pool/resource.tf @@ -16,7 +16,7 @@ resource "civo_kubernetes_cluster" "my-cluster" { name = "my-cluster" applications = "Portainer,Linkerd:Linkerd & Jaeger" firewall_id = civo_firewall.my-firewall.id - node_pool { + pools { size = element(data.civo_size.xsmall.sizes, 0).name node_count = 3 } diff --git a/go.mod b/go.mod index d68d3036..1bb078f2 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,79 @@ module github.com/civo/terraform-provider-civo require ( + github.com/civo/civogo v0.3.58 + github.com/google/uuid v1.3.1 + github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 + github.com/stretchr/testify v1.8.4 + golang.org/x/crypto v0.18.0 + k8s.io/api v0.29.1 +) + +require ( + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/agext/levenshtein v1.2.3 // indirect - github.com/civo/civogo v0.3.51 - github.com/google/uuid v1.3.0 + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fatih/color v1.13.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 - github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect + github.com/hashicorp/go-checkpoint v0.5.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/hc-install v0.6.2 // indirect + github.com/hashicorp/hcl/v2 v2.19.1 // indirect + github.com/hashicorp/logutils v1.0.0 // indirect + github.com/hashicorp/terraform-exec v0.19.0 // indirect + github.com/hashicorp/terraform-json v0.18.0 // indirect + github.com/hashicorp/terraform-plugin-go v0.20.0 // indirect + github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.3 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/oklog/run v1.1.0 // indirect - github.com/stretchr/testify v1.8.2 - github.com/vmihailenco/tagparser v0.1.2 // indirect - golang.org/x/crypto v0.13.0 - golang.org/x/net v0.15.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220715211116-798f69b842b9 // indirect - k8s.io/api v0.28.2 - k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/zclconf/go-cty v1.14.1 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.60.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/apimachinery v0.29.1 // indirect + k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) -go 1.16 +go 1.21 diff --git a/go.sum b/go.sum index 01d5daf9..87bcab93 100644 --- a/go.sum +++ b/go.sum @@ -1,104 +1,77 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/civo/civogo v0.3.50 h1:5EG3zimDhcS4SO0DSWi4cQtQPFzga6Q8riuHNmgJpw8= -github.com/civo/civogo v0.3.50/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= -github.com/civo/civogo v0.3.51 h1:GFIo0EnV/yat0CU9VE3pBIWqzJe7af/oDgT3lVZuxXc= -github.com/civo/civogo v0.3.51/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= +github.com/civo/civogo v0.3.57 h1:KotP07TE6ZbYPmo+oOty5YAPDD8CCxLwmD8Ii10D6Ns= +github.com/civo/civogo v0.3.57/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= +github.com/civo/civogo v0.3.58 h1:FikCbwAKB5ovD8+NmSi7rzYBSpC4nUpGVpCyngEkTo4= +github.com/civo/civogo v0.3.58/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.10.1 h1:tu8/D8i+TWxgKpzQ3Vc43e+kkhXqtsZCKI/egajKnxk= +github.com/go-git/go-git/v5 v5.10.1/go.mod h1:uEuHjxkHap8kAl//V5F/nNWwqIYtP/402ddd05mp0wg= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -106,24 +79,21 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -132,84 +102,67 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I= -github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= -github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= -github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= -github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= -github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/hc-install v0.6.2 h1:V1k+Vraqz4olgZ9UzKiAcbman9i9scg9GgSt/U3mw/M= +github.com/hashicorp/hc-install v0.6.2/go.mod h1:2JBpd+NCFKiHiu/yYCGaPyPHhZLxXTpz8oreHa/a3Ps= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= -github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= -github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= -github.com/hashicorp/terraform-json v0.16.0 h1:UKkeWRWb23do5LNAFlh/K3N0ymn1qTOO8c+85Albo3s= -github.com/hashicorp/terraform-json v0.16.0/go.mod h1:v0Ufk9jJnk6tcIZvScHvetlKfiNTC+WS21mnXIlc0B0= -github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+3BL/DBBxFEki+j0= -github.com/hashicorp/terraform-plugin-go v0.14.3/go.mod h1:7ees7DMZ263q8wQ6E4RdIdR6nHHJtrdt4ogX5lPkX1A= -github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= -github.com/hashicorp/terraform-plugin-log v0.8.0 h1:pX2VQ/TGKu+UU1rCay0OlzosNKe4Nz1pepLXj95oyy0= -github.com/hashicorp/terraform-plugin-log v0.8.0/go.mod h1:1myFrhVsBLeylQzYYEV17VVjtG8oYPRFdaZs7xdW2xs= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ= -github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U= -github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J+x6AzmKuVM/JWCQwkWm6GW/MUR6I= -github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= +github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= +github.com/hashicorp/terraform-json v0.18.0 h1:pCjgJEqqDESv4y0Tzdqfxr/edOIGkjs8keY42xfNBwU= +github.com/hashicorp/terraform-json v0.18.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= +github.com/hashicorp/terraform-plugin-go v0.20.0 h1:oqvoUlL+2EUbKNsJbIt3zqqZ7wi6lzn4ufkn/UA51xQ= +github.com/hashicorp/terraform-plugin-go v0.20.0/go.mod h1:Rr8LBdMlY53a3Z/HpP+ZU3/xCDqtKNCkeI9qOyT10QE= +github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= +github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 h1:Bl3e2ei2j/Z3Hc2HIS15Gal2KMKyLAZ2om1HCEvK6es= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0/go.mod h1:i2C41tszDjiWfziPQDL5R/f3Zp0gahXe5No/MIO9rCE= +github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= +github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -220,39 +173,25 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= @@ -263,10 +202,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -282,8 +219,6 @@ github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1L github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk= github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= -github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= -github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= @@ -297,90 +232,61 @@ github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdM github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw= github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= -github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= -github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= -github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= +github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -393,32 +299,21 @@ golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -430,17 +325,11 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -448,32 +337,20 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -484,17 +361,15 @@ golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -503,15 +378,11 @@ golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= -golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= @@ -520,12 +391,9 @@ golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -542,7 +410,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -550,31 +419,19 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20220715211116-798f69b842b9 h1:1aEQRgZ4Gks2SRAkLzIPpIszRazwVfjSFe1cKc+e0Jg= -google.golang.org/genproto v0.0.0-20220715211116-798f69b842b9/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= +google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= +google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -584,18 +441,16 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -606,7 +461,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -614,36 +468,33 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.27.1/go.mod h1:z5g/BpAiD+f6AArpqNjkY+cji8ueZDU/WV1jcj5Jk4E= -k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= -k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= +k8s.io/api v0.29.1 h1:DAjwWX/9YT7NQD4INu49ROJuZAAAP/Ijki48GUPzxqw= +k8s.io/api v0.29.1/go.mod h1:7Kl10vBRUXhnQQI8YR/R327zXC8eJ7887/+Ybta+RoQ= k8s.io/apimachinery v0.27.1/go.mod h1:5ikh59fK3AJ287GUvpUsryoMFtH9zj/ARfWCo3AyXTM= -k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= -k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= +k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= +k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= -sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=