Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add initial implementation for common controller and tfstate parsing&conversion #2

Closed
wants to merge 2 commits into from

Conversation

turkenh
Copy link
Member

@turkenh turkenh commented Aug 10, 2021

This PR adds an initial implementation (subject to change) for Terraform common controller interacting with the Scheduler interface.

It also adds support parse tfstate and primitives to do conversions.

I'll open a follow-up pr using this common controller in https://github.com/crossplane-contrib/provider-tf-aws repo.

Signed-off-by: Hasan Turken <turkenh@gmail.com>
@turkenh turkenh force-pushed the skeleton-common-controller branch from 17c1f04 to f0f6457 Compare August 10, 2021 14:16
Signed-off-by: Hasan Turken <turkenh@gmail.com>
(cherry picked from commit c416e6f9837010c29cc1506b93cee374c47e5bf9)
@turkenh turkenh changed the title Add initial implementation for common controller Add initial implementation for common controller and tfstate parsing&conversion Aug 12, 2021
)

const (
errUnexpectedObject = "The managed resource is not an Terraformed resource"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (e *TerraformExternal) Create(ctx context.Context, mg xpresource.Managed) (managed.ExternalCreation, error) {
u, err := e.Update(ctx, mg)
return managed.ExternalCreation{
ExternalNameAssigned: meta.GetExternalName(mg) != "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this external name always be assigned by Terraform at first? The intention of this field is that it should only be true if the external name was assigned somewhere inside of the Create call.

Comment on lines +123 to +126
if dr.Completed {
return nil
}
return errors.Errorf("still deleting")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? Do we need to wait? 🤔

ar, err := e.executor.Apply(ctx, tr)
if err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "failed to apply")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to wait for ar.Completed?

)

const (
AnnotationKeyStateMeta = "tf.crossplane.io/state-meta"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file excluded from linting? It seems like it would fail due to missing commentary.

@turkenh turkenh marked this pull request as draft August 13, 2021 07:59
@turkenh
Copy link
Member Author

turkenh commented Aug 13, 2021

Thanks @negz for the review but this PR is intended to be a draft (just converted) to sync on a high-level structure.
I'll apply your comments for the actual PR if applicable.

@turkenh
Copy link
Member Author

turkenh commented Aug 16, 2021

Closing in favor of #14

@turkenh turkenh closed this Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants