utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCHEME_HTTP_PREFIX  = "http://"
	SCHEME_HTTPS_PREFIX = "https://"
)
View Source
const (
	ContentTypeBinary = "application/octet-stream"
	ContentTypeForm   = "application/x-www-form-urlencoded"
	ContentTypeJSON   = "application/json"
	ContentTypeHTML   = "text/html; charset=utf-8"
	ContentTypeText   = "text/plain; charset=utf-8"
)

Variables

This section is empty.

Functions

func AddQueryParams

func AddQueryParams(url string, params map[string][]string) string

func BuildServiceHostname

func BuildServiceHostname(name, namespace string) string

func CheckAndCreateObject

func CheckAndCreateObject(client client.Client, namespacedName types.NamespacedName, obj runtime.Object) error

func Client

func Client(options client.Options) (client.Client, error)

func Contains

func Contains(arr []string, str string) bool

func DecodeBasicAuth

func DecodeBasicAuth(basic string) (username, password string)

DecodeBasicAuth decode and splits username and password from basic auth string

func DiffKeyList

func DiffKeyList(diffList []Diff) []string

func EncryptBasicAuth

func EncryptBasicAuth(username, password string) string

EncryptBasicAuth encrypt username and password by base64

func FileExists

func FileExists(path string) bool

func GetBasicAuth

func GetBasicAuth(imagePullSecret, namespace, registryURL string) (string, error)

GetBasicAuth returns `username:password` as string encrypted by base64 from imagePullSecghret

func GetCAData

func GetCAData(secretName, namespace string) ([]byte, error)

GetCAData returns ca

func GetCondition added in v0.3.2

func GetCondition(obj interface{}, conditionType status.ConditionType) *status.Condition

func GetRegistryLogger

func GetRegistryLogger(subresource interface{}, resNamespace, resName string) logr.Logger

[TODO] API is not worked well

func GetSecret

func GetSecret(name, namespace string) (*corev1.Secret, error)

GetSecret returns secret if found

func HTTPEncodeBasicAuth

func HTTPEncodeBasicAuth(username, password string) string

HTTPEncodeBasicAuth encodes basic auth string by base64

func Matched

func Matched(pattern string, image string) bool

func Namespace

func Namespace() (string, error)

func OperatorServiceName

func OperatorServiceName() string

func ParseBasicAuth

func ParseBasicAuth(sec *corev1.Secret, host string) (string, error)

ParseBasicAuth returns `username:password` as string encrypted by base64

func ParseImageName

func ParseImageName(imageName string) string

func RandomString

func RandomString(length int) string

RandomString generate random string with lower case alphabets and digits

func RemovePemBlock

func RemovePemBlock(data []byte, blockType string) []byte

func RespondError

func RespondError(w http.ResponseWriter, code int, msg string) error

func RespondJSON

func RespondJSON(w http.ResponseWriter, data interface{}) error

func SetCondition

func SetCondition(error error, patch interface{}, condition *status.Condition)

SetCondition sets a condition of patch status

func SetErrorConditionIfChanged added in v0.3.2

func SetErrorConditionIfChanged(target, origin interface{}, condition *status.Condition, err error)

SetErrorConditionIfChanged sets target's condition If target's condition, origin's condition and condtion is same, don't set target's condition If not, set target's condition

func TrimHTTPScheme added in v0.3.0

func TrimHTTPScheme(url string) string

TrimHTTPScheme trims 'http://' or 'https://' prefix in the url

Types

type CertPair

type CertPair struct {
	ParentCert *x509.Certificate
	ParentKey  *rsa.PrivateKey

	Template *x509.Certificate
	Key      *rsa.PrivateKey

	X509CertData []byte
}

func NewCertPair

func NewCertPair(key *rsa.PrivateKey, isCA bool) (*CertPair, error)

func (*CertPair) CertDataToPem

func (c *CertPair) CertDataToPem() ([]byte, error)

func (*CertPair) CreateCertificateData

func (c *CertPair) CreateCertificateData() error

func (*CertPair) KeyToPem

func (c *CertPair) KeyToPem() ([]byte, error)

func (*CertPair) SetParent

func (c *CertPair) SetParent(cert *x509.Certificate, key *rsa.PrivateKey)

func (*CertPair) SetSubject

func (c *CertPair) SetSubject(subject *pkix.Name)

func (*CertPair) SetSubjectAltName

func (c *CertPair) SetSubjectAltName(ips []net.IP, domains []string)

type Diff

type Diff struct {
	Type  DiffType
	Key   string
	Value interface{}
}

type DiffType

type DiffType string
const (
	Add     DiffType = "Add"
	Replace DiffType = "Replace"
	Remove  DiffType = "Remove"
)

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type Patcher

type Patcher struct {
	PatchType types.PatchType
	DataBytes []byte
}

func (*Patcher) Data

func (p *Patcher) Data(obj runtime.Object) ([]byte, error)

func (*Patcher) Type

func (p *Patcher) Type() types.PatchType

type RegistryLogger

type RegistryLogger struct {
	// contains filtered or unexported fields
}

func NewRegistryLogger

func NewRegistryLogger(subresource interface{}, resNamespace, resName string) *RegistryLogger

func (*RegistryLogger) Error

func (r *RegistryLogger) Error(err error, msg string, keysAndValues ...interface{})

func (*RegistryLogger) Info

func (r *RegistryLogger) Info(msg string, keysAndValues ...interface{})

Directories

Path Synopsis
k8s

Jump to

Keyboard shortcuts

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