Skip to content

Commit

Permalink
Merge pull request #3 from upbound/bootstrap
Browse files Browse the repository at this point in the history
Bootstrap
  • Loading branch information
humoflife authored Mar 5, 2024
2 parents 411f495 + 490aeb4 commit b18eefa
Show file tree
Hide file tree
Showing 540 changed files with 199,431 additions and 756 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ on:
# See also commands.yml for the /backport triggered variant of this workflow.

jobs:
backport:
uses: upbound/uptest/.github/workflows/provider-backport.yml@main
- backport:
- uses: upbound/uptest/.github/workflows/provider-backport.yml@main
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ on:

env:
# Common versions
GO_VERSION: '1.19'
GOLANGCI_VERSION: 'v1.50.0'
DOCKER_BUILDX_VERSION: 'v0.8.2'
GO_VERSION: '1.21.2'
GOLANGCI_VERSION: 'v1.54.2'
DOCKER_BUILDX_VERSION: 'v0.10.0'

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
# step 'if env.XXX != ""', so we copy these to succinctly test whether
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
kubeconfig

/.cache
/.work
/_output
Expand All @@ -9,3 +11,5 @@ cover.out
# ignore IDE folders
.vscode/
.idea/

terraform/
52 changes: 37 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
run:
deadline: 10m
timeout: 10m

skip-files:
- "zz_\\..+\\.go$"
- "zz_generated\\..+\\.go$"

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
Expand All @@ -27,22 +27,20 @@ linters-settings:
# report about shadowed variables
check-shadowing: false

golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8

gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true

goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/upbound/upjet-provider-template
# gci:
# custom-order: true
# sections:
# - standard
# - default
# - prefix(github.com/upbound/provider-datadog)

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
min-complexity: 20

maligned:
# print struct with more effective memory layout or not, false by default
Expand Down Expand Up @@ -102,21 +100,40 @@ linters-settings:
rangeValCopy:
sizeThreshold: 32

nolintlint:
require-explanation: false
require-specific: true

revive:
rules:
- name: package-comments
disabled: true


linters:
enable:
- megacheck
- govet
- gocyclo
- gocritic
- interfacer
- goconst
- goimports
# - gci
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
- revive
- unconvert
- misspell
- nakedret
- nolintlint

disable:
# These linters are all deprecated as of golangci-lint v1.49.0. We disable
# them explicitly to avoid the linter logging deprecation warnings.
- deadcode
- varcheck
- scopelint
- structcheck
- interfacer

presets:
- bugs
Expand All @@ -136,7 +153,7 @@ issues:
- gosec
- scopelint
- unparam

# Ease some gocritic warnings on test files.
- path: _test\.go
text: "(unnamedResult|exitAfterDefer)"
Expand Down Expand Up @@ -174,6 +191,11 @@ issues:
- gosec
- gas

# Some k8s dependencies do not have JSON tags on all fields in structs.
- path: k8s.io/
linters:
- musttag

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [YEAR] Upbound Inc. All rights reserved.
Copyright 2024 Upbound Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
29 changes: 14 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# ====================================================================================
# Setup Project

PROJECT_NAME ?= upjet-provider-template
PROJECT_NAME ?= provider-datadog
PROJECT_REPO ?= github.com/upbound/$(PROJECT_NAME)

export TERRAFORM_VERSION ?= 1.2.1
export TERRAFORM_VERSION ?= 1.5.5

export TERRAFORM_PROVIDER_SOURCE ?= hashicorp/null
export TERRAFORM_PROVIDER_REPO ?= https://github.com/hashicorp/terraform-provider-null
export TERRAFORM_PROVIDER_VERSION ?= 3.1.0
export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-null
export TERRAFORM_PROVIDER_SOURCE ?= DataDog/datadog
export TERRAFORM_PROVIDER_REPO ?= https://github.com/DataDog/terraform-provider-datadog
export TERRAFORM_PROVIDER_VERSION ?= 3.37.0
export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-datadog
export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= https://releases.hashicorp.com/$(TERRAFORM_PROVIDER_DOWNLOAD_NAME)/$(TERRAFORM_PROVIDER_VERSION)
export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-null_v3.1.0_x5
export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-datadog_v3.37.0
export TERRAFORM_DOCS_PATH ?= docs/resources


PLATFORMS ?= linux_amd64 linux_arm64

# -include will silently skip missing files, which allows us
Expand All @@ -40,8 +39,8 @@ NPROCS ?= 1
# to half the number of CPU cores.
GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))

