Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't panic when passed an Asset or an Archive #751

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Remove undocumented kubectl replace invoke method. (https://github.com/pulumi/pulumi-kubernetes/pull/738).
- Don't populate `.status` in input types (https://github.com/pulumi/pulumi-kubernetes/pull/635).
- Allow a user to pass CustomTimeouts as part of ResourceOptions (fixes https://github.com/pulumi/pulumi-kubernetes/issues/672)
- Don't panic when an Asset or an Archive are passed into a resource definition (https://github.com/pulumi/pulumi-kubernetes/pull/751).

### Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/json-iterator/go v1.1.6 // indirect
github.com/mitchellh/go-wordwrap v1.0.0
github.com/pkg/errors v0.8.1
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190824005806-5188232afad4
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190826221914-99d70e4610d2
github.com/stretchr/testify v1.3.0
google.golang.org/grpc v1.20.1
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190824005806-5188232afad4 h1:rlLlWLCZUsGvjosGPrFVFeQrm8KYr7G+KLFIa1/aIMY=
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190824005806-5188232afad4/go.mod h1:eSrIzt/kTqyrir8kE4KnCPYbxJm1ChSg1DD7lkBw0mA=
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190826221914-99d70e4610d2 h1:7vMIliNeAaCWLhTxg5G02Fc4l1XIHL1sXftzXu/ZxHo=
github.com/pulumi/pulumi v1.0.0-beta.4.0.20190826221914-99d70e4610d2/go.mod h1:eSrIzt/kTqyrir8kE4KnCPYbxJm1ChSg1DD7lkBw0mA=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/reconquest/loreley v0.0.0-20160708080500-2ab6b7470a54 h1:J2RvHxEMIzMV6XbaZIj9s5G4lG3hhqWxS7Cl1Jii44c=
github.com/reconquest/loreley v0.0.0-20160708080500-2ab6b7470a54/go.mod h1:1NF/j951kWm+ZnRXpOkBqweImgwhlzFVwTA4A0V7TEU=
Expand Down
31 changes: 22 additions & 9 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ func (k *kubeProvider) DiffConfig(ctx context.Context, req *pulumirpc.DiffReques
Label: fmt.Sprintf("%s.news", label),
KeepUnknowns: true,
SkipNulls: true,
RejectAssets: true,
})
if err != nil {
return nil, err
return nil, pkgerrors.Wrapf(err, "diffconfig failed because malformed resource inputs")
}

// We can't tell for sure if a computed value has changed, so we make the conservative choice
Expand Down Expand Up @@ -355,10 +356,13 @@ func (k *kubeProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (
// an update.
newResInputs := req.GetNews()
news, err := plugin.UnmarshalProperties(newResInputs, plugin.MarshalOptions{
Label: fmt.Sprintf("%s.news", label), KeepUnknowns: true, SkipNulls: true,
Label: fmt.Sprintf("%s.news", label),
KeepUnknowns: true,
SkipNulls: true,
RejectAssets: true,
})
if err != nil {
return nil, err
return nil, pkgerrors.Wrapf(err, "check failed because malformed resource inputs")
}
newInputs := propMapToUnstructured(news)

Expand Down Expand Up @@ -512,10 +516,13 @@ func (k *kubeProvider) Diff(

// Get new resource inputs. The user is submitting these as an update.
newResInputs, err := plugin.UnmarshalProperties(req.GetNews(), plugin.MarshalOptions{
Label: fmt.Sprintf("%s.news", label), KeepUnknowns: true, SkipNulls: true,
Label: fmt.Sprintf("%s.news", label),
KeepUnknowns: true,
SkipNulls: true,
RejectAssets: true,
})
if err != nil {
return nil, err
return nil, pkgerrors.Wrapf(err, "diff failed because malformed resource inputs")
}
newInputs := propMapToUnstructured(newResInputs)

Expand Down Expand Up @@ -688,10 +695,13 @@ func (k *kubeProvider) Create(

// Parse inputs
newResInputs, err := plugin.UnmarshalProperties(req.GetProperties(), plugin.MarshalOptions{
Label: fmt.Sprintf("%s.properties", label), KeepUnknowns: true, SkipNulls: true,
Label: fmt.Sprintf("%s.properties", label),
KeepUnknowns: true,
SkipNulls: true,
RejectAssets: true,
})
if err != nil {
return nil, err
return nil, pkgerrors.Wrapf(err, "create failed because malformed resource inputs")
}
newInputs := propMapToUnstructured(newResInputs)

Expand Down Expand Up @@ -988,10 +998,13 @@ func (k *kubeProvider) Update(

// Obtain new properties, create a Kubernetes `unstructured.Unstructured`.
newResInputs, err := plugin.UnmarshalProperties(req.GetNews(), plugin.MarshalOptions{
Label: fmt.Sprintf("%s.news", label), KeepUnknowns: true, SkipNulls: true,
Label: fmt.Sprintf("%s.news", label),
KeepUnknowns: true,
SkipNulls: true,
RejectAssets: true,
})
if err != nil {
return nil, err
return nil, pkgerrors.Wrapf(err, "update failed because malformed resource inputs")
}
newInputs := propMapToUnstructured(newResInputs)

Expand Down