Skip to content

Commit

Permalink
Embed sdk version (#67)
Browse files Browse the repository at this point in the history
Enable respectSchemaVersion:
- Update schema to add respectSchemaVersion.
- Use `pulumi package gen-sdk` so we can set the version (install pulumi
CLI in local folder).
- Update python build to match other providers.

Tidy old generation code:
- Remove obsolete go generate step
- Remove codegen program
  • Loading branch information
danielrbradley authored May 28, 2024
1 parent 856a270 commit dbe98a6
Show file tree
Hide file tree
Showing 50 changed files with 119 additions and 241 deletions.
1 change: 1 addition & 0 deletions .pulumi.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.116.1
51 changes: 24 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ PACK := kubernetes-cert-manager
PROJECT := github.com/pulumi/pulumi-${PACK}

PROVIDER := pulumi-resource-${PACK}
CODEGEN := pulumi-gen-${PACK}
VERSION_PATH := pkg/version.Version

WORKING_DIR := $(shell pwd)
SCHEMA_PATH := ${WORKING_DIR}/provider/cmd/${PROVIDER}/schema.json

GOPATH := $(shell go env GOPATH)

export PULUMI_IGNORE_AMBIENT_PLUGINS = true

codegen: # Required by CI
rm -rf ${WORKING_DIR}/bin/${CODEGEN}
cd provider/cmd/${CODEGEN} && go build -o ${WORKING_DIR}/bin/${CODEGEN}
# Ensure the codegen file is present so that the hard-coded "Tar Provider Binaries" step doesn't fail
codegen: .pulumi/bin/pulumi # Required by CI
mkdir -p bin && touch bin/pulumi-gen-kubernetes-cert-manager

provider: build_provider # Required by CI
test_provider: # Required by CI
Expand All @@ -37,7 +37,6 @@ install:: install_provider install_dotnet_sdk install_nodejs_sdk

build_provider::
rm -rf ${WORKING_DIR}/bin/${PROVIDER}
cd provider/cmd/${PROVIDER} && VERSION=${VERSION_GENERIC} SCHEMA=${SCHEMA_PATH} go generate main.go
cd provider/cmd/${PROVIDER} && go build -o ${WORKING_DIR}/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION_GENERIC}" .

install_provider:: build_provider
Expand All @@ -46,26 +45,23 @@ install_provider:: build_provider

# Go SDK

gen_go_sdk::
gen_go_sdk: .pulumi/bin/pulumi
rm -rf sdk/go
bin/${CODEGEN} go sdk/go ${SCHEMA_PATH}
.pulumi/bin/pulumi package gen-sdk ${SCHEMA_PATH} --language go --version ${VERSION_GENERIC}
build_go_sdk::
generate_go: gen_go_sdk # Required by CI
build_go: # Required by CI
install_go_sdk:: # Required by CI


# .NET SDK

gen_dotnet_sdk::
gen_dotnet_sdk: .pulumi/bin/pulumi
rm -rf sdk/dotnet
bin/${CODEGEN} dotnet sdk/dotnet ${SCHEMA_PATH}
.pulumi/bin/pulumi package gen-sdk ${SCHEMA_PATH} --language dotnet --version ${VERSION_GENERIC}

build_dotnet_sdk:: DOTNET_VERSION := $(shell pulumictl convert-version --language dotnet -v "$(VERSION_GENERIC)")
build_dotnet_sdk:: gen_dotnet_sdk
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
dotnet build

install_dotnet_sdk:: # Required by CI
rm -rf ${WORKING_DIR}/nuget
Expand All @@ -77,46 +73,40 @@ build_dotnet: build_dotnet_sdk # Required by CI

# Node.js SDK

gen_nodejs_sdk::
gen_nodejs_sdk: .pulumi/bin/pulumi
rm -rf sdk/nodejs
bin/${CODEGEN} nodejs sdk/nodejs ${SCHEMA_PATH}
.pulumi/bin/pulumi package gen-sdk ${SCHEMA_PATH} --language nodejs --version ${VERSION_GENERIC}
# HACKHACK: work around https://github.com/pulumi/pulumi/issues/7979:
find sdk/nodejs -name "*.ts" -exec sed -i.bak \
's/pulumiKubernetes\.types\.input\.\([a-zA-Z0-9]*\)\.\([a-zA-Z0-9]*\)\.\([a-zA-Z]*\)Args/pulumiKubernetes.types.input.\1.\2.\3/g' \
'{}' \;

