Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
- func GetAdmissionName() (string, error)
- func GetAdmissionReference() (*metav1.OwnerReference, error)
- func GetSecret(namespace string, secretName string) (*corev1.Secret, error)
- func GetValidatorWebhook(validator string) (*v1.ValidatingWebhookConfiguration, error)
- func InitValidationServer(ownerReference metav1.OwnerReference) error
- func New(p Parameters, kubeClient kubernetes.Interface, ...) (*webhook, error)
- func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, ...) (*x509.Certificate, error)
- func StrPtr(s string) *string
- type AdmissionResponse
- type KeyPair
- type Parameters
Constants ¶
const ( // PrivateKeyBlockType is a possible value for pem.Block.Type. PrivateKeyBlockType = "PRIVATE KEY" // PublicKeyBlockType is a possible value for pem.Block.Type. PublicKeyBlockType = "PUBLIC KEY" // CertificateBlockType is a possible value for pem.Block.Type. CertificateBlockType = "CERTIFICATE" // RSAPrivateKeyBlockType is a possible value for pem.Block.Type. RSAPrivateKeyBlockType = "RSA PRIVATE KEY" )
const ( // AdmissionNameEnvVar is the constant for env variable ADMISSION_WEBHOOK_NAME // which is the name of the current admission webhook AdmissionNameEnvVar = "ADMISSION_WEBHOOK_NAME" )
Variables ¶
var ( // Ignore means that an error calling the webhook is ignored. Ignore = v1.Ignore // Fail means that an error calling the webhook causes the admission to fail. Fail = v1.Fail // SideEffectClassNone means that calling the webhook will have no side effects. SideEffectClassNone = v1.SideEffectClassNone // WebhookFailurePolicye represents failure policy env name to make it configurable // via ENV WebhookFailurePolicy = "ADMISSION_WEBHOOK_FAILURE_POLICY" )
var DefaultEllipticCurve = elliptic.P256()
DefaultEllipticCurve specifies the default elliptic curve to be used for key generation
Functions ¶
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM returns PEM-endcoded certificate data
func EncodePrivateKeyPEM ¶
func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
EncodePrivateKeyPEM returns PEM-encoded private key data
func GetAdmissionName ¶
GetAdmissionName return the admission server name
func GetAdmissionReference ¶
func GetAdmissionReference() (*metav1.OwnerReference, error)
GetAdmissionReference is a utility function to fetch a reference to the admission webhook deployment object
func GetValidatorWebhook ¶
func GetValidatorWebhook( validator string, ) (*v1.ValidatingWebhookConfiguration, error)
GetValidatorWebhook fetches the webhook validator resource in Openebs namespace.
func InitValidationServer ¶
func InitValidationServer( ownerReference metav1.OwnerReference, ) error
InitValidationServer creates secret, service and admission validation k8s resources. All these resources are created in the same namespace where openebs components is running.
func New ¶
func New(p Parameters, kubeClient kubernetes.Interface, openebsClient clientset.Interface, snapClient snapclient.Interface, ndmClient ndmclientset.Interface) ( *webhook, error)
New creates a new instance of a webhook. Prior to invoking this function, InitValidationServer function must be called to set up secret (for TLS certs) k8s resource. This function runs forever.
func NewSignedCert ¶
func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)
NewSignedCert creates a signed certificate using the given CA certificate and key
Types ¶
type AdmissionResponse ¶
type AdmissionResponse struct {
AR *v1.AdmissionResponse
}
AdmissionResponse embeds K8S admission response API.
func BuildForAPIObject ¶
func BuildForAPIObject(ar *v1.AdmissionResponse) *AdmissionResponse
BuildForAPIObject builds for api admission response object.
func NewAdmissionResponse ¶
func NewAdmissionResponse() *AdmissionResponse
NewAdmissionResponse returns an empty instance of AdmissionResponse.
func (*AdmissionResponse) SetAllowed ¶
func (ar *AdmissionResponse) SetAllowed() *AdmissionResponse
SetAllowed sets allowed to true.
func (*AdmissionResponse) UnSetAllowed ¶
func (ar *AdmissionResponse) UnSetAllowed() *AdmissionResponse
UnSetAllowed sets allowed to false.
func (*AdmissionResponse) WithResultAsFailure ¶
func (ar *AdmissionResponse) WithResultAsFailure(err error, code int32) *AdmissionResponse
WithResultAsFailure sets failure result.
func (*AdmissionResponse) WithResultAsSuccess ¶
func (ar *AdmissionResponse) WithResultAsSuccess(code int32) *AdmissionResponse
WithResultAsSuccess sets success result.
type KeyPair ¶
type KeyPair struct { Key *rsa.PrivateKey Cert *x509.Certificate }
KeyPair ...
func NewClientKeyPair ¶
NewClientKeyPair ...
type Parameters ¶
type Parameters struct { // Port is webhook server port Port int //CertFile is path to the x509 certificate for https CertFile string //KeyFile is path to the x509 private key matching `CertFile` KeyFile string }
Parameters are server configures parameters