Skip to content

Commit

Permalink
fix: upgrade UpJet and bump TF provider to v0.19.2 (#17)
Browse files Browse the repository at this point in the history
* fix: always init controller-runtime logger

Signed-off-by: Tyler Gillson <[email protected]>

* chore: upgrade upjet

Signed-off-by: Tyler Gillson <[email protected]>

* docs: fix README

Signed-off-by: Tyler Gillson <[email protected]>

* chore: regenerate provider

Signed-off-by: Tyler Gillson <[email protected]>

* docs: add launch config

Signed-off-by: Tyler Gillson <[email protected]>

* docs: update release version in README

Signed-off-by: Tyler Gillson <[email protected]>

* fix: default external names to tfstate[name]

Signed-off-by: Tyler Gillson <[email protected]>

* docs: update README

Signed-off-by: Tyler Gillson <[email protected]>

* docs: update setup guide in README

Signed-off-by: Tyler Gillson <[email protected]>

* chore: bump TF provider to v0.19.2

Signed-off-by: Tyler Gillson <[email protected]>

---------

Signed-off-by: Tyler Gillson <[email protected]>
  • Loading branch information
TylerGillson authored May 8, 2024
1 parent c6df8c1 commit da925a5
Show file tree
Hide file tree
Showing 240 changed files with 7,554 additions and 3,788 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ cover.out

# ignore IDE folders
.vscode/
!.vscode/launch.json
.idea/
*__debug_bin*
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/provider/main.go",
"args": [
"--debug",
"--terraform-version=1.3.3",
"--terraform-provider-version=0.19.2",
"--terraform-provider-source=spectrocloud/spectrocloud"
],
"env": {
"KUBECONFIG": "/Users/tylergillson/Downloads/oam-dev.kubeconfig",
// "TF_REATTACH_PROVIDERS": "{\"registry.terraform.io/spectrocloud/spectrocloud\":{\"Protocol\":\"grpc\",\"ProtocolVersion\":5,\"Pid\":100,\"Test\":true,\"Addr\":{\"Network\":\"unix\",\"String\":\"/var/folders/w1/sm7f2fb959j2xkxln196ksj40000gn/T/plugin2559404211\"}}}",
"UPBOUND_CONTEXT": "local"
},
// "showLog": true,
// "trace": "verbose",
}
]
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ PROJECT_NAME := provider-palette
PROJECT_REPO := github.com/crossplane-contrib/$(PROJECT_NAME)

export TERRAFORM_VERSION := 1.3.3

export TERRAFORM_PROVIDER_SOURCE := spectrocloud/spectrocloud
export TERRAFORM_PROVIDER_REPO := https://github.com/spectrocloud/terraform-provider-spectrocloud
export TERRAFORM_PROVIDER_VERSION := 0.18.0
export TERRAFORM_PROVIDER_VERSION := 0.19.2
export TERRAFORM_PROVIDER_DOWNLOAD_NAME := terraform-provider-spectrocloud
export TERRAFORM_NATIVE_PROVIDER_BINARY := terraform-provider-spectrocloud_$(TERRAFORM_PROVIDER_VERSION)
export TERRAFORM_DOCS_PATH := docs/resources
Expand Down Expand Up @@ -110,6 +109,7 @@ $(TERRAFORM):

$(TERRAFORM_PROVIDER_SCHEMA): $(TERRAFORM)
@$(INFO) generating provider schema for $(TERRAFORM_PROVIDER_SOURCE) $(TERRAFORM_PROVIDER_VERSION)
@rm -rf $(TERRAFORM_WORKDIR)
@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
Expand Down
153 changes: 98 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,119 @@
# Provider Palette

