Rest Strategy is a collection of packages to enable idempotent seeding of data against REST endpoints.
This repo uses workspaces and is made up of following modules/components.
-
seeder modules which can be used as a library (used by the controller) or a CLI.
-
controller k8s controller code.
-
apis holds the types for the controller.
See the individual components for a lower level overview.
When interacting with the modules use the top level Makefile tasks.
After any change or before any push to remote
make build
make test
To run tests against the controller or the CLI use the test/crd-test.yml
.
To see some examples...
General notes section
INFO
When assigning ConfigManager tokens to the templates - it is highly recommended to use the variables section and reference that instead of inlining the tokens in payloads themselves.
e.g. prefer this - see the full example here
...
payloadTemplate: |
{"email":"[email protected]","password":"${oldPass}","passwordConfirm":"${oldPass}"}
patchPayloadTemplate: |
{"password":"${newPass}","passwordConfirm":"${newPass}"}
variables:
oldPass: AWSPARAMSTR:///int-test/pocketbase/admin-pwd
newPass: AWSPARAMSTR:///int-test/pocketbase/admin-pwd
as opposed to the below
...
payloadTemplate: |
{"email":"[email protected]","password":"Password123_alwaysChange","passwordConfirm":"Password123_alwaysChange"}
patchPayloadTemplate: |
{"password":"AWSPARAMSTR:///int-test/pocketbase/admin-pwd","passwordConfirm":"AWSPARAMSTR:///int-test/pocketbase/admin-pwd"}
variables: {}
IF the exchanged config value for a token includes an unescaped $
it will try to be templated and may result in unexpected errors.
The templating function is provided already with a replaced value: P4s$w0rd123!
for token: AWSPARAMSTR:///int-test/pocketbase/admin-pwd
.
$w0rd123
portion of the replaced value will be picked up by the envsubst lexer as a variable token and will yield no results.
This is a bit of experiment with controller structures and workspaces to see if some re-usable patterns can be gleamed and used in some code generation scaffolding.
At the very least a copy and paste into a new workspace of existing structure and Make tasks -> deleting following seeder
, controller/pkg/rstservice
, removing k8sutils should leave you with a fairly re-useable controller pkg which can be exchanged with other top level types coming from custom/new apis
module.
Using kubebuilder can be found in this dir kubebuilder-controller.
kubebuilder init --domain dnitsch.net --repo github.com/dnitsch/reststrategy/controller
kubebuilder create api --plugins=base.go.kubebuilder.io/v3 --group seeder --version v1alpha1 --kind RestStrategy --controller --namespaced --plural reststrategies --resource --force
make manifests