Skip to content

Commit

Permalink
ci(selproj): move to go-utils (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-held-aiven authored Feb 12, 2024
2 parents 73152d1 + 199e70d commit b28b1dc
Show file tree
Hide file tree
Showing 29 changed files with 198 additions and 396 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $(TERRAFMT): $(TOOLS_BIN_DIR) $(TOOLS_DIR)/go.mod
SELPROJ := $(TOOLS_BIN_DIR)/selproj

$(SELPROJ): $(TOOLS_BIN_DIR) $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -tags tools -o bin/selproj github.com/aiven/terraform-provider-aiven/tools/selproj
cd $(TOOLS_DIR) && $(GO) build -tags tools -o bin/selproj github.com/aiven/go-utils/selproj


# See https://github.com/hashicorp/terraform/blob/main/tools/protobuf-compile/protobuf-compile.go#L215
Expand Down
6 changes: 3 additions & 3 deletions internal/schemautil/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ServiceCommonSchema() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
Description: "Defines where the cloud provider and region where the service is hosted in. This can be changed freely after service is created. Changing the value will trigger a potentially lengthy migration process for the service. Format is cloud provider name (`aws`, `azure`, `do` `google`, `upcloud`, etc.), dash, and the cloud provider specific region name. These are documented on each Cloud provider's own support articles, like [here for Google](https://cloud.google.com/compute/docs/regions-zones/) and [here for AWS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html).",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
// This is a workaround for a bug when migrating from V3 to V4 Aiven Provider.
// The bug is that the cloud_name is not set in the state file, but it is set
// on the API side. This causes a diff during plan, and it will not disappear
Expand Down Expand Up @@ -103,7 +103,7 @@ func ServiceCommonSchema() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
Description: "Day of week when maintenance operations should be performed. One monday, tuesday, wednesday, etc.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
return new == ""
},
// There is also `never` value, which can't be set, but can be received from the backend.
Expand All @@ -115,7 +115,7 @@ func ServiceCommonSchema() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
Description: "Time of day when maintenance operations should be performed. UTC time in HH:mm:ss format.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
return new == ""
},
},
Expand Down
10 changes: 5 additions & 5 deletions internal/sdkprovider/service/account/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func listTestAccounts(ctx context.Context) ([]aiven.Account, error) {
}

func sweepAccountAuthentications(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down Expand Up @@ -107,7 +107,7 @@ func sweepAccountAuthentications(ctx context.Context) func(region string) error
}

