common

package
v0.0.0-...-d125d34 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationQueryName             = "filter"
	ApplicationQueryByUser           = "userID"
	ApplicationQueryByTemplate       = "template"
	ApplicationQueryByRelease        = "templateRelease"
	ApplicationQueryByGroup          = "groupID"
	ApplicationQueryByGroupRecursive = "groupRecursive"
	ApplicationQueryID               = "id"

	ApplicationQueryWithDeleted = "withDeleted"
)
View Source
const (
	ClusterQueryEnvironment   = "environment"
	ClusterQueryName          = "filter"
	ClusterQueryByUser        = "userID"
	ClusterQueryByTemplate    = "template"
	ClusterQueryByRelease     = "templateRelease"
	ClusterQueryByRegion      = "region"
	ClusterQueryTagSelector   = "tagSelector"
	ClusterQueryMergePatch    = "mergePatch"
	ClusterQueryTargetBranch  = "targetBranch"
	ClusterQueryTargetCommit  = "targetCommit"
	ClusterQueryTargetTag     = "targetTag"
	ClusterQueryContainerName = "containerName"
	ClusterQueryPodName       = "podName"
	ClusterQueryTailLines     = "tailLines"
	ClusterQueryExtraOwner    = "extraOwner"
	ClusterQueryHard          = "hard"

	// ClusterQueryIsFavorite is used to query cluster with favorite for current user only.
	ClusterQueryIsFavorite = "isFavorite"
	// ClusterQueryWithFavorite is used to query cluster with favorite field inside.
	ClusterQueryWithFavorite = "withFavorite"
	ClusterQueryUpdatedAfter = "updatedAfter"
	ClusterQueryOnlyDeleted  = "onlyDeleted"
)
View Source
const (
	ClusterClusterLabelKey = "cloudnative.music.netease.com/cluster"
	ClusterRestartTimeKey  = "cloudnative.music.netease.com/user-restart-time"
)
View Source
const (
	ClusterStatusEmpty    = ""
	ClusterStatusFreeing  = "Freeing"
	ClusterStatusFreed    = "Freed"
	ClusterStatusDeleting = "Deleting"
	ClusterStatusCreating = "Creating"
)

status of cluster

View Source
const (
	PageNumber      = "pageNumber"
	PageSize        = "pageSize"
	Filter          = "filter"
	Template        = "template"
	TemplateRelease = "templateRelease"
	TagSelector     = "tagSelector"

	// Offset should be type int
	Offset = "offset"
	// Limit should be type int
	Limit     = "limit"
	StartID   = "startID"
	EndID     = "endID"
	EventType = "eventType"
	WebhookID = "webhookID"
	CreatedAt = "createdAt"
	Enabled   = "enabled"
	Orphaned  = "orphaned"
	OrderBy   = "orderBy"
	ReqID     = "reqID"

	DefaultPageNumber = 1
	DefaultPageSize   = 20
	MaxPageSize       = 50
	MaxItems          = 100000
)

const variables

