Skip to content

Commit

Permalink
Adopt changes to Read and Diff
Browse files Browse the repository at this point in the history
1. Return resource inputs as well as resource state from Read()
2. Return a list of properties that changed from Diff()

We implement the former by reading the last applied configuration
from the `kubectl.kubernetes.io/last-applied-configuration`
annotation in the live object state. If this key is not present, no
inputs are populated and the old inputs are retained. These changes
also update the provider to set this field during `Create` and
`Update`.

We implement the latter by scanning the JSON diff and recording the
names of the top-level properties that changed. The engine uses this
information to filter diffs to only those that are semantically
meaningful.

These changes required a couple of bugfixes:
- Old names are only adopted if the old resource was auto-named. This
  ensures that a name must be specified when importing a resource that
  was not autonamed.
- URN to GVK conversion was fixed for resources in the "core" group.
  These resources have no group part in the GVK. Parsing was also
  simplified through the use of pulumi/pulumi's token manipulation
  functions.
- When reading a resource, the GVK for the resource to read is now
  pulled from the URN if it is absent from the inputs.
  • Loading branch information
pgavlin committed Jun 24, 2019
1 parent 1853784 commit a3f8c2a
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 51 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ As such, we are rev'ing the minor version of the package from 0.16 to 0.17. Rec

### Improvements

- None
- The Kubernetes provider now supports the internal features necessary for the Pulumi engine to detect diffs between
the actual and desired state of a resource after a `pulumi refresh` (https://github.com/pulumi/pulumi-kubernetes/pull/477)

### Bug fixes

Expand Down
12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module github.com/pulumi/pulumi-kubernetes
go 1.12

require (
contrib.go.opencensus.io/exporter/ocagent v0.4.12 // indirect
github.com/Azure/go-autorest v12.0.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go v30.1.0+incompatible // indirect
github.com/Azure/go-autorest v12.1.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.2.0 // indirect
github.com/ahmetb/go-linq v3.0.0+incompatible
github.com/cbroglie/mustache v1.0.1
github.com/evanphx/json-patch v4.1.0+incompatible
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.3.1
github.com/google/gofuzz v1.0.0 // indirect
Expand All @@ -19,19 +21,23 @@ require (
github.com/mitchellh/go-wordwrap v1.0.0
github.com/pkg/errors v0.8.1
github.com/pulumi/pulumi v0.17.15
github.com/stretchr/testify v1.2.2
github.com/stretchr/testify v1.3.0
google.golang.org/grpc v1.20.1
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
k8s.io/client-go v11.0.0+incompatible
k8s.io/klog v0.3.0 // indirect
k8s.io/kube-openapi v0.0.0-20190418160015-6b3d3b2d5666
k8s.io/kubernetes v1.14.1
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
)

replace (
github.com/Nvveen/Gotty => github.com/ijc25/Gotty v0.0.0-20170406111628-a8b993ba6abd
github.com/golang/glog => github.com/pulumi/glog v0.0.0-20180820174630-7eaa6ffb71e4
github.com/grpc/grpc-go => google.golang.org/grpc v1.20.1
)

replace github.com/pulumi/pulumi => ../pulumi
Loading

0 comments on commit a3f8c2a

Please sign in to comment.