gen

package
v0.0.0-...-5756e46 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

package gen implements helper functions to construct API resource test fixtures.

Index

Constants

View Source
const (
	// DefaultTestNamespace is the default namespace set on resources that
	// are namespaced.
	DefaultTestNamespace = "default-unit-test-ns"
)

Variables

This section is empty.

Functions

func CSR

func CSR(keyAlgorithm x509.PublicKeyAlgorithm, mods ...CSRModifier) (csr []byte, sk crypto.Signer, err error)

func CSRForCertificate

func CSRForCertificate(crt *v1.Certificate, mods ...CSRModifier) (csr []byte, sk crypto.Signer, err error)

func CSRWithSigner

func CSRWithSigner(sk crypto.Signer, mods ...CSRModifier) (csr []byte, err error)

func CSRWithSignerForCertificate

func CSRWithSignerForCertificate(crt *v1.Certificate, sk crypto.Signer, mods ...CSRModifier) (csr []byte, err error)

func Certificate

func Certificate(name string, mods ...CertificateModifier) *v1.Certificate

func CertificateFrom

func CertificateFrom(crt *v1.Certificate, mods ...CertificateModifier) *v1.Certificate

func CertificateRef

func CertificateRef(certName, certUID string) metav1.OwnerReference

CertificateRef creates an owner reference for a certificate without having to give the full certificate. Only use this function for testing purposes.

Note that the only "important" field that must be filled in ownerReference [1] is the UID. Most notably, the IsControlledBy function [2] only cares about the UID. The apiVersion, kind and name are only used for information purposes.

[1]: https://github.com/kubernetes/apimachinery/blob/10b3882/pkg/apis/meta/v1/types.go#L273-L275
[2]: https://github.com/kubernetes/apimachinery/blob/10b3882/pkg/apis/meta/v1/controller_ref.go#L29

func CertificateRequest

func CertificateRequest(name string, mods ...CertificateRequestModifier) *v1.CertificateRequest

func Challenge

func Challenge(name string, mods ...ChallengeModifier) *cmacme.Challenge

func ChallengeFrom

func ChallengeFrom(ch *cmacme.Challenge, mods ...ChallengeModifier) *cmacme.Challenge

func ClusterIssuer

func ClusterIssuer(name string, mods ...IssuerModifier) *v1.ClusterIssuer

func ClusterIssuerFrom

func ClusterIssuerFrom(iss *v1.ClusterIssuer, mods ...IssuerModifier) *v1.ClusterIssuer

func ClusterIssuerWithRandomName

func ClusterIssuerWithRandomName(prefix string, mods ...IssuerModifier) *v1.ClusterIssuer

ClusterIssuerWithRandomName returns a ClusterIssuer named 'prefix<random-string>' with the specified modifications.

func Issuer

func Issuer(name string, mods ...IssuerModifier) *v1.Issuer

func IssuerConditionFrom

func IssuerConditionFrom(c *v1.IssuerCondition, mods ...IssuerConditionModifier) *v1.IssuerCondition

func IssuerFrom

func IssuerFrom(iss *v1.Issuer, mods ...IssuerModifier) *v1.Issuer

func IssuerWithRandomName

func IssuerWithRandomName(prefix string, mods ...IssuerModifier) *v1.Issuer

IssuerWithRandomName returns a new Issuer named prefix<random-string> with the provided modifications.

func ObjectMeta

func ObjectMeta(name string, mods ...ObjectMetaModifier) metav1.ObjectMeta

ObjectMeta creates a new metav1.ObjectMeta with the given name, optionally applying the provided ObjectMetaModifiers. It applies a DefaultTestNamespace by default. Cluster-scoped resource generators should explicitly add `SetNamespace("")` to their constructors.

func Order

func Order(name string, mods ...OrderModifier) *cmacme.Order

func OrderFrom

func OrderFrom(order *cmacme.Order, mods ...OrderModifier) *cmacme.Order

func Secret

func Secret(name string, mods ...SecretModifier) *corev1.Secret

func SecretFrom

func SecretFrom(sec *corev1.Secret, mods ...SecretModifier) *corev1.Secret

Types

type CSRModifier

type CSRModifier func(*x509.CertificateRequest) error

func SetCSRCommonName

