Skip to content

Commit

Permalink
Use provider dependencies in schema (#1487)
Browse files Browse the repository at this point in the history
This PR changes the schema generation to read provider dependency
versions (AWS & Kube) from the `package.json` file (like in
[awsx](https://github.com/pulumi/pulumi-awsx/blob/bb9d7462d8be5279267e2ba651f2de2cb6e54953/schemagen/pkg/gen/schema.go#L264)).
This is the first step towards automating provider dependency upgrades.

To achieve the correct behavior, provider dependencies now need to use a
fixed version instead of a semver range. I used the current versions
form the lock file, except for the aws provider. Versions 6.42 - 6.46 of
the aws provider are not present on mavencentral. To keep the diff of
this PR as small as possible, I upgraded aws to the next possible
version (`6.47.0`).

I'll update all provider versions to latest in a separate PR.
  • Loading branch information
flostadler authored Nov 14, 2024
1 parent 9801c10 commit 2f95d29
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 72 deletions.
4 changes: 2 additions & 2 deletions nodejs/eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"bugs": "https://github.com/pulumi/pulumi-eks/issues",
"dependencies": {
"@pulumi/aws": "^6.18.2",
"@pulumi/kubernetes": "^4.1.1",
"@pulumi/aws": "6.47.0",
"@pulumi/kubernetes": "4.15.0",
"@pulumi/pulumi": "^3.138.0",
"https-proxy-agent": "^5.0.1",
"jest": "^29.7.0",
Expand Down
10 changes: 5 additions & 5 deletions nodejs/eks/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1656,17 +1656,17 @@
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==

"@pulumi/aws@^6.18.2":
version "6.45.0"
resolved "https://registry.yarnpkg.com/@pulumi/aws/-/aws-6.45.0.tgz#f3cf0fea34214906cf2e35f7ab57d6195b4d668a"
integrity sha512-EhRlYs0Ig53nHRNv3NSgb5TPpJuDmA+N0HCUkPhODUT9n1KTahQnoLbMc+hbvJKPngx6hgye7fagARPO3kWPVw==
"@pulumi/aws@6.47.0":
version "6.47.0"
resolved "https://registry.yarnpkg.com/@pulumi/aws/-/aws-6.47.0.tgz#606d71cc9121bf41bbdf662e3e7c84ae5d33eb27"
integrity sha512-zd3Mh7Hlen9xAW85Prsxbot8Z89Vnel42qCEkYrvFZYYnGPZl0sxuAWgUG54J6AsJ5syPDYNKpl65x3L6YHLSg==
dependencies:
"@pulumi/pulumi" "^3.0.0"
builtin-modules "3.0.0"
mime "^2.0.0"
resolve "^1.7.1"

"@pulumi/kubernetes@^4.1.1":
"@pulumi/kubernetes@4.15.0":
version "4.15.0"
resolved "https://registry.yarnpkg.com/@pulumi/kubernetes/-/kubernetes-4.15.0.tgz#a1f1839371504474cecc342cae447db145c4a2eb"
integrity sha512-X+EFpmcuB+bXGArA4QMvAXDM2IshkvSckcVIXsyR1XolaZ+UyCMrDHLfIzb5+nDj3LWS49A+aOWRjSWr+QynlQ==
Expand Down
43 changes: 35 additions & 8 deletions provider/cmd/pulumi-gen-eks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ package main
import (
"encoding/json"
"fmt"
"log"
"os"
"path"
"path/filepath"

"github.com/blang/semver"
Expand All @@ -44,6 +46,30 @@ const (
Schema Language = "schema"
)

type Dependencies struct {
Aws string `json:"@pulumi/aws"`
Kubernetes string `json:"@pulumi/kubernetes"`
}

type PackageJSON struct {
Dependencies Dependencies
}

func readPackageDependencies(packageDir string) Dependencies {
content, err := os.ReadFile(path.Join(packageDir, "package.json"))
if err != nil {
log.Fatal("Error when opening file: ", err)
}

var payload PackageJSON
err = json.Unmarshal(content, &payload)
if err != nil {
log.Fatal("Error during Unmarshal(): ", err)
}

return payload.Dependencies
}

func main() {
printUsage := func() {
fmt.Printf("Usage: %s <language> <out-dir> <root-pulumi-eks-dir> [schema-file] [version]\n", os.Args[0])
Expand Down Expand Up @@ -81,7 +107,7 @@ func main() {
case Python:
genPython(readSchema(schemaFile, version), outdir)
case Schema:
pkgSpec := generateSchema(semver.MustParse(version))
pkgSpec := generateSchema(semver.MustParse(version), outdir)
mustWritePulumiSchema(pkgSpec, outdir)
default:
panic(fmt.Sprintf("Unrecognized language %q", language))
Expand All @@ -102,7 +128,8 @@ func k8sRef(ref string) string {
}

//nolint:lll,goconst
func generateSchema(version semver.Version) schema.PackageSpec {
func generateSchema(version semver.Version, outdir string) schema.PackageSpec {
dependencies := readPackageDependencies(path.Join(outdir, "..", "..", "..", "nodejs", "eks"))
return schema.PackageSpec{
Name: "eks",
Description: "Pulumi Amazon Web Services (AWS) EKS Components.",
Expand Down Expand Up @@ -2026,8 +2053,8 @@ func generateSchema(version semver.Version) schema.PackageSpec {
}),
"python": rawMessage(map[string]interface{}{
"requires": map[string]string{
"pulumi-aws": ">=6.0.0,<7.0.0",
"pulumi-kubernetes": ">=4.0.0,<5.0.0",
"pulumi-aws": fmt.Sprintf(">=%s,<7.0.0", dependencies.Aws),
"pulumi-kubernetes": fmt.Sprintf(">=%s,<5.0.0", dependencies.Kubernetes),
},
"usesIOClasses": true,
// TODO: Embellish the readme
Expand All @@ -2047,15 +2074,15 @@ func generateSchema(version semver.Version) schema.PackageSpec {
}),
"java": rawMessage(map[string]interface{}{
"dependencies": map[string]string{
"com.pulumi:aws": "6.18.2",
"com.pulumi:kubernetes": "4.4.0",
"com.pulumi:aws": dependencies.Aws,
"com.pulumi:kubernetes": dependencies.Kubernetes,
},
}),
"nodejs": rawMessage(map[string]interface{}{
"respectSchemaVersion": true,
"dependencies": map[string]string{
"@pulumi/aws": "^6.18.2",
"@pulumi/kubernetes": "^4.1.1",
"@pulumi/aws": "^" + dependencies.Aws,
"@pulumi/kubernetes": "^" + dependencies.Kubernetes,
"https-proxy-agent": "^5.0.1",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
Expand Down
12 changes: 6 additions & 6 deletions provider/cmd/pulumi-resource-eks/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
},
"java": {
"dependencies": {
"com.pulumi:aws": "6.18.2",
"com.pulumi:kubernetes": "4.4.0"
"com.pulumi:aws": "6.47.0",
"com.pulumi:kubernetes": "4.15.0"
}
},
"nodejs": {
"dependencies": {
"@pulumi/aws": "^6.18.2",
"@pulumi/kubernetes": "^4.1.1",
"@pulumi/aws": "^6.47.0",
"@pulumi/kubernetes": "^4.15.0",
"https-proxy-agent": "^5.0.1",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
Expand All @@ -60,8 +60,8 @@
},
"readme": "Pulumi Amazon Web Services (AWS) EKS Components.",
"requires": {
"pulumi-aws": "\u003e=6.0.0,\u003c7.0.0",
"pulumi-kubernetes": "\u003e=4.0.0,\u003c5.0.0"
"pulumi-aws": "\u003e=6.47.0,\u003c7.0.0",
"pulumi-kubernetes": "\u003e=4.15.0,\u003c5.0.0"
},
"respectSchemaVersion": true,
"usesIOClasses": true
Expand Down
4 changes: 2 additions & 2 deletions sdk/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ repositories {
dependencies {
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("com.google.code.gson:gson:2.8.9")
implementation("com.pulumi:aws:6.18.2")
implementation("com.pulumi:kubernetes:4.4.0")
implementation("com.pulumi:aws:6.47.0")
implementation("com.pulumi:kubernetes:4.15.0")
implementation("com.pulumi:pulumi:0.16.1")
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"build": "tsc"
},
"dependencies": {
"@pulumi/aws": "^6.18.2",
"@pulumi/kubernetes": "^4.1.1",
"@pulumi/aws": "^6.47.0",
"@pulumi/kubernetes": "^4.15.0",
"@pulumi/pulumi": "^3.136.0",
"https-proxy-agent": "^5.0.1",
"jest": "^29.7.0",
Expand Down
56 changes: 10 additions & 46 deletions sdk/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -898,65 +898,29 @@
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==

"@pulumi/aws@^6.18.2":
version "6.50.1"
resolved "https://registry.yarnpkg.com/@pulumi/aws/-/aws-6.50.1.tgz#7b4f29131dbee9d8bcdbb6e536535e80211ab7b2"
integrity sha512-PzU8DnOsLCFgqeV7eFSrmcyqos2ilsuuRNbGLxP9pP1dXhsBvXoLFVyLNdTuI+zDG58fOmC2c7KsXXuyo3vjvg==
"@pulumi/aws@^6.47.0":
version "6.59.1"
resolved "https://registry.yarnpkg.com/@pulumi/aws/-/aws-6.59.1.tgz#b9ad23a720011f32d75dd4f7a6dbb227132d601f"
integrity sha512-JuMgE61wO8n0HgOCsx8XKn2JqwPRbFcxHvfWgfyCmQ2KZeMBhlkiHBfEWG80mUtztGX3jj3DmKUw4hP5vLL82A==
dependencies:
"@pulumi/pulumi" "^3.0.0"
"@pulumi/pulumi" "^3.136.0"
builtin-modules "3.0.0"
mime "^2.0.0"
resolve "^1.7.1"

"@pulumi/kubernetes@^4.1.1":
version "4.17.1"
resolved "https://registry.yarnpkg.com/@pulumi/kubernetes/-/kubernetes-4.17.1.tgz#01b1c54429836d5c96e3e713ede0009e92b98dde"
integrity sha512-XmPhPG7vqXHo0/hs14JX25oNF7Aum0dmdqYTWIvbUUqi9GUD05eJTYh0PyNpOm4sFuRbFVvqHdc8NbVbc1R6Fg==
"@pulumi/kubernetes@^4.15.0":
version "4.18.3"
resolved "https://registry.yarnpkg.com/@pulumi/kubernetes/-/kubernetes-4.18.3.tgz#10e7d25c35282b6fa40b305427b5822cbf78c6de"
integrity sha512-mv8QbAmAeLw72MIExSPvamODAW4CdJi/kMUEKVrL/XRZjzffX+++L4BAKkjvnsL/XYPXpmr+mA11fQ+otLps7Q==
dependencies:
"@pulumi/pulumi" "^3.25.0"
"@pulumi/pulumi" "^3.136.0"
"@types/node-fetch" "^2.1.4"
"@types/tmp" "^0.0.33"
glob "^10.3.10"
node-fetch "^2.3.0"
shell-quote "^1.6.1"
tmp "^0.0.33"

"@pulumi/pulumi@^3.0.0", "@pulumi/pulumi@^3.25.0":
version "3.130.0"
resolved "https://registry.yarnpkg.com/@pulumi/pulumi/-/pulumi-3.130.0.tgz#526f5e248900af1a4cacf213ece38e506f92881f"
integrity sha512-WsvXRfEdCz+AcuzP41ABgN5Ye3qLt4v/EVZXUT7sMHU6G8uazaLtS92tpvNp+pgeRZf9kbotCEoABXKg+d+1oQ==
dependencies:
"@grpc/grpc-js" "^1.10.1"
"@logdna/tail-file" "^2.0.6"
"@npmcli/arborist" "^7.3.1"
"@opentelemetry/api" "^1.9"
"@opentelemetry/exporter-zipkin" "^1.25"
"@opentelemetry/instrumentation" "^0.52"
"@opentelemetry/instrumentation-grpc" "^0.52"
"@opentelemetry/resources" "^1.25"
"@opentelemetry/sdk-trace-base" "^1.25"
"@opentelemetry/sdk-trace-node" "^1.25"
"@opentelemetry/semantic-conventions" "^1.25"
"@pulumi/query" "^0.3.0"
"@types/google-protobuf" "^3.15.5"
"@types/semver" "^7.5.6"
"@types/tmp" "^0.2.6"
execa "^5.1.0"
fdir "^6.1.1"
google-protobuf "^3.5.0"
got "^11.8.6"
ini "^2.0.0"
js-yaml "^3.14.0"
minimist "^1.2.6"
normalize-package-data "^6.0.0"
picomatch "^3.0.1"
pkg-dir "^7.0.0"
require-from-string "^2.0.1"
semver "^7.5.2"
source-map-support "^0.5.6"
tmp "^0.2.1"
upath "^1.1.0"

"@pulumi/pulumi@^3.136.0":
version "3.138.0"
resolved "https://registry.yarnpkg.com/@pulumi/pulumi/-/pulumi-3.138.0.tgz#71ec3379ae1451ea3b824389a8347a38e7cc2308"
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "pulumi_eks"
description = "Pulumi Amazon Web Services (AWS) EKS Components."
dependencies = ["parver>=0.2.1", "pulumi>=3.136.0,<4.0.0", "pulumi-aws>=6.0.0,<7.0.0", "pulumi-kubernetes>=4.0.0,<5.0.0", "semver>=2.8.1", "typing-extensions>=4.11; python_version < \"3.11\""]
dependencies = ["parver>=0.2.1", "pulumi>=3.136.0,<4.0.0", "pulumi-aws>=6.47.0,<7.0.0", "pulumi-kubernetes>=4.15.0,<5.0.0", "semver>=2.8.1", "typing-extensions>=4.11; python_version < \"3.11\""]
keywords = ["pulumi", "aws", "eks"]
readme = "README.md"
requires-python = ">=3.8"
Expand Down

0 comments on commit 2f95d29

Please sign in to comment.