mirror of https://github.com/rancher/hull.git
4.1 KiB
4.1 KiB
Developing Hull
Repository Structure
## This directory will contain additional docs to assist users in getting started with using Hull
docs/
## This directory contains an example of a Helm Chart Test Suite built using Hull that operates on the chart found in testdata/charts/example-chart
examples/
## This directory contains the image that is used to build rancher/hull, which is hosted on hub.docker.com
package/
Dockerfile
## The main source directory for the code. See below for more details.
pkg/
## This directory contains scripts that are using to build, maintain, and release Hull. While you can directly call these scripts (assuming you have the required build dependencies), it's generally recommended that you run these scripts via `make` commands, which will run the build commands in a Dapper container (see https://github.com/rancher/dapper) that already has the pre-requisites installed.
scripts/
## This directory contains any data that Go tests in this repository, including examples/example_test.go and those defined on each module in pkg/, rely on to successfully test Hull.
testdata/
## The Dockerfile used to run CI and other scripts executed by make in a Docker container (powered by https://github.com/rancher/dapper)
Dockerfile.dapper
## The main entrypoint into Hull
main.go
Making changes to the codebase (pkg)
Most of the code for Hull is contained in the pkg directory, which has the following structure:
## This directory contains the logic used to parse Helm Charts into Charts that can produce Templates that tests can be run on via calling HelmLint, YamlLint, and Check
chart/
configuration/
## This file contains the default YAMLLint configuration we use to run the YamlLint command on Templates
yamllint.yaml
# This directory contains utility functions used to extract information from the Chart.yaml of a chart, which can be useful in setting up a test.Suite
metadata/
## This directory contains the logic for defining a Checker on a given set of manifests, which can either be a String, an objectset.ObjectSet, or a map of objectSet.ObjectSet that encodes multiple manifests tests should be run on.
##
## Note:
##
## As a result of this logic being in an independent package, Hull's checker can be used to run the same Checks
## you run on Helm chart on any arbitrary Kubernetes manifest, in case users would like to use Hull's testing
## methodology to test manifests that are non-Helm-based (i.e. if you wanted to use it to test raw manifests
## or those generated by Kustomize).
##
## Contributions are also welcome to add additional support for these types of test.Suites in the test package!
checker/
## This directory contains the simple logic for parsing a manifest from a string into a *objectset.ObjectSet containing *unstructured.Unstructured objects, which will later be marshalled into specific Go types in pkg/checker
parser/
## This directory contains the logic used to define test suites on Helm charts; it's specifically designed to be
## opinionated in the way that it runs these tests (i.e. leveraging Go subtests to execute each individual test)
## and wraps the function calls exposed by all of the other packages in a single Go struct that can be instantiated
## to simply be able to run tests via a call to suite.Run().
##
## In addition, since it expects a specific format in which tests are encoded, it also encodes the logic to be able
## to inspect the provided Cases and output the inferred test coverage that your Cases seem to address.
test/
## This directory contains the logic for generating Markdown reports on Helm or YAML lint failures that come from
## running template.YAMLLint or template.HelmLint from the chart package
writer/
Once you have made a change
Ensure that you add a Go test to add coverage for the new functionality you added. Once you have, verify your results by running ./scripts/test (or make test if you do not have the build dependencies installed on your local machine and would prefer to run the command in your container).
Also ensure that ./scripts/validate (or make validate) passes to ensure your changes pass golangci-lint and go fmt.