func SetCSRCommonName(commonName string) CSRModifier

func SetCSRDNSNames

func SetCSRDNSNames(dnsNames ...string) CSRModifier

func SetCSREmails

func SetCSREmails(emails []string) CSRModifier

func SetCSRIPAddresses

func SetCSRIPAddresses(ips ...net.IP) CSRModifier

func SetCSRIPAddressesFromStrings

func SetCSRIPAddressesFromStrings(ips ...string) CSRModifier

func SetCSRURIs

func SetCSRURIs(uris ...*url.URL) CSRModifier

func SetCSRURIsFromStrings

func SetCSRURIsFromStrings(uris ...string) CSRModifier

type CertificateModifier

type CertificateModifier func(*v1.Certificate)

func AddCertificateAnnotations

func AddCertificateAnnotations(annotations map[string]string) CertificateModifier

func AddCertificateLabels

func AddCertificateLabels(labels map[string]string) CertificateModifier

func SetCertificateAdditionalOutputFormats

func SetCertificateAdditionalOutputFormats(additionalOutputFormats ...v1.CertificateAdditionalOutputFormat) CertificateModifier

func SetCertificateCommonName

func SetCertificateCommonName(commonName string) CertificateModifier

func SetCertificateCreationTimestamp

func SetCertificateCreationTimestamp(creationTimestamp metav1.Time) CertificateModifier

func SetCertificateDNSNames

func SetCertificateDNSNames(dnsNames ...string) CertificateModifier

func SetCertificateDuration

func SetCertificateDuration(duration *metav1.Duration) CertificateModifier

func SetCertificateEmails

func SetCertificateEmails(emails ...string) CertificateModifier

func SetCertificateGeneration

func SetCertificateGeneration(gen int64) CertificateModifier

func SetCertificateIPs

func SetCertificateIPs(ips ...string) CertificateModifier

func SetCertificateIsCA

func SetCertificateIsCA(isCA bool) CertificateModifier

func SetCertificateIssuanceAttempts

func SetCertificateIssuanceAttempts(ia *int) CertificateModifier

func SetCertificateIssuer

func SetCertificateIssuer(o cmmeta.ObjectReference) CertificateModifier

SetIssuer sets the Certificate.spec.issuerRef field

func SetCertificateKeyAlgorithm

func SetCertificateKeyAlgorithm(keyAlgorithm v1.PrivateKeyAlgorithm) CertificateModifier

func SetCertificateKeyEncoding

func SetCertificateKeyEncoding(keyEncoding v1.PrivateKeyEncoding) CertificateModifier

func SetCertificateKeySize

func SetCertificateKeySize(keySize int) CertificateModifier

func SetCertificateKeyUsages

func SetCertificateKeyUsages(usages ...v1.KeyUsage) CertificateModifier

func SetCertificateLastFailureTime

func SetCertificateLastFailureTime(p metav1.Time) CertificateModifier

func SetCertificateNamespace

func SetCertificateNamespace(namespace string) CertificateModifier

func SetCertificateNextPrivateKeySecretName

func SetCertificateNextPrivateKeySecretName(name string) CertificateModifier

func SetCertificateNotAfter

func SetCertificateNotAfter(p metav1.Time) CertificateModifier

func SetCertificateNotBefore

func SetCertificateNotBefore(p metav1.Time) CertificateModifier

func SetCertificateOrganization

func SetCertificateOrganization(orgs ...string) CertificateModifier

func SetCertificateOtherNames

func SetCertificateOtherNames(otherNames ...v1.OtherName) CertificateModifier

func SetCertificateRenewBefore

func SetCertificateRenewBefore(renewBefore *metav1.Duration) CertificateModifier

func SetCertificateRenewalTime

func SetCertificateRenewalTime(p metav1.Time) CertificateModifier

func SetCertificateRevision

func SetCertificateRevision(revision int) CertificateModifier

func SetCertificateRevisionHistoryLimit

func SetCertificateRevisionHistoryLimit(limit int32) CertificateModifier

func SetCertificateSecretName

func SetCertificateSecretName(secretName string) CertificateModifier

func SetCertificateSecretTemplate

func SetCertificateSecretTemplate(annotations, labels map[string]string) CertificateModifier

SetCertificateSecretTemplate sets annotations and labels to be attached to the secret metadata.

