crossplane-contrib / provider-jet-rancher

Apache License 2.0
3 stars 4 forks source link

Update Terrajet #7

Closed sboschman closed 2 years ago

sboschman commented 2 years ago

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 https://github.com/crossplane/terrajet/issues/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:

How has this code been tested

sboschman commented 2 years ago

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

ytsarev commented 2 years ago

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

sboschman commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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...