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

Customizable late initialization function for a resource #963

Closed
sboschman opened this issue Jul 27, 2022 · 1 comment
Closed

Customizable late initialization function for a resource #963

sboschman opened this issue Jul 27, 2022 · 1 comment

Comments

@sboschman
Copy link
Contributor

sboschman commented Jul 27, 2022

Currently late initialization is configured with

r.LateInitializer = config.LateInitializer{
  IgnoredFields: []string{"address_prefix"},
}

As the generation template defaults to using the GenericLateInitializer I don't see a way to have a custom late init function for a specific resource.

A configurable custom late init function per resource would be helpful to solve an issue I believe.
This custom function should be able to handle the following use cases:

  1. Have access to the forProvider fields to use as decision input which parameters from the terraform state to ignore
  2. Use a wildcard glob or regex to match terraform state parameters to exclude

Scenario 1:

forProvider:
  gkeConfigV2:
    - imported: true

This imported=true use case requires only a specific few attributes to be set, the terraform state on the other hand returns more computed attributes. These computed attributes should be ignored during a tf plan/apply, otherwise they conflict with the imported=true attribute.

Scenario 2:

forProvider:
  annotations:
    example.com/crossplane: hello
  gkeConfigV2:
    - imported: true

Terraform state return additional annotations and labels, but these are externally managed (imported=true). These labels/annotations should be excluded from tf plan/apply and resource drift detection. Crossplane should not be trying to 'revert' the values of these labels/annotations to the value it got after the create/initial apply.

For example, Rancher adds annotations for its own internal housekeeping with a timestamp value:

clusters.management.cattle.io/ke-last-refresh: "1658949309"

When Rancher refreshes, and updates the value of this annotation, Crossplane triggers resource drift and tries to revert the value, which is obviously not what should be happening.

@sboschman
Copy link
Contributor Author

sboschman commented Jul 28, 2022

My apologies, wrong repository, this is a Crossplane Terrajet issue (286)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant