Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/mmv1-check-templates.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
name: mmv1-lint-product-yaml
name: mmv1

permissions: read-all

on:
pull_request:
paths:
- 'mmv1/products/**'
- 'mmv1/**'

jobs:
version-guard-check:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
with:
path: repo
fetch-depth: 0
- name: Merge base branch
id: pull_request
run: |
cd repo
git config user.name "modular-magician"
git config user.email "magic-modules@google.com"
git fetch origin ${{ github.base_ref }} # Fetch the base branch
git merge --no-ff origin/${{ github.base_ref }} # Merge with the base branch
- name: Check for invalid version guards
run: |
cd repo/tools/template-check
git diff --name-only --diff-filter=d origin/${{ github.base_ref }} ../../*.tmpl | sed 's=^=../../=g' | go run main.go
lint-yaml:
runs-on: ubuntu-22.04
steps:
Expand All @@ -34,3 +54,16 @@ jobs:
- name: Lint YAML files
if: ${{ !failure() && steps.pull_request.outputs.yamlfiles != '' }}
run: yamllint -c repo/.yamllint ${{steps.pull_request.outputs.yamlfiles}}
unit-tests:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '^1.23'
- name: Run mmv1 unit tests
run: |
cd mmv1
go test ./... -v

4 changes: 2 additions & 2 deletions mmv1/provider/terraform_tgc_next.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (tgc TerraformGoogleConversionNext) CompileCommonFiles(outputFolder string,
// common
"pkg/transport/config.go": "third_party/terraform/transport/config.go.tmpl",
"pkg/transport/provider_handwritten_endpoint.go": "third_party/terraform/transport/provider_handwritten_endpoint.go.tmpl",
"pkg/tpgresource/common_diff_suppress.go": "third_party/terraform/tpgresource/common_diff_suppress.go.tmpl",
"pkg/tpgresource/common_diff_suppress.go": "third_party/terraform/tpgresource/common_diff_suppress.go",
"pkg/provider/provider.go": "third_party/terraform/provider/provider.go.tmpl",
"pkg/provider/provider_validators.go": "third_party/terraform/provider/provider_validators.go.tmpl",
"pkg/provider/provider_validators.go": "third_party/terraform/provider/provider_validators.go",

// tfplan2cai
"pkg/tfplan2cai/converters/resource_converters.go": "templates/tgc_next/tfplan2cai/resource_converters.go.tmpl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ func ValidateServiceAccountEmail(v interface{}, k string) (warnings []string, er
}

return
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
referenceTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.UTC)

context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"project": envvar.GetTestProjectFromEnv(),
"effective_time": referenceTime.Add(24 * time.Hour).Format(time.RFC3339),
"random_suffix": acctest.RandString(t, 10),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -97,4 +97,4 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
allow_missing = "true"
}
`, context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccBinaryAuthorizationPolicy_basic(t *testing.T) {
pid := "tf-test-" + acctest.RandString(t, 10)
billingId := envvar.GetTestBillingAccountFromEnv(t)
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -165,9 +165,9 @@ func testAccCheckBinaryAuthorizationPolicyDefault(t *testing.T, pid string) reso
config := acctest.GoogleProviderConfig(t)
url := fmt.Sprintf("https://binaryauthorization.googleapis.com/v1/projects/%s/policy", pid)
pol, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
RawURL: url,
Config: config,
Method: "GET",
RawURL: url,
UserAgent: config.UserAgent,
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func DataSourceGoogleCloudAssetSearchAllResources() *schema.Resource {

func datasourceGoogleCloudAssetSearchAllResourcesRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
return err
}
Expand Down Expand Up @@ -147,10 +147,10 @@ func datasourceGoogleCloudAssetSearchAllResourcesRead(d *schema.ResourceData, me
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Project: project,
Method: "GET",
RawURL: url,
Config: config,
Project: project,
Method: "GET",
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
Expand Down Expand Up @@ -195,7 +195,7 @@ func flattenDatasourceGoogleCloudAssetSearchAllResources(v interface{}) []map[st
for _, raw := range ls {
p := raw.(map[string]interface{})

var mName, mAssetType, mProject, mFolders, mOrganization, mDisplayName, mDescription, mLocation, mLabels, mNetworkTags, mKmsKeys, mCreateTime, mUpdateTime, mState, mParentFullResourceName, mParentAssetType interface{}
var mName, mAssetType, mProject, mFolders, mOrganization, mDisplayName, mDescription, mLocation, mLabels, mNetworkTags, mKmsKeys, mCreateTime, mUpdateTime, mState, mParentFullResourceName, mParentAssetType interface{}
if pName, ok := p["name"]; ok {
mName = pName
}
Expand Down Expand Up @@ -266,4 +266,3 @@ func flattenDatasourceGoogleCloudAssetSearchAllResources(v interface{}) []map[st

return results
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccDataSourceGoogleCloudAssetSearchAllResources_basic(t *testing.T) {
Expand Down Expand Up @@ -46,4 +46,3 @@ data google_cloud_asset_search_all_resources resources {
}
`, project)
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cloudtasks_test

import (
"fmt"
"testing"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
Expand Down Expand Up @@ -127,17 +127,17 @@ func TestAccCloudTasksQueue_HttpTargetOIDC_update(t *testing.T) {
Config: testAccCloudTasksQueue_HttpTargetOIDC(name, serviceAccountID),
},
{
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudTasksQueue_basic(name),
},
{
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand All @@ -157,17 +157,17 @@ func TestAccCloudTasksQueue_HttpTargetOAuth_update(t *testing.T) {
Config: testAccCloudTasksQueue_HttpTargetOAuth(name, serviceAccountID),
},
{
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudTasksQueue_basic(name),
},
{
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
ResourceName: "google_cloud_tasks_queue.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand Down Expand Up @@ -332,7 +332,6 @@ resource "google_service_account" "test" {
`, name, serviceAccountID)
}


func testAccCloudTasksQueue_HttpTargetOAuth(name, serviceAccountID string) string {
return fmt.Sprintf(`
resource "google_cloud_tasks_queue" "default" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func checkSecretDataSourceMatchesResource() resource.TestCheckFunc {
}
// ignore diff if it's due to secrets being masked.
if strings.HasPrefix(k, "data.") {
if _, ok := dsAttr[k]; !ok{
if _, ok := dsAttr[k]; !ok {
errMsg += fmt.Sprintf("%s is defined in resource and not in datasource\n", k)
}
if dsAttr[k] == "**********" {
Expand Down
Loading
Loading