utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthClient

func AuthClient() (*authorization.AuthorizationV1Client, error)

AuthClient is a K8s client for Authorization

func Client

func Client(scheme *runtime.Scheme) (client.Client, error)

Client is a k8s client

func CreateOrPatchObject added in v0.1.4

func CreateOrPatchObject(obj, original, parent runtime.Object, cli client.Client, scheme *runtime.Scheme) error

CreateOrPatchObject patches the object if it exists, and creates one if not

func FileExists

func FileExists(path string) bool

FileExists checks if the file exists in path

func GetGitCli

func GetGitCli(cfg *cicdv1.IntegrationConfig, cli client.Client) (git.Client, error)

GetGitCli generates git client, depending on the git type in the cfg

func Namespace

func Namespace() (string, error)

Namespace can retrieve current namespace

func ParseApproversList

func ParseApproversList(str string) ([]string, error)

ParseApproversList parses user/email from line-separated and comma-separated approvers list

func ParseEmailFromUsers

func ParseEmailFromUsers(users []string) []string

ParseEmailFromUsers parses email from approvers list

func RandomString

func RandomString(length int) string

RandomString generate random string with lower case alphabets and digits

func RespondError

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

RespondError responds to a HTTP request with body of ErrorResponse

func RespondJSON

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

RespondJSON responds with arbitrary data objects

Types

type ErrorResponse

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

ErrorResponse is a common struct for responding error for HTTP requests

type RestClient added in v0.4.0

type RestClient interface {
	Get(name string, getOpt *metav1.GetOptions, into runtime.Object) error
	List(listOpt *metav1.ListOptions, into runtime.Object) error
	Watch(listOpt *metav1.ListOptions) (watch.Interface, error)
	Create(obj runtime.Object, createOpt *metav1.CreateOptions) error
	Update(obj runtime.Object, opts *metav1.UpdateOptions) error
	Delete(name string, opt *metav1.DeleteOptions) error
}

RestClient is a group-version-resource specific rest client

func NewGroupVersionResourceClient added in v0.4.0

func NewGroupVersionResourceClient(cfg *rest.Config, ns string, groupVersionResource schema.GroupVersionResource) (RestClient, error)

NewGroupVersionResourceClient creates a new group-version-resource specific rest client

Jump to

Keyboard shortcuts

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