Skip to content
Open
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
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,5 @@ require (
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
)

replace github.com/crossplane/crossplane-runtime/v2 => github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lpr
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee h1:6Wp0RzkQQGKWCw89AbWHDWN/9HoF+ONUOv318FR4sQU=
github.com/ajnye/crossplane-runtime/v2 v2.2.1-0.20260429154540-465317a68bee/go.mod h1:8I+x4w5bG4x8aO8ifF/QC8GZoNCN6v21NHzgoYPNYAQ=
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/kong v0.2.16/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
Expand Down Expand Up @@ -37,8 +39,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crossplane/crossplane-runtime/v2 v2.2.0 h1:jLoQm9D5buk9lBqwRtQ40ueaFotjOljJATq+24bVYI8=
github.com/crossplane/crossplane-runtime/v2 v2.2.0/go.mod h1:8I+x4w5bG4x8aO8ifF/QC8GZoNCN6v21NHzgoYPNYAQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down
10 changes: 6 additions & 4 deletions pkg/controller/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.
case res.ASyncInProgress:
mg.SetConditions(resource.AsyncOperationOngoingCondition())
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
}, nil
case !res.Exists:
return managed.ExternalObservation{
Expand Down Expand Up @@ -474,8 +475,9 @@ func (e *external) Import(ctx context.Context, tr resource.Terraformed) (managed
if res.ASyncInProgress {
tr.SetConditions(resource.AsyncOperationOngoingCondition())
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
}, nil
}
// If the resource doesn't exist, we don't need to do anything else.
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/external_async_tfpluginfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ func (n *terraformPluginFrameworkAsyncExternalClient) Observe(ctx context.Contex
if n.opTracker.LastOperation.IsRunning() {
n.logger.WithValues("opType", n.opTracker.LastOperation.Type).Debug("ongoing async operation")
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/external_async_tfpluginsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ func (n *terraformPluginSDKAsyncExternal) Observe(ctx context.Context, mg xpreso
if n.opTracker.LastOperation.IsRunning() {
n.logger.WithValues("opType", n.opTracker.LastOperation.Type).Debug("ongoing async operation")
return managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
}, nil
}
n.opTracker.LastOperation.Clear(true)
Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/external_async_tfpluginsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,27 @@ func TestAsyncTerraformPluginSDKObserve(t *testing.T) {
},
},
},
"AsyncInProgress": {
args: args{
r: mockResource{},
cfg: cfgAsync,
obj: objAsync,
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
},
},
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
terraformPluginSDKAsyncExternal := prepareTerraformPluginSDKAsyncExternal(tc.args.r, tc.args.cfg, CallbackFns{})
if name == "AsyncInProgress" {
terraformPluginSDKAsyncExternal.opTracker.LastOperation.MarkStart("update")
}
observation, err := terraformPluginSDKAsyncExternal.Observe(context.TODO(), tc.args.obj)
if diff := cmp.Diff(tc.want.obs, observation); diff != "" {
t.Errorf("\n%s\nObserve(...): -want observation, +got observation:\n", diff)
Expand Down
10 changes: 6 additions & 4 deletions pkg/controller/external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ func TestObserve(t *testing.T) {
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
},
},
},
Expand Down Expand Up @@ -398,8 +399,9 @@ func TestObserve(t *testing.T) {
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ResourceExists: true,
ResourceUpToDate: true,
AsyncOperationInProgress: true,
},
},
},
Expand Down