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

Update Terrajet #7

Merged
merged 6 commits into from
Jul 13, 2022
Merged

Update Terrajet #7

merged 6 commits into from
Jul 13, 2022

Conversation

sboschman
Copy link
Contributor

Description of your changes

This PR upgrades to the latest Terrajet, based on the provider-jet-template repository, including a bump to go 1.18, and bumps terraform-provider-rancher2 to 1.24.0.

In its current state I am unable to get this provider generating anything to work on fixing some other open issues. I end up in panics, golang dependency hell, compile errors or partly generated resources. This is most likely my lack of golang skills in combination with my environment (golang 1.18). So I opted to start with upgrading the provider to the latest Terrajet build using the template repo.

To, hopefully, make the review less painful the process is split in a few commits.

Commit 1: Update provider-jet-template
This is the initial repo commit if you start a provider from scratch using the provider-jet-template repo and following the first steps from the docu to customise the template. Not the most relevant commit imo, as the next commit is the merge and shows the diff vs the provider-jet-rancher repo.

Commit 2: Merge remote-tracking branch
This is the commit merging the commit above into the existing provider-jet-rancher repo. The 'build' directory shows up as a lot of removed files. Reason is switching it to a git submodule, as per the template repo.

Commit 3: Bump go
Bumping go to 1.18 and pinning golang.org/x/tools to v0.1.11 (fixes a panic, see crossplane/terrajet#271) and running a go mod tidy afterwards.

Commit 4: Bump terraform-provider-rancher2
Bump to v1.24.0

Commit 5: Regenerate provider schema
Running make generate to recreate everything. All changes in this commit are the result of running make generate.

I have:

  • [ X ] Read and followed Crossplane's contribution process.
  • [ X ] Run make reviewable test to ensure this PR is ready for review.
    (yes, golangci-lint throws a 'unknown iexport format version 2' exception)

How has this code been tested

@sboschman
Copy link
Contributor Author

Hopefully you can find some time to have a look at this @ytsarev ?

@ytsarev
Copy link
Collaborator

ytsarev commented Jul 12, 2022

@sboschman sure, did you make any e2e tests after regeneration? do basic examples work?

This was referenced Jul 12, 2022
Signed-off-by: Sverre Boschman <[email protected]>
@sboschman
Copy link
Contributor Author

Does this project have any e2e tests, did not see them? As you need a Rancher instance to connect with, making e2e tests for a crossplane providers is probably not a trivial task?

See #8 en #9, (gke) cluster and namespace resources are working, so I would assume the ProviderConfig part, api client and general provider functions are working.

@ytsarev
Copy link
Collaborator

ytsarev commented Jul 12, 2022

@sboschman I meant if you managed to try to instantiate the example resources against real rancher instance in general, no need to extend pipeline with it at the moment

@sboschman
Copy link
Contributor Author

Catalog example works if you take into account that Terrajet has no knowledge of 'default' values as described in the upstream terraform provider docs. So the scope = global has to be explicitly set with crossplane:

apiVersion: rancher2.rancher.jet.crossplane.io/v1alpha1
kind: Catalog
metadata:
  name: hello-crossplane
spec:
  forProvider:
    url: https://www.k8gb.io
    scope: global

Status:

Events:
  Type    Reason                   Age   From                                                               Message
  ----    ------                   ----  ----                                                               -------
  Normal  CreatedExternalResource  64s   managed/rancher2.rancher.jet.crossplane.io/v1alpha1, kind=catalog  Successfully requested creation of external resource

Rancher api browsing to check creation:

"annotations": { },
"baseType": "catalog",
"branch": "master",
"commit": "07b46b55f4e3ac701901d52ad3f3f757",
"created": "2022-07-12T15:11:19Z",
"createdTS": 1657638679000,
"creatorId": "user-xxxxx",
"description": "",
"id": ["hello-crossplane"](https://rancher..../v3/catalogs/hello-crossplane),
"kind": "helm",
"labels": {
"cattle.io/creator": "norman"
},
"name": "hello-crossplane",
"state": "active",
"transitioning": "no",
"transitioningMessage": "",
"type": ["catalog"](https://rancher..../v3/schemas/catalog),
"url": ["https://www.k8gb.io"](https://www.k8gb.io/),
"uuid": "cbc1d853-329e-472c-805f-6fb295918100"
},

ProviderConfig works if you take into account #4

StoreConfig uses Vault, we don't use Vault, so I don't have access to any Vault stuff to test, example is from the template repo so...

Copy link
Collaborator

@ytsarev ytsarev left a comment

Choose a reason for hiding this comment

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

@sboschman that looks great, thank you so much for this contribution!

@ytsarev ytsarev merged commit 078238a into crossplane-contrib:main Jul 13, 2022
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

Successfully merging this pull request may close these issues.

2 participants