utils

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrPatchObject added in v0.1.4

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

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

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

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 []cicdv1.ApprovalUser) []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