common

package
v0.0.0-...-432d548 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfStarAgentSidecar = "staragent-sidecar"
	ConfInterposeObject  = "interpose"
	ConfSkylineAPI       = "skyline-api"
	ConfSkylineDefault   = "skyline-default"
	// in corev1.Container format
	ConfSkylineInitContainer  = "skyline-container-template"
	ConfFiberBoxIdMapping     = "fiber-box-id-mapping"
	ConfFiberBox              = "fiber-box-config"
	ConfPoolMetaCopy          = "pool-meta-copy"
	ConfFiberZkRoot           = "fiber-zk-root"
	ConfServerlessTweaks      = "serverless-tweaks"
	ConfRollingsetTweaks      = "rollingset-tweaks"
	ConfProxyCopyLabels       = "proxy-copy-labels"
	ConfVipserverEnvInterpose = "vipserver-env-interpose"
	ConfNonVersionedKeys      = "non-versioned-keys"
)

all config keys

View Source
var (
	// HealthCheckPath HealthCheckPath
	HealthCheckPath = "/status.html"
)

Functions

func AddToUniqueSlice

func AddToUniqueSlice(src string, to []string) []string

AddToUniqueSlice add a string to slice unique

func CorrecteShellExpr

func CorrecteShellExpr(src string) string

CorrecteShellExpr CorrecteShellExpr

func DeleteFromSlice

func DeleteFromSlice(src string, from []string) []string

DeleteFromSlice delete a string from slice

func GetBatcherTimeout

func GetBatcherTimeout(defaultValue time.Duration) time.Duration

GetBatcherTimeout get batcher time out from env / args

func GetCommonID

func GetCommonID() string

GetCommonID 通用id

func GetEnvWithDefault

func GetEnvWithDefault(defaultValue, envkey string) string

GetEnvWithDefault get env if default is nil

func GetGlobalConfigJSON

func GetGlobalConfigJSON(confKey, namespace string, obj interface{}) error

GetGlobalConfigJSON get json config

func GetGlobalConfigVal

func GetGlobalConfigVal(confKey, namespace string) (string, error)

GetGlobalConfigVal get config value, `namespace` is optional

func GetGlobalConfigValForObj

func GetGlobalConfigValForObj(confKey string, kind string, object metav1.Object) (string, error)

GetGlobalConfigValForObj get interposed object config

func GetRequestID

func GetRequestID() string

GetRequestID 请求id

func HealthCheck

func HealthCheck(w http.ResponseWriter, r *http.Request)

HealthCheck HealthCheck

func InitFlags

func InitFlags(flagset *pflag.FlagSet)

InitFlags is for explicitly initializing the flags.

func InitGlobalKubeConfiger

func InitGlobalKubeConfiger(namespace string, kubeClient clientset.Interface, stopCh <-chan struct{}) error

InitGlobalKubeConfiger initializes the configer

func IsInterfaceNil

func IsInterfaceNil(i interface{}) bool

IsInterfaceNil IsInterfaceNil

func ProxyTo

func ProxyTo(req *restful.Request, responseWriter http.ResponseWriter, host string) (int, error)

ProxyTo proxies the request to the host's server directly. It tries its best to keep the origal data from host's server.

func QueryParameter

func QueryParameter(req *http.Request, paramName string) string

QueryParameter QueryParameter

func SetGlobalConfiger

func SetGlobalConfiger(c config.Configer, ns string)

SetGlobalConfiger for test only

func TestCallHTTPDecoder

func TestCallHTTPDecoder(method, uri string, body []byte, headers map[string]string,
	decoder func(rr *httptest.ResponseRecorder) (interface{}, error)) (interface{}, error)

TestCallHTTPDecoder test func

func TestCallHTTPJson

func TestCallHTTPJson(method, uri string, body []byte, headers map[string]string, resp interface{}) (interface{}, error)

TestCallHTTPJson test func

func TestCallHTTPPB

func TestCallHTTPPB(method, uri string, body []byte, headers map[string]string, resp proto.Message) (interface{}, error)

TestCallHTTPPB test func

func TestCallHTTPPBInput

func TestCallHTTPPBInput(method, uri string, body []byte, headers map[string]string, resp interface{}) (interface{}, error)

TestCallHTTPPBInput test func

Types

type Config

type Config struct {
	MatchRule MatchRule       `json:"matchRule,omitempty"`
	Data      json.RawMessage `json:"data,omitempty"`
}

type HTTPClient

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

HTTPClient is

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient create http client

func NewWithHTTPClient

func NewWithHTTPClient(client *http.Client) *HTTPClient

NewWithHTTPClient create with http client

func (*HTTPClient) SendFormRequest

func (c *HTTPClient) SendFormRequest(ctx context.Context, method, urls string, reqForm map[string]string, headers map[string]string) (*http.Response, error)

SendFormRequest SendFormRequest

func (*HTTPClient) SendJSONRequest

func (c *HTTPClient) SendJSONRequest(ctx context.Context, method, url string, req interface{}, headers map[string]string) (*http.Response, error)

SendJSONRequest SendJSONRequest

type JsonMatcher

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

matcher for gomock

func NewJSONMatcher

func NewJSONMatcher(b []byte, obj interface{}) *JsonMatcher

func (*JsonMatcher) Matches

func (m *JsonMatcher) Matches(x interface{}) bool

func (*JsonMatcher) String

func (m *JsonMatcher) String() string

type MatchRule

type MatchRule struct {
	LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
	Namespaces    []string              `json:"namespaces,omitempty"`
	Kind          string                `json:"kind,omitempty"`
}

Directories

Path Synopsis
Package config is a generated GoMock package.
Package config is a generated GoMock package.

Jump to

Keyboard shortcuts

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