`provider-palette` is a [Crossplane](https://crossplane.io/) provider that is
built using [Upjet](https://github.com/crossplane/upjet) code generation tools and
exposes XRM-conformant managed resources for the Palette API. The provider helps
you create resources declaratively using the Spectro Cloud Palette API.

For more information on the Spectro Cloud Palette API, visit:
https://docs.spectrocloud.com/api/
`provider-palette` is a [Crossplane](https://crossplane.io/) provider built using [Upjet](https://github.com/crossplane/upjet) code generation tools. It exposes XRM-conformant managed resources for the [Palette API](https://docs.spectrocloud.com/api/). `provider-palette`, manages Palette resources declaratively using the [Spectro Cloud Palette Terraform provider](https://github.com/spectrocloud/terraform-provider-spectrocloud).

## Getting Started

Install the provider by using the following command after changing the image tag
to the [latest
release](https://marketplace.upbound.io/providers/crossplane-contrib/provider-palette):
```
up ctp provider install crossplane-contrib/provider-palette:v0.1.0
```

Alternatively, you can use declarative installation:
```
cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-palette
spec:
package: crossplane-contrib/provider-palette:v0.1.0
EOF
```

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-palette).
### Prerequisites
- A kubernetes cluster with crossplane pre-installed OR install [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
- Install [helm](https://helm.sh/docs/intro/install/)
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/)
- Install [up](https://docs.upbound.io/reference/cli/) (optional)

### Instructions

1. If you have access to a kubernetes cluster with crossplane pre-installed, ensure that your `KUBECONFIG` is properly configured. Otherwise, deploy a kind cluster locally, then follow the [crossplane installation instructions](https://docs.crossplane.io/latest/software/install/).

2. Create a secret containing your Palette credentials:
```
export PALETTE_API_KEY="" # Edit me
export PALETTE_PROJECT_NAME=Default
export PALETTE_HOST=api.spectrocloud.com
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: palette-creds
namespace: crossplane-system
type: Opaque
stringData:
credentials: |
{
"api_key": "$PALETTE_API_KEY",
"project_name": "$PALETTE_PROJECT_NAME",
"host": "$PALETTE_HOST"
}
EOF
```

3. Install `provider-palette` using the following command:
```
up ctp provider install crossplane-contrib/provider-palette:v0.19.2
```

Alternatively, you may install by creating a `Provider` resource:
```
cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-palette
spec:
package: crossplane-contrib/provider-palette:v0.19.2
EOF
```
> [!IMPORTANT]
> Ensure the image tag you use matches the [latest release](https://marketplace.upbound.io/providers/crossplane-contrib/provider-palette)
4. Create a ProviderConfig to authenticate the Provider:
```
cat <<EOF | kubectl apply -f -
apiVersion: palette.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: provider-palette-config
spec:
credentials:
source: Secret
secretRef:
name: palette-creds
namespace: crossplane-system
key: credentials
EOF
```

5. Refer to the [examples](./examples/), [examples-generated](./examples-generated/), and [API reference](https://doc.crds.dev/github.com/crossplane-contrib/provider-palette) to learn how to start creating Palette resources.

## Developing

Before getting started, you should read the [Upjet docs](https://github.com/crossplane/upjet/tree/main/docs). At a minimum, read about [generating a provider](https://github.com/crossplane/upjet/blob/main/docs/generating-a-provider.md).

Generate/regenerate the provider:
### Generate/regenerate `provider-palette`
```console
# Install dependencies
go install golang.org/x/tools/cmd/goimports@latest

make submodules
# Prepare repo for generation
make submodules vendor vendor.check

# Generate provider-palette. To upgrade, you must first edit TERRAFORM_PROVIDER_VERSION in the Makefile.
make generate
```

Run code-generation pipeline:
```console
go run cmd/generator/main.go "$PWD"
```

Run against a Kubernetes cluster:

```console
make run
```

Build, push, and install:

```console
make all
```

Build binary:

```console
make build
```
### Misc. development actions
- Run `provider-palette` in debug mode against a Kubernetes cluster:
```
make run
```
- Build, push, and install:
```
make all
```
- Build xpkgs:
```
make -j2 build
```

### Debug with VSCode
1. Install CRDs
```console
kubectl apply -f package/crds/
```
2. Edit the `Debug` configuration in `.vscode/launch.json`:
- Ensure `env.KUBECONFIG` is correct
- Optionally specify `env.TF_REATTACH_PROVIDERS` to hook into your dev Terraform provider
3. Execute the `Debug` launch configuration

## Report a Bug

Expand Down

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

9 changes: 3 additions & 6 deletions apis/addon/v1alpha1/zz_deployment_types.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/addon/v1alpha1/zz_generated.conversion_hubs.go

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

4 changes: 0 additions & 4 deletions apis/addon/v1alpha1/zz_groupversion_info.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/application/v1alpha1/zz_generated.conversion_hubs.go

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

4 changes: 0 additions & 4 deletions apis/application/v1alpha1/zz_groupversion_info.go

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

Loading

0 comments on commit da925a5

Please sign in to comment.