GO_REQUIRED_VERSION ?= 1.19
GOLANGCILINT_VERSION ?= 1.50.0
GO_REQUIRED_VERSION ?= 1.21.2
GOLANGCILINT_VERSION ?= 1.54.2
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider $(GO_PROJECT)/cmd/generator
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION)
GO_SUBDIRS += cmd internal apis
Expand All @@ -50,10 +49,10 @@ GO_SUBDIRS += cmd internal apis
# ====================================================================================
# Setup Kubernetes tools

KIND_VERSION = v0.15.0
UP_VERSION = v0.18.0
KIND_VERSION = v0.20.0
UP_VERSION = v0.22.1
UP_CHANNEL = stable
UPTEST_VERSION = v0.5.0
UPTEST_VERSION = v0.10.0
-include build/makelib/k8s_tools.mk

# ====================================================================================
Expand Down Expand Up @@ -89,7 +88,7 @@ fallthrough: submodules

# NOTE(hasheddan): we force image building to happen prior to xpkg build so that
# we ensure image is present in daemon.
xpkg.build.upjet-provider-template: do.build.images
xpkg.build.provider-datadog: do.build.images

# NOTE(hasheddan): we ensure up is installed prior to running platform-specific
# build steps in parallel to avoid encountering an installation race condition.
Expand Down Expand Up @@ -182,7 +181,7 @@ CROSSPLANE_NAMESPACE = upbound-system
# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "${UPTEST_EXAMPLE_LIST}" --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=cluster/test/setup.sh --default-conditions="Test" || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e "${UPTEST_EXAMPLE_LIST}" --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=cluster/test/setup.sh --default-conditions="Test" || $(FAIL)
@$(OK) running automated tests

local-deploy: build controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME)
Expand Down
76 changes: 64 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,69 @@
# Provider Template
# Provider Datadog

`upjet-provider-template` is a [Crossplane](https://crossplane.io/) provider that
`provider-datadog` 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
Template API.
Datadog API.

## Prerequisites

This provider interacts with a
[Datadog account](https://www.datadoghq.com/). It authenticates
to the account using a Datadog API Key, an Application key, and
a Datadog account endpoint URL.
The keys can be generated inside the account
and be stored in a Kubernetes secret on the Crossplane
management cluster. The format of the secret is as follows:
```
{
"api_key": "INSERT_API_KEY",
"app_key": "INSERT_APP_KEY",
"api_url": "https://api.datadoghq.com/"
}
```
Note that your preferred endpoint may differ.
The Kubernertes secret can be referenced by
the ProviderConfig, so that the provider-datadog can connect
to the desired Datadog account. A ProviderConfig may look
as follows:
```
apiVersion: datadog.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: default
spec:
credentials:
source: Secret
secretRef:
name: datadog-creds
namespace: upbound-system
key: credentials
```

To run local tests, create a datadog-secret file per above.
Then create an `UPTEST_CLOUD_CREDENTIALS` environment variable
as follows
```
export UPTEST_CLOUD_CREDENTIALS=$(cat <PATH-TO-DATADOG-SECRET-FILE> )
```
Once complete, specify the tests that you would like to run
in the `UPTEST_EXAMPLE_LIST` environment variable. An example
is as follows:
```
export UPTEST_EXAMPLE_LIST="./examples/datadog/dashboardjson.yaml"
```
Note that you may specify multiple comma separated tests.
Now run `UPTEST_EXAMPLE_LIST="./examples/datadog/v1alpha1/dashboardjson.yaml" make e2e`. This will create a local kind cluster,
install Crossplane and the provider-datadog from a local build
and run Uptests managed resources apply, update, import, delete
tests.

## Getting Started

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

Alternatively, you can use declarative installation:
Expand All @@ -19,21 +72,20 @@ cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upjet-provider-template
name: provider-datadog
spec:
package: upbound/upjet-provider-template:v0.1.0
package: upbound/provider-datadog: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/upbound/upjet-provider-template).
You can see the API reference [here](https://doc.crds.dev/github.com/upbound/provider-datadog).

## Developing

Run code-generation pipeline:

```console
go run cmd/generator/main.go "$PWD"
make clean; make generate
```

Run against a Kubernetes cluster:
Expand All @@ -57,4 +109,4 @@ make build
## Report a Bug

For filing bugs, suggesting improvements, or requesting new features, please
open an [issue](https://github.com/upbound/upjet-provider-template/issues).
open an [issue](https://github.com/upbound/provider-datadog/issues).
17 changes: 17 additions & 0 deletions apis/apm/v1alpha1/zz_generated.conversion_hubs.go

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

Loading

0 comments on commit b18eefa

Please sign in to comment.