diff --git a/.github/workflows/automation-regenerate-go-sdk.yaml b/.github/workflows/automation-regenerate-go-sdk.yaml index 247b5596f20..a7d7d12ea7a 100644 --- a/.github/workflows/automation-regenerate-go-sdk.yaml +++ b/.github/workflows/automation-regenerate-go-sdk.yaml @@ -24,18 +24,6 @@ jobs: with: go-version: '1.21.3' - - name: Setup .NET - uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 - with: - dotnet-version: 7.0.x - - - name: "Build Data API" - run: | - cd ./data - make build - cd ../tools/data-api - make build - - name: "Launch SSH Agent" run: | # launch an ssh agent and export it's env vars diff --git a/.github/workflows/unit-test-end-to-end-resource-manager.yaml b/.github/workflows/unit-test-end-to-end-resource-manager.yaml index 343dd9615b6..52a41948bfa 100644 --- a/.github/workflows/unit-test-end-to-end-resource-manager.yaml +++ b/.github/workflows/unit-test-end-to-end-resource-manager.yaml @@ -17,20 +17,10 @@ jobs: with: submodules: recursive - - name: Setup .NET - uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 - with: - dotnet-version: 7.0.x - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: '1.21.3' - - name: "Build Data API" - run: | - cd ./data - make build - - name: "Build and Run importer-rest-api-specs" id: import-data run: | diff --git a/scripts/automation-generate-and-commit-go-sdk.sh b/scripts/automation-generate-and-commit-go-sdk.sh index 2e4195d15c5..47b0d251fd4 100755 --- a/scripts/automation-generate-and-commit-go-sdk.sh +++ b/scripts/automation-generate-and-commit-go-sdk.sh @@ -5,28 +5,34 @@ set -e DIR="$(cd "$(dirname "$0")" && pwd)/.." function buildAndInstallDependencies { - echo "Installing the Go SDK Generator into the GOBIN.." - cd "${DIR}/tools/generator-go-sdk" - go install . - cd "${DIR}" - - echo "Building Wrapper.." - cd "${DIR}/tools/wrapper-automation" - go build -o wrapper-automation - cd "${DIR}" + echo "Outputting Go Version.." + go version + + echo "Installing the Data API V2 onto the GOBIN.." + cd "${DIR}/tools/data-api" + go install . + cd "${DIR}" + + echo "Installing the Go SDK Generator into the GOBIN.." + cd "${DIR}/tools/generator-go-sdk" + go install . + cd "${DIR}" + + echo "Building Wrapper.." + cd "${DIR}/tools/wrapper-automation" + go build -o wrapper-automation + cd "${DIR}" } function runWrapper { - local dataApiAssemblyPath=$1 + local apiDefinitionsDirectory=$1 local outputDirectory=$2 - local useV2Generator=$4 echo "Running Wrapper.." cd "${DIR}/tools/wrapper-automation" ./wrapper-automation go-sdk \ - -data-api-assembly-path="../../$dataApiAssemblyPath"\ - -output-dir="../../$outputDirectory"\ - -use-v2-generator="$useV2Generator" + --api-definitions-dir="../../$apiDefinitionsDirectory"\ + --output-dir="../../$outputDirectory" cd "${DIR}" @@ -109,23 +115,16 @@ function cleanup { } function main { - local dataApiAssemblyPath="data/Pandora.Api/bin/Debug/net7.0/Pandora.Api.dll" - local dataApiV2Path="tools/data-api/data-api" + local apiDefinitionsDirectory="./api-definitions" local swaggerSubmodule="./submodules/rest-api-specs" local outputDirectory="tmp/go-azure-sdk" local sdkRepo="git@github.com:hashicorp/go-azure-sdk.git" local sha - local useV2Generator=true buildAndInstallDependencies sha=$(getSwaggerSubmoduleSha "$swaggerSubmodule") prepareGoSdk "$outputDirectory" "$sdkRepo" - if [ "$useV2Generator" = true ] - then - runWrapper "$dataApiV2Path" "$outputDirectory" "$sha" "$useV2Generator" - else - runWrapper "$dataApiAssemblyPath" "$outputDirectory" "$sha" "$useV2Generator" - fi + runWrapper "$apiDefinitionsDirectory" "$outputDirectory" conditionallyCommitAndPushGoSdk "$outputDirectory" "$sha" cleanup "$outputDirectory" } diff --git a/scripts/automation-generate-and-commit-terraform.sh b/scripts/automation-generate-and-commit-terraform.sh index 0d220cd4ebd..07fa524e6c5 100755 --- a/scripts/automation-generate-and-commit-terraform.sh +++ b/scripts/automation-generate-and-commit-terraform.sh @@ -5,34 +5,34 @@ set -e DIR="$(cd "$(dirname "$0")" && pwd)/.." function buildAndInstallDependencies { - echo "Outputting Go Version.." - go version + echo "Outputting Go Version.." + go version - echo "Outputting .net Version.." - dotnet --version + echo "Installing the Data API into the GOBIN.." + cd "${DIR}/tools/data-api" + go install . + cd "${DIR}" - echo "Installing the Terraform Generator into the GOBIN.." - cd "${DIR}/tools/generator-terraform" - go install . - cd "${DIR}" + echo "Installing the Terraform Generator into the GOBIN.." + cd "${DIR}/tools/generator-terraform" + go install . + cd "${DIR}" - echo "Building Wrapper.." - cd "${DIR}/tools/wrapper-automation" - go build -o wrapper-automation - cd "${DIR}" + echo "Building Wrapper.." + cd "${DIR}/tools/wrapper-automation" + go build -o wrapper-automation + cd "${DIR}" } function runWrapper { - local dataApiAssemblyPath=$1 + local apiDefinitionsDirectory=$1 local outputDirectory=$2 - local useV2Generator=$4 echo "Running Wrapper.." cd "${DIR}/tools/wrapper-automation" ./wrapper-automation terraform \ - -data-api-assembly-path="../../$dataApiAssemblyPath"\ - -output-dir="../../$outputDirectory"\ - -use-v2-generator="$useV2Generator" + --api-definitions-dir="../../$apiDefinitionsDirectory"\ + --output-dir="../../$outputDirectory" cd "${DIR}" @@ -141,23 +141,16 @@ function cleanup { } function main { - local dataApiAssemblyPath="data/Pandora.Api/bin/Debug/net7.0/Pandora.Api.dll" - local dataApiV2Path="tools/data-api/data-api" + local apiDefinitionsDirectory="./api-definitions" local swaggerSubmodule="./submodules/rest-api-specs" local outputDirectory="tmp/terraform-provider-azurerm" local providerRepo="git@github.com:hashicorp/terraform-provider-azurerm.git" local sha - local useV2Generator=false buildAndInstallDependencies sha=$(getSwaggerSubmoduleSha "$swaggerSubmodule") prepareTerraformProvider "$outputDirectory" "$providerRepo" - if [ "$useV2Generator" = true ] - then - runWrapper "$dataApiV2Path" "$outputDirectory" "$sha" "$useV2Generator" - else - runWrapper "$dataApiAssemblyPath" "$outputDirectory" "$sha" "$useV2Generator" - fi + runWrapper "$apiDefinitionsDirectory" "$outputDirectory" runFmtImportsAndGenerate "$outputDirectory" conditionallyCommitAndPushTerraformProvider "$outputDirectory" "$sha" cleanup "$outputDirectory" diff --git a/scripts/automation-generate-go-sdk.sh b/scripts/automation-generate-go-sdk.sh index 90176db1901..b595ce5b02b 100755 --- a/scripts/automation-generate-go-sdk.sh +++ b/scripts/automation-generate-go-sdk.sh @@ -5,28 +5,34 @@ set -e DIR="$(cd "$(dirname "$0")" && pwd)/.." function buildAndInstallDependencies { - echo "Installing the Go SDK Generator into the GOBIN.." - cd "${DIR}/tools/generator-go-sdk" - go install . - cd "${DIR}" - - echo "Building Wrapper.." - cd "${DIR}/tools/wrapper-automation" - go build -o wrapper-automation - cd "${DIR}" + echo "Outputting Go Version.." + go version + + echo "Installing the Data API V2 onto the GOBIN.." + cd "${DIR}/tools/data-api" + go install . + cd "${DIR}" + + echo "Installing the Go SDK Generator into the GOBIN.." + cd "${DIR}/tools/generator-go-sdk" + go install . + cd "${DIR}" + + echo "Building Wrapper.." + cd "${DIR}/tools/wrapper-automation" + go build -o wrapper-automation + cd "${DIR}" } function runWrapper { - local dataApiAssemblyPath=$1 + local apiDefinitionsDirectory=$1 local outputDirectory=$2 - local useV2Generator=$4 echo "Running Wrapper.." cd "${DIR}/tools/wrapper-automation" ./wrapper-automation go-sdk \ - -data-api-assembly-path="../../$dataApiAssemblyPath"\ - -output-dir="../../$outputDirectory"\ - -use-v2-generator="$useV2Generator" + --api-definitions-dir="../../$apiDefinitionsDirectory"\ + --output-dir="../../$outputDirectory" cd "${DIR}" @@ -89,23 +95,16 @@ function cleanup { } function main { - local dataApiAssemblyPath="data/Pandora.Api/bin/Debug/net7.0/Pandora.Api.dll" - local dataApiV2Path="tools/data-api/data-api" + local apiDefinitionsDirectory="./api-definitions" local swaggerSubmodule="./submodules/rest-api-specs" local outputDirectory="tmp/go-azure-sdk" local sdkRepo="https://github.com/hashicorp/go-azure-sdk.git" local sha - local useV2Generator=false buildAndInstallDependencies sha=$(getSwaggerSubmoduleSha "$swaggerSubmodule") prepareGoSdk "$outputDirectory" "$sdkRepo" - if [ "$useV2Generator" = true ] - then - runWrapper "$dataApiV2Path" "$outputDirectory" "$sha" "$useV2Generator" - else - runWrapper "$dataApiAssemblyPath" "$outputDirectory" "$sha" "$useV2Generator" - fi + runWrapper "$apiDefinitionsDirectory" "$outputDirectory" runGoSDKUnitTests "$outputDirectory" cleanup "$outputDirectory" } diff --git a/scripts/automation-generate-terraform.sh b/scripts/automation-generate-terraform.sh index 932e02e3a8d..f5bd0584403 100755 --- a/scripts/automation-generate-terraform.sh +++ b/scripts/automation-generate-terraform.sh @@ -5,34 +5,34 @@ set -e DIR="$(cd "$(dirname "$0")" && pwd)/.." function buildAndInstallDependencies { - echo "Outputting Go Version.." - go version + echo "Outputting Go Version.." + go version - echo "Outputting .net Version.." - dotnet --version + echo "Installing the Data API V2 onto the GOBIN.." + cd "${DIR}/tools/data-api" + go install . + cd "${DIR}" - echo "Installing the Terraform Generator into the GOBIN.." - cd "${DIR}/tools/generator-terraform" - go install . - cd "${DIR}" + echo "Installing the Terraform Generator into the GOBIN.." + cd "${DIR}/tools/generator-terraform" + go install . + cd "${DIR}" - echo "Building Wrapper.." - cd "${DIR}/tools/wrapper-automation" - go build -o wrapper-automation - cd "${DIR}" + echo "Building Wrapper.." + cd "${DIR}/tools/wrapper-automation" + go build -o wrapper-automation + cd "${DIR}" } function runWrapper { - local dataApiAssemblyPath=$1 + local apiDefinitionsDirectory=$1 local outputDirectory=$2 - local useV2Generator=$3 echo "Running Wrapper.." cd "${DIR}/tools/wrapper-automation" ./wrapper-automation terraform \ - -data-api-assembly-path="../../$dataApiAssemblyPath"\ - -output-dir="../../$outputDirectory"\ - -use-v2-generator="$useV2Generator" + --api-definitions-dir="../../$apiDefinitionsDirectory"\ + --output-dir="../../$outputDirectory" cd "${DIR}" @@ -110,20 +110,13 @@ function cleanup { } function main { - local dataApiAssemblyPath="data/Pandora.Api/bin/Debug/net7.0/Pandora.Api.dll" - local dataApiV2Path="tools/data-api/data-api" + local apiDefinitionsDirectory="./api-definitions" local outputDirectory="tmp/provider-azurerm" local providerRepo="git@github.com:hashicorp/terraform-provider-azurerm.git" - local useV2Generator=false buildAndInstallDependencies prepareTerraformProvider "$outputDirectory" "$providerRepo" - if [ "$useV2Generator" = true ] - then - runWrapper "$dataApiV2Path" "$outputDirectory" "$useV2Generator" - else - runWrapper "$dataApiAssemblyPath" "$outputDirectory" "$useV2Generator" - fi + runWrapper "$apiDefinitionsDirectory" "$outputDirectory" runFmtImportsAndGenerate "$outputDirectory" runTerraformProviderUnitTests "$outputDirectory" cleanup "$outputDirectory" diff --git a/tools/wrapper-automation/go_sdk_generator.go b/tools/wrapper-automation/go_sdk_generator.go index 3193675d9c9..d2599992d5e 100644 --- a/tools/wrapper-automation/go_sdk_generator.go +++ b/tools/wrapper-automation/go_sdk_generator.go @@ -23,9 +23,9 @@ func (c GoSdkGeneratorCmd) Run(args []string) int { } f := flag.NewFlagSet("wrapper-automation", flag.ExitOnError) - f.StringVar(&arguments.DataApiAssemblyPath, "data-api-assembly-path", "", "-data-api-assembly-path=../data/Pandora.Api.dll") - f.StringVar(&arguments.OutputDirectory, "output-dir", "", "-output-dir=../output") - f.BoolVar(&arguments.UseV2Generator, "use-v2-generator", false, "-use-v2-generator=true") + f.StringVar(&arguments.ApiDefinitionsDirectory, "api-definitions-dir", "", "--api-definitions-dir=./api-definitions") + f.StringVar(&arguments.DataApiAssemblyPath, "data-api-assembly-path", "", "--data-api-assembly-path=../data/Pandora.Api.dll") + f.StringVar(&arguments.OutputDirectory, "output-dir", "", "--output-dir=../output") if err := f.Parse(args); err != nil { log.Fatalf("parsing arguments: %+v", err) diff --git a/tools/wrapper-automation/models.go b/tools/wrapper-automation/models.go index b075a0ca646..4bc2b57a5c5 100644 --- a/tools/wrapper-automation/models.go +++ b/tools/wrapper-automation/models.go @@ -3,29 +3,47 @@ package main import ( "fmt" "os" + "path/filepath" ) type Arguments struct { + ApiDefinitionsDirectory string DataApiAssemblyPath string DataApiPort int OutputDirectory string RunGoSdkGenerator bool RunTerraformGenerator bool RunRestApiSpecsImporter bool - UseV2Generator bool } func (a Arguments) Validate() error { - if a.DataApiAssemblyPath == "" { - return fmt.Errorf("missing 'data-api-assembly-path'") + if a.ApiDefinitionsDirectory != "" { + abs, err := filepath.Abs(a.ApiDefinitionsDirectory) + if err != nil { + return fmt.Errorf("determining absolute path to %q: %+v", a.ApiDefinitionsDirectory, err) + } + a.ApiDefinitionsDirectory = abs + if _, err := os.Stat(a.ApiDefinitionsDirectory); err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("the API Definitions Directory doesn't exist at %q", a.ApiDefinitionsDirectory) + } + + return fmt.Errorf("validating API Definitions Directory exists at %q: %+v", a.ApiDefinitionsDirectory, err) + } } - if _, err := os.Stat(a.DataApiAssemblyPath); err != nil { - if os.IsNotExist(err) { - return fmt.Errorf("the Data API Assembly doesn't exist at %q", a.DataApiAssemblyPath) + if a.DataApiAssemblyPath != "" { + if _, err := os.Stat(a.DataApiAssemblyPath); err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("the Data API Assembly doesn't exist at %q", a.DataApiAssemblyPath) + } + + return fmt.Errorf("validating Data API Assembly exists: %+v", err) } + } - return fmt.Errorf("validating Data API Assembly exists: %+v", err) + if a.ApiDefinitionsDirectory == "" && a.DataApiAssemblyPath == "" { + return fmt.Errorf("one of either 'api-definitions-dir' or 'data-api-assembly-path' must be specified") } return nil diff --git a/tools/wrapper-automation/rest_api_specs_importer.go b/tools/wrapper-automation/rest_api_specs_importer.go index 43e9d323a4b..7f9c4002b17 100644 --- a/tools/wrapper-automation/rest_api_specs_importer.go +++ b/tools/wrapper-automation/rest_api_specs_importer.go @@ -23,6 +23,7 @@ func (c RestApiSpecsImporterCmd) Run(args []string) int { } f := flag.NewFlagSet("wrapper-automation", flag.ExitOnError) + f.StringVar(&arguments.ApiDefinitionsDirectory, "api-definitions-dir", "", "--api-definitions-dir=./api-definitions") f.StringVar(&arguments.DataApiAssemblyPath, "data-api-assembly-path", "", "-data-api-assembly-path=../data/Pandora.Api.dll") f.StringVar(&arguments.OutputDirectory, "output-dir", "", "-output-dir=../output") diff --git a/tools/wrapper-automation/run.go b/tools/wrapper-automation/run.go index 2fcb06f2f99..7f4fd92898c 100644 --- a/tools/wrapper-automation/run.go +++ b/tools/wrapper-automation/run.go @@ -15,10 +15,9 @@ func run(args Arguments) error { } // 1: Launch the Data API - var dataApi *exec.Cmd - if args.UseV2Generator { - dataApi = exec.Command(args.DataApiAssemblyPath, "serve") - } else { + dataApi := exec.Command("data-api", "serve", fmt.Sprintf("--data-directory=%s", args.ApiDefinitionsDirectory)) + if args.DataApiAssemblyPath != "" { + // Data API v1 dataApi = exec.Command("dotnet", args.DataApiAssemblyPath) } env := os.Environ() diff --git a/tools/wrapper-automation/terraform_generator.go b/tools/wrapper-automation/terraform_generator.go index e5cf5d0e3cf..dcc77b1eced 100644 --- a/tools/wrapper-automation/terraform_generator.go +++ b/tools/wrapper-automation/terraform_generator.go @@ -23,9 +23,9 @@ func (c TerraformCmd) Run(args []string) int { } f := flag.NewFlagSet("wrapper-automation", flag.ExitOnError) - f.StringVar(&arguments.DataApiAssemblyPath, "data-api-assembly-path", "", "-data-api-assembly-path=../data/Pandora.Api.dll") - f.StringVar(&arguments.OutputDirectory, "output-dir", "", "-output-dir=../output") - f.BoolVar(&arguments.UseV2Generator, "use-v2-generator", false, "-use-v2-generator=true") + f.StringVar(&arguments.ApiDefinitionsDirectory, "api-definitions-dir", "", "--api-definitions-dir=./api-definitions") + f.StringVar(&arguments.DataApiAssemblyPath, "data-api-assembly-path", "", "--data-api-assembly-path=../data/Pandora.Api.dll") + f.StringVar(&arguments.OutputDirectory, "output-dir", "", "--output-dir=../output") if err := f.Parse(args); err != nil { log.Fatalf("parsing arguments: %+v", err)