func SetCertificateStatusCondition

func SetCertificateStatusCondition(c v1.CertificateCondition) CertificateModifier

func SetCertificateUID

func SetCertificateUID(uid types.UID) CertificateModifier

func SetCertificateURIs

func SetCertificateURIs(uris ...string) CertificateModifier

type CertificateRequestModifier

type CertificateRequestModifier func(*v1.CertificateRequest)

func AddCertificateRequestAnnotations

func AddCertificateRequestAnnotations(annotations map[string]string) CertificateRequestModifier

func AddCertificateRequestOwnerReferences

func AddCertificateRequestOwnerReferences(owners ...metav1.OwnerReference) CertificateRequestModifier

func DeleteCertificateRequestAnnotation

func DeleteCertificateRequestAnnotation(key string) CertificateRequestModifier

func SetCertificateRequestAnnotations

func SetCertificateRequestAnnotations(annotations map[string]string) CertificateRequestModifier

func SetCertificateRequestCA

func SetCertificateRequestCA(ca []byte) CertificateRequestModifier

func SetCertificateRequestCSR

func SetCertificateRequestCSR(csr []byte) CertificateRequestModifier

func SetCertificateRequestCertificate

func SetCertificateRequestCertificate(cert []byte) CertificateRequestModifier

func SetCertificateRequestDuration

func SetCertificateRequestDuration(duration *metav1.Duration) CertificateRequestModifier

func SetCertificateRequestFailureTime

func SetCertificateRequestFailureTime(p metav1.Time) CertificateRequestModifier

func SetCertificateRequestGenerateName

func SetCertificateRequestGenerateName(generateName string) CertificateRequestModifier

func SetCertificateRequestGroups

func SetCertificateRequestGroups(groups []string) CertificateRequestModifier

func SetCertificateRequestIsCA

func SetCertificateRequestIsCA(isCA bool) CertificateRequestModifier

func SetCertificateRequestIssuer

func SetCertificateRequestIssuer(o cmmeta.ObjectReference) CertificateRequestModifier

SetIssuer sets the CertificateRequest.spec.issuerRef field

func SetCertificateRequestKeyUsages

func SetCertificateRequestKeyUsages(usages ...v1.KeyUsage) CertificateRequestModifier

func SetCertificateRequestName

func SetCertificateRequestName(name string) CertificateRequestModifier

func SetCertificateRequestNamespace

func SetCertificateRequestNamespace(namespace string) CertificateRequestModifier

func SetCertificateRequestRevision

func SetCertificateRequestRevision(rev string) CertificateRequestModifier

func SetCertificateRequestTypeMeta

func SetCertificateRequestTypeMeta(tm metav1.TypeMeta) CertificateRequestModifier

func SetCertificateRequestUsername

func SetCertificateRequestUsername(username string) CertificateRequestModifier

type CertificateSigningRequestModifier

type CertificateSigningRequestModifier func(*certificatesv1.CertificateSigningRequest)

func AddCertificateSigningRequestAnnotations

func AddCertificateSigningRequestAnnotations(annotations map[string]string) CertificateSigningRequestModifier

func SetCertificateSigningRequestCertificate

func SetCertificateSigningRequestCertificate(cert []byte) CertificateSigningRequestModifier

func SetCertificateSigningRequestDuration

func SetCertificateSigningRequestDuration(duration string) CertificateSigningRequestModifier

func SetCertificateSigningRequestExpirationSeconds

func SetCertificateSigningRequestExpirationSeconds(seconds int32) CertificateSigningRequestModifier

func SetCertificateSigningRequestGroups

func SetCertificateSigningRequestGroups(groups []string) CertificateSigningRequestModifier

func SetCertificateSigningRequestIsCA

func SetCertificateSigningRequestIsCA(isCA bool) CertificateSigningRequestModifier

func SetCertificateSigningRequestRequest

func SetCertificateSigningRequestRequest(request []byte) CertificateSigningRequestModifier

func SetCertificateSigningRequestSignerName

func SetCertificateSigningRequestSignerName(signerName string) CertificateSigningRequestModifier

func SetCertificateSigningRequestUID

func SetCertificateSigningRequestUID(uid string) CertificateSigningRequestModifier

