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

Provider config should be available as outputs #2598

Merged
merged 29 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7d08477
Promote provider input properties to properties
EronWright Oct 4, 2023
a4bc41f
Normalize provider inputs
EronWright Oct 5, 2023
f11ea37
New test: TestHelmReleaseProviderNamespace
EronWright Oct 5, 2023
017b8f7
New test: TestProviderOutputs
EronWright Oct 5, 2023
9d90ae8
SDK generation
EronWright Oct 5, 2023
30b90a4
Improve error message when kubeconfig is a path
EronWright Oct 6, 2023
80c1392
changelog
EronWright Oct 6, 2023
582373c
gofmt
EronWright Oct 6, 2023
affacd6
remove special case for default provider
EronWright Oct 6, 2023
938099c
remove path detection logic
EronWright Oct 6, 2023
1e3e4ee
remove changes to kubeconfig loader
EronWright Oct 6, 2023
c52f572
changelog
EronWright Oct 6, 2023
2a0c11d
Suppress kubeconfig errors for default provider only
EronWright Oct 7, 2023
224aeb4
Avoid parsing paths as content in kubeconfig loader
EronWright Oct 7, 2023
6b47428
Use non-interactive kubeconfig loader
EronWright Oct 7, 2023
5be418f
changelog
EronWright Oct 7, 2023
a60ebd4
changelog
EronWright Oct 7, 2023
0eb9347
Reuse olds in degraded mode
EronWright Oct 9, 2023
b31ac13
cleanup
EronWright Oct 9, 2023
f715982
robustness of default namespace
EronWright Oct 9, 2023
af30389
cleanup
EronWright Oct 9, 2023
3efa13c
More config validity checks
EronWright Oct 17, 2023
15e5ad1
remove PULUMI_K8S_NORMALIZE_KUBECONFIG
EronWright Oct 17, 2023
415ae2b
remove non-string properties from schema
EronWright Oct 17, 2023
5891a98
update example dependencies
EronWright Oct 17, 2023
b1736db
Fix for path-like kubeconfig, simply cluster replacement
EronWright Oct 18, 2023
9afac39
go imports
EronWright Oct 18, 2023
819e5b4
remove dead code
EronWright Oct 18, 2023
4d854c1
linting
EronWright Oct 18, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fix normalizing fields with empty objects/slices (https://github.com/pulumi/pulumi-kubernetes/pull/2576)
- helm.v3.Release: Improved cancellation support (https://github.com/pulumi/pulumi-kubernetes/pull/2579)
- Update Kubernetes client library to v0.28.2 (https://github.com/pulumi/pulumi-kubernetes/pull/2585)
- Normalize provider inputs and make available as outputs (https://github.com/pulumi/pulumi-kubernetes/pull/2598)

## 4.3.0 (September 25, 2023)

Expand Down
2 changes: 1 addition & 1 deletion provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ func buildPulumiFieldsFromTerraform(path string, block *TerraformBlockSchema) ma
if path == "kubernetes_deployment.spec.template.spec.container" && blockName == "port" {
field["name"] = "ports"
}
// 3. kubernetes_service has a field "port" wich is a list, but we call it "ports"
// 3. kubernetes_service has a field "port" which is a list, but we call it "ports"
if path == "kubernetes_service.spec" && blockName == "port" {
field["name"] = "ports"
}
Expand Down
32 changes: 32 additions & 0 deletions provider/cmd/pulumi-resource-kubernetes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65021,6 +65021,38 @@
},
"provider": {
"description": "The provider type for the kubernetes package.",
"properties": {
"cluster": {
"type": "string",
"description": "If present, the name of the kubeconfig cluster to use."
},
"context": {
"type": "string",
"description": "If present, the name of the kubeconfig context to use."
},
"kubeconfig": {
"type": "string",
EronWright marked this conversation as resolved.
Show resolved Hide resolved
"description": "The contents of a kubeconfig file or the path to a kubeconfig file.",
"defaultInfo": {
"environment": [
"KUBECONFIG"
]
},
"language": {
"csharp": {
"name": "KubeConfig"
}
}
},
"namespace": {
"type": "string",
"description": "If present, the default namespace to use. This flag is ignored for cluster-scoped resources.\n\nA namespace can be specified in multiple places, and the precedence is as follows:\n1. `.metadata.namespace` set on the resource.\n2. This `namespace` parameter.\n3. `namespace` set for the active context in the kubeconfig."
},
"renderYamlToDirectory": {
"type": "string",
"description": "BETA FEATURE - If present, render resource manifests to this directory. In this mode, resources will not\nbe created on a Kubernetes cluster, but the rendered manifests will be kept in sync with changes\nto the Pulumi program. This feature is in developer preview, and is disabled by default.\n\nNote that some computed Outputs such as status fields will not be populated\nsince the resources are not created on a Kubernetes cluster. These Output values will remain undefined,\nand may result in an error if they are referenced by other resources. Also note that any secret values\nused in these resources will be rendered in plaintext to the resulting YAML."
}
},
"type": "object",
"inputProperties": {
"cluster": {
Expand Down
9 changes: 9 additions & 0 deletions provider/pkg/gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func PulumiSchema(swagger map[string]any) pschema.PackageSpec {
ObjectTypeSpec: pschema.ObjectTypeSpec{
Description: "The provider type for the kubernetes package.",
Type: "object",
Properties: map[string]pschema.PropertySpec{},
},
InputProperties: map[string]pschema.PropertySpec{
"kubeconfig": {
Expand Down Expand Up @@ -216,6 +217,14 @@ func PulumiSchema(swagger map[string]any) pschema.PackageSpec {
Language: map[string]pschema.RawMessage{},
}

for name, inputProp := range pkg.Provider.InputProperties {
// FIXME: provider outputs are limited to strings due to:
// https://github.com/pulumi/pulumi/issues/13435
if inputProp.TypeSpec.Type != "string" {
continue
}
pkg.Provider.Properties[name] = inputProp
}
goImportPath := "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes"

csharpNamespaces := map[string]string{
Expand Down
15 changes: 3 additions & 12 deletions provider/pkg/provider/helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,9 @@ func (r *helmReleaseProvider) getActionConfig(namespace string) (*action.Configu
// explicitly set the namespace (e.g. through namespace: {{ .Release.Namespace }}).
overrides.Context.Namespace = namespace

var clientConfig clientcmd.ClientConfig
if r.apiConfig != nil {
clientConfig = clientcmd.NewDefaultClientConfig(*r.apiConfig, &overrides)
} else {
// Use client-go to resolve the final configuration values for the client. Typically these
// values would reside in the $KUBECONFIG file, but can also be altered in several
// places, including in env variables, client-go default values, and (if we allowed it) CLI
// flags.
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
clientConfig = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &overrides)
}
contract.Assertf(r.apiConfig != nil, "expected non-nil apiConfig")
contract.Assertf(r.restConfig != nil, "expected non-nil restConfig")
clientConfig := clientcmd.NewDefaultClientConfig(*r.apiConfig, &overrides)
kc := NewKubeConfig(r.restConfig, clientConfig)

if err := conf.Init(kc, namespace, r.helmDriver, debug); err != nil {
Expand Down
Loading
Loading