Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
- Rename versionMap
- Document TokenModule
- Update docs on version files.
  • Loading branch information
danielrbradley committed Jan 22, 2025
1 parent 5385514 commit 4a9ba92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ Updates to the version selection is done conservatively within the same major ve

### Configuration Files

Version configuration files are prefixed with the major version they're for (e.g. `v2-`) and live within the `versions/` folder. There's three steps to the versioning process:
Version configuration files are prefixed with the major version they're for (e.g. `v2-`) and live within the `versions/` folder.

1. Config: (e.g. [`v2-config.json`](./versions/v2-config.json)) is a hand-edited file to control how the Spec is updated.
2. Spec: (e.g. [`v2-spec.yaml`](./versions/v2-spec.yaml)) is automatically appended to but can be manually edited.
3. Lock: (e.g. [`v2-lock.json`](./versions/v2-lock.json)) is generated from the Spec and is the exact selection of resource versions to use.
3. Removed resources/invokes: (e.g. [`v2-removed-resources.json`](./versions/v2-removed-resources.json))
4. Removed versions: (e.g. [`v2-removed.json`](./versions/v2-removed.json))

The default version selection is calculated as a part of the `make schema` target.
The default versions file (e.g. [`v2.yaml`](./versions/v2.yaml)) is calculated as a part of the `make schema` target and shouldn't be modified directly.

### Config

Expand All @@ -100,7 +101,7 @@ A spec file consists of service names, each specifying:

Both `tracking` and `additions` can be specified together but if the set of resources overlaps (the same resource exists) in both the tracking version and the additions, then the versioning program will fail with an error.

From the Spec file, we generate the Lock JSON file (e.g. [`v2-lock.json`](./versions/v2-lock.json)) which contain the fully expanded set of default resources. These are the files used at the point of generating the schema.
From the Spec file, we calculate the default versions file (e.g. [`v2.yaml`](./versions/v2.yaml)) which contain the fully expanded set of resource versions for each module. These are the files used at the point of generating the schema.

### Creating a new major version default selection

Expand All @@ -116,9 +117,9 @@ Supporting every version of every API causes the SDK size to be very large. One

Ideally, at the point a new incompatible version of the type is added, it should then be created with a unique, stable name. Alternatively, we could create a union of the two possible types

### Default Version Locks
### Default Versions File

The default version is calculated and written to a 'lock' file which list every resource (or invoke) at a specific API version. This file is read in during the schema and SDK generation. Currently there is a `v1-lock.json` and `v2-lock.json` lock file. These lock files should not be edited directly, but should be calculated by the versioner tool using a specific algorithm.
The default version is calculated and written to a YAML file which list every resource (or invoke) at a specific API version. This file is read in during the schema and SDK generation. Currently there is a `v1.json` and `v2.json` file. These files should not be edited directly, but should be calculated by the versioner tool using a specific algorithm.

### Additional Reports

Expand Down
7 changes: 4 additions & 3 deletions provider/pkg/gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ func PulumiSchema(rootDir string, modules openapi.AzureModules, versioning Versi
resourcesPathTracker := newResourcesPathConflictsTracker()

for _, moduleName := range util.SortedKeys(modules) {
versionMap := modules[moduleName]
moduleVersions := modules[moduleName]

resourcePaths := map[openapi.ResourceName]map[string][]openapi.ApiVersion{}

versions := util.SortedKeys(versionMap)
versions := util.SortedKeys(moduleVersions)
// The version in the parsed module is "" for the default version.
for _, moduleVersion := range versions {
var sdkVersion openapi.SdkVersion
Expand Down Expand Up @@ -330,7 +330,7 @@ func PulumiSchema(rootDir string, modules openapi.AzureModules, versioning Versi
golangImportAliases[goModuleName(gen.moduleName, gen.sdkVersion)] = moduleName.Lowered()

// Populate resources and get invokes.
items := versionMap[moduleVersion]
items := moduleVersions[moduleVersion]
var resources []string
for resource := range items.Resources {
resources = append(resources, resource)
Expand Down Expand Up @@ -1292,6 +1292,7 @@ func (g *packageGenerator) genFunctions(typeName, path string, specParams []spec
g.metadata.Invokes[functionTok] = f
}

// TokenModule is the module as appears in the token e.g. `compute/v20200701` or `network`.
type TokenModule string

// moduleWithVersion produces the token's module part from the module name and the version e.g. `compute/v20200701` or `network`.
Expand Down

0 comments on commit 4a9ba92

Please sign in to comment.