Thank you for your interest in contributing to opencenter! We welcome contributions from everyone. This document provides guidelines and instructions to help you get started.
Before you can contribute, you'll need to set up your local development environment.
- Mise: For managing project-specific tool versions.
- Go: The correct version is managed by Mise.
- Git: For version control.
-
Fork and Clone the Repository:
git clone git@github.com:your-username/opencenter.git cd opencenter -
Install Tools: Use Mise to install the correct versions of all development tools.
mise install
-
Build the CLI: Compile the
opencenterbinary.mise run build
You should now have a working
opencenterexecutable in your project root.
- Make Your Changes: Implement your bug fix or new feature.
- Run Tests: Before submitting your changes, ensure that all BDD tests pass. This is a critical step to prevent regressions.
For more details, see the How-To Guide on Running Tests.
mise run bdd
- Submit a Pull Request: Push your changes to your fork and open a pull request against the
mainbranch of the upstream repository.
opencenter is designed to be extensible. Here are the most common ways to add new functionality:
- Extend the Structs: Add your new field to the appropriate struct in
internal/config/config.go. - Update the Schema: Add the corresponding entry for your new field in
internal/config/schema.go. - Update the Default Config: If your field should have a default value, add it to the
defaultConfigfunction ininternal/config/config.go. - Ensure any new fields have sensible defaults and schema entries;
cluster initis non-interactive and relies on defaults and explicit flags.
- Create a new directory under
internal/cloud/<provider>. - Inside that directory, create a
preflight.gofile that implements thePreflight(map[string]any) []stringfunction. This function should contain all the preflight checks specific to your new provider. - Add a branch in the
cluster preflightcommand logic to call your new preflight function whencloud.providermatches your new provider's name.
- Add your new template files or directories under
internal/gitops/gitops-base-dir/. - If your file needs to be processed by the templating engine, give it a
.tmplextension. You can use any values from theConfigstruct in your template (e.g.,{{ .ClusterName }}). - If your file should be copied verbatim, do not give it a
.tmplextension. - The
embed.FSininternal/gitops/embed.gowill automatically pick up your new files.
- Create a new file in the
cmd/directory (e.g.,cmd/cluster_mynewcommand.go). - In that file, create a
newClusterMyNewCommandCmd()function that returns a*cobra.Command. - Register your new command in
cmd/cluster.goby addingcmd.AddCommand(newClusterMyNewCommandCmd())to thenewClusterCmdfunction.
This documentation was written based on a thorough analysis of the repository's source code, tests, and existing documentation. In the process, the following points were noted:
.mise.tomlFile: The originalREADME.mdand the project's workflow rely heavily on tasks defined in a.mise.tomlfile. However, this file was not visible in the initial recursive file listing. The documentation for developer tasks has been written based on the descriptions in theREADME.md. If the file exists and contains different or additional tasks, thedocs/reference/tasks.mdfile should be updated.