Skip to content

Commit

Permalink
Enable respectSchemaVersion (#3028)
Browse files Browse the repository at this point in the history
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

Embed provider version in all SDKs. Part of
pulumi/ci-mgmt#915, follow up to:
#3008

1. Enable `respectSchemaVersion` for each language so codegen includes
the version number.
2. Pass the _provider_ version into codegen rather than a
language-specific version - as codegen will do the conversion for us.

### Related issues (optional)

- #3008
- pulumi/ci-mgmt#915
  • Loading branch information
danielrbradley authored May 28, 2024
1 parent c529a7d commit b6f6eff
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
allowed-changes: |-
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/*/internal/pulumiUtilities.go
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- run: git status --porcelain
Expand Down
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,33 @@ test_provider::

dotnet_sdk:: DOTNET_VERSION := $(shell pulumictl convert-version --language dotnet -v "$(VERSION_GENERIC)")
dotnet_sdk::
$(WORKING_DIR)/bin/$(CODEGEN) -version=${DOTNET_VERSION} dotnet $(SCHEMA_FILE) $(CURDIR)
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION_GENERIC} dotnet $(SCHEMA_FILE) $(CURDIR)
rm -rf sdk/dotnet/bin/Debug
cd ${PACKDIR}/dotnet/&& \
echo "module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
dotnet build

go_sdk::
# Delete generated SDK before regenerating.
rm -rf sdk/go/kubernetes
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION} go $(SCHEMA_FILE) $(CURDIR)
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION_GENERIC} go $(SCHEMA_FILE) $(CURDIR)

nodejs_sdk:: NODE_VERSION := $(shell pulumictl convert-version --language javascript -v "$(VERSION_GENERIC)")
nodejs_sdk::
$(WORKING_DIR)/bin/$(CODEGEN) -version=${NODE_VERSION} nodejs $(SCHEMA_FILE) $(CURDIR)
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION_GENERIC} nodejs $(SCHEMA_FILE) $(CURDIR)
cd ${PACKDIR}/nodejs/ && \
echo "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
yarn install && \
yarn run tsc
cp README.md LICENSE ${PACKDIR}/nodejs/package.json ${PACKDIR}/nodejs/yarn.lock ${PACKDIR}/nodejs/bin/
sed -i.bak 's/$${VERSION}/$(NODE_VERSION)/g' ${PACKDIR}/nodejs/bin/package.json

python_sdk:: PYPI_VERSION := $(shell pulumictl convert-version --language python -v "$(VERSION_GENERIC)")
python_sdk::
# Delete only files and folders that are generated.
rm -rf sdk/python/pulumi_kubernetes/*/ sdk/python/pulumi_kubernetes/__init__.py
# Delete files not tracked in Git
cd ${PACKDIR}/python/ && git clean -fxd
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION} python $(SCHEMA_FILE) $(CURDIR)
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION_GENERIC} python $(SCHEMA_FILE) $(CURDIR)
cp README.md ${PACKDIR}/python/
PYPI_VERSION=$(PYPI_VERSION) ./scripts/build_python_sdk.sh

Expand Down
10 changes: 7 additions & 3 deletions provider/cmd/pulumi-resource-kubernetes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"packageReferences": {
"Glob": "1.1.5",
"Pulumi": "3.*"
}
},
"respectSchemaVersion": true
},
"go": {
"generateExtraInputTypes": true,
Expand Down Expand Up @@ -232,7 +233,8 @@
"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/storage/v1beta1": "storagev1beta1",
"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/storagemigration/v1alpha1": "storagemigrationv1alpha1",
"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/yaml/v2": "yamlv2"
}
},
"respectSchemaVersion": true
},
"java": {
"packages": {
Expand Down Expand Up @@ -389,7 +391,8 @@
"storage.k8s.io/v1beta1": "storage/v1beta1",
"storagemigration.k8s.io/v1alpha1": "storagemigration/v1alpha1"
},
"readme": "The Kubernetes provider package offers support for all Kubernetes resources and their properties.\nResources are exposed as types from modules based on Kubernetes API groups such as 'apps', 'core',\n'rbac', and 'storage', among many others. Additionally, support for deploying Helm charts ('helm')\nand YAML files ('yaml') is available in this package. Using this package allows you to\nprogrammatically declare instances of any Kubernetes resources and any supported resource version\nusing infrastructure as code, which Pulumi then uses to drive the Kubernetes API.\n\nIf this is your first time using this package, these two resources may be helpful:\n\n* [Kubernetes Getting Started Guide](https://www.pulumi.com/docs/quickstart/kubernetes/): Get up and running quickly.\n* [Kubernetes Pulumi Setup Documentation](https://www.pulumi.com/docs/quickstart/kubernetes/configure/): How to configure Pulumi\n for use with your Kubernetes cluster.\n\nUse the navigation below to see detailed documentation for each of the supported Kubernetes resources.\n"
"readme": "The Kubernetes provider package offers support for all Kubernetes resources and their properties.\nResources are exposed as types from modules based on Kubernetes API groups such as 'apps', 'core',\n'rbac', and 'storage', among many others. Additionally, support for deploying Helm charts ('helm')\nand YAML files ('yaml') is available in this package. Using this package allows you to\nprogrammatically declare instances of any Kubernetes resources and any supported resource version\nusing infrastructure as code, which Pulumi then uses to drive the Kubernetes API.\n\nIf this is your first time using this package, these two resources may be helpful:\n\n* [Kubernetes Getting Started Guide](https://www.pulumi.com/docs/quickstart/kubernetes/): Get up and running quickly.\n* [Kubernetes Pulumi Setup Documentation](https://www.pulumi.com/docs/quickstart/kubernetes/configure/): How to configure Pulumi\n for use with your Kubernetes cluster.\n\nUse the navigation below to see detailed documentation for each of the supported Kubernetes resources.\n",
"respectSchemaVersion": true
},
"python": {
"compatibility": "kubernetes20",
Expand Down Expand Up @@ -470,6 +473,7 @@
"pulumi": ">=3.109.0,<4.0.0",
"requests": ">=2.21,<3.0"
},
"respectSchemaVersion": true,
"usesIOClasses": true
}
},
Expand Down
6 changes: 5 additions & 1 deletion provider/pkg/gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ additional information about using Server-Side Apply to manage Kubernetes resour
const kubernetes20 = "kubernetes20"

