Skip to content

Commit

Permalink
Merge branch 'master' into iwahbe/8689/dotnet-add-PluginDownloadURL
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Jan 13, 2022
2 parents 19024c6 + 48012b5 commit f37297f
Show file tree
Hide file tree
Showing 13 changed files with 705 additions and 53 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ jobs:
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: Convert Node coverage data
if: ${{ matrix.platform != 'windows-latest' }}
run: |
cd sdk/nodejs
if [ -e .nyc_output ]; then yarn run nyc report -r cobertura --report-dir $PULUMI_TEST_COVERAGE_PATH; fi
- name: Merge Go coverage data
if: ${{ inputs.enable-coverage && (matrix.platform != 'windows-latest') }}
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ jobs:
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: Convert Node coverage data
if: ${{ matrix.platform != 'windows-latest' }}
run: |
cd sdk/nodejs
if [ -e .nyc_output ]; then yarn run nyc report -r cobertura --report-dir $PULUMI_TEST_COVERAGE_PATH; fi
- name: Merge Go coverage data
if: ${{ inputs.enable-coverage && (matrix.platform != 'windows-latest') }}
run: |
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
CHANGELOG
=========

## 3.22.0 (2022-01-12)

### Improvements

- [sdk/{nodejs,go,python}] - 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)

### 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)


## 3.21.1 (2022-01-07)

### Improvements
Expand Down
11 changes: 2 additions & 9 deletions CHANGELOG_PENDING.md
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)
153 changes: 153 additions & 0 deletions pkg/engine/lifeycletest/analyzer_test.go
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)
}

0 comments on commit f37297f

Please sign in to comment.