util

package
v0.0.0-...-c5a53a6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_PARAMETER_AUTHORIZATION = "authorization"
	QUERY_PARAMETER_OFFSET         = "offset"
	QUERY_PARAMETER_LIMIT          = "limit"
	QUERY_PARAMETER_NAMESPACE      = "namespace"
	QUERY_PARAMETER_USER_ID        = "userId"
	QUERY_PARAMETER_TIMEUNIT       = "timeUnit"
	QUERY_PARAMETER_STARTTIME      = "startTime"
	QUERY_PARAMETER_ENDTIME        = "endTime"
	QUERY_PARAMETER_SORT           = "sort"
	QUERY_PARAMETER_RESOURCE       = "resource"
	QUERY_PARAMETER_CODE           = "code"
	QUERY_PARAMETER_CONTINUE       = "continue"
	QUERY_PARAMETER_LABEL_SELECTOR = "labelSelector"
	QUERY_PARAMETER_PERIOD         = "period"
	QUERY_PARAMETER_NAME           = "name"
	QUERY_PARAMETER_USER_GROUP     = "userGroup"
	QUERY_PARAMETER_GRANULARITY    = "granularity"
	QUERY_PARAMETER_METRICS        = "metrics"
	QUERY_PARAMETER_DIMENSION      = "dimension"

	//HyperAuth
	//HYPERAUTH_URL = "http://hyperauth.hyperauth"
	HYPERAUTH_URL                                    = "http://192.168.6.151"
	HYPERAUTH_SERVICE_NAME_LOGIN_AS_ADMIN            = "auth/realms/master/protocol/openid-connect/token"
	HYPERAUTH_SERVICE_NAME_USER_DETAIL_WITHOUT_TOKEN = "auth/realms/tmax/user/"

	HYPERCLOUD4_NAMESPACE       = "hypercloud4-system"
	HYPERCLOUD4_CLAIM_API_GROUP = "claim.tmax.io"

	CLAIM_API_GROUP             = "claim.tmax.io"
	CLAIM_API_Kind              = "clusterclaims"
	CLAIM_API_GROUP_VERSION     = "claim.tmax.io/v1alpha1"
	CLUSTER_API_GROUP           = "cluster.tmax.io"
	CLUSTER_API_Kind            = "clustermanagers"
	CLUSTER_API_GROUP_VERSION   = "cluster.tmax.io/v1alpha1"
	HYPERCLOUD_SYSTEM_NAMESPACE = "hypercloud5-system"

	GRAFANA_URI = "grafana.monitoring.svc.cluster.local:3000/"
	TEST        = "<!DOCTYPE html>\r\n" +
		"<html lang=\"en\">\r\n" +
		"<head>\r\n" +
		"    <meta charset=\"UTF-8\">\r\n" +
		"    <title>HyperCloud 서비스 신청 승인 완료</title>\r\n" +
		"</head>\r\n" +
		"<body>\r\n" +
		"<div style=\"border: #c5c5c8 0.06rem solid; border-bottom: 0; width: 42.5rem; height: 53.82rem; padding: 0 1.25rem\">\r\n" +
		"    <header>\r\n" +
		"        <div style=\"margin: 0;\">\r\n" +
		"            <p style=\"font-size: 1rem; font-weight: bold; color: #333333; line-height: 3rem; letter-spacing: 0; border-bottom: #c5c5c8 0.06rem solid;\">\r\n" +
		"                HyperCloud 서비스 신청 승인 완료\r\n" +
		"            </p>\r\n" +
		"        </div>\r\n" +
		"    </header>\r\n" +
		"    <section>\r\n" +
		"        <figure style=\"text-align: center;\">\r\n" +
		"            <img style=\"margin: 0.94rem 0;\"\r\n" +
		"                 src=\"cid:trial-approval\">\r\n" +
		"        </figure>\r\n" +
		"        <div style=\"width: 35.70rem; margin: 0 2.75rem;\">\r\n" +
		"            <p style=\"font-size: 1.5rem; font-weight: bold; line-height: 3rem;\">\r\n" +
		"                축하합니다.\r\n" +
		"            </p>\r\n" +
		"            <p style=\"line-height: 1.38rem;\">\r\n" +
		"                고객님의 Trial 서비스 신청이 성공적으로 승인되었습니다. <br>\r\n" +
		"                지금 바로 티맥스의 소프트웨어와 검증을 거친 오픈소스 서비스를 결합한 클라우드 플랫폼, <br>\r\n" +
		"                HyperCloud를 이용해 보세요. <br>\r\n" +
		"                <br>\r\n" +
		"                네임스페이스 이름 : <span style=\"font-weight: 600;\">%%NAMESPACE_NAME%%</span> <br>\r\n" +
		"                Trial 기한 : %%TRIAL_START_TIME%% ~ %%TRIAL_END_TIME%% <br>\r\n" +
		"                <br>\r\n" +
		"                리소스 정보 <br>\r\n" +
		"                -CPU : 1 Core <br>\r\n" +
		"                -Memory : 4 GIB <br>\r\n" +
		"                -Storage : 4 GIB <br>\r\n" +
		"                <br>\r\n" +
		"<!--                <span style=\"font-weight: 600;\">승인사유</span> <br>-->\r\n" +
		"                <br>\r\n" +
		"\r\n" +
		"                감사합니다. <br>\r\n" +
		"                TmaxCloud 드림.\r\n" +
		"            </p>\r\n" +
		"            <p style=\"margin: 3rem 0;\">\r\n" +
		"                <a href=\"https://console.tmaxcloud.com\">Tmax Console 바로가기 ></a>\r\n" +
		"            </p>\r\n" +
		"        </div>\r\n" +
		"    </section>\r\n" +
		"</div>\r\n" +
		"<footer style=\"background-color: #3669B3; width: 45.12rem; height: 1.88rem; font-size: 0.75rem; color: #FFFFFF; display: flex;\r\n" +
		"    align-items: center; justify-content: center;\">\r\n" +
		"    <div>\r\n" +
		"        COPYRIGHT2020. TMAX A&C., LTD. ALL RIGHTS RESERVED\r\n" +
		"    </div>\r\n" +
		"</footer>\r\n" +
		"</body>\r\n" +
		"</html>"
)

