Skip to content

Commit

Permalink
Revert "Put all resources in specified provider namespace (#506)" (#522)
Browse files Browse the repository at this point in the history
This reverts commit 5204b3b.
  • Loading branch information
lblackstone committed Apr 5, 2019
1 parent 1e7b1da commit 69b92fa
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 212 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

- Move helm module into a directory (https://github.com/pulumi/pulumi-kubernetes/pull/512)
- Move yaml module into a directory (https://github.com/pulumi/pulumi-kubernetes/pull/513)
- Put all resources in specified provider namespace (https://github.com/pulumi/pulumi-kubernetes/pull/506)

### Bug fixes

Expand Down
13 changes: 4 additions & 9 deletions pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (dcs *DynamicClientSet) ResourceClient(gvk schema.GroupVersionKind, namespa
}

// For namespaced Kinds, create a namespaced client. If no namespace is provided, use the "default" namespace.
namespaced, err := dcs.NamespacedKind(gvk)
namespaced, err := dcs.namespaced(gvk)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -132,15 +132,10 @@ func (dcs *DynamicClientSet) gvkForKind(kind kinds.Kind) (*schema.GroupVersionKi
return nil, fmt.Errorf("failed to find gvk for Kind: %q", kind)
}

func (dcs *DynamicClientSet) NamespacedKind(gvk schema.GroupVersionKind) (bool, error) {
gv := gvk.GroupVersion().String()
if strings.Contains(gv, "core/v1") {
gv = "v1"
}

resourceList, err := dcs.DiscoveryClientCached.ServerResourcesForGroupVersion(gv)
func (dcs *DynamicClientSet) namespaced(gvk schema.GroupVersionKind) (bool, error) {
resourceList, err := dcs.DiscoveryClientCached.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
if err != nil {
return false, fmt.Errorf("failed to find server resources for GV: %q - %v", gv, err)
return false, err
}

for _, resource := range resourceList.APIResources {
Expand Down
28 changes: 6 additions & 22 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ type kubeOpts struct {
}

type kubeProvider struct {
host *provider.HostClient
canceler *cancellationContext
name string
version string
providerPrefix string
opts kubeOpts
overrideNamespace string
host *provider.HostClient
canceler *cancellationContext
name string
version string
providerPrefix string
opts kubeOpts

clientSet *clients.DynamicClientSet
}
Expand Down Expand Up @@ -139,10 +138,6 @@ func (k *kubeProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
CurrentContext: vars["kubernetes:config:context"],
}

if overrides.Context.Namespace != "" {
k.overrideNamespace = overrides.Context.Namespace
}

var kubeconfig clientcmd.ClientConfig
if configJSON, ok := vars["kubernetes:config:kubeconfig"]; ok {
config, err := clientcmd.Load([]byte(configJSON))
Expand Down Expand Up @@ -277,17 +272,6 @@ func (k *kubeProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (
return nil, err
}

if k.overrideNamespace != "" {
namespacedKind, err := k.clientSet.NamespacedKind(gvk)
if err != nil {
return nil, err
}

if namespacedKind {
newInputs.SetNamespace(k.overrideNamespace)
}
}

// HACK: Do not validate against OpenAPI spec if there is a computed value. The OpenAPI spec
// does not know how to deal with the placeholder values for computed values.
if !hasComputedValue(newInputs) {
Expand Down
81 changes: 0 additions & 81 deletions tests/integration/provider/provider_test.go

This file was deleted.

3 changes: 0 additions & 3 deletions tests/integration/provider/step1/Pulumi.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions tests/integration/provider/step1/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions tests/integration/provider/step1/package.json

This file was deleted.

22 changes: 0 additions & 22 deletions tests/integration/provider/step1/tsconfig.json

This file was deleted.

0 comments on commit 69b92fa

Please sign in to comment.