func sweepAccounts(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand All @@ -134,7 +134,7 @@ func sweepAccounts(ctx context.Context) func(region string) error {
}

func sweepAccountTeams(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down Expand Up @@ -166,7 +166,7 @@ func sweepAccountTeams(ctx context.Context) func(region string) error {
}
}
func sweepAccountTeamMembers(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down Expand Up @@ -220,7 +220,7 @@ func sweepAccountTeamMembers(ctx context.Context) func(region string) error {
}

func sweepAccountTeamProjects(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/connectionpool/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
}

func sweepConnectionPoll(ctx context.Context) func(string) error {
return func(id string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/sdkprovider/service/kafka/kafka_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func ResourceKafkaConnector() *schema.Resource {

// customizeDiffKafkaConnectorConfigName `config.name` should be equal to `connector_name`
func customizeDiffKafkaConnectorConfigName() func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error {
return func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error {
return func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
connectorName := diff.Get("connector_name").(string)
config := make(aiven.KafkaConnectorConfig)
for k, cS := range diff.Get("config").(map[string]interface{}) {
Expand All @@ -124,7 +124,7 @@ func customizeDiffKafkaConnectorConfigName() func(ctx context.Context, diff *sch

// kafkaConnectorConfigNameShouldNotBeEmpty `config.name` should not be empty
func kafkaConnectorConfigNameShouldNotBeEmpty() func(ctx context.Context, oldValue interface{}, newValue interface{}, meta interface{}) bool {
return func(ctx context.Context, oldValue, newValue, meta interface{}) bool {
return func(_ context.Context, _, newValue, _ interface{}) bool {
for k, cS := range newValue.(map[string]interface{}) {
if k == "name" && cS.(string) != "" {
return true
Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestAccAiven_kafka(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "service_host"),
resource.TestCheckResourceAttrSet(resourceName, "service_port"),
resource.TestCheckResourceAttrSet(resourceName, "service_uri"),
func(state *terraform.State) error {
func(_ *terraform.State) error {
c := acc.GetTestAivenClient()

ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions internal/sdkprovider/service/kafkaschema/kafka_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var aivenKafkaSchemaSchema = map[string]*schema.Schema{
"and PROTOBUF.",
Default: "AVRO",
ValidateFunc: validation.StringInSlice([]string{"AVRO", "JSON", "PROTOBUF"}, false),
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, oldValue, _ string, d *schema.ResourceData) bool {
// This field can't be retrieved once resource is created.
// That produces a diff on plan on resource import.
// Ignores imported field.
Expand All @@ -62,7 +62,7 @@ var aivenKafkaSchemaSchema = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(compatibilityLevels, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
// When a compatibility level is not set to any value and consequently is null (empty string).
// Allow ignoring those.
return new == ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var aivenKafkaSchemaConfigurationSchema = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(compatibilityLevels, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
// When a compatibility level is not set to any value and consequently is null (empty string).
// Allow ignoring those.
return new == ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func TestAccAivenKafkaTopic_recreate_missing(t *testing.T) {
// Saved in state
resource.TestCheckResourceAttr(kafkaResource, "id", kafkaID),
resource.TestCheckResourceAttr(topicResource, "id", topicID),
func(state *terraform.State) error {
func(_ *terraform.State) error {
// Topic exists and active
client := acc.GetTestAivenClient()
return retry.RetryContext(
Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/organization/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func init() {
}

func sweepOrganizations(ctx context.Context) func(string) error {
return func(id string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/sdkprovider/service/project/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {
}

func sweepProjects(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down Expand Up @@ -84,7 +84,7 @@ func sweepProjects(ctx context.Context) func(region string) error {
}

func sweepBillingGroups(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
client, err := sweep.SharedClient()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/sdkprovider/service/serviceintegration/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func init() {
}

func sweepServiceIntegrations(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down Expand Up @@ -70,7 +70,7 @@ func sweepServiceIntegrations(ctx context.Context) func(region string) error {
}

func sweepServiceIntegrationEndpoints(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/staticip/static_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ resource "aiven_static_ip" "foo" {
Config: manifest,
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: func(s *terraform.State) (string, error) {
ImportStateIdFunc: func(_ *terraform.State) (string, error) {
return "non-existent/identifier", nil
},
ExpectError: regexp.MustCompile(`Cannot import non-existent remote object`),
Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/staticip/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
}

func sweepStaticIPs(ctx context.Context) func(region string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var aivenAWSVPCPeeringConnectionSchema = map[string]*schema.Schema{
ForceNew: true,
Required: true,
Type: schema.TypeString,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
DiffSuppressFunc: func(_, _, new string, _ *schema.ResourceData) bool {
return new == ""
},
Description: userconfig.Desc("AWS region of the peered VPC (if not in the same region as Aiven VPC).").ForceNew().Build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAccAivenGCPPeeringConnection_basic(t *testing.T) {
},
{
Config: testAccGCPVPCPeeringConnection(&s),
Check: func(state *terraform.State) error {
Check: func(_ *terraform.State) error {
c := acc.GetTestAivenClient()

ctx := context.Background()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func DatasourceProjectVPC() *schema.Resource {
Description: "ID of the VPC. This can be used to filter out the specific VPC if there are more than one datasource returned.",
Optional: true,
ConflictsWith: []string{"project", "cloud_name"},
ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics {
ValidateDiagFunc: func(i interface{}, _ cty.Path) diag.Diagnostics {
_, err := schemautil.SplitResourceID(i.(string), 2)
if err != nil {
return diag.Errorf("invalid vpc_id, should have the following format {project_name}/{project_vpc_id}: %s", err)
Expand Down
10 changes: 5 additions & 5 deletions internal/sdkprovider/service/vpc/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func init() {
}

func sweepVPCs(ctx context.Context) func(string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand All @@ -116,7 +116,7 @@ func sweepVPCs(ctx context.Context) func(string) error {
}

func sweepVPCPeeringCons(ctx context.Context) func(string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down Expand Up @@ -179,7 +179,7 @@ func sweepVPCPeeringCons(ctx context.Context) func(string) error {
}

func sweepAWSPrivatelinks(ctx context.Context) func(string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down Expand Up @@ -213,7 +213,7 @@ func sweepAWSPrivatelinks(ctx context.Context) func(string) error {
}

func sweepAzurePrivatelinks(ctx context.Context) func(string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down Expand Up @@ -247,7 +247,7 @@ func sweepAzurePrivatelinks(ctx context.Context) func(string) error {
}

func sweepGCPPrivatelinks(ctx context.Context) func(string) error {
return func(region string) error {
return func(_ string) error {
projectName := os.Getenv("AIVEN_PROJECT_NAME")
client, err := sweep.SharedClient()
if err != nil {
Expand Down
Loading

0 comments on commit b28b1dc

Please sign in to comment.