func SetCertificateSigningRequestUsages

func SetCertificateSigningRequestUsages(usages []certificatesv1.KeyUsage) CertificateSigningRequestModifier

func SetCertificateSigningRequestUsername

func SetCertificateSigningRequestUsername(username string) CertificateSigningRequestModifier

type ChallengeModifier

type ChallengeModifier func(*cmacme.Challenge)

func ResetChallengeStatus

func ResetChallengeStatus() ChallengeModifier

func SetChallengeDNSName

func SetChallengeDNSName(dnsName string) ChallengeModifier

func SetChallengeDeletionTimestamp

func SetChallengeDeletionTimestamp(ts metav1.Time) ChallengeModifier

func SetChallengeFinalizers

func SetChallengeFinalizers(finalizers []string) ChallengeModifier

func SetChallengeIssuer

func SetChallengeIssuer(o cmmeta.ObjectReference) ChallengeModifier

SetIssuer sets the challenge.spec.issuerRef field

func SetChallengeKey

func SetChallengeKey(k string) ChallengeModifier

func SetChallengeNamespace

func SetChallengeNamespace(ns string) ChallengeModifier

func SetChallengePresented

func SetChallengePresented(p bool) ChallengeModifier

func SetChallengeProcessing

func SetChallengeProcessing(b bool) ChallengeModifier

func SetChallengeReason

func SetChallengeReason(s string) ChallengeModifier

func SetChallengeState

func SetChallengeState(s cmacme.State) ChallengeModifier

func SetChallengeToken

func SetChallengeToken(t string) ChallengeModifier

func SetChallengeURL

func SetChallengeURL(s string) ChallengeModifier

func SetChallengeWildcard

func SetChallengeWildcard(p bool) ChallengeModifier

type IssuerConditionModifier

type IssuerConditionModifier func(*v1.IssuerCondition)

func SetIssuerConditionLastTransitionTime

func SetIssuerConditionLastTransitionTime(t *metav1.Time) IssuerConditionModifier

func SetIssuerConditionMessage

func SetIssuerConditionMessage(s string) IssuerConditionModifier

func SetIssuerConditionReason

func SetIssuerConditionReason(s string) IssuerConditionModifier

type IssuerModifier

type IssuerModifier func(v1.GenericIssuer)

func AddIssuerCondition

func AddIssuerCondition(c v1.IssuerCondition) IssuerModifier

func SetIssuerACME

func SetIssuerACME(a cmacme.ACMEIssuer) IssuerModifier

func SetIssuerACMEAccountURL

func SetIssuerACMEAccountURL(url string) IssuerModifier

func SetIssuerACMEDisableAccountKeyGeneration

func SetIssuerACMEDisableAccountKeyGeneration(disabled bool) IssuerModifier

func SetIssuerACMEDuration

func SetIssuerACMEDuration(enabled bool) IssuerModifier

func SetIssuerACMEEAB

func SetIssuerACMEEAB(keyID, secretName string) IssuerModifier

func SetIssuerACMEEABWithKeyAlgorithm

func SetIssuerACMEEABWithKeyAlgorithm(keyID, secretName string, keyAlgorithm cmacme.HMACKeyAlgorithm) IssuerModifier

SetIssuerACMEEABWithKeyAlgorithm returns an ACME Issuer modifier that sets ACME External Account Binding with the legacy keyAlgorithm field set.

func SetIssuerACMEEmail

func SetIssuerACMEEmail(email string) IssuerModifier

func SetIssuerACMELastPrivateKeyHash

func SetIssuerACMELastPrivateKeyHash(privateKeyHash string) IssuerModifier

func SetIssuerACMELastRegisteredEmail

func SetIssuerACMELastRegisteredEmail(email string) IssuerModifier

func SetIssuerACMEPreferredChain

func SetIssuerACMEPreferredChain(chain string) IssuerModifier

func SetIssuerACMEPrivKeyRef

func SetIssuerACMEPrivKeyRef(privateKeyName string) IssuerModifier

func SetIssuerACMESkipTLSVerify

func SetIssuerACMESkipTLSVerify(shouldSkip bool) IssuerModifier

func SetIssuerACMESolvers

func SetIssuerACMESolvers(solvers []cmacme.ACMEChallengeSolver) IssuerModifier