build_nodejs_sdk:: NODE_VERSION := $(shell pulumictl convert-version --language javascript -v "$(VERSION_GENERIC)")
build_nodejs_sdk:: gen_nodejs_sdk
cd sdk/nodejs/ && \
yarn install && \
yarn run tsc --version && \
yarn run tsc && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(NODE_VERSION)/g" ./bin/package.json && \
rm ./bin/package.json.bak
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/

generate_nodejs: gen_nodejs_sdk # Required by CI
build_nodejs: build_nodejs_sdk # Required by CI
install_nodejs_sdk:: # Required by CI
yarn unlink ${PACK} || true
yarn link --cwd ${WORKING_DIR}/sdk/nodejs/bin


# Python SDK

gen_python_sdk::
gen_python_sdk: .pulumi/bin/pulumi
rm -rf sdk/python
bin/${CODEGEN} python sdk/python ${SCHEMA_PATH}
.pulumi/bin/pulumi package gen-sdk ${SCHEMA_PATH} --language python --version ${VERSION_GENERIC}
cp ${WORKING_DIR}/README.md sdk/python

build_python_sdk:: PYPI_VERSION := $(shell pulumictl convert-version --language python -v "$(VERSION_GENERIC)")
build_python_sdk:: gen_python_sdk
cd sdk/python/ && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION_GENERIC)"/g' ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist
python3 -m venv venv && \
./venv/bin/python -m pip install build && \
cd ./bin && ../venv/bin/python -m build .

generate_python: gen_python_sdk # Required by CI
build_python: build_python_sdk # Required by CI
Expand All @@ -131,3 +121,10 @@ build_java: # Required by CI
cd sdk/java && gradle --console=plain build

install_java_sdk: # Required by CI

# Pulumi for codegen

.pulumi/bin/pulumi: PULUMI_VERSION := $(shell cat .pulumi.version)
.pulumi/bin/pulumi: HOME := $(WORKING_DIR)
.pulumi/bin/pulumi: .pulumi.version
curl -fsSL https://get.pulumi.com | sh -s -- --version "$(PULUMI_VERSION)"
109 changes: 0 additions & 109 deletions provider/cmd/pulumi-gen-kubernetes-cert-manager/main.go

This file was deleted.

35 changes: 21 additions & 14 deletions provider/cmd/pulumi-resource-kubernetes-cert-manager/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,37 +889,44 @@
"packageReferences": {
"Pulumi": "3.*",
"Pulumi.Kubernetes": "4.*"
}
},
"respectSchemaVersion": true
},
"go": {
"generateResourceContainerTypes": true,
"importBasePath": "github.com/pulumi/pulumi-kubernetes-cert-manager/sdk/go/kubernetes-cert-manager"
"importBasePath": "github.com/pulumi/pulumi-kubernetes-cert-manager/sdk/go/kubernetes-cert-manager",
"respectSchemaVersion": true
},
"java": {
"basePackage": "",
"buildFiles": "gradle",
"dependencies": {
"com.google.code.findbugs:jsr305": "3.0.2",
"com.google.code.gson:gson": "2.8.9",
"com.pulumi:pulumi": "0.9.9",
"com.pulumi:kubernetes": "4.11.0"
},
"gradleNexusPublishPluginVersion": "1.1.0",
"gradleTest": ""
"basePackage": "",
"buildFiles": "gradle",
"dependencies": {
"com.google.code.findbugs:jsr305": "3.0.2",
"com.google.code.gson:gson": "2.8.9",
"com.pulumi:pulumi": "0.9.9",
"com.pulumi:kubernetes": "4.11.0"
},
"gradleNexusPublishPluginVersion": "1.1.0",
"gradleTest": ""
},
"nodejs": {
"dependencies": {
"@pulumi/kubernetes": "^4.0.0"
},
"devDependencies": {
"typescript": "^4.3.5"
}
},
"respectSchemaVersion": true
},
"python": {
"requires": {
"pulumi": ">=3.0.0,<4.0.0",
"pulumi-kubernetes": ">=3.7.1,<5.0.0"
},
"respectSchemaVersion": true,
"pyproject": {
"enabled": true
}
}
}
}
}
2 changes: 1 addition & 1 deletion sdk/dotnet/CertManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerCaInjectorArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerGlobalArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerGlobalLeaderElectionArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerGlobalRbacArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerImageArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerIngressShimArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerPrometheusArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerServiceAccountArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerStartupAPICheckArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerStartupAPICheckRBACArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerWebhookArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/CertManagerWebhookURLArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Inputs/ReleaseArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
Expand Down
Loading

0 comments on commit dbe98a6

Please sign in to comment.