|
1 |
| -# go-bootstrap |
| 1 | +# appcat-comp-functions |
2 | 2 |
|
3 |
| -[][build] |
4 |
| - |
5 |
| -[][releases] |
6 |
| -[][releases] |
| 3 | +[][build] |
| 4 | + |
| 5 | +[][releases] |
| 6 | +[][releases] |
7 | 7 |
|
8 |
| -[build]: https://github.com/vshn/go-bootstrap/actions?query=workflow%3ATest |
9 |
| -[releases]: https://github.com/vshn/go-bootstrap/releases |
| 8 | +[build]: https://github.com/vshn/appcat-comp-functions/actions?query=workflow%3ATest |
| 9 | +[releases]: https://github.com/vshn/appcat-comp-functions/releases |
| 10 | +## Repository structure |
10 | 11 |
|
11 |
| -Template repository for common Go setups |
| 12 | +This repository will build different docker images for different services. For that reason some folder structure is bound to the name of the service. |
12 | 13 |
|
13 |
| -## Features |
14 |
| - |
15 |
| -* GitHub Workflows |
16 |
| - - Build (Go & Docker image) |
17 |
| - - Test |
18 |
| - - Lint (Go & GolangCI) |
19 |
| - - Release (Goreleaser & Changelog generator) |
20 |
| - |
21 |
| -* GitHub issue templates |
22 |
| - - PR template |
23 |
| - - Issue templates using GitHub issue forms |
24 |
| - |
25 |
| -* Goreleaser |
26 |
| - - Go build for `amd64`, `armv8` |
27 |
| - - Docker build for `latest` and `vx.y.z` tags |
28 |
| - - Push Docker image to GitHub's registry `ghcr.io` |
29 |
| - |
30 |
| -* Antora documentation |
31 |
| - - Build default documentation with VSHN styling |
32 |
| - - Publish to GitHub Pages by default (opt-out) |
33 |
| - - Automated with GitHub workflows to build in `master` branch and (pre-)releases. |
34 |
| - - Available `make` targets are prefixed with `docs-` |
35 |
| - |
36 |
| -* Local Kubernetes environment |
37 |
| - - Setup Kubernetes-In-Docker (kind) |
38 |
| - - Prepares a kubeconfig file in `.kind/` |
39 |
| - - Optionally install NGINX as ingress controller |
40 |
| - - Available `make` targets are prefixed with `kind-` |
41 |
| - |
42 |
| -* CLI and logging framework |
43 |
| - - To help get you started with CLI subcommands, flags and environment variables |
44 |
| - - If you don't need subcommands, remove `example_command.go` and adjust `cli.App` settings in `main.go` |
45 |
| - |
46 |
| -## TODO's after generating from this template |
47 |
| - |
48 |
| -TIP: You can search for these tasks using `grep -n -r "TODO:" .` |
49 |
| - |
50 |
| -1. `go.mod`: Adjust module name. |
51 |
| -1. `.goreleaser.yml`: Adjust Docker image location in `dockers` and `docker_manifests` parameters. |
52 |
| -1. `.gitignore`: Adjust binary file name. |
53 |
| -1. `Dockerfile`: Adjust binary file name. |
54 |
| -1. `Makefile.vars.mk`: Adjust project meta. |
55 |
| -1. `.github/ISSUE_TEMPLATE/config.yml` (optional): Enable forwarding questions to GitHub Discussions or other page. |
56 |
| -1. `docs/antora.yml`: Adjust project meta. |
57 |
| -1. `docs/antora-playbook.yml`: Adjust project meta. |
58 |
| -1. `docs/modules/pages/index.adoc`: Edit start page. |
59 |
| -1. `docs/modules/nav.adoc`: Edit navigation. |
60 |
| -1. `main.go`: Adjust variables. |
61 |
| -1. Edit this README (including badges links) |
62 |
| -1. Start hacking in `example_command.go`. |
63 |
| - |
64 |
| -After completing a task, you can remove the comment in the files. |
65 |
| - |
66 |
| -## Other repository settings |
67 |
| - |
68 |
| -1. GitHub Settings |
69 |
| - - "Options > Wiki" (disable) |
70 |
| - - "Options > Allow auto-merge" (enable) |
71 |
| - - "Options > Automatically delete head branches" (enable) |
72 |
| - - "Collaborators & Teams > Add Teams and users to grant maintainer permissions |
73 |
| - - "Branches > Branch protection rules": |
74 |
| - - Branch name pattern: `master` |
75 |
| - - Require status check to pass before merging: `["lint"]` (you may need to push come commits first) |
76 |
| - - "Pages > Source": Branch `gh-pages` |
77 |
| - |
78 |
| -1. GitHub Issue labels |
79 |
| - - "Issues > Labels > New Label" for the following labels with color suggestions: |
80 |
| - - `change` (`#D93F0B`) |
81 |
| - - `dependency` (`#ededed`) |
82 |
| - - `breaking` (`#FBCA04`) |
83 |
| - |
84 |
| -## Antora documentation |
85 |
| - |
86 |
| -This template comes with an Antora documentation module to help you create Asciidoctor documentation. |
87 |
| -By default, it is automatically published to GitHub Pages in `gh-pages` branch, however it can also be included in external Antora playbooks. |
88 |
| - |
89 |
| -### Setup GitHub Pages |
| 14 | +``` |
| 15 | +. |
| 16 | +├── cmd |
| 17 | +│ ├── vshn-postgres-func |
| 18 | +│ └── vshn-redis-func |
| 19 | +├── kind |
| 20 | +├── functions |
| 21 | +│ ├── vshn-common-func |
| 22 | +│ ├── vshn-postgres-func |
| 23 | +│ └── vshn-redis-func |
| 24 | +├── runtime |
| 25 | +└── test |
| 26 | +``` |
90 | 27 |
|
91 |
| -Once you generated a new repository using this template, the initial commit automatically runs a Job that creates the documentation in the `gh-pages` branch. |
92 |
| -All you need to do is then to enable Pages in the settings. |
| 28 | +- `./cmd` contains the entry point boilerplate for each service. |
| 29 | +- `./pkg/functions` contains the actual logic for the function. Each transform should be in its own package. |
93 | 30 |
|
94 |
| -The `gh-pages` branch is a parent-less commit that only contains the Antora-generated files. |
| 31 | +## Add a new function |
95 | 32 |
|
96 |
| -However, if that's not the case or if you are setting up Antora in an existing repository, here's how you can achieve the same, but make sure to **commit or stash current changes first!** |
97 |
| -```bash |
98 |
| -current_branch=$(git rev-parse --abbrev-ref HEAD) |
99 |
| -initial_commit=$(git rev-list --max-parents=0 HEAD | tail -n 1) |
100 |
| -git switch --create gh-pages $initial_commit |
101 |
| -git rm -r --cached . |
102 |
| -git commit -m "Prepare gh-pages branch" |
103 |
| -git push --set-upstream origin gh-pages |
104 |
| -git switch -f $current_branch |
105 |
| -``` |
| 33 | +The framework is designed to easily add new composition functions to any AppCat service. |
106 | 34 |
|
107 |
| -And you're done! |
108 |
| -GitHub automatically recognizes activity and sets up Pages if there's a `gh-pages` branch. |
| 35 | +To add a new function to PostgreSQL by VSHN: |
109 | 36 |
|
110 |
| ---- |
| 37 | +- Create a new package under `./pkg/functions/vshn-postgres-func` |
| 38 | +- Add the transform function to the list in `./cmd/vshn-postgres-func` |
| 39 | +- implement the actual `transform()` function by using the helper functions from `io.go` |
111 | 40 |
|
112 |
| -If you want to skip deployment to GitHub Pages you need to delete specific files and references: |
113 |
| -`rm -f .github/workflows/docs.yml docs/package*.json docs/antora-playbook.yml docs/antora-build.mk`. |
114 |
| -Also don't forget to delete the branch and disable Pages in the repository settings. |
| 41 | +This architecture allows us to run all the functions with a single command. But for debugging and development purpose it's possible to run each function seperately, by using the `--function` flag. |
115 | 42 |
|
116 |
| ---- |
| 43 | +## Manually testing a function |
| 44 | +To test a function you can leverage the FunctionIO file in the `./test` folder. |
117 | 45 |
|
118 |
| -If you want to remove documentation completely simply run `rm -rf docs .github/workflows/docs.yml`. |
| 46 | +`cat test/function-io.yaml | go run cmd/vshn-postgres-func/main.go --function myfunction > test.yaml` |
0 commit comments