func SetIssuerACMEURL

func SetIssuerACMEURL(url string) IssuerModifier

func SetIssuerCA

func SetIssuerCA(a v1.CAIssuer) IssuerModifier

func SetIssuerCASecretName

func SetIssuerCASecretName(secretName string) IssuerModifier

func SetIssuerNamespace

func SetIssuerNamespace(namespace string) IssuerModifier

func SetIssuerSelfSigned

func SetIssuerSelfSigned(a v1.SelfSignedIssuer) IssuerModifier

func SetIssuerVault

func SetIssuerVault(v v1.VaultIssuer) IssuerModifier

func SetIssuerVaultAppRoleAuth

func SetIssuerVaultAppRoleAuth(keyName, approleName, roleId, path string) IssuerModifier

func SetIssuerVaultCABundle

func SetIssuerVaultCABundle(caBundle []byte) IssuerModifier

func SetIssuerVaultCABundleSecretRef

func SetIssuerVaultCABundleSecretRef(name, namespace, key string) IssuerModifier

func SetIssuerVaultClientCertSecretRef

func SetIssuerVaultClientCertSecretRef(vaultClientCertificateSecretName, key string) IssuerModifier

func SetIssuerVaultClientCertificateAuth

func SetIssuerVaultClientCertificateAuth(path, secretName string) IssuerModifier

func SetIssuerVaultClientKeySecretRef

func SetIssuerVaultClientKeySecretRef(vaultClientCertificateSecretName, key string) IssuerModifier

func SetIssuerVaultKubernetesAuthSecret

func SetIssuerVaultKubernetesAuthSecret(secretKey, secretName, vaultRole, vaultPath string) IssuerModifier

func SetIssuerVaultKubernetesAuthServiceAccount

func SetIssuerVaultKubernetesAuthServiceAccount(serviceAccount, role, path string) IssuerModifier

func SetIssuerVaultPath

func SetIssuerVaultPath(path string) IssuerModifier

func SetIssuerVaultTokenAuth

func SetIssuerVaultTokenAuth(keyName, tokenName string) IssuerModifier

func SetIssuerVaultURL

func SetIssuerVaultURL(url string) IssuerModifier

func SetIssuerVenafi

func SetIssuerVenafi(a v1.VenafiIssuer) IssuerModifier

type ObjectMetaModifier

type ObjectMetaModifier func(*metav1.ObjectMeta)

ObjectMetaModifier applies a transformation to the provider ObjectMeta

type OrderModifier

type OrderModifier func(*cmacme.Order)

func SetOrderAnnotations

func SetOrderAnnotations(annotations map[string]string) OrderModifier

func SetOrderCertificate

func SetOrderCertificate(d []byte) OrderModifier

func SetOrderCommonName

func SetOrderCommonName(commonName string) OrderModifier

func SetOrderCsr

func SetOrderCsr(csr []byte) OrderModifier

func SetOrderDNSNames

func SetOrderDNSNames(dnsNames ...string) OrderModifier

func SetOrderDuration

func SetOrderDuration(duration time.Duration) OrderModifier

func SetOrderIPAddresses

func SetOrderIPAddresses(ips ...string) OrderModifier

func SetOrderIssuer

func SetOrderIssuer(o cmmeta.ObjectReference) OrderModifier

SetIssuer sets the Order.spec.issuerRef field

func SetOrderNamespace

func SetOrderNamespace(namespace string) OrderModifier

func SetOrderOwnerReference

func SetOrderOwnerReference(ref metav1.OwnerReference) OrderModifier

func SetOrderReason

func SetOrderReason(reason string) OrderModifier

func SetOrderState

func SetOrderState(s cmacme.State) OrderModifier

func SetOrderStatus

func SetOrderStatus(s cmacme.OrderStatus) OrderModifier

func SetOrderURL

func SetOrderURL(url string) OrderModifier

type SecretModifier

type SecretModifier func(*corev1.Secret)

func SetSecretAnnotations

func SetSecretAnnotations(an map[string]string) SecretModifier

func SetSecretData

func SetSecretData(data map[string][]byte) SecretModifier

func SetSecretNamespace

func SetSecretNamespace(namespace string) SecretModifier

Jump to

Keyboard shortcuts

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