Compare commits

...

3 commits

Author SHA1 Message Date
evanboyle 9c4d67d50a add skipinstall flag for plugin acquisition 2021-06-01 13:45:29 -07:00
evanboyle 5664332d0a changelog 2021-05-28 09:28:07 -07:00
evanboyle be0ebf4ba7 update Registry to respect provider aliases 2021-05-28 09:22:28 -07:00
6 changed files with 70 additions and 1 deletions

View file

@ -5,6 +5,9 @@
### Bug Fixes
- [cli] - Respect provider aliases
[#7166](https://github.com/pulumi/pulumi/pull/7166)
- [cli] - Send plugin install output to stderr, so that it doesn't
clutter up --json, automation API scenarios, and so on.
[#7115](https://github.com/pulumi/pulumi/pull/7115)

View file

@ -254,6 +254,18 @@ func (r *Registry) Check(urn resource.URN, olds, news resource.PropertyMap,
return inputs, nil, nil
}
// RegisterAliases takes the computed alias map, and updates the registry such that the new URNSs
// point to the alised providers
func (r *Registry) RegisterAliases(aliases map[resource.URN]resource.URN) {
for prev, new := range aliases {
for ref, prov := range r.providers {
if ref.urn == prev {
r.setProvider(mustNewReference(new, ref.id), prov)
}
}
}
}
// Diff diffs the configuration of the indicated provider. The provider corresponding to the given URN must have
// previously been loaded by a call to Check.
func (r *Registry) Diff(urn resource.URN, id resource.ID, olds, news resource.PropertyMap,

View file

@ -317,6 +317,55 @@ func TestNewRegistryOldState(t *testing.T) {
}
}
func TestRegistryAliases(t *testing.T) {
old := newProviderState("pkgA", "a", "id1", false, nil)
olds := []*resource.State{
old,
}
loaders := []*providerLoader{
newSimpleLoader(t, "pkgA", "", nil),
}
host := newPluginHost(t, loaders)
r, err := NewRegistry(host, olds, false, nil)
assert.NoError(t, err)
assert.NotNil(t, r)
assert.Equal(t, len(olds), len(r.providers))
alias := newProviderState("pkgA", "alias", "id1", false, nil)
aliases := map[resource.URN]resource.URN{
old.URN: alias.URN,
}
r.RegisterAliases(aliases)
all := []*resource.State{
old, alias,
}
for _, old := range all {
ref, err := NewReference(old.URN, old.ID)
assert.NoError(t, err)
p, ok := r.GetProvider(ref)
assert.True(t, ok)
assert.NotNil(t, p)
assert.True(t, p.(*testProvider).configured)
assert.Equal(t, GetProviderPackage(old.Type), p.Pkg())
ver, err := GetProviderVersion(old.Inputs)
assert.NoError(t, err)
if ver != nil {
info, err := p.GetPluginInfo()
assert.NoError(t, err)
assert.True(t, info.Version.GTE(*ver))
}
}
}
func TestNewRegistryOldStateNoProviders(t *testing.T) {
olds := []*resource.State{
newProviderState("pkgA", "a", "id1", false, nil),

View file

@ -233,6 +233,9 @@ func (sg *stepGenerator) generateSteps(event RegisterResourceEvent) ([]Step, res
}
}
// register aliases with the provider registry
sg.deployment.providers.RegisterAliases(sg.aliased)
// Create the desired inputs from the goal state
inputs := goal.Properties
if hasOld {

View file

@ -374,7 +374,7 @@ func (info PluginInfo) Install(tgz io.ReadCloser) error {
if err != nil && !os.IsNotExist(err) {
return errors.Wrap(err, "loading PulumiPlugin.yaml")
}
if proj != nil {
if proj != nil && !proj.SkipInstall {
runtime := strings.ToLower(proj.Runtime.Name())
// For now, we only do this for Node.js and Python. For Go, the expectation is the binary is
// already built. For .NET, similarly, a single self-contained binary could be used, but

View file

@ -157,6 +157,8 @@ func (proj *PolicyPackProject) Save(path string) error {
type PluginProject struct {
// Runtime is a required runtime that executes code.
Runtime ProjectRuntimeInfo `json:"runtime" yaml:"runtime"`
// skips installation of runtime depenencies
SkipInstall bool `json:"skipInstall" yaml:"skipInstall"`
}
func (proj *PluginProject) Validate() error {