utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 19 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

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(app *cdv1.Application, cli client.Client) (git.Client, error)

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

func Namespace

func Namespace() (string, error)

Namespace can retrieve current namespace

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

Jump to

Keyboard shortcuts

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