Skip to content

Commit

Permalink
Generalise version in the makefile (#3770)
Browse files Browse the repository at this point in the history
- Remove hard-coded version numbers for the versions files. Calculate
MAJOR_VERSION, NEXT_MAJOR_VERSION and PREVIOUS_MAJOR_VERSION
- Use same format for removed-resources for the previous, current and
next version (JSON).
- Add missing dependencies for when building the schema.
  • Loading branch information
danielrbradley authored Dec 10, 2024
1 parent 021d995 commit a8d8df8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ PROVIDER_VERSION ?= 2.0.0-alpha.0+dev
# These variables are lazy (no `:`) so they're not calculated until after the dependency is installed
VERSION_GENERIC = $(shell bin/pulumictl convert-version -l generic -v "$(PROVIDER_VERSION)")
VERSION_FLAGS = -ldflags "-X github.com/pulumi/pulumi-azure-native/v2/provider/pkg/version.Version=${VERSION_GENERIC}"
MAJOR_VERSION = $(shell echo $(PROVIDER_VERSION) | cut -d. -f1)
PREVIOUS_MAJOR_VERSION = $(shell echo $(MAJOR_VERSION)-1 | bc)
NEXT_MAJOR_VERSION = $(shell echo $(MAJOR_VERSION)+1 | bc)

# Ensure make directory exists
# For targets which either don't generate a single file output, or the file is committed, we use a "sentinel"
Expand All @@ -61,7 +64,6 @@ provider_prebuild: .make/provider_prebuild
.PHONY: prebuild
prebuild: .make/prebuild

# We don't include v2 here yet as this is executed on the nightly updates
.PHONY: schema generate_schema generate_docs
schema: bin/schema-full.json
generate_schema: bin/schema-full.json
Expand Down Expand Up @@ -221,12 +223,12 @@ bin/$(CODEGEN): bin/pulumictl .make/prebuild .make/provider_mod_download provide

# Writes schema-full.json and metadata-compact.json to bin/
# Also re-calculates files in versions/ at same time
bin/schema-full.json bin/metadata-compact.json &: bin/$(CODEGEN) $(SPECS) versions/az-provider-list.json versions/v1-lock.json versions/v2-config.yaml versions/v2-spec.yaml versions/v2-removed-resources.json
bin/schema-full.json bin/metadata-compact.json &: bin/$(CODEGEN) $(SPECS) versions/az-provider-list.json versions/v${PREVIOUS_MAJOR_VERSION}-lock.json versions/v${MAJOR_VERSION}-config.yaml versions/v${MAJOR_VERSION}-spec.yaml versions/v${MAJOR_VERSION}-removed-resources.json versions/v${NEXT_MAJOR_VERSION}-removed-resources.json
bin/$(CODEGEN) schema $(VERSION_GENERIC)

# Docs schema - treat as phony becasuse it's committed so we always need to rebuild it.
.PHONY: provider/cmd/pulumi-resource-azure-native/schema.json
provider/cmd/pulumi-resource-azure-native/schema.json: bin/$(CODEGEN) $(SPECS) versions/v1-lock.json versions/v2-config.yaml versions/v2-removed-resources.json
provider/cmd/pulumi-resource-azure-native/schema.json: bin/$(CODEGEN) $(SPECS) versions/v${PREVIOUS_MAJOR_VERSION}-lock.json versions/v${MAJOR_VERSION}-config.yaml versions/v${MAJOR_VERSION}-removed-resources.json
bin/$(CODEGEN) docs $(VERSION_GENERIC)

bin/$(LOCAL_PROVIDER_FILENAME): bin/pulumictl .make/prebuild .make/provider_mod_download provider/cmd/$(PROVIDER)/*.go .make/provider_prebuild $(PROVIDER_PKG)
Expand Down Expand Up @@ -269,13 +271,13 @@ dist/pulumi-azure-native_$(VERSION_GENERIC)_checksums.txt: dist/$(PROVIDER)-v$(P
cd provider && go mod download
@touch $@

.make/provider_prebuild: .make/prebuild bin/schema-full.json bin/metadata-compact.json versions/v2-lock.json
.make/provider_prebuild: .make/prebuild bin/schema-full.json bin/metadata-compact.json versions/v${MAJOR_VERSION}-lock.json
cp bin/schema-full.json provider/cmd/$(PROVIDER)
cp bin/metadata-compact.json provider/cmd/$(PROVIDER)
@touch $@

.make/prebuild: .pulumi/bin/pulumi
cp -v versions/v2-lock.json provider/pkg/versionLookup/
cp -v versions/v${MAJOR_VERSION}-lock.json provider/pkg/versionLookup/
@touch $@

define FAKE_MODULE
Expand Down
2 changes: 1 addition & 1 deletion provider/pkg/versioning/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func ReadVersionSources(rootDir string, providers openapi.AzureProviders, majorV
}

nextVersionFilePrefix := fmt.Sprintf("v%d-", majorVersion+1)
nextResourcesToRemovePath := path.Join(rootDir, "versions", nextVersionFilePrefix+"removed-resources.yaml")
nextResourcesToRemovePath := path.Join(rootDir, "versions", nextVersionFilePrefix+"removed-resources.json")
nextResourcesToRemove, err := ReadResourceRemovals(nextResourcesToRemovePath)
if err != nil {
return VersionSources{}, fmt.Errorf("could not read %s: %v", nextResourcesToRemovePath, err)
Expand Down
1 change: 1 addition & 0 deletions versions/v3-removed-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file removed versions/v3-removed-resources.yaml
Empty file.

0 comments on commit a8d8df8

Please sign in to comment.