Skip to content

Latest commit

 

History

History
69 lines (60 loc) · 3.6 KB

code-generation.md

File metadata and controls

69 lines (60 loc) · 3.6 KB

Generate code

Generate SDK packages

Generate Go Mgmt SDK from Typespec

Prerequisites

  • Node.js 18.x LTS or later

  • Go 1.23.x or later

  • Git

  • Identify the tspconfig.yaml file for your package in the Rest API Spec Repo and ensure there is a configuration for the Go SDK similar to that shown below and in this example

    options:
      "@azure-tools/typespec-go":
        service-dir: "SERVICE_DIRECTORY_NAME"
        package-dir: "PACKAGE_DIRECTORY_NAME" # Should start with 'arm' following namespace review result. e.g. https://github.com/Azure/azure-sdk/issues/8290
        module: "github.com/Azure/azure-sdk-for-go/{service-dir}/{package-dir}"
        fix-const-stuttering: true
        flavor: "azure"
        generate-examples: true
        generate-fakes: true
        head-as-boolean: true
        inject-spans: true
  • Local Clone of Rest API Spec Repo Fork

    • If you don't already have a fork, Fork the Rest API Spec Repo.

    • Clone your fork of the repo.

        git clone https://github.com/{YOUR_GITHUB_USERNAME}/azure-rest-api-specs.git
      
  • Local Clone of Go Language Repo Fork

    • If you don't already have a fork, Fork the Go Repo.

    • Clone your fork of the repo.

        git clone https://github.com/{YOUR_GITHUB_USERNAME}/azure-sdk-for-go.git
      

Steps

  1. Complete the prerequisites listed above

  2. Run automation_init.sh

      cd "~/azure-sdk-for-go/eng/scripts" # navigate to the script directory
      ./automation_init.sh

    On windows you can use Git Bash to run the script. This script also installs the generator as a global tool.

  3. Create a local json file named generatedInput.json with content similar to that shown below

       {
         "dryRun": false,
         "specFolder": "LOCAL_AZURE-REST-API-SPECS_REPO_ROOT", // e.g. "C:/git/azure-rest-api-specs"
         "headSha": "SHA_OF_AZURE-REST-API-SPECS_REPO", // use ' git rev-parse HEAD ' on the local azure-rest-api-specs repo root 
         "repoHttpsUrl": "https://github.com/Azure/azure-rest-api-specs",
         "relatedTypeSpecProjectFolder": [
           "specification/SERVICE_DIRECTORY_NAME/PACKAGE_DIRECTORY_NAME/" // e.g specification/contosowidgetmanager/Contoso.Management
         ]
       }
  4. Run the Generator

      generator automation-v2 "PATH_TO_generatedInput.json" generateOutput.json

    generateOutput.json is a parameter for the name of the output file that will be created by the script.

  5. View information about the generated SDK in generateOutput.json

  6. Prepare your SDK for release. The necessary approvals, guidance for testing, documentation, and release pipelines is described in your release plan. More information about the Azure SDK Release Tool is here