-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into iwahbe/8689/dotnet-add-PluginDownloadURL
- Loading branch information
Showing
13 changed files
with
705 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
### Improvements | ||
|
||
- [sdk/all] - Add `PluginDownloadURL` as a resource option. When provided by | ||
- [sdk/dotnet] - Add `PluginDownloadURL` as a resource option. When provided by | ||
the schema, `PluginDownloadURL` will be baked into `new Resource` and `Invoke` | ||
requests in generated SDKs. | ||
[#8698](https://github.com/pulumi/pulumi/pull/8698) | ||
[#8690](https://github.com/pulumi/pulumi/pull/8690) | ||
[#8692](https://github.com/pulumi/pulumi/pull/8692) | ||
[#8702](https://github.com/pulumi/pulumi/pull/8702) | ||
[#8739](https://github.com/pulumi/pulumi/pull/8739) | ||
|
||
### Bug Fixes | ||
|
||
- [auto/python] - Fixes an issue with exception isolation in a | ||
sequence of inline programs that caused all inline programs to fail | ||
after the first one failed | ||
[#8693](https://github.com/pulumi/pulumi/pull/#8693) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package lifecycletest | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/blang/semver" | ||
. "github.com/pulumi/pulumi/pkg/v3/engine" | ||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest" | ||
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype" | ||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type testRequiredPolicy struct { | ||
name string | ||
version string | ||
config map[string]*json.RawMessage | ||
} | ||
|
||
func (p *testRequiredPolicy) Name() string { | ||
return p.name | ||
} | ||
|
||
func (p *testRequiredPolicy) Version() string { | ||
return p.version | ||
} | ||
|
||
func (p *testRequiredPolicy) Install(_ context.Context) (string, error) { | ||
return "", nil | ||
} | ||
|
||
func (p *testRequiredPolicy) Config() map[string]*json.RawMessage { | ||
return p.config | ||
} | ||
|
||
func NewRequiredPolicy(name, version string, config map[string]*json.RawMessage) RequiredPolicy { | ||
return &testRequiredPolicy{ | ||
name: name, | ||
version: version, | ||
config: config, | ||
} | ||
} | ||
|
||
func TestSimpleAnalyzer(t *testing.T) { | ||
loaders := []*deploytest.PluginLoader{ | ||
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) { | ||
return &deploytest.Provider{}, nil | ||
}), | ||
deploytest.NewAnalyzerLoader("analyzerA", func(_ *plugin.PolicyAnalyzerOptions) (plugin.Analyzer, error) { | ||
return &deploytest.Analyzer{}, nil | ||
}), | ||
} | ||
|
||
program := deploytest.NewLanguageRuntime(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error { | ||
_, _, _, err := monitor.RegisterResource("pkgA:m:typA", "resA", true) | ||
assert.NoError(t, err) | ||
return nil | ||
}) | ||
host := deploytest.NewPluginHost(nil, nil, program, loaders...) | ||
|
||
p := &TestPlan{ | ||
Options: UpdateOptions{ | ||
RequiredPolicies: []RequiredPolicy{NewRequiredPolicy("analyzerA", "", nil)}, | ||
Host: host, | ||
}, | ||
} | ||
|
||
project := p.GetProject() | ||
_, res := TestOp(Update).Run(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil) | ||
assert.Nil(t, res) | ||
} | ||
|
||
func TestSimpleAnalyzeResourceFailure(t *testing.T) { | ||
loaders := []*deploytest.PluginLoader{ | ||
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) { | ||
return &deploytest.Provider{}, nil | ||
}), | ||
deploytest.NewAnalyzerLoader("analyzerA", func(_ *plugin.PolicyAnalyzerOptions) (plugin.Analyzer, error) { | ||
return &deploytest.Analyzer{ | ||
AnalyzeF: func(r plugin.AnalyzerResource) ([]plugin.AnalyzeDiagnostic, error) { | ||
return []plugin.AnalyzeDiagnostic{{ | ||
PolicyName: "always-fails", | ||
PolicyPackName: "analyzerA", | ||
Description: "a policy that always fails", | ||
Message: "a policy failed", | ||
EnforcementLevel: apitype.Mandatory, | ||
URN: r.URN, | ||
}}, nil | ||
}, | ||
}, nil | ||
}), | ||
} | ||
|
||
program := deploytest.NewLanguageRuntime(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error { | ||
_, _, _, err := monitor.RegisterResource("pkgA:m:typA", "resA", true) | ||
assert.Error(t, err) | ||
return nil | ||
}) | ||
host := deploytest.NewPluginHost(nil, nil, program, loaders...) | ||
|
||
p := &TestPlan{ | ||
Options: UpdateOptions{ | ||
RequiredPolicies: []RequiredPolicy{NewRequiredPolicy("analyzerA", "", nil)}, | ||
Host: host, | ||
}, | ||
} | ||
|
||
project := p.GetProject() | ||
_, res := TestOp(Update).Run(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil) | ||
assert.NotNil(t, res) | ||
} | ||
|
||
func TestSimpleAnalyzeStackFailure(t *testing.T) { | ||
loaders := []*deploytest.PluginLoader{ | ||
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) { | ||
return &deploytest.Provider{}, nil | ||
}), | ||
deploytest.NewAnalyzerLoader("analyzerA", func(_ *plugin.PolicyAnalyzerOptions) (plugin.Analyzer, error) { | ||
return &deploytest.Analyzer{ | ||
AnalyzeStackF: func(rs []plugin.AnalyzerStackResource) ([]plugin.AnalyzeDiagnostic, error) { | ||
return []plugin.AnalyzeDiagnostic{{ | ||
PolicyName: "always-fails", | ||
PolicyPackName: "analyzerA", | ||
Description: "a policy that always fails", | ||
Message: "a policy failed", | ||
EnforcementLevel: apitype.Mandatory, | ||
URN: rs[0].URN, | ||
}}, nil | ||
}, | ||
}, nil | ||
}), | ||
} | ||
|
||
program := deploytest.NewLanguageRuntime(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error { | ||
_, _, _, err := monitor.RegisterResource("pkgA:m:typA", "resA", true) | ||
assert.NoError(t, err) | ||
return nil | ||
}) | ||
host := deploytest.NewPluginHost(nil, nil, program, loaders...) | ||
|
||
p := &TestPlan{ | ||
Options: UpdateOptions{ | ||
RequiredPolicies: []RequiredPolicy{NewRequiredPolicy("analyzerA", "", nil)}, | ||
Host: host, | ||
}, | ||
} | ||
|
||
project := p.GetProject() | ||
_, res := TestOp(Update).Run(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil) | ||
assert.NotNil(t, res) | ||
} |
Oops, something went wrong.