Skip to content

Commit

Permalink
Initial pass
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Oct 5, 2022
1 parent ca6687f commit dcc2746
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sdk/dotnet/Pulumi/Resources/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public class Resource
: componentOpts?.Providers;

this._providers = this._providers.AddRange(ConvertToProvidersMap(providerList));
this._providers = this._providers.AddRange(
options.Parent?._providers.Where(kv => !this._providers.ContainsKey(kv.Key)) ??
Enumerable.Empty<KeyValuePair<string, ProviderResource>>());
}

this._protect = options.Protect == true;
Expand Down
8 changes: 8 additions & 0 deletions sdk/go/pulumi/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,14 @@ func (ctx *Context) registerResource(
return err
}

if !custom && parent != nil {
for k, p := range parent.getProviders() {
if _, ok := providers[k]; !ok {
providers[k] = p
}
}
}

// Get the provider for the resource.
provider := getProvider(t, options.Provider, providers)

Expand Down
1 change: 1 addition & 0 deletions sdk/nodejs/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export abstract class Resource {
...this.__providers,
...convertToProvidersMap((<ComponentResourceOptions>opts).providers),
...convertToProvidersMap(opts.provider ? [opts.provider] : {}),
...(custom ? {} : opts.parent?.__providers),
};

// provider is the first option that does not return none
Expand Down
7 changes: 6 additions & 1 deletion sdk/python/lib/pulumi/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import copy
import warnings
from typing import (
Dict,
Optional,
List,
Any,
Expand Down Expand Up @@ -908,6 +909,10 @@ def __init__(
[pkg, _, _] = type_components

opts.provider, providers = self._get_providers(t, pkg, opts)
if custom and opts.parent is not None:
for k, v in opts.parent._providers.items():
if k not in providers:
providers[k] = v

self._protect = bool(opts.protect)
self._provider = opts.provider if custom else None
Expand Down Expand Up @@ -944,7 +949,7 @@ def __init__(

def _get_providers(
self, t: str, pkg: Optional[str], opts: ResourceOptions
) -> Tuple[Optional["ProviderResource"], Mapping[str, "ProviderResource"]]:
) -> Tuple[Optional["ProviderResource"], Dict[str, "ProviderResource"]]:
"""
Fetches the correct provider and providers for this resource.
Expand Down

0 comments on commit dcc2746

Please sign in to comment.