gen

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

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 added in v1.8.0

func CSR(keyAlgorithm x509.PublicKeyAlgorithm, mods ...CSRModifier) (csr []byte, sk crypto.Signer, 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 added in v1.8.0

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 added in v1.8.0

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

func CertificateRequestFrom added in v1.8.0

func CertificateRequestFrom(cr *v1.CertificateRequest, mods ...CertificateRequestModifier) *v1.CertificateRequest

func CertificateSigningRequest added in v1.8.0

func CertificateSigningRequest(name string, mods ...CertificateSigningRequestModifier) *certificatesv1.CertificateSigningRequest

func CertificateSigningRequestWithRandomName added in v1.8.0

func CertificateSigningRequestWithRandomName(prefix string, mods ...CertificateSigningRequestModifier) *certificatesv1.CertificateSigningRequest

func Challenge

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

func ChallengeFrom

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

func ClusterIssuer added in v0.6.0

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

func ClusterIssuerFrom added in v0.6.0

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

func ClusterIssuerWithRandomName added in v1.8.0

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 IssuerCondition added in v1.8.0

func IssuerConditionFrom added in v1.8.0

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

func IssuerFrom

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

func IssuerWithRandomName added in v1.8.0

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 added in v1.8.0

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

func OrderFrom added in v1.8.0

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

func Secret added in v1.8.0

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

func SecretFrom added in v1.8.0

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

Types

type CSRModifier added in v1.8.0

type CSRModifier func(*x509.CertificateRequest)

func SetCSRCommonName added in v1.8.0

func SetCSRCommonName(commonName string) CSRModifier

func SetCSRDNSNames added in v1.8.0

func SetCSRDNSNames(dnsNames ...string) CSRModifier

func SetCSREmails added in v1.8.0

func SetCSREmails(emails []string) CSRModifier

func SetCSRIPAddresses added in v1.8.0

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

func SetCSRURIs added in v1.8.0

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

type CertificateModifier

type CertificateModifier func(*v1.Certificate)

func AddCertificateAnnotations added in v1.8.0

func AddCertificateAnnotations(annotations map[string]string) CertificateModifier

func AddCertificateLabels added in v1.8.0

func AddCertificateLabels(labels map[string]string) CertificateModifier

func SetCertificateAdditionalOutputFormats added in v1.8.0

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

func SetCertificateCommonName

func SetCertificateCommonName(commonName string) CertificateModifier

func SetCertificateDNSNames

func SetCertificateDNSNames(dnsNames ...string) CertificateModifier

func SetCertificateDuration added in v1.8.0

func SetCertificateDuration(duration time.Duration) CertificateModifier

func SetCertificateEmails added in v1.8.0

func SetCertificateEmails(emails ...string) CertificateModifier

func SetCertificateGeneration added in v1.8.0

func SetCertificateGeneration(gen int64) CertificateModifier

func SetCertificateIPs added in v1.8.0

func SetCertificateIPs(ips ...string) CertificateModifier

func SetCertificateIsCA

func SetCertificateIsCA(isCA bool) CertificateModifier

func SetCertificateIssuanceAttempts added in v1.8.0

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 added in v1.8.0

func SetCertificateKeyEncoding(keyEncoding v1.PrivateKeyEncoding) CertificateModifier

func SetCertificateKeySize

func SetCertificateKeySize(keySize int) CertificateModifier

func SetCertificateKeyUsages added in v1.8.0

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

func SetCertificateLastFailureTime

func SetCertificateLastFailureTime(p metav1.Time) CertificateModifier

func SetCertificateNamespace added in v1.8.0

func SetCertificateNamespace(namespace string) CertificateModifier

func SetCertificateNextPrivateKeySecretName added in v1.8.0

func SetCertificateNextPrivateKeySecretName(name string) CertificateModifier

func SetCertificateNotAfter added in v0.7.0

func SetCertificateNotAfter(p metav1.Time) CertificateModifier

func SetCertificateNotBefore added in v1.8.0

func SetCertificateNotBefore(p metav1.Time) CertificateModifier

func SetCertificateOrganization added in v0.7.0

func SetCertificateOrganization(orgs ...string) CertificateModifier

func SetCertificateRenewBefore added in v1.8.0

func SetCertificateRenewBefore(renewBefore time.Duration) CertificateModifier

func SetCertificateRenewalTime added in v1.8.0

func SetCertificateRenewalTime(p metav1.Time) CertificateModifier

func SetCertificateRevision added in v1.8.0

func SetCertificateRevision(revision int) CertificateModifier

func SetCertificateRevisionHistoryLimit added in v1.8.0

func SetCertificateRevisionHistoryLimit(limit int32) CertificateModifier

func SetCertificateSecretName

func SetCertificateSecretName(secretName string) CertificateModifier

func SetCertificateSecretTemplate added in v1.8.0

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

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

func SetCertificateStatusCondition added in v0.7.0

func SetCertificateStatusCondition(c v1.CertificateCondition) CertificateModifier

func SetCertificateUID added in v1.8.0

func SetCertificateUID(uid types.UID) CertificateModifier

func SetCertificateURIs added in v1.8.0

func SetCertificateURIs(uris ...string) CertificateModifier

type CertificateRequestModifier added in v1.8.0

type CertificateRequestModifier func(*v1.CertificateRequest)

func AddCertificateRequestAnnotations added in v1.8.0

func AddCertificateRequestAnnotations(annotations map[string]string) CertificateRequestModifier

func AddCertificateRequestOwnerReferences added in v1.8.0

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

func AddCertificateRequestStatusCondition added in v1.8.0

func AddCertificateRequestStatusCondition(c v1.CertificateRequestCondition) CertificateRequestModifier

func DeleteCertificateRequestAnnotation added in v1.8.0

func DeleteCertificateRequestAnnotation(key string) CertificateRequestModifier

func SetCertificateRequestAnnotations added in v1.8.0

func SetCertificateRequestAnnotations(annotations map[string]string) CertificateRequestModifier

func SetCertificateRequestCA added in v1.8.0

func SetCertificateRequestCA(ca []byte) CertificateRequestModifier

func SetCertificateRequestCSR added in v1.8.0

func SetCertificateRequestCSR(csr []byte) CertificateRequestModifier

func SetCertificateRequestCertificate added in v1.8.0

func SetCertificateRequestCertificate(cert []byte) CertificateRequestModifier

func SetCertificateRequestDuration added in v1.8.0

func SetCertificateRequestDuration(duration *metav1.Duration) CertificateRequestModifier

func SetCertificateRequestFailureTime added in v1.8.0

func SetCertificateRequestFailureTime(p metav1.Time) CertificateRequestModifier

func SetCertificateRequestGroups added in v1.8.0

func SetCertificateRequestGroups(groups []string) CertificateRequestModifier

func SetCertificateRequestIsCA added in v1.8.0

func SetCertificateRequestIsCA(isCA bool) CertificateRequestModifier

func SetCertificateRequestIssuer added in v1.8.0

func SetCertificateRequestIssuer(o cmmeta.ObjectReference) CertificateRequestModifier

SetIssuer sets the CertificateRequest.spec.issuerRef field

func SetCertificateRequestKeyUsages added in v1.8.0

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

func SetCertificateRequestName added in v1.8.0

func SetCertificateRequestName(name string) CertificateRequestModifier

func SetCertificateRequestNamespace added in v1.8.0

func SetCertificateRequestNamespace(namespace string) CertificateRequestModifier

func SetCertificateRequestRevision added in v1.8.0

func SetCertificateRequestRevision(rev string) CertificateRequestModifier

func SetCertificateRequestStatusCondition added in v1.8.0

func SetCertificateRequestStatusCondition(c v1.CertificateRequestCondition) CertificateRequestModifier

func SetCertificateRequestTypeMeta added in v1.8.0

func SetCertificateRequestTypeMeta(tm metav1.TypeMeta) CertificateRequestModifier

func SetCertificateRequestUsername added in v1.8.0

func SetCertificateRequestUsername(username string) CertificateRequestModifier

type CertificateSigningRequestModifier added in v1.8.0

type CertificateSigningRequestModifier func(*certificatesv1.CertificateSigningRequest)

func AddCertificateSigningRequestAnnotations added in v1.8.0

func AddCertificateSigningRequestAnnotations(annotations map[string]string) CertificateSigningRequestModifier

func SetCertificateSigningRequestCertificate added in v1.8.0

func SetCertificateSigningRequestCertificate(cert []byte) CertificateSigningRequestModifier

func SetCertificateSigningRequestDuration added in v1.8.0

func SetCertificateSigningRequestDuration(duration string) CertificateSigningRequestModifier

func SetCertificateSigningRequestExpirationSeconds added in v1.8.0

func SetCertificateSigningRequestExpirationSeconds(seconds int32) CertificateSigningRequestModifier

func SetCertificateSigningRequestExtra added in v1.8.0

func SetCertificateSigningRequestExtra(extra map[string]certificatesv1.ExtraValue) CertificateSigningRequestModifier

func SetCertificateSigningRequestGroups added in v1.8.0

func SetCertificateSigningRequestGroups(groups []string) CertificateSigningRequestModifier

func SetCertificateSigningRequestIsCA added in v1.8.0

func SetCertificateSigningRequestIsCA(isCA bool) CertificateSigningRequestModifier

func SetCertificateSigningRequestRequest added in v1.8.0

func SetCertificateSigningRequestRequest(request []byte) CertificateSigningRequestModifier

func SetCertificateSigningRequestSignerName added in v1.8.0

func SetCertificateSigningRequestSignerName(signerName string) CertificateSigningRequestModifier

func SetCertificateSigningRequestUID added in v1.8.0

func SetCertificateSigningRequestUID(uid string) CertificateSigningRequestModifier

func SetCertificateSigningRequestUsages added in v1.8.0

func SetCertificateSigningRequestUsages(usages []certificatesv1.KeyUsage) CertificateSigningRequestModifier

func SetCertificateSigningRequestUsername added in v1.8.0

func SetCertificateSigningRequestUsername(username string) CertificateSigningRequestModifier

type ChallengeModifier

type ChallengeModifier func(*cmacme.Challenge)

func SetChallengeDNSName

func SetChallengeDNSName(dnsName string) ChallengeModifier

func SetChallengeIssuer

func SetChallengeIssuer(o cmmeta.ObjectReference) ChallengeModifier

SetIssuer sets the challenge.spec.issuerRef field

func SetChallengeNamespace added in v1.8.0

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 added in v1.8.0

func SetChallengeToken(t string) ChallengeModifier

func SetChallengeURL

func SetChallengeURL(s string) ChallengeModifier

func SetChallengeWildcard added in v0.6.0

func SetChallengeWildcard(p bool) ChallengeModifier

type IssuerConditionModifier added in v1.8.0

type IssuerConditionModifier func(*v1.IssuerCondition)

func SetIssuerConditionLastTransitionTime added in v1.8.0

func SetIssuerConditionLastTransitionTime(t *metav1.Time) IssuerConditionModifier

func SetIssuerConditionMessage added in v1.8.0

func SetIssuerConditionMessage(s string) IssuerConditionModifier

func SetIssuerConditionReason added in v1.8.0

func SetIssuerConditionReason(s string) IssuerConditionModifier

func SetIssuerConditionStatus added in v1.8.0

func SetIssuerConditionStatus(s cmmeta.ConditionStatus) 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 added in v1.8.0

func SetIssuerACMEAccountURL(url string) IssuerModifier

func SetIssuerACMEDisableAccountKeyGeneration added in v1.8.0

func SetIssuerACMEDisableAccountKeyGeneration(disabled bool) IssuerModifier

func SetIssuerACMEDuration added in v1.8.0

func SetIssuerACMEDuration(enabled bool) IssuerModifier

func SetIssuerACMEEAB added in v1.8.0

func SetIssuerACMEEAB(keyID, secretName string) IssuerModifier

func SetIssuerACMEEABWithKeyAlgorithm added in v1.8.0

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 added in v1.8.0

func SetIssuerACMEEmail(email string) IssuerModifier

func SetIssuerACMELastRegisteredEmail added in v1.8.0

func SetIssuerACMELastRegisteredEmail(email string) IssuerModifier

func SetIssuerACMEPrivKeyRef added in v1.8.0

func SetIssuerACMEPrivKeyRef(privateKeyName string) IssuerModifier

func SetIssuerACMESkipTLSVerify added in v1.8.0

func SetIssuerACMESkipTLSVerify(shouldSkip bool) IssuerModifier

func SetIssuerACMESolvers added in v1.8.0

func SetIssuerACMESolvers(solvers []cmacme.ACMEChallengeSolver) IssuerModifier

func SetIssuerACMEURL added in v1.8.0

func SetIssuerACMEURL(url string) IssuerModifier

func SetIssuerCA

func SetIssuerCA(a v1.CAIssuer) IssuerModifier

func SetIssuerCASecretName added in v1.8.0

func SetIssuerCASecretName(secretName string) IssuerModifier

func SetIssuerNamespace added in v1.8.0

func SetIssuerNamespace(namespace string) IssuerModifier

func SetIssuerSelfSigned

func SetIssuerSelfSigned(a v1.SelfSignedIssuer) IssuerModifier

func SetIssuerVault added in v1.8.0

func SetIssuerVault(v v1.VaultIssuer) IssuerModifier

func SetIssuerVaultAppRoleAuth added in v1.8.0

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

func SetIssuerVaultCABundle added in v1.8.0

func SetIssuerVaultCABundle(caBundle []byte) IssuerModifier

func SetIssuerVaultKubernetesAuth added in v1.8.0

func SetIssuerVaultKubernetesAuth(keyName, secretServiceAccount, role, path string) IssuerModifier

func SetIssuerVaultPath added in v1.8.0

func SetIssuerVaultPath(path string) IssuerModifier

func SetIssuerVaultTokenAuth added in v1.8.0

func SetIssuerVaultTokenAuth(keyName, tokenName string) IssuerModifier

func SetIssuerVaultURL added in v1.8.0

func SetIssuerVaultURL(url string) IssuerModifier

func SetIssuerVenafi added in v1.8.0

func SetIssuerVenafi(a v1.VenafiIssuer) IssuerModifier

type ObjectMetaModifier

type ObjectMetaModifier func(*metav1.ObjectMeta)

ObjectMetaModifier applies a transformation to the provider ObjectMeta

type OrderModifier added in v1.8.0

type OrderModifier func(*cmacme.Order)

func SetOrderAnnotations added in v1.8.0

func SetOrderAnnotations(annotations map[string]string) OrderModifier

func SetOrderCertificate added in v1.8.0

func SetOrderCertificate(d []byte) OrderModifier

func SetOrderCommonName added in v1.8.0

func SetOrderCommonName(commonName string) OrderModifier

func SetOrderCsr added in v1.8.0

func SetOrderCsr(csr []byte) OrderModifier

func SetOrderDNSNames added in v1.8.0

func SetOrderDNSNames(dnsNames ...string) OrderModifier

func SetOrderDuration added in v1.8.0

func SetOrderDuration(duration time.Duration) OrderModifier

func SetOrderIPAddresses added in v1.8.0

func SetOrderIPAddresses(ips ...string) OrderModifier

func SetOrderIssuer added in v1.8.0

func SetOrderIssuer(o cmmeta.ObjectReference) OrderModifier

SetIssuer sets the Order.spec.issuerRef field

func SetOrderNamespace added in v1.8.0

func SetOrderNamespace(namespace string) OrderModifier

func SetOrderOwnerReference added in v1.8.0

func SetOrderOwnerReference(ref metav1.OwnerReference) OrderModifier

func SetOrderReason added in v1.8.0

func SetOrderReason(reason string) OrderModifier

func SetOrderState added in v1.8.0

func SetOrderState(s cmacme.State) OrderModifier

func SetOrderStatus added in v1.8.0

func SetOrderStatus(s cmacme.OrderStatus) OrderModifier

func SetOrderURL added in v1.8.0

func SetOrderURL(url string) OrderModifier

type SecretModifier added in v1.8.0

type SecretModifier func(*corev1.Secret)

func SetSecretAnnotations added in v1.8.0

func SetSecretAnnotations(an map[string]string) SecretModifier

func SetSecretData added in v1.8.0

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

func SetSecretNamespace added in v1.8.0

func SetSecretNamespace(namespace string) SecretModifier

Jump to

Keyboard shortcuts

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