secret

package
v0.0.0-...-841a27c Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Example (Full)
package main

import (
	"embed"
	"os"

	v1 "k8s.io/api/core/v1"
	"knative.dev/reconciler-test/pkg/manifest"
	"knative.dev/reconciler-test/pkg/resources/secret"

	testlog "knative.dev/reconciler-test/pkg/logging"
)

//go:embed *.yaml
var yaml embed.FS

func main() {
	ctx := testlog.NewContext()
	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
	}

	opts := []manifest.CfgFn{
		secret.WithLabels(map[string]string{
			"color": "green",
		}),
		secret.WithAnnotations(map[string]interface{}{
			"app.kubernetes.io/name": "app",
		}),
		secret.WithType(v1.SecretTypeOpaque),
		secret.WithData(map[string][]byte{
			"key1": []byte("val1"),
		}),
		secret.WithStringData(map[string]string{
			"key2": "val2",
		}),
	}

	for _, opt := range opts {
		opt(cfg)
	}

	files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg)
	if err != nil {
		panic(err)
	}

	manifest.OutputYAML(os.Stdout, files)
}
Output:

apiVersion: v1
kind: Secret
metadata:
  name: foo
  namespace: bar
  annotations:
    app.kubernetes.io/name: "app"
  labels:
    color: "green"
type: Opaque
data:
  key1: dmFsMQ==
stringData:
  key2: val2
Example (Min)
package main

import (
	"embed"
	"os"

	"knative.dev/reconciler-test/pkg/manifest"

	testlog "knative.dev/reconciler-test/pkg/logging"
)

//go:embed *.yaml
var yaml embed.FS

func main() {
	ctx := testlog.NewContext()
	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
	}

	files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg)
	if err != nil {
		panic(err)
	}

	manifest.OutputYAML(os.Stdout, files)
}
Output:

apiVersion: v1
kind: Secret
metadata:
  name: foo
  namespace: bar

Index

Examples

Constants

This section is empty.

Variables

View Source
var WithAnnotations = manifest.WithAnnotations
View Source
var WithLabels = manifest.WithLabels

Functions

func Install

func Install(name string, options ...manifest.CfgFn) feature.StepFn

func IsPresent

func IsPresent(name string, assertions ...Assertion) feature.StepFn

func IsPresentInNamespace

func IsPresentInNamespace(name string, ns string, assertions ...Assertion) feature.StepFn

func WithData

func WithData(data map[string][]byte) manifest.CfgFn

func WithStringData

func WithStringData(stringdata map[string]string) manifest.CfgFn

func WithType

func WithType(secretType corev1.SecretType) manifest.CfgFn

Types

type Assertion

type Assertion func(s *corev1.Secret) error

func AssertKey

func AssertKey(key string) Assertion

Jump to

Keyboard shortcuts

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