Skip to content

Latest commit

 

History

History
145 lines (96 loc) · 3.81 KB

File metadata and controls

145 lines (96 loc) · 3.81 KB

Development Guide

Prerequisites

The Linode Cloud Controller Manager development requires:

  • A fairly up-to-date GNU tools environment
  • Go 1.26 or higher

Setting Up Development Environment

Option 1: Using Mise (Recommended)

The simplest way to set up your development environment is using mise:

  1. Install mise by following the instructions at mise.jdx.dev

  2. Install the pinned toolchain from the repository root:

mise install
  1. Run commands through mise so the pinned toolchain is used:
mise run build
mise run test

This will automatically set up all required dependencies and tools for development.

Option 2: Manual Setup

  1. If you haven't set up a Go development environment, follow these instructions to install Go.

On macOS, you can use Homebrew:

brew install golang

Getting Started

Download Source

go get github.com/linode/linode-cloud-controller-manager
cd $(go env GOPATH)/src/github.com/linode/linode-cloud-controller-manager

Building the Project

Build Binary

Use the following mise tasks to build and run a local binary:

# Build the binary
mise run build

# Run the binary
mise run run

# You can also run the binary directly to pass additional args
dist/linode-cloud-controller-manager

Building Container Images

The local image build task loads the built image into your local Docker-compatible daemon.

To build and push an image with ko:

# Build locally into your Docker-compatible daemon
IMAGE_TAGS=canary mise run ko-build

# Publish Image
KO_DOCKER_REPO=docker.io/linode/linode-cloud-controller-manager IMAGE_TAGS=canary mise run ko-publish

To run the locally built image after ko-build:

docker run -ti ko.local/github.com/linode/linode-cloud-controller-manager:canary

Managing Dependencies

The Linode Cloud Controller Manager uses Go Modules to manage dependencies.

To update or add dependencies:

go mod tidy

Development Guidelines

Code Quality Standards

  • Write correct, up-to-date, bug-free, fully functional, secure, and efficient code
  • Use the latest stable version of Go
  • Follow Go idioms and best practices
  • Implement proper error handling with custom error types when beneficial
  • Include comprehensive input validation
  • Utilize built-in language features for performance optimization
  • Follow relevant design patterns and principles
  • Leave NO todos, placeholders, or incomplete implementations

Code Structure

  • Include necessary imports and declarations
  • Implement proper logging using appropriate logging mechanisms
  • Consider implementing middleware or interceptors for cross-cutting concerns
  • Structure code in a modular and maintainable way
  • Use appropriate naming conventions and code organization

Security & Performance

  • Implement security best practices
  • Consider rate limiting when appropriate
  • Include authentication/authorization where needed
  • Optimize for performance while maintaining readability
  • Consider scalability in design decisions

Documentation & Testing

  • Provide brief comments for complex logic or language-specific idioms
  • Include clear documentation for public interfaces
  • Write tests using appropriate testing frameworks
  • Document any assumptions or limitations

Pull Request Process

  1. Ensure your code follows the project's coding standards
  2. Update documentation as needed
  3. Add or update tests as appropriate
  4. Make sure all tests pass locally
  5. Submit the PR with a clear description of the changes

Getting Help

For development related questions or discussions, join us in #linode on the Kubernetes Slack.