View Source
const (
	MetaVersion2              = "0.0.2"
	ApplicationRepoDefaultEnv = "default"
)
View Source
const (
	// InternalError internal server error code
	InternalError = "InternalError"

	// InvalidRequestParam invalid request param error code
	InvalidRequestParam = "InvalidRequestParam"

	// InvalidRequestBody invalid request body error code
	InvalidRequestBody = "InvalidRequestBody"

	// NotImplemented not implemented error code
	NotImplemented = "NotImplemented"

	// RequestInfoError error to format the request
	RequestInfoError = "RequestInfoError"

	// Unauthorized  401 error code
	Unauthorized = "Unauthorized"

	// Forbidden 403 Forbidden error code
	Forbidden = "Forbidden"

	// CodeExpired 403 AccessToken and Authorization Token error code
	CodeExpired = "Expired"

	// NotFound 404 NotFound error code
	NotFound = "NotFound"
)
View Source
const (
	// ResourceApplication represent the application  member entry.
	ResourceApplication = "applications"

	// ResourceCluster represent the application instance member entry
	ResourceCluster = "clusters"

	ResourceRegion = "regions"

	// ResourceGroup represent the group member entry.
	ResourceGroup = "groups"

	// ResourcePipelinerun currently pipelineruns do not have direct member info, will
	// use the pipeline's cluster's member info
	ResourcePipelinerun = "pipelineruns"

	// ResourceCheckrun currently checkruns do not have direct member info, will
	// use the member info of the clusters that they belong to
	ResourceCheckrun = "checkruns"

	// ResourceOauthApps currently oauthapp do not have direct member info, will
	// use the oauthapp's groups member info
	ResourceOauthApps = "oauthapps"

	ResourceTemplate = "templates"

	ResourceTemplateRelease = "templatereleases"
	AliasTemplateRelease    = "releases"

	ResourceWebhook    = "webhooks"
	ResourceWebhookLog = "webhooklogs"

	ResourceMember = "members"
)
View Source
const (
	ParamApplicationID = "applicationID"
	ParamGroupID       = "groupID"
	ParamClusterID     = "clusterID"
	ParamClusterName   = "cluster"
	ParamTemplateID    = "templateID"
	ParamReleaseID     = "releaseID"
	ParamResourceType  = "resourceType"
	ParamResourceID    = "resourceID"
	ParamAccessTokenID = "accessTokenID"
)
View Source
const (
	GitlabGitops   = "gitops"
	GitlabTemplate = "template"
)
View Source
const (
	CookieKeyAuth      = "horizon|session"
	SessionKeyAuthUser = "user"
)
View Source
const (
	// fileName
	GitopsFileChart          = "Chart.yaml"
	GitopsFileApplication    = "application.yaml"
	GitopsFileTags           = "tags.yaml"
	GitopsFileSRE            = "sre/sre.yaml"
	GitopsFileBase           = "system/horizon.yaml"
	GitopsFileEnv            = "system/env.yaml"
	GitopsFileRestart        = "system/restart.yaml"
	GitopsFilePipeline       = "pipeline/pipeline.yaml"
	GitopsFilePipelineOutput = "pipeline/pipeline-output.yaml"
	GitopsFileManifest       = "manifest.yaml"

	// value namespace
	GitopsEnvValueNamespace  = "env"
	GitopsBaseValueNamespace = "horizon"

	GitopsMergeRequestStateOpen = "opened"

	GitopsGroupClusters          = "clusters"
	GitopsGroupRecyclingClusters = "recycling-clusters"

	GitopsKeyTags = "tags"
)
View Source
const (
	PipelineQueryByStatus = "status"

	MessageQueryBySystem = "system"

	MessagePipelinerunStopped   = "stopped pipelinerun"
	MessagePipelinerunExecuted  = "executed pipelinerun"
	MessagePipelinerunCancelled = "cancelled pipelinerun"
	MessagePipelinerunReady     = "marked pipelinerun as ready to execute"
)
View Source
const (
	URLOauthAuthorization = "/login/oauth/authorize"

	URLLoginCallback = "/apis/core/v1/login/callback"
)
View Source
const (
	TemplateQueryWithoutCI        = "withoutCI"
	TemplateQueryByUser           = "userID"
	TemplateQueryByGroup          = "groupID"
	TemplateQueryByGroupRecursive = "groupIDRecursive"
	TemplateQueryByGroups         = "templateGroupIDs"
	TemplateQueryWithRelease      = "withRelease"
	TemplateQueryName             = "filter"
	TemplateQueryType             = "type"
)
View Source
const (
	UserQueryName = "filter"
	UserQueryType = "userType"
	UserQueryID   = "id"
)
View Source
const (
	AuthorizationHeaderKey = "Authorization"
	TokenHeaderValuePrefix = "Bearer"
)
View Source
const (
	ChartVersionFormat = "%s-%s"
)
View Source
const (
	GroupCore = "core"
)
View Source
const (
	// IDThan query parameter, used for "id > IDThan"
	IDThan = "idThan"
)
View Source
const (
	TektonTriggersEventIDKey = triggers.GroupName + triggers.EventIDLabelKey
)
View Source
const (
	URLFrontLogin = "/user/login"
)

Variables

View Source
var ContextAuthRecord = "authRecord"

Functions

func ElegantExit

func ElegantExit(h hook.Hook)

func GetToken

func GetToken(c *gin.Context) (string, error)

func JWTTokenStringFromContext

func JWTTokenStringFromContext(ctx context.Context) (string, error)

func Response

func Response(ctx context.Context, resp *http.Response) string

func SetUser

func SetUser(c *gin.Context, user user.User)

func UnmarshalTraversalIDS

func UnmarshalTraversalIDS(traversalIDs string) ([]uint, error)

func UserContextKey

func UserContextKey() string

func UserFromContext

func UserFromContext(ctx context.Context) (user.User, error)

func WithContext

func WithContext(parent context.Context, user user.User) context.Context

func WithContextJWTTokenString

func WithContextJWTTokenString(ctx context.Context, tokenStr string) context.Context

Types

type Resource

type Resource struct {
	ResourceID uint   `json:"resource_id" yaml:"resourceID"`
	Type       string `gorm:"column:resource_type" json:"resource_type" yaml:"resourceType"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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