Garbage test provider only for tests and pure amusement
Note : This repo is malformed in the way that repositories for crossplane providers should be name provider-xxx. Some of the commands in this section are only run to fix this issue, but it may be useful if we want to have a provider name that differs from the repository's name for some reason.
Run :
export provider_name=TestProvider
make provider.prepare provider=${provider_name}
export group=TestGroup
export type=TestType
make provider.addtype provider=${provider_name} group=${group} kind=${type}Then :
- edit
apis/testprovider.goand put correct path at L24 - edit
internal/controller/testprovider.goand put correct path at L24 + replace accordingly at L32 - edit
apis/testgrop/v1alpha1/testtype_types.goand replace attribute names at L30 and L35 - run
make generate - edit
Makefile:- replace
PROJECT_NAME(L3),IMAGES(L33) andXPKGS(L43) values to match the repo's name - replace
PROJECT_REPOvalue at L4 to match the repo's path - remove
linux_arm64fromPLATFORMSvalue at L6 - replace
XPKG_REG_ORGS(L39) andXPKG_REG_ORGS_NO_PROMOTE(L42) values to match our artifactory's path
- replace
- rename
cluster/images/provider-testproviderfolder tocluster/images/test-providerto match the repo's name - run a big sed to replace
github.com/crossplane/provider-testproviderwithgithub.com/frigaut-orange/test-provider - run
VERSION=v0.0.1-rc1 make build - run
VERSION=v0.0.1-rc1 make publish - deploy with
crossplane xpkg install provider kaastools-xpkg/test-provider:v0.0.1-rc1 --package-pull-secrets=kaastoolsbot-docker-creds - if you want to, deploy test resources with
kubectl apply -f examples/provider/config.yamlandkubectl apply -f examples/sample/testtype.yaml
Note : I also tried a version where I edited build/makelib/xpkg.mk (git submodule) to use crossplane xpkg build instead of up build (L72). It included :
- a renaming of the
--controlleroption with--embed-runtime-image - a removal of the
--auth-extoption, which doesn't exist with thecrossplanecommand - a renaming of the
--outputcommand with--package-file
Since crossplane expects an XPKG-formatted OCI image, you can't just docker build and docker push (hence the makefile build and release commands). You have to use xpkg build and xpkg push (run by makefile). Otherwise, the provider's pod won't create with an error saying something like package.yaml not found (annotated layer: false).
When creating TestType objects, the provider will say "external resources ready". It is because the logic in internal/controller/testtype/testtype.go:Observe (L134) always returns ResourceExists: true (L147). This is where we would add the logic for our managed resources.
The following text is what was automatically generated by the makefile, left here as an example.
provider-testprovider is a minimal Crossplane Provider
that is meant to be used as a testprovider for implementing new Providers. It comes
with the following features that are meant to be refactored:
- A
ProviderConfigtype that only points to a credentialsSecret. - A
MyTyperesource type that serves as an example managed resource. - A managed resource controller that reconciles
MyTypeobjects and simply prints their configuration in itsObservemethod.
- Use this repository as a testprovider to create a new one.
- Run
make submodulesto initialize the "build" Make submodule we use for CI/CD. - Rename the provider by running the following command:
export provider_name=MyProvider # Camel case, e.g. GitHub
make provider.prepare provider=${provider_name}- Add your new type by running the following command:
export group=sample # lower case e.g. core, cache, database, storage, etc.
export type=MyType # Camel casee.g. Bucket, Database, CacheCluster, etc.
make provider.addtype provider=${provider_name} group=${group} kind=${type}- Replace the sample group with your new group in apis/{provider}.go
- Replace the mytype type with your new type in internal/controller/{provider}.go
- Replace the default controller and ProviderConfig implementations with your own
- Run
make reviewableto run code generation, linters, and tests. - Run
make buildto build the provider.
Refer to Crossplane's CONTRIBUTING.md file for more information on how the Crossplane community prefers to work. The Provider Development guide may also be of use.