gochassis

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
const (
	ServiceStageMountPath = `/opt/CSE/etc/auth`
	DefaultSecretFile     = `.dockerconfigjson`
)

default secret path and file mounted to container by ServiceStage

View Source
const DefaultRefreshInterval = 60 * time.Second

DefaultRefreshInterval is default refresh interval

Variables

View Source
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

View Source
var ErrAuthConfNotExist = errors.New("auth config is not exist")

ErrAuthConfNotExist means the auth config not exist

Functions

func Init

func Init() error

Init initializes auth module

func IsAuthConfNotExist

func IsAuthConfNotExist(e error) bool

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

type AuthInfoQueryerFromServiceStage struct {
	MountPath string
	File      string
}

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

Source implements AuthInfoQueryer.Source

type DockerConfig

type DockerConfig struct {
	Auths map[string]AuthData `json:"auths"`
}

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

Jump to

Keyboard shortcuts

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