Skip to content

Commit

Permalink
Merge pull request #14 from lawrencegripper/lg/issue/11
Browse files Browse the repository at this point in the history
Enable CRD support
  • Loading branch information
lawrencegripper authored Apr 11, 2019
2 parents d9a4b8c + 0aae236 commit ae8538a
Show file tree
Hide file tree
Showing 71 changed files with 10,796 additions and 1,187 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ website/node_modules
*~
.*.swp
.idea
.vscode/
*.iml
*.test
*.iml
Expand All @@ -32,3 +31,4 @@ website/vendor
!command/test-fixtures/**/.terraform/
**/terraform-provider-kubernetes-yaml
**/terraform-provider-k8sraw
k3s
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ go:
- "1.10.x"
dist: xenial

# This moves Kubernetes specific config files.
env:
- CHANGE_MINIKUBE_NONE_USER=true

install:
- bash scripts/gogetcookie.sh
- go get github.com/kardianos/govendor

script:
- bash scripts/startminikube_ci.sh
- bash scripts/startk3s_ci.sh
- make build
- make testacc
- KUBECONFIG=/etc/rancher/k3s/k3s.yaml make testacc

matrix:
fast_finish: true
Expand Down
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// 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": "Launch K3s",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceRoot}/kubernetes/.",
"env": {
"TF_ACC": 1,
"KUBECONFIG": "/etc/rancher/k3s/k3s.yaml",
},
"args": ["-test.v"]
},
{
"name": "Launch KubeContext current",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceRoot}/kubernetes/.",
"env": {
"TF_ACC": 1,
},
"args": ["-test.v"]
}
]
}
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ test: fmtcheck
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc: fmtcheck
TF_ACC=1 go test ./kubernetes -v $(TESTARGS) -timeout 120m
TF_ACC=1 go test ./kubernetes -v $(TESTARGS) -timeout 120m -count=1

testacck3: fmtcheck
TF_ACC=1 TF_LOG=DEBUG KUBECONFIG=/etc/rancher/k3s/k3s.yaml go test ./kubernetes -v $(TESTARGS) -timeout 120m -count=1

vet:
@echo "go vet ."
Expand Down
58 changes: 47 additions & 11 deletions Gopkg.lock

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

16 changes: 16 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@
[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/go-yaml/yaml"
version = "2.2.2"

[[constraint]]
name = "gopkg.in/yaml.v2"
version = "2.2.2"

[[constraint]]
branch = "master"
name = "github.com/icza/dyno"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.3.0"
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ This was originally proposed [as a PR to add a YAML resource](https://github.com

While the work is ongoing to provide a better experience in the official provider I've pulled the code out into a standalone provider which just provides the YAML resource. This allows for it to be used alongside the existing providers.

![demo](docs/yamldemo.gif)

## Status: Experimental

Currently the code has been tried on a limited number of use cases. I would expect wider use to find issue, please raise them on the repository and make contributions to resolve them if you can.



## Using the provider

![demo](docs/yamldemo.gif)

Download a binary for your system from the release page and remove the `-os-arch` details so you're left with `terraform-provider-k8sraw`. Use `chmod +x` to make it executable and then either place it at the root of your Terraform folder or in the Terraform plugin folder on your system.

Then you can create a YAML resources by using the following Terraform:
Expand Down Expand Up @@ -71,6 +72,9 @@ Each scenario can be placed in a folder, to help others navigate and use the exa

> Note: The test infrastructure doesn't support multi-file TF configurations so ensure your test scenario is in a single file.
### Debugging

Using `vscode` with `delve` and `golang` configured the launch task in the repo will start a debugging session for the tests. Open the repo and press `F5` to get started.

### Development Environment

Expand Down
40 changes: 40 additions & 0 deletions _examples/crds/basic_crd.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
provider "k8sraw" {}


resource "k8sraw_yaml" "test" {
depends_on = ["k8sraw_yaml.definecrd"]
yaml_body = <<YAML
apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
name: name-here-crd
spec:
cronSpec: "* * * * /5"
image: my-awesome-cron-image
YAML
}

resource "k8sraw_yaml" "definecrd" {
yaml_body = <<YAML
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: name-here-crontabs.stable.example.com
spec:
group: stable.example.com
conversion:
strategy: None
scope: Namespaced
names:
plural: name-here-crontabs
singular: crontab
kind: CronTab
shortNames:
- ct
version: v1
versions:
- name: v1
served: true
storage: true
YAML
}
Loading

0 comments on commit ae8538a

Please sign in to comment.