Variables

View Source
var (
	SMTPUsernamePath string
	SMTPPasswordPath string
	SMTPHost         string
	SMTPPort         int
	AccessSecretPath string

	HtmlHomePath           string
	TokenExpiredDate       string
	ParsedTokenExpiredDate time.Duration
	ValidTime              string
)
View Source
var GrafanaKey string

Functions

func Contains

func Contains(slice []string, item string) bool

func CreatePatch

func CreatePatch(po *[]PatchOps, o, p string, v interface{})

Jsonpatch를 하나 만들어서 slice에 추가하는 함수

func CreateToken

func CreateToken(clusterMember ClusterMemberInfo) (string, error)

func ExtractTokenFromHeader

func ExtractTokenFromHeader(r *http.Request) string

func ExtractTokenFromQuery

func ExtractTokenFromQuery(r *http.Request) string

func MonthToInt

func MonthToInt(month time.Month) int

func ReadFile

func ReadFile()

func Remove

func Remove(slice []string, item string) []string

func SendEmail

func SendEmail(from string, to []string, subject string, bodyParameter map[string]string) error

func SetResponse

func SetResponse(res http.ResponseWriter, outString string, outJson interface{}, status int) http.ResponseWriter

func StringParameterException

func StringParameterException(userGroups []string, args ...string) error

func ToAdmissionResponse

func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse

Response.result.message에 err 메시지 넣고 반환

func TokenValid

func TokenValid(r *http.Request, clusterMember ClusterMemberInfo) ([]string, error)

func VerifyToken

func VerifyToken(r *http.Request) (*jwt.Token, error)

Types

type ClusterMemberInfo

type ClusterMemberInfo struct {
	Id          int64
	Namespace   string
	Cluster     string
	MemberId    string
	Groups      []string
	MemberName  string
	Attribute   string
	Role        string
	Status      string
	CreatedTime time.Time
	UpdatedTime time.Time
}

type GrafanaKeyBody

type GrafanaKeyBody struct {
	Name          string `json:"name"`
	Role          string `json:"role"`
	SecondsToLive int    `json:"secondsToLive"`
}

type GrafanaUser

type GrafanaUser struct {
	Id       string `json:"id"`
	Password string `json:"password"`
}

type Grafana_Dashboad_resp

type Grafana_Dashboad_resp struct {
	Id      int    `json:"id"`
	Uid     string `json:"uid"`
	Url     string `json:"url"`
	Status  string `json:"status"`
	Version string `json:"version"`
	Slug    string `json:"slug"`
}

type Grafana_Namespace

type Grafana_Namespace struct {
	Email     string `json:"email"`
	Namespace string `json:"namespace"`
}

type Grafana_User_Get

type Grafana_User_Get struct {
	Id             int    `json:"id"`
	Email          string `json:"email"`
	Name           string `json:"name"`
	Login          string `json:"login"`
	Theme          string `json:"light"`
	OrgId          string `json:"OrgId"`
	IsGrafanaAdmin string `json:"isGrafanaAdmin"`
	IsDisabled     string `json:"isDisabled"`
	IsExternal     string `json:"isExternal"`
	AuthLabels     string `json:"authLabels"`
	UpdatedAt      string `json:"updatedAt"`
	CreatedAt      string `json:"createdAt"`
	AvatarUrl      string `json:"avatarUrl"`
}

type Grafana_key

type Grafana_key struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

type Grafana_user

type Grafana_user struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Login    string `json:"login"`
	Password string `json:"password"`
}

type PatchOps

type PatchOps struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value,omitempty"`
}

Jsonpatch를 담을 수 있는 구조체

Directories

Path Synopsis
dataFactory

Jump to

Keyboard shortcuts

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