Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigGroup V2 (Component) #2844

Merged
merged 14 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
## Unreleased

- Use async invokes to avoid hangs/stalls in Python `helm`, `kustomize`, and `yaml` components (https://github.com/pulumi/pulumi-kubernetes/pull/2863)
- ConfigGroup V2 (https://github.com/pulumi/pulumi-kubernetes/pull/2844)

### New Features

A new MLC-based implementation of `ConfigGroup` is now available in the "yaml/v2" package. This resource is
usable in all Pulumi languages, including Pulumi YAML and in the Java Pulumi SDK.

Note that transformations aren't supported in this release (see https://github.com/pulumi/pulumi/issues/12996).

## 4.9.0 (March 4, 2024)

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ k8sprovider::
(cd provider && CGO_ENABLED=0 go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))

k8sprovider_debug::
$(WORKING_DIR)/bin/${CODEGEN} kinds $(SCHEMA_FILE) $(CURDIR)
@[ ! -f "provider/cmd/${PROVIDER}/schema.go" ] || \
(echo "\n Please remove provider/cmd/${PROVIDER}/schema.go, which is no longer used\n" && false)
(cd provider && VERSION=${VERSION} go generate cmd/${PROVIDER}/main.go)
(cd provider && CGO_ENABLED=0 go build -o $(WORKING_DIR)/bin/${PROVIDER} -gcflags="all=-N -l" -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))

test_provider::
Expand Down
6 changes: 5 additions & 1 deletion provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ func generateSchema(swaggerPath string) schema.PackageSpec {
}

// This is to mostly filter resources from the spec.
var resourcesToFilterFromTemplate = codegen.NewStringSet("kubernetes:helm.sh/v3:Release")
var resourcesToFilterFromTemplate = codegen.NewStringSet(
"kubernetes:helm.sh/v3:Release",
"kubernetes:yaml/v2:ConfigGroup",
)

func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) {
resources, err := nodejsgen.LanguageResources(pkg)
Expand Down Expand Up @@ -404,6 +407,7 @@ func writeGoClient(pkg *schema.Package, outdir string, templateDir string) {
files["kubernetes/yaml/configGroup.go"] = mustLoadGoFile(filepath.Join(templateDir, "yaml", "configGroup.go"))
files["kubernetes/yaml/transformation.go"] = mustLoadGoFile(filepath.Join(templateDir, "yaml", "transformation.go"))
files["kubernetes/yaml/yaml.go"] = mustRenderGoTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources)
files["kubernetes/yaml/v2/kinds.go"] = mustRenderGoTemplate(filepath.Join(templateDir, "yaml", "v2", "kinds.tmpl"), templateResources)

mustWriteFiles(outdir, files)
}
Expand Down
47 changes: 45 additions & 2 deletions provider/cmd/pulumi-resource-kubernetes/schema.json

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module github.com/pulumi/pulumi-kubernetes/provider/v4

go 1.21

replace (
EronWright marked this conversation as resolved.
Show resolved Hide resolved
github.com/pulumi/pulumi-kubernetes/sdk/v4 => ../sdk
github.com/pulumi/pulumi-kubernetes/tests/v4 => ../tests
)

require (
github.com/ahmetb/go-linq v3.0.0+incompatible
github.com/evanphx/json-patch v5.7.0+incompatible
Expand All @@ -14,10 +19,12 @@ require (
github.com/onsi/gomega v1.30.0
github.com/pkg/errors v0.9.1
github.com/pulumi/cloud-ready-checks v1.1.0
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.0.0
github.com/pulumi/pulumi-kubernetes/tests/v4 v4.0.0-20240302002028-652829a1ed71
github.com/pulumi/pulumi/pkg/v3 v3.109.0
github.com/pulumi/pulumi/sdk/v3 v3.109.0
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.17.0
golang.org/x/crypto v0.18.0
google.golang.org/grpc v1.59.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.14.2
Expand Down Expand Up @@ -189,15 +196,15 @@ require (
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0
golang.org/x/time v0.4.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.151.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.31.0
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
12 changes: 6 additions & 6 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2019,8 +2019,8 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -2343,8 +2343,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -2354,8 +2354,8 @@ golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuX
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
63 changes: 63 additions & 0 deletions provider/pkg/gen/_go-templates/yaml/v2/kinds.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2016-2024, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// *** WARNING: this file was generated by pulumigen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package v2

import (
"fmt"

"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/apiextensions"
{{- range .Imports}}
{{.}}
{{- end}}
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func IsListKind(apiVersion, kind string) bool {
fullKind := fmt.Sprintf("%s/%s", apiVersion, kind)
switch fullKind {
case "v1/List",
{{range $idx, $v := .ListKinds -}} {{if $idx}},
{{end}}"{{$v.GVK}}" {{- end}}:
return true
default:
return false
}
}

func RegisterResource(ctx *pulumi.Context, apiVersion, kind, name string, props pulumi.Input,
opts ...pulumi.ResourceOption) (pulumi.CustomResource, error) {
fullKind := fmt.Sprintf("%s/%s", apiVersion, kind)
switch fullKind {
{{- range .NonListKinds}}
case "{{.GVK}}":
var res {{.Alias}}.{{.Name}}
err := ctx.RegisterResource("{{.Token}}", name, props, &res, opts...)
if err != nil {
return nil, err
}
{{`return &res, nil`}}
{{- end}}
default:
var res apiextensions.CustomResource
err := ctx.RegisterResource(fmt.Sprintf("kubernetes:%s:%s", apiVersion, kind), name, props, &res, opts...)
if err != nil {
return nil, err
}
{{`return &res, nil`}}
}
}
2 changes: 1 addition & 1 deletion provider/pkg/gen/examples/overlays/configGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const example = new k8s.yaml.ConfigGroup("example", {
});
```
```python
from pulumi_kubernetes.yaml import ConfigFile
from pulumi_kubernetes.yaml import ConfigGroup

# Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.
def make_service_private(obj, opts):
Expand Down
Loading
Loading