Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: moving the swagger submodule to submodules/rest-api-specs #2887

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
gh pr create --title "$PR_TITLE" --body "$PR_BODY" -H "$PR_SOURCE" -B "$PR_TARGET"
env:
PR_TITLE: "Data: regenerating based on ${{ github.sha }}"
PR_TITLE: "Data: Microsoft Graph - regenerating based on ${{ github.sha }}"
PR_BODY: "This PR is automatically generated based on the commit ${{ github.sha }}"
PR_SOURCE: "data/regeneration-from-${{ github.sha }}"
PR_TARGET: "main"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automation-rest-api-specs-importer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- '.github/workflows/**'
- 'config/**'
- 'swagger'
- 'submodules/rest-api-specs'
- 'tools/importer-rest-api-specs/**'


Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
run: |
gh pr create --title "$PR_TITLE" --body "$PR_BODY" -H "$PR_SOURCE" -B "$PR_TARGET"
env:
PR_TITLE: "Data: regenerating based on ${{ github.sha }}"
PR_TITLE: "Data: Rest Api Specs - regenerating based on ${{ github.sha }}"
PR_BODY: "This PR is automatically generated based on the commit ${{ github.sha }}"
PR_SOURCE: "data/regeneration-from-${{ github.sha }}"
PR_TARGET: "main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/automation-version-bumper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- '.github/workflows/**'
- 'config/**'
- 'submodules/msgraph-metadata'
- 'swagger'
- 'submodules/rest-api-specs'
- 'tools/version-bumper/**'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-rest-api-specs-importer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- '.github/workflows/**'
- 'config/**'
- 'swagger'
- 'submodules/rest-api-specs'
- 'tools/importer-rest-api-specs/**'

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "swagger"]
path = swagger
url = [email protected]:Azure/azure-rest-api-specs.git
[submodule "msgraph-metadata"]
path = submodules/msgraph-metadata
url = [email protected]:microsoftgraph/msgraph-metadata.git
[submodule "submodules/rest-api-specs"]
path = submodules/rest-api-specs
url = [email protected]:Azure/azure-rest-api-specs.git
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Pandora's primarily intended to be run in automation (using both Github Actions

