-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-vertex-ai-model-COPY
- Loading branch information
Showing
35 changed files
with
447 additions
and
1,501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ package provider | |
import ( | ||
"bytes" | ||
"errors" | ||
"fmt" | ||
"go/format" | ||
"log" | ||
"os" | ||
"os/exec" | ||
|
@@ -65,18 +63,16 @@ func wrapMultipleParams(params ...interface{}) (map[string]interface{}, error) { | |
} | ||
|
||
var TemplateFunctions = template.FuncMap{ | ||
"title": google.SpaceSeparatedTitle, | ||
"replace": strings.Replace, | ||
"camelize": google.Camelize, | ||
"underscore": google.Underscore, | ||
"plural": google.Plural, | ||
"contains": strings.Contains, | ||
"join": strings.Join, | ||
"lower": strings.ToLower, | ||
"upper": strings.ToUpper, | ||
"dict": wrapMultipleParams, | ||
"format2regex": google.Format2Regex, | ||
"orderProperties": api.OrderProperties, | ||
"title": google.SpaceSeparatedTitle, | ||
"replace": strings.Replace, | ||
"camelize": google.Camelize, | ||
"underscore": google.Underscore, | ||
"plural": google.Plural, | ||
"contains": strings.Contains, | ||
"join": strings.Join, | ||
"lower": strings.ToLower, | ||
"upper": strings.ToUpper, | ||
"dict": wrapMultipleParams, | ||
} | ||
|
||
var GA_VERSION = "ga" | ||
|
@@ -103,13 +99,11 @@ func NewTemplateData(outputFolder string, version product.Version) *TemplateData | |
func (td *TemplateData) GenerateResourceFile(filePath string, resource api.Resource) { | ||
templatePath := "templates/terraform/resource.go.tmpl" | ||
templates := []string{ | ||
templatePath, | ||
"templates/terraform/schema_property.go.tmpl", | ||
"templates/terraform/schema_subresource.go.tmpl", | ||
templatePath, | ||
"templates/terraform/expand_resource_ref.tmpl", | ||
"templates/terraform/custom_flatten/go/bigquery_table_ref.go.tmpl", | ||
"templates/terraform/flatten_property_method.go.tmpl", | ||
"templates/terraform/expand_property_method.go.tmpl", | ||
} | ||
td.GenerateFile(filePath, templatePath, resource, true, templates...) | ||
} | ||
|
@@ -120,6 +114,7 @@ func (td *TemplateData) GenerateDocumentationFile(filePath string, resource api. | |
templatePath, | ||
"templates/terraform/property_documentation.html.markdown.tmpl", | ||
"templates/terraform/nested_property_documentation.html.markdown.tmpl", | ||
templatePath, | ||
} | ||
td.GenerateFile(filePath, templatePath, resource, false, templates...) | ||
} | ||
|
@@ -131,21 +126,22 @@ func (td *TemplateData) GenerateTestFile(filePath string, resource api.Resource) | |
templatePath, | ||
} | ||
tmplInput := TestInput{ | ||
Res: resource, | ||
ImportPath: td.ImportPath(), | ||
PROJECT_NAME: "my-project-name", | ||
CREDENTIALS: "my/credentials/filename.json", | ||
REGION: "us-west1", | ||
ORG_ID: "123456789", | ||
ORG_DOMAIN: "example.com", | ||
ORG_TARGET: "123456789", | ||
PROJECT_NUMBER: "1111111111111", | ||
BILLING_ACCT: "000000-0000000-0000000-000000", | ||
MASTER_BILLING_ACCT: "000000-0000000-0000000-000000", | ||
SERVICE_ACCT: "[email protected]", | ||
CUST_ID: "A01b123xz", | ||
IDENTITY_USER: "cloud_identity_user", | ||
PAP_DESCRIPTION: "description", | ||
Res: resource, | ||
ImportPath: td.ImportPath(), | ||
PROJECT_NAME: "my-project-name", | ||
FIRESTORE_PROJECT_NAME: "my-project-name", | ||
CREDENTIALS: "my/credentials/filename.json", | ||
REGION: "us-west1", | ||
ORG_ID: "123456789", | ||
ORG_DOMAIN: "example.com", | ||
ORG_TARGET: "123456789", | ||
PROJECT_NUMBER: "1111111111111", | ||
BILLING_ACCT: "000000-0000000-0000000-000000", | ||
MASTER_BILLING_ACCT: "000000-0000000-0000000-000000", | ||
SERVICE_ACCT: "[email protected]", | ||
CUST_ID: "A01b123xz", | ||
IDENTITY_USER: "cloud_identity_user", | ||
PAP_DESCRIPTION: "description", | ||
} | ||
|
||
td.GenerateFile(filePath, templatePath, tmplInput, true, templates...) | ||
|
@@ -168,14 +164,12 @@ func (td *TemplateData) GenerateFile(filePath, templatePath string, input any, g | |
|
||
sourceByte := contents.Bytes() | ||
|
||
if goFormat { | ||
formattedByte, err := format.Source(sourceByte) | ||
if err != nil { | ||
glog.Error(fmt.Errorf("error formatting %s: %s", filePath, err)) | ||
} else { | ||
sourceByte = formattedByte | ||
} | ||
} | ||
// if goFormat { | ||
// sourceByte, err = format.Source(sourceByte) | ||
// if err != nil { | ||
// glog.Error(fmt.Errorf("error formatting %s", filePath)) | ||
// } | ||
// } | ||
|
||
err = os.WriteFile(filePath, sourceByte, 0644) | ||
if err != nil { | ||
|
@@ -282,19 +276,20 @@ func (td *TemplateData) ImportPath() string { | |
} | ||
|
||
type TestInput struct { | ||
Res api.Resource | ||
ImportPath string | ||
PROJECT_NAME string | ||
CREDENTIALS string | ||
REGION string | ||
ORG_ID string | ||
ORG_DOMAIN string | ||
ORG_TARGET string | ||
PROJECT_NUMBER string | ||
BILLING_ACCT string | ||
MASTER_BILLING_ACCT string | ||
SERVICE_ACCT string | ||
CUST_ID string | ||
IDENTITY_USER string | ||
PAP_DESCRIPTION string | ||
Res api.Resource | ||
ImportPath string | ||
PROJECT_NAME string | ||
FIRESTORE_PROJECT_NAME string | ||
CREDENTIALS string | ||
REGION string | ||
ORG_ID string | ||
ORG_DOMAIN string | ||
ORG_TARGET string | ||
PROJECT_NUMBER string | ||
BILLING_ACCT string | ||
MASTER_BILLING_ACCT string | ||
SERVICE_ACCT string | ||
CUST_ID string | ||
IDENTITY_USER string | ||
PAP_DESCRIPTION string | ||
} |
Oops, something went wrong.