pkg.Language["csharp"] = rawMessage(map[string]any{
"respectSchemaVersion": true,
"packageReferences": map[string]string{
"Glob": "1.1.5",
"Pulumi": "3.*",
Expand All @@ -483,6 +484,7 @@ additional information about using Server-Side Apply to manage Kubernetes resour
})

pkg.Language["go"] = rawMessage(map[string]any{
"respectSchemaVersion": true,
"importBasePath": goImportPath,
"moduleToPackage": modToPkg,
"packageImportAliases": pkgImportAliases,
Expand All @@ -491,7 +493,8 @@ additional information about using Server-Side Apply to manage Kubernetes resour
"internalModuleName": "utilities",
})
pkg.Language["nodejs"] = rawMessage(map[string]any{
"compatibility": kubernetes20,
"respectSchemaVersion": true,
"compatibility": kubernetes20,
"dependencies": map[string]string{
"@pulumi/pulumi": "^3.25.0",
"shell-quote": "^1.6.1",
Expand Down Expand Up @@ -524,6 +527,7 @@ Use the navigation below to see detailed documentation for each of the supported
`,
})
pkg.Language["python"] = rawMessage(map[string]any{
"respectSchemaVersion": true,
"requires": map[string]string{
"pulumi": ">=3.109.0,<4.0.0",
"requests": ">=2.21,<3.0",
Expand Down
1 change: 1 addition & 0 deletions sdk/dotnet/Pulumi.Kubernetes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageProjectUrl>https://pulumi.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/pulumi/pulumi-kubernetes</RepositoryUrl>
<PackageIcon>logo.png</PackageIcon>
<Version>4.0.0-alpha.0+dev</Version>

<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
Expand Down
3 changes: 2 additions & 1 deletion sdk/dotnet/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"resource": true,
"name": "kubernetes"
"name": "kubernetes",
"version": "4.0.0-alpha.0+dev"
}
3 changes: 2 additions & 1 deletion sdk/go/kubernetes/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"resource": true,
"name": "kubernetes"
"name": "kubernetes",
"version": "4.0.0-alpha.0+dev"
}
4 changes: 2 additions & 2 deletions sdk/go/kubernetes/utilities/pulumiUtilities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions sdk/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pulumi/kubernetes",
"version": "${VERSION}",
"version": "4.0.0-alpha.0+dev",
"keywords": [
"pulumi",
"kubernetes",
Expand Down Expand Up @@ -31,6 +31,7 @@
},
"pulumi": {
"resource": true,
"name": "kubernetes"
"name": "kubernetes",
"version": "4.0.0-alpha.0+dev"
}
}
3 changes: 2 additions & 1 deletion sdk/python/pulumi_kubernetes/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"resource": true,
"name": "kubernetes"
"name": "kubernetes",
"version": "4.0.0-alpha.0+dev"
}
2 changes: 1 addition & 1 deletion sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
keywords = ["pulumi", "kubernetes", "category/cloud", "kind/native"]
readme = "README.md"
requires-python = ">=3.8"
version = "0.0.0"
version = "4.0.0a0+dev"
[project.license]
text = "Apache-2.0"
[project.urls]
Expand Down

0 comments on commit b6f6eff

Please sign in to comment.