* Once a Pull Request is merged that updates one of the following paths, the Rest API Specs Importer is run.
* The Resource Manager Config (`./config/resource-manager.hcl`).
* The Resource Manager Swagger Git Submodule (`./swagger`).
* The Resource Manager Swagger Git Submodule (`./submodules/rest-api-specs`).
* Any of the tooling within `./tools`.
* If the Rest API Specs Importer outputs any changes to the Imported API Definitions, those are committed and a Pull Request is opened.
* Once that PR is merged, if there's any changes then the `hashicorp/go-azure-sdk` repository is updated in the same fashion via the Go SDK Generator (outputting any new/changes to the Go SDK).
Expand All @@ -58,9 +58,11 @@ More information on [how to import a new Resource Manager Service/API Version fo
- `./config/resource-manager.hcl` - contains the list of Resource Manager Services and API Versions which should be imported.
- `./data` - contains the Data API, containing the transformed Azure API Definitions in the intermediate C# format.
- `./docs` - contains documentation.
- `./swagger` - contains the Git Submodule to [the Azure Rest API Specs repository](https://github.com/Azure/azure-rest-api-specs) - containing the OpenAPI/Swagger definitions for Azure Resource Manager.
- `./submodules/msgraph-metadata` - contains the Git Submodule to [the `microsoftgraph/msgraph-metadata` repository](https://github.com/microsoftgraph/msgraph-metadata) - containing the OpenAPI/Swagger definitions for Microsoft Graph.
- `./submodules/rest-api-specs` - contains the Git Submodule to [the `Azure/azure-rest-api-specs` repository](https://github.com/Azure/azure-rest-api-specs) - containing the OpenAPI/Swagger definitions for Azure Resource Manager.
- `./tools/generator-go-sdk` - contains the Go SDK Generator, pulling information from the Data API.
- `./tools/generator-terraform` - contains the Terraform Generator, pulling information from the Data API.
- `./tools/importer-msgraph-metadata` - contains the Importer for the Microsoft Graph API Definitions.
- `./tools/importer-rest-api-specs` - contains the Importer for the Azure Resource Manager OpenAPI/Swagger definitions.
- `./tools/version-bumper` - contains a small tool to add new Services and new API Versions for existing Services to the config.

Expand Down
2 changes: 1 addition & 1 deletion scripts/automation-generate-and-commit-go-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function cleanup {

function main {
local dataApiAssemblyPath="data/Pandora.Api/bin/Debug/net7.0/Pandora.Api.dll"
local swaggerSubmodule="./swagger"
local swaggerSubmodule="./submodules/rest-api-specs"
local outputDirectory="tmp/go-azure-sdk"
local sdkRepo="[email protected]:hashicorp/go-azure-sdk.git"
local sha
Expand Down
6 changes: 3 additions & 3 deletions tools/importer-rest-api-specs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Tool: `importer-rest-api-specs`

This tool imports data from the `Azure/azure-rest-api-specs` repository (accessible in the Git Submodule located at `./swagger`)
This tool imports data from the `Azure/azure-rest-api-specs` repository (accessible in the Git Submodule located at `./submodules/rest-api-specs`)
into the Data format used by the Data API.

For most use-cases you'll want to run `make import` which will parse and process the Swagger Data into the Definitions used by the Data API.
Expand All @@ -12,7 +12,7 @@ However the binary supports a couple of other commands:
Usage: importer-rest-api-specs [--version] [--help] <command> [<args>]

Available commands are:
import Parses and Processes the Data from the './swagger' submodule
import Parses and Processes the Data from the './submodules/rest-api-specs' submodule
segments Outputs a list of Segments used in the Resource IDs
validate Validates that the data within the './swagger' submodule can be parsed
validate Validates that the data within the './submodules/rest-api-specs' submodule can be parsed
```
4 changes: 2 additions & 2 deletions tools/importer-rest-api-specs/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ImportCommand struct {
}

func (ImportCommand) Help() string {
return `Import parses and processes the Swagger Data from the './swagger' submodule, determining
return `Import parses and processes the Swagger Data from the './submodules/rest-api-specs' submodule, determining
which Terraform Data Sources & Resources can be generated - and then finally
outputs this Data in the format used by the Data API.
Expand Down Expand Up @@ -91,5 +91,5 @@ func (c ImportCommand) Run(args []string) int {
}

func (ImportCommand) Synopsis() string {
return "Parses and Processes the Data from the './swagger' submodule"
return "Parses and Processes the Data from the './submodules/rest-api-specs' submodule"
}
4 changes: 2 additions & 2 deletions tools/importer-rest-api-specs/cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ValidateCommand struct {
}

func (ValidateCommand) Help() string {
return "Validates that the data within the './swagger' submodule can be parsed"
return "Validates that the data within the './submodules/rest-api-specs' submodule can be parsed"
}

func (c ValidateCommand) Run(args []string) int {
Expand Down Expand Up @@ -62,5 +62,5 @@ func (c ValidateCommand) Run(args []string) int {
}

func (ValidateCommand) Synopsis() string {
return "Validates that the data within the './swagger' submodule can be parsed"
return "Validates that the data within the './submodules/rest-api-specs' submodule can be parsed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/components/discovery"
)

const swaggerDirectory = "../../../swagger/specification"
const swaggerDirectory = "../../../submodules/rest-api-specs/specification"
const runAllEnvVar = "ALL"

func TestAllSwaggersUsingParser(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tools/importer-rest-api-specs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const (
outputDirectory = "../../data/"
swaggerDirectory = "../../swagger"
swaggerDirectory = "../../submodules/rest-api-specs"
resourceManagerConfig = "../../config/resource-manager.hcl"
terraformDefinitionsPath = "../../config/resources/"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const (
outputDirectory = "../../../data/"
swaggerDirectory = "../../../swagger"
swaggerDirectory = "../../../submodules/rest-api-specs"
resourceManagerConfig = "../../../config/resource-manager.hcl"
)

Expand Down
2 changes: 1 addition & 1 deletion tools/version-bumper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This tool will update the Configs for Resource Manager (and other API's in the F
This does this by:

* Parsing the config (`./config/resource-manager.hcl`)
* Retrieving a list of Services and Service Versions from the `./swagger/specification` Git Submodule.
* Retrieving a list of Services and Service Versions from the `./submodules/rest-api-specs` Git Submodule.
* If it's a new Service (that is, we're not defining it already) - we pick the latest version available (preferring a Stable version, but accepting a Preview version if necessary).
* If we already define that Service, we only add the version if it's a new Stable version. New Preview Versions can be added by updating the Config directly.

Expand Down
2 changes: 1 addition & 1 deletion tools/version-bumper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func run(directory string) error {
servicesToUpdate := map[string]ServiceLocator{
// TODO: active-directory / data-plane in time
"resource-manager": ResourceManagerService{
swaggerDirectory: "../../swagger",
swaggerDirectory: "../../submodules/rest-api-specs",
},
}
for name, service := range servicesToUpdate {
Expand Down
Loading