Skip to content

Latest commit

 

History

History
115 lines (69 loc) · 2.81 KB

README.md

File metadata and controls

115 lines (69 loc) · 2.81 KB

Develop Steward

Folder structure

The project "Steward" sources are structured in the following folders:

  • backend-k8s

    This folder contains the components which need to be applied to a k8s cluster to provide the backend.

  • cmd

    The go coding for the command line / image for the pipeline executor

  • docs/example

    This folder contains examples how to interact with the service

  • pkg/apis

    The go api for the pipelineRun object

  • pkg/client (generated)

    This folder contains the generated clientset, informers and listers for project "Steward". The generation is done via hack/update-codegen.sh.

    The controllers use client-go library extensively. The details of interaction points of the controllers with various mechanisms from this library are explained here.

  • pkg/runctl & pkg/tenantctl

    The go implementation of the controllers

Contribution

You are welcome to contribute to this project via Pull Requests.

Development

Prerequisites

# Prepare Code Generator
git clone https://github.com/kubernetes/code-generator.git
cd code-generator/

# We need a specific version matching to our K8s client-go version (currently kubernetes-1.14.9)
#
# Unfortunately old versions are not yet modularized.
#     We take the module info from a newer release.
git checkout kubernetes-1.14.9
git checkout kubernetes-1.16.1 -- go.mod go.sum

# CODEGEN_PKG is used by the script to find the code-generator
export CODEGEN_PKG=${PWD}
# Prepare mockgen tool
go get github.com/golang/mock/mockgen

Build

To run build and test simply execute ./build.sh from the project root folder.

To build only the controllers run:

# Build the run controller executable
go build -o runController ./cmd/run_controller/

# Build the tenant controller executable
go build -o tenantController ./cmd/tenant_controller/

Code Generation

The generated clients and mocks have been committed into the project sources. Generation is not necessary in every build, but for some changes (e.g. API changes) the clients and mocks need to be generate again (and committed). This can be done using:

# Client generation
hack/update-codegen.sh

Test

go test -coverprofile coverage.txt ./...
go tool cover -html=coverage.txt -o coverage.html

Known Issues

'unknown escape sequence' during generation

For some reason \ characters are generated into imports on Windows. Those are interpreted as (wrong) escape chars which fails the generation.

import (
	stewardv1alpha1 "github.com/SAP/stewardci-core\..."
)

Solution: Linux or Ubuntu sub system on Windows. Cygwin does not help. See also issue #68