utils

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Server The operation looked fine on paper, but something went wrong
	Server Type = "server"
	// Missing The thing you mentioned, whatever it is, just doesn't exist
	Missing = "missing"
	// User The operation was well-formed, but you asked for something that
	// can't happen at present (e.g., because you've not supplied some
	// config yet)
	User = "user"
)

Variables

This section is empty.

Functions

func ApplyApplicationWithSync

func ApplyApplicationWithSync(client kubernetes.Interface, radixclient radixclient.Interface, commonTestUtils *commontest.Utils, applicationBuilder utils.ApplicationBuilder)

ApplyApplicationWithSync syncs based on application builder, and default builder for registration.

func ApplyDeploymentWithSync

func ApplyDeploymentWithSync(client kubernetes.Interface, radixclient radixclient.Interface, commonTestUtils *commontest.Utils, deploymentBuilder builders.DeploymentBuilder)

ApplyDeploymentWithSync syncs based on deployment builder, and default builders for application and registration.

func ApplyRegistrationWithSync

func ApplyRegistrationWithSync(client kubernetes.Interface, radixclient radixclient.Interface, commonTestUtils *commontest.Utils, registrationBuilder utils.RegistrationBuilder)

ApplyRegistrationWithSync syncs based on registration builder

func BearerTokenHeaderVerifyerMiddleware

func BearerTokenHeaderVerifyerMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

BearerTokenHeaderVerifyerMiddleware Will verify that the request has a bearer token in header

func BearerTokenQueryVerifyerMiddleware

func BearerTokenQueryVerifyerMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

BearerTokenQueryVerifyerMiddleware Will verify that the request has a bearer token as query variable

func CreateApplicationConfig

func CreateApplicationConfig(client kubernetes.Interface,
	radixClient radixclient.Interface,
	appName string) (*applicationconfig.ApplicationConfig, error)

CreateApplicationConfig creates an application config based on input

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, r *http.Request, apiError error)

ErrorResponse Marshals error

func FormatTime

func FormatTime(time *metav1.Time) string

FormatTime Converts kubernetes time to formatted timestamp

func FormatTimestamp

func FormatTimestamp(timestamp time.Time) string

FormatTimestamp Converts time to formatted timestamp

func GetTokenFromQuery

func GetTokenFromQuery(request *http.Request) string

GetTokenFromQuery Gets token from query of the request

func JSONResponse

func JSONResponse(w http.ResponseWriter, r *http.Request, result interface{})

JSONResponse Marshals response with header

func ParseTimestamp

func ParseTimestamp(timestamp string) (time.Time, error)

ParseTimestamp Converts timestamp to time

func StringResponse

func StringResponse(w http.ResponseWriter, r *http.Request, result string)

StringResponse Used for textual response data. I.e. log data

func TypeMissingError

func TypeMissingError(message string, underlyingError error) error

TypeMissingError indication of underlying type missing

func UnexpectedError

func UnexpectedError(message string, underlyingError error) error

UnexpectedError any unexpected error

func ValidationError

func ValidationError(kind, message string) error

ValidationError Used for indication of validation errors

Types

type DeployKey

type DeployKey struct {
	PrivateKey string
	PublicKey  string
}

DeployKey Represention of a deploy key pair

func GenerateDeployKey

func GenerateDeployKey() (*DeployKey, error)

GenerateDeployKey Generates a deploy key

type Error

type Error struct {
	Type Type
	// a message that can be printed out for the user
	Message string `json:"message"`
	// the underlying error that can be e.g., logged for developers to look at
	Err error
}

Error Representation of errors in the API. These are divided into a small number of categories, essentially distinguished by whose fault the error is; i.e., is this error:

  • a transient problem with the service, so worth trying again?
  • not going to work until the user takes some other action, e.g., updating config?

func CoverAllError

func CoverAllError(err error) *Error

CoverAllError Cover all other errors

func (*Error) Error

func (e *Error) Error() string

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON Writes error as json

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) error

UnmarshalJSON Parses json

type KubeUtil

type KubeUtil interface {
	GetOutClusterKubernetesClient(string) (kubernetes.Interface, radixclient.Interface)
	GetOutClusterKubernetesClientWithImpersonation(string, models.Impersonation) (kubernetes.Interface, radixclient.Interface)
	GetInClusterKubernetesClient() (kubernetes.Interface, radixclient.Interface)
}

KubeUtil Interface to be mocked in tests

func NewKubeUtil

func NewKubeUtil(useOutClusterClient bool) KubeUtil

NewKubeUtil Constructor

type RadixMiddleware

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

RadixMiddleware The middleware beween router and radix handler functions

func NewRadixMiddleware

func NewRadixMiddleware(kubeUtil KubeUtil, path, method string, next models.RadixHandlerFunc) *RadixMiddleware

NewRadixMiddleware Constructor for radix middleware

func (*RadixMiddleware) Handle

func (handler *RadixMiddleware) Handle(w http.ResponseWriter, r *http.Request)

Handle Wraps radix handler methods

type Type

type Type string

Type Type of error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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