How grupoboticario/plat-eng-alquimia-crossplane-provider-sonar works
Project type and purpose
• This is a Crossplane “provider” scaffold called provider-sonar.
• Its purpose is to serve as a minimal example (“sonar”) for creating new Crossplane providers. It defines a custom resource (MyType), a ProviderConfig, a controller that reconciles managed resources, and code-generation & packaging pipelines.
File structure
• Top-level directories:
• apis/ – API definitions & generated deepcopy plus CRD manifests in package/crds
• internal/ – core logic: clients (Sonar API), controller implementations
• cmd/provider – entrypoint for running the provider’s controller
• cluster/ – local / integration test harness (images, scripts)
• hack/ – code-generation and scaffolding helpers
• examples/ – sample YAML to exercise CRDs and ProviderConfig
• package/crds & crossplane.yaml – distribution artifacts
• Configuration/build: Makefile, go.mod, .github workflows for CI, codegen, and release.
Extract insights from README
• Defines key features: ProviderConfig → Secret, MyType managed resource, a controller that logs observed configuration.
• Intended workflow: scaffold a new provider, generate code, run make build, install CRDs, and run the controller in-cluster or locally.
Main components
a. Kubernetes API Server (with CRDs installed)
b. provider-sonar Controller Manager (the cmd/provider/main.go binary)
c. Custom Resources:
• ProviderConfig (references kube-secret)
• MyType (the sample managed resource)
d. Secret store (Kubernetes Secret) holding provider credentials
e. External service endpoint (“Sonar API”) accessed by internal/clients/sonar
f. Codegen pipeline (hack scripts → controller-gen → CRD YAML)
g. Packaging & CI/CD artifacts (Makefile, .github workflows, cluster images)
Relationships & interactions
• The Controller Manager watches CRDs (MyType, ProviderConfig) via controller-runtime.
• On reconcile:
1. Reads ProviderConfig → fetches Secret with credentials
2. Uses internal/clients/sonar to call external Sonar API
3. Updates MyType.Status via Kubernetes API
• Codegen (hack/helpers + Makefile) produces deepcopy & CRDs → applied to API server → available for controllers.
• CI/CD workflows build & publish container images (cluster/images) and provider package (package/).
Architectural patterns & design principles
• Kubernetes operator pattern (control-loop reconciliation)
• Separation of concerns:
• apis/ defines schema
• internal/clients isolates external API calls
• internal/controller contains business-logic reconcile code
• Code generation for CRD manifests and client deepcopy methods
• GitHub Actions for automated testing, code analysis, and releases