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
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
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/new_resource_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Help us for prioritization of the resource support by giving more details about
why you need it.
-->

### Would you be willing to contribute it using [Terrajet](https://github.com/crossplane-contrib/terrajet)?
### Would you be willing to contribute it using [Terrajet](https://github.com/crossplane/terrajet)?

<!--
Please take a look at code generator instructions to see whether you'd like to
contribute the missing parts where Terrajet cannot automate. See
https://github.com/crossplane-contrib/terrajet#readme
https://github.com/crossplane/terrajet#readme
-->
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
# Common versions
GO_VERSION: '1.16'
GO_VERSION: '1.18'
GOLANGCI_VERSION: 'v1.31'
DOCKER_BUILDX_VERSION: 'v0.4.2'

Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
# prefer this action because it leaves 'annotations' (i.e. it comments
# on PRs to point out linter violations).
- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_VERSION }}
skip-go-installation: true
Expand Down Expand Up @@ -295,28 +295,28 @@ jobs:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v2
with:
name: output
path: _output/**

- name: Login to Docker
uses: docker/login-action@v1
if: env.DOCKER_USR != ''
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PSW }}

- name: Publish Artifacts to S3 and Docker Hub
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.AWS_USR != '' && env.DOCKER_USR != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Promote Artifacts in S3 and Docker Hub
if: github.ref == 'refs/heads/main' && env.AWS_USR != '' && env.DOCKER_USR != ''
run: make -j2 promote
Expand All @@ -325,3 +325,4 @@ jobs:
CHANNEL: main
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}

44 changes: 33 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
PROJECT_NAME := provider-jet-rancher
PROJECT_REPO := github.com/crossplane-contrib/$(PROJECT_NAME)

export TERRAFORM_VERSION := 1.0.11
export TERRAFORM_VERSION := 1.1.6

export TERRAFORM_PROVIDER_SOURCE := rancher/rancher2
export TERRAFORM_PROVIDER_VERSION := 1.22.2
export TERRAFORM_PROVIDER_VERSION := 1.24.0
export TERRAFORM_PROVIDER_DOWNLOAD_NAME := terraform-provider-rancher2
export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX := https://github.com/rancher/terraform-provider-rancher2/releases/download/v$(TERRAFORM_PROVIDER_VERSION)

Expand Down Expand Up @@ -54,7 +55,7 @@ IMAGES = provider-jet-rancher provider-jet-rancher-controller
-include build/makelib/image.mk

# ====================================================================================
# Targets
# Fallthrough

# run `make help` to see the targets and options

Expand All @@ -67,6 +68,35 @@ fallthrough: submodules
@echo Initial setup complete. Running make again . . .
@make

# ====================================================================================
# Setup Terraform for fetching provider schema
TERRAFORM := $(TOOLS_HOST_DIR)/terraform-$(TERRAFORM_VERSION)
TERRAFORM_WORKDIR := $(WORK_DIR)/terraform
TERRAFORM_PROVIDER_SCHEMA := config/schema.json

$(TERRAFORM):
@$(INFO) installing terraform $(HOSTOS)-$(HOSTARCH)
@mkdir -p $(TOOLS_HOST_DIR)/tmp-terraform
@curl -fsSL https://releases.hashicorp.com/terraform/$(TERRAFORM_VERSION)/terraform_$(TERRAFORM_VERSION)_$(SAFEHOST_PLATFORM).zip -o $(TOOLS_HOST_DIR)/tmp-terraform/terraform.zip
@unzip $(TOOLS_HOST_DIR)/tmp-terraform/terraform.zip -d $(TOOLS_HOST_DIR)/tmp-terraform
@mv $(TOOLS_HOST_DIR)/tmp-terraform/terraform $(TERRAFORM)
@rm -fr $(TOOLS_HOST_DIR)/tmp-terraform
@$(OK) installing terraform $(HOSTOS)-$(HOSTARCH)

$(TERRAFORM_PROVIDER_SCHEMA): $(TERRAFORM)
@$(INFO) generating provider schema for $(TERRAFORM_PROVIDER_SOURCE) $(TERRAFORM_PROVIDER_VERSION)
@mkdir -p $(TERRAFORM_WORKDIR)
@echo '{"terraform":[{"required_providers":[{"provider":{"source":"'"$(TERRAFORM_PROVIDER_SOURCE)"'","version":"'"$(TERRAFORM_PROVIDER_VERSION)"'"}}],"required_version":"'"$(TERRAFORM_VERSION)"'"}]}' > $(TERRAFORM_WORKDIR)/main.tf.json
@$(TERRAFORM) -chdir=$(TERRAFORM_WORKDIR) init > $(TERRAFORM_WORKDIR)/terraform-logs.txt 2>&1
@$(TERRAFORM) -chdir=$(TERRAFORM_WORKDIR) providers schema -json=true > $(TERRAFORM_PROVIDER_SCHEMA) 2>> $(TERRAFORM_WORKDIR)/terraform-logs.txt
@$(OK) generating provider schema for $(TERRAFORM_PROVIDER_SOURCE) $(TERRAFORM_PROVIDER_VERSION)

generate.init: $(TERRAFORM_PROVIDER_SCHEMA)

.PHONY: $(TERRAFORM_PROVIDER_SCHEMA)
# ====================================================================================
# Targets

# NOTE: the build submodule currently overrides XDG_CACHE_HOME in order to
# force the Helm 3 to use the .work/helm directory. This causes Go on Linux
# machines to use that directory as the build cache as well. We should adjust
Expand All @@ -83,14 +113,6 @@ cobertura:
grep -v zz_ | \
$(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml

crds.clean:
@$(INFO) cleaning generated CRDs
@find package/crds -name '*.yaml' -exec sed -i.sed -e '1,2d' {} \; || $(FAIL)
@find package/crds -name '*.yaml.sed' -delete || $(FAIL)
@$(OK) cleaned generated CRDs

generate.done: crds.clean

# Update the submodules, such as the common build scripts.
submodules:
@git submodule sync
Expand Down
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Terrajet Rancher Provider

`provider-jet-rancher` is a [Crossplane](https://crossplane.io/) provider that
is built using [Terrajet](https://github.com/crossplane-contrib/terrajet) code
generation tools and exposes XRM-conformant managed resources for the
is built using [Terrajet](https://github.com/crossplane/terrajet) code
generation tools and exposes XRM-conformant managed resources for the
Rancher API.

## Getting Started
Expand All @@ -13,13 +13,26 @@ to the [latest release](https://github.com/crossplane-contrib/provider-jet-ranch
kubectl crossplane install provider crossplane/provider-jet-rancher:v0.1.0
```

Alternatively, you can use declarative installation:
```
kubectl apply -f examples/install.yaml
```

Notice that in this example Provider resource is referencing ControllerConfig with debug enabled.

You can see the API reference [here](https://doc.crds.dev/github.com/crossplane-contrib/provider-jet-rancher).

## Developing

Run code-generation pipeline:
Clone this repository and cd into the repository directory. Fetch the upbound/build submodule by running the following:

```console
go run cmd/generator/main.go
make submodules
```

Run code-generation pipeline:
```
make generate
```

Run against a Kubernetes cluster:
Expand All @@ -34,18 +47,6 @@ Build, push, and install:
make all
```

Build image:

```console
make image
```

Push image:

```console
make push
```

Build binary:

```console
Expand Down
25 changes: 21 additions & 4 deletions apis/app/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions apis/app/v1alpha1/zz_generated.managed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apis/app/v1alpha1/zz_v2_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 0 additions & 100 deletions apis/auth/v1alpha1/zz_configactivedirectory_terraformed.go

This file was deleted.

Loading