Documentation
¶
Index ¶
Constants ¶
const ( EnvKubernetesServiceHost = "KUBERNETES_SERVICE_HOST" EnvKubernetesServicePort = "KUBERNETES_SERVICE_PORT" HeaderAuthorization = "Authorization" ExpectedArrLength = 2 ServiceAccountPath = `/var/run/secrets/kubernetes.io/serviceaccount` )
constant value for communication to CCE
const ( ServiceStageMountPath = `/opt/CSE/etc/auth` DefaultSecretFile = `.dockerconfigjson` )
default secret path and file mounted to container by ServiceStage
const DefaultRefreshInterval = 60 * time.Second
DefaultRefreshInterval is default refresh interval
Variables ¶
var CCEEnvIdentifications = []string{
"PAAS_APP_NAME",
"PAAS_NAMESPACE",
"PAAS_PROJECT_ID",
"PAAS_POD_ID",
"PAAS_CLUSTER_ID",
}
CCEEnvIdentifications is to judge whether a container runs in CCE cluster
var ErrAuthConfNotExist = errors.New("auth config is not exist")
ErrAuthConfNotExist means the auth config not exist
Functions ¶
func IsAuthConfNotExist ¶
IsAuthConfNotExist judges whether an error is equal to ErrAuthConfNotExist
Types ¶
type AuthData ¶
type AuthData struct {
Auth string `json:"auth"`
}
AuthData contains AK/SHAAKSK/PROJECT
type AuthHeaderGenerator ¶
type AuthHeaderGenerator struct {
RefreshInterval time.Duration
AuthInfoGener AuthInfoQueryer
// contains filtered or unexported fields
}
AuthHeaderGenerator gets auth infomation and transfers it to auth headers and refresh the auth headers frequently
func GetAuthHeaderGenerator ¶
func GetAuthHeaderGenerator() (*AuthHeaderGenerator, error)
GetAuthHeaderGenerator news an AuthHeaderGenerator
func GetAuthHeaderGeneratorFromCustomAuthInfoQueryers ¶
func GetAuthHeaderGeneratorFromCustomAuthInfoQueryers(qs ...AuthInfoQueryer) (*AuthHeaderGenerator, error)
GetAuthHeaderGeneratorFromCustomAuthInfoQueryers news an AuthHeaderGenerator from several AuthInfoQueryer this is to make pkg more testable front param has higher priority
func (*AuthHeaderGenerator) GenAuthHeaders ¶
func (h *AuthHeaderGenerator) GenAuthHeaders() http.Header
GenAuthHeaders returns the latest auth headers
type AuthInfoQueryer ¶
type AuthInfoQueryer interface {
GetAuthInfos() (string, string, string, error)
Source() string //source name
}
AuthInfoQueryer queries auth infomation: project, AK, SHAAKSK, error
type AuthInfoQueryerFromCCE ¶
type AuthInfoQueryerFromCCE struct {
Client *http.Client
ServiceAccountPath string
EnvIdentifiers []string
}
AuthInfoQueryerFromCCE queries auth infomation from CCE
func GetAuthInfoQueryerFromCCE ¶
func GetAuthInfoQueryerFromCCE() *AuthInfoQueryerFromCCE
GetAuthInfoQueryerFromCCE news AuthInfoQueryerFromCCE
func (*AuthInfoQueryerFromCCE) API4ImagePullSecret ¶
func (q *AuthInfoQueryerFromCCE) API4ImagePullSecret(namespace string) string
API4ImagePullSecret get secret api for a namespace
func (*AuthInfoQueryerFromCCE) GetAuthInfos ¶
func (q *AuthInfoQueryerFromCCE) GetAuthInfos() (string, string, string, error)
GetAuthInfos implements AuthInfoQueryer.GetAuthInfos
func (*AuthInfoQueryerFromCCE) Source ¶
func (q *AuthInfoQueryerFromCCE) Source() string
Source implements AuthInfoQueryer.Source
type AuthInfoQueryerFromServiceStage ¶
AuthInfoQueryerFromServiceStage queries auth infomation from ServiceStage
func GetAuthInfoQueryerFromServiceStage ¶
func GetAuthInfoQueryerFromServiceStage() *AuthInfoQueryerFromServiceStage
GetAuthInfoQueryerFromServiceStage news AuthInfoQueryerFromServiceStage
func (*AuthInfoQueryerFromServiceStage) GetAuthInfos ¶
func (q *AuthInfoQueryerFromServiceStage) GetAuthInfos() (string, string, string, error)
GetAuthInfos implements AuthInfoQueryer.GetAuthInfos
func (*AuthInfoQueryerFromServiceStage) Source ¶
func (q *AuthInfoQueryerFromServiceStage) Source() string
Source implements AuthInfoQueryer.Source
type DockerConfig ¶
DockerConfig is a tenant's default secret
type KubeSecrets ¶
type KubeSecrets struct {
Data KubeSecretsData `json:"data"`
}
KubeSecrets is response struct of CCE secret api
type KubeSecretsData ¶
type KubeSecretsData struct {
DockerConfigJSON string `json:".dockerconfigjson"`
}
KubeSecretsData is the data of KubeSecrets