manifesttestutils

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

Manifest Test Library

This package contains some utils for easily parsing installation manifests (i.e. Helm-generated yaml files) and writing tests against those manifests. This is to ensure your Helm chart is properly linted and meets expectations.

Usage

  • Define a test suite that parses a manifest, for example see test/example_suite_test.go.
  • Define a test file that tests the manifest, for example see test/example_test.go.

These tests should be very concise based on the resource builder utilities provided.

Future

In the short term, the goal is increasing test coverage of helm charts that are published by different projects. Some useful extensions in the future would include:

  • Extra utilities for helping test helm charts with different values overrides.

It may make sense to turn this into a Helm chart generator in the future, to the extent that process can be simplified (see github.com/solo-io/build for more info about the Solo common build SDK).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppLabels

func GetAppLabels(appName, category string) map[string]string

func GetClusterAdminRoleRef

func GetClusterAdminRoleRef() rbacv1.RoleRef

func GetClusterRoleRef

func GetClusterRoleRef(name string) rbacv1.RoleRef

func GetCoreRule

func GetCoreRule() rbacv1.PolicyRule

func GetCrdRule

func GetCrdRule() rbacv1.PolicyRule

func GetDefaultServiceAccountSubject

func GetDefaultServiceAccountSubject(namespace string) rbacv1.Subject

func GetIstioRule

func GetIstioRule() rbacv1.PolicyRule

func GetPodNamespaceEnvVar

func GetPodNamespaceEnvVar() v1.EnvVar

func GetServiceAccountSubject

func GetServiceAccountSubject(namespace, name string) rbacv1.Subject

func MustCanonicalizeYaml

func MustCanonicalizeYaml(input string) string

Types

type ContainerSpec

type ContainerSpec struct {
	Image      string
	PullPolicy v1.PullPolicy
	Name       string
	Args       []string
	EnvVars    []v1.EnvVar
}

func GetContainerSpec

func GetContainerSpec(registry, name, tag string, envVars ...v1.EnvVar) ContainerSpec

func GetQuayContainerSpec

func GetQuayContainerSpec(image, tag string, envVars ...v1.EnvVar) ContainerSpec

type PortSpec

type PortSpec struct {
	Name string
	Port int
}

type ResourceBuilder

type ResourceBuilder struct {
	Namespace   string
	Name        string
	Args        []string
	Labels      map[string]string
	Annotations map[string]string
	Rules       []rbacv1.PolicyRule
	Data        map[string]string
	Subjects    []rbacv1.Subject
	RoleRef     rbacv1.RoleRef
	Containers  []ContainerSpec
	Service     ServiceSpec
	SecretType  v1.SecretType
}

func (*ResourceBuilder) GetClusterRole

func (b *ResourceBuilder) GetClusterRole() *rbacv1.ClusterRole

func (*ResourceBuilder) GetClusterRoleBinding

func (b *ResourceBuilder) GetClusterRoleBinding() *rbacv1.ClusterRoleBinding

func (*ResourceBuilder) GetClusterRoleRef

func (b *ResourceBuilder) GetClusterRoleRef() rbacv1.RoleRef

func (*ResourceBuilder) GetConfigMap

func (b *ResourceBuilder) GetConfigMap() *v1.ConfigMap

func (*ResourceBuilder) GetDeployment

func (b *ResourceBuilder) GetDeployment() *v1beta1.Deployment

func (*ResourceBuilder) GetNamespace

func (b *ResourceBuilder) GetNamespace() *v1.Namespace

func (*ResourceBuilder) GetSecret

func (b *ResourceBuilder) GetSecret() *v1.Secret

func (*ResourceBuilder) GetService

func (b *ResourceBuilder) GetService() *v1.Service

func (*ResourceBuilder) GetServiceAccount

func (b *ResourceBuilder) GetServiceAccount() *v1.ServiceAccount

func (*ResourceBuilder) GetServiceAccountSubject

func (b *ResourceBuilder) GetServiceAccountSubject() rbacv1.Subject

type ServiceSpec

type ServiceSpec struct {
	Ports []PortSpec
}

type TestManifest

type TestManifest interface {
	ExpectDeployment(deployment *v1beta1.Deployment)
	ExpectServiceAccount(serviceAccount *corev1.ServiceAccount)
	ExpectClusterRole(clusterRole *rbacv1.ClusterRole)
	ExpectClusterRoleBinding(clusterRoleBinding *rbacv1.ClusterRoleBinding)
	ExpectConfigMap(configMap *corev1.ConfigMap)
	ExpectConfigMapWithYamlData(configMap *corev1.ConfigMap)
	ExpectSecret(secret *corev1.Secret)
	ExpectService(service *corev1.Service)
	ExpectNamespace(namespace *corev1.Namespace)
	ExpectCrd(crd *extv1beta1.CustomResourceDefinition)
	ExpectCustomResource(gvk, namespace, name string)
	NumResources() int
}

func NewTestManifest

func NewTestManifest(relativePathToManifest string) TestManifest

func NewTestManifestWithResources

func NewTestManifestWithResources(resources kuberesource.UnstructuredResources) TestManifest

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL