openshift

package
v0.0.0-...-932a72f Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldKind                     = "kind"
	FieldAPIVersion               = "apiVersion"
	FieldObjects                  = "objects"
	FieldSpec                     = "spec"
	FieldTemplate                 = "template"
	FieldItems                    = "items"
	FieldMetadata                 = "metadata"
	FieldLabels                   = "labels"
	FieldReplicas                 = "replicas"
	FieldVersion                  = "version"
	FieldNamespace                = "namespace"
	FieldName                     = "name"
	FieldResourceVersion          = "resourceVersion"
	ValKindTemplate               = "Template"
	ValKindNamespace              = "Namespace"
	ValKindProjectRequest         = "ProjectRequest"
	ValKindPersistenceVolumeClaim = "PersistentVolumeClaim"
	ValKindServiceAccount         = "ServiceAccount"
	ValKindRoleBindingRestriction = "RoleBindingRestriction"
	ValKindRoleBinding            = "RoleBinding"
	ValKindList                   = "List"
	ValKindDeploymentConfig       = "DeploymentConfig"
)

Variables

This section is empty.

Functions

func Apply

func Apply(source string, opts ApplyOptions) error

Apply a given template structure to a target API

func ApplyProcessed

func ApplyProcessed(objects []map[interface{}]interface{}, opts ApplyOptions) error

func CleanTenant

func CleanTenant(ctx context.Context, config Config, username string, templateVars map[string]string) error

func CreateAdminRoleBinding

func CreateAdminRoleBinding(namespace string) map[interface{}]interface{}

func CreateName

func CreateName(username string) string

CreateName returns a safe namespace basename based on a username

func EnsureKeyCloakHasJenkinsRedirectURL

func EnsureKeyCloakHasJenkinsRedirectURL(config Config, kcConfig keycloak.Config, jenkinsNS string) (string, error)

EnsureKeyCloakHasJenkinsRedirectURL checks that the client has a redirect URI for the jenkins URL

func Filter

func Filter(vs []map[interface{}]interface{}, f FilterFunc) []map[interface{}]interface{}

func FindKeyCloakURL

func FindKeyCloakURL(config Config) (string, error)

FindKeyCloakURL returns the external URL of keycloak

func FindKeyCloakUserPassword

func FindKeyCloakUserPassword(config Config, namespace string) (string, string, error)

func FindServiceURL

func FindServiceURL(config Config, namespace string, svcName string) (string, error)

FindServiceURL returns the external URL of the service

func GetJSON

func GetJSON(config Config, url string, token string) (int, string, error)

func GetKeyCloakAdminToken

func GetKeyCloakAdminToken(config Config, kcConfig keycloak.Config, namespace string) (string, error)

func GetKind

func GetKind(obj map[interface{}]interface{}) string

func GetLabel

func GetLabel(obj map[interface{}]interface{}, name string) string

func GetLabelVersion

func GetLabelVersion(obj map[interface{}]interface{}) string

func GetName

func GetName(obj map[interface{}]interface{}) string

func GetNamespace

func GetNamespace(obj map[interface{}]interface{}) string

func GetOrCreateKubeToken

func GetOrCreateKubeToken(config Config, openshiftUsername string) (string, error)

GetOrCreateKubeToken will try to load the ServiceAccount for the given user name and return its token otherwise if allowed it will lazily create a new ServiceAccount for the username

func GetSpec

func GetSpec(obj map[interface{}]interface{}) map[interface{}]interface{}

func GetTemplate

func GetTemplate(obj map[interface{}]interface{}) map[interface{}]interface{}

func HasJenkinsNamespace

func HasJenkinsNamespace(config Config, username string) bool

HasJenkinsNamespace returns true if the tenant namespace has been created

func InitTenant

func InitTenant(ctx context.Context, kcConfig keycloak.Config, config Config, callback Callback, username, usertoken string, templateVars map[string]string) error

InitTenant initializes a new tenant in openshift Creates the new x-test|stage|run and x-jenkins|che namespaces and install the required services/routes/deployment configurations to run e.g. Jenkins and Che

func KubeConnected

func KubeConnected(kcConfig keycloak.Config, config Config, username string) (string, error)

func KubernetesMode

func KubernetesMode() bool

func LoadExposeControllerVariables

func LoadExposeControllerVariables(config Config) (map[string]string, error)

LoadExposeControllerVariables loads the exposecontroller template parameter values from the exposecontroller ConfigMap if it can be found

func LoadKubernetesProjectVariables

func LoadKubernetesProjectVariables() (map[string]string, error)

LoadKubernetesProjectVariables loads the jenkins template parameter values

func LoadProcessedTemplates

func LoadProcessedTemplates(ctx context.Context, config Config, username string, templateVars map[string]string) ([]map[interface{}]interface{}, error)

func MapByNamespaceAndSort

func MapByNamespaceAndSort(objs []map[interface{}]interface{}) (map[string][]map[interface{}]interface{}, error)

func ParseObjects

func ParseObjects(source string, namespace string) ([]map[interface{}]interface{}, error)

ParseObjects return a string yaml and return a array of the objects/items from a Template/List kind

func Process

func Process(source string, variables map[string]string) (string, error)

Process takes a K8/Openshift Template as input and resolves the variable expresions

func ProcessTemplate

func ProcessTemplate(template, namespace string, vars map[string]string) ([]map[interface{}]interface{}, error)

func RawInitTenant

func RawInitTenant(ctx context.Context, config Config, callback Callback, username, usertoken string, templateVars map[string]string) error

func RawUpdateTenant

func RawUpdateTenant(ctx context.Context, config Config, callback Callback, username string, templateVars map[string]string) error

func RemoveReplicas

func RemoveReplicas(vs []map[interface{}]interface{}) []map[interface{}]interface{}

func UpdateTenant

func UpdateTenant(ctx context.Context, kcConfig keycloak.Config, config Config, callback Callback, username, usertoken string, templateVars map[string]string) error

func WhoAmI

func WhoAmI(config Config) (string, error)

WhoAmI checks with OSO who owns the current token. returns the username

Types

type ApplyOptions

type ApplyOptions struct {
	Config
	Namespace string
	Callback  Callback
}

ApplyOptions contains options for connecting to the target API

func (*ApplyOptions) CreateHttpClient

func (a *ApplyOptions) CreateHttpClient() *http.Client

func (*ApplyOptions) WithCallback

func (a *ApplyOptions) WithCallback(callback Callback) ApplyOptions

func (*ApplyOptions) WithNamespace

func (a *ApplyOptions) WithNamespace(namespace string) ApplyOptions

type ByKind

type ByKind []map[interface{}]interface{}

ByKind represents a list of Openshift objects sortable by Kind

func (ByKind) Len

func (a ByKind) Len() int

func (ByKind) Less

func (a ByKind) Less(i, j int) bool

func (ByKind) Swap

func (a ByKind) Swap(i, j int)

type Callback

type Callback func(statusCode int, method string, request, response map[interface{}]interface{}) (string, map[interface{}]interface{})

Callback is called after initial action

type Config

type Config struct {
	MasterURL      string
	MasterUser     string
	Token          string
	HttpTransport  *http.Transport
	TemplateDir    string
	MavenRepoURL   string
	TeamVersion    string
	CheVersion     string
	JenkinsVersion string
	LogCallback    LogCallback
}

func (Config) GetLogCallback

func (c Config) GetLogCallback() LogCallback

func (Config) WithToken

func (c Config) WithToken(token string) Config

func (Config) WithUserSettings

func (c Config) WithUserSettings(cheVersion string, jenkinsVersion string, teamVersion string, mavenRepoURL string) Config

type FilterFunc

type FilterFunc func(map[interface{}]interface{}) bool

func IsNotOfKind

func IsNotOfKind(kinds ...string) FilterFunc

func IsOfKind

func IsOfKind(kinds ...string) FilterFunc

type LogCallback

type LogCallback func(message string)

Jump to

Keyboard shortcuts

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