pkg

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: UPL-1.0 Imports: 56 Imported by: 0

Documentation

Overview

Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

Index

Constants

View Source
const (
	// NumRetries - maximum number of retries
	NumRetries = 7

	// RetryWaitMin - minimum retry wait
	RetryWaitMin = 1 * time.Second

	// RetryWaitMax - maximum retry wait
	RetryWaitMax = 30 * time.Second
)
View Source
const (
	// ClusterTypeKind represents a Kind cluster
	ClusterTypeKind = "kind"
	// ClusterTypeOlcne represents an OLCNE cluster
	ClusterTypeOlcne = "OLCNE"
)
View Source
const (
	// ISO8601Layout defines the timestamp format
	ISO8601Layout = "2006-01-02T15:04:05.999999999-07:00"
)
View Source
const (
	// Username - the username of the verrazzano admin user
	Username = "verrazzano"
)

Variables

This section is empty.

Functions

func APIExtensionsClientSet

func APIExtensionsClientSet() *apixv1beta1client.ApiextensionsV1beta1Client

APIExtensionsClientSet returns a Kubernetes ClientSet for this cluster.

func AssertURLAccessibleAndAuthorized

func AssertURLAccessibleAndAuthorized(client *retryablehttp.Client, url string, credentials *UsernamePassword) bool

AssertURLAccessibleAndAuthorized - Assert that a URL is accessible using the provided credentials

func BodyContains added in v0.17.0

func BodyContains(expected string) types.GomegaMatcher

BodyContains asserts that an HTTPResponse body contains a given substring.

func BodyDoesNotContain added in v0.17.0

func BodyDoesNotContain(unexpected string) types.GomegaMatcher

BodyDoesNotContain asserts that an HTTPResponse body does not contain a given substring.

func BodyEquals added in v0.17.0

func BodyEquals(expected string) types.GomegaMatcher

BodyEquals asserts that an HTTPResponse body equals a given string.

func BodyNotEmpty added in v0.17.0

func BodyNotEmpty() types.GomegaMatcher

BodyNotEmpty asserts that an HTTPResponse body is not empty.

func CanI added in v0.13.0

func CanI(userOCID string, namespace string, verb string, resource string) (bool, string, error)

func CanIForAPIGroup added in v0.13.0

func CanIForAPIGroup(userOCID string, namespace string, verb string, resource string, group string) (bool, string, error)

func CanIForAPIGroupForServiceAccountOrUser added in v0.15.0

func CanIForAPIGroupForServiceAccountOrUser(saOrUserOCID string, namespace string, verb string, resource string, group string, isServiceAccount bool, saNamespace string) (bool, string, error)

func CheckNoServerHeader added in v0.16.0

func CheckNoServerHeader(resp *HTTPResponse) bool

CheckNoServerHeader validates that the response does not include a Server header.

func Concurrently

func Concurrently(assertions ...func())

Concurrently executes the given assertions in parallel and waits for them all to complete

func CreateCredentialsSecret

func CreateCredentialsSecret(namespace string, name string, username string, pw string, labels map[string]string) (*corev1.Secret, error)

CreateCredentialsSecret creates opaque secret

func CreateCredentialsSecretFromMap

func CreateCredentialsSecretFromMap(namespace string, name string, values, labels map[string]string) (*corev1.Secret, error)

CreateCredentialsSecretFromMap creates opaque secret from the given map of values

func CreateDockerSecret

func CreateDockerSecret(namespace string, name string, server string, username string, password string) (*corev1.Secret, error)

CreateDockerSecret creates docker secret

func CreateLogFile

func CreateLogFile(filename string, content string) error

CreateLogFile creates a file with the given name (or truncates the file if it already exists) and writes the given content string to the file.

func CreateNamespace

func CreateNamespace(name string, labels map[string]string) (*corev1.Namespace, error)

CreateNamespace creates a namespace

func CreateOrUpdateResourceFromFile

func CreateOrUpdateResourceFromFile(file string) error

CreateOrUpdateResourceFromFile creates or updates a Kubernetes resources from a YAML test data file. The test data file is found using the FindTestDataFile function. This is intended to be equivalent to `kubectl apply` The cluster used is the one set by default in the environment

func CreateOrUpdateResourceFromFileInCluster added in v0.14.0

func CreateOrUpdateResourceFromFileInCluster(file string, kubeconfigPath string) error

CreateOrUpdateResourceFromFileInCluster is identical to CreateOrUpdateResourceFromFile, except that it uses the cluster specified by the kubeconfigPath argument instead of the default cluster in the environment

func CreatePasswordSecret

func CreatePasswordSecret(namespace string, name string, pw string, labels map[string]string) (*corev1.Secret, error)

CreatePasswordSecret creates opaque secret

func CreateRoleBinding added in v0.13.0

func CreateRoleBinding(userOCID string, namespace string, rolebindingname string, clusterrolename string) error

func DeleteNamespace

func DeleteNamespace(name string) error

DeleteNamespace deletes a namespace in the cluster specified in the environment

func DeleteNamespaceInCluster added in v0.14.0

func DeleteNamespaceInCluster(name string, kubeconfigPath string) error

func DeleteResourceFromFile

func DeleteResourceFromFile(file string) error

DeleteResourceFromFile deletes Kubernetes resources using names found in a YAML test data file. This is intended to be equivalent to `kubectl delete` The test data file is found using the FindTestDataFile function.

func DeleteResourceFromFileInCluster added in v0.14.0

func DeleteResourceFromFileInCluster(file string, kubeconfigPath string) error

DeleteResourceFromFileInCluster is identical to DeleteResourceFromFile, except that // it uses the cluster specified by the kubeconfigPath argument instead of the default cluster in the environment

func DeleteSecret

func DeleteSecret(namespace string, name string) error

DeleteSecret deletes the specified secret in the specified namespace

func DoesCRDExist

func DoesCRDExist(crdName string) (bool, error)

DoesCRDExist returns whether a CRD with the given name exists for the cluster

func DoesClusterRoleBindingExist

func DoesClusterRoleBindingExist(name string) (bool, error)

DoesClusterRoleBindingExist returns whether a cluster role with the given name exists in the cluster

func DoesClusterRoleExist

func DoesClusterRoleExist(name string) (bool, error)

DoesClusterRoleExist returns whether a cluster role with the given name exists in the cluster

func DoesNamespaceExist

func DoesNamespaceExist(name string) (bool, error)

DoesNamespaceExist returns whether a namespace with the given name exists for the cluster set in the environment

func DoesNamespaceExistInCluster added in v0.14.0

func DoesNamespaceExistInCluster(name string, kubeconfigPath string) (bool, error)

DoesNamespaceExistInCluster returns whether a namespace with the given name exists in the specified cluster

func DoesPodExist

func DoesPodExist(namespace string, name string) bool

DoesPodExist returns whether a pod with the given name and namespace exists for the cluster

func DoesRoleBindingContainSubject added in v0.13.0

func DoesRoleBindingContainSubject(namespace, name, subjectKind, subjectName string) (bool, error)

DoesRoleBindingContainSubject returns true if the RoleBinding exists and it contains the specified subject

func DoesRoleBindingExist added in v0.13.0

func DoesRoleBindingExist(name string, namespace string) bool

DoesClusterRoleBindingExist returns whether a cluster role with the given name exists in the cluster

func DoesServiceAccountExist added in v0.13.0

func DoesServiceAccountExist(namespace, name string) (bool, error)

DoesServiceAccountExist returns whether a service account with the given name and namespace exists in the cluster

func DoesServiceExist

func DoesServiceExist(namespace string, name string) bool

DoesServiceExist returns whether a service with the given name and namespace exists for the cluster

func Execute added in v0.15.0

func Execute(podName, containerName, namespace string, command []string) (string, string, error)

Execute executes the given command on the pod and container identified by the given names and returns the resulting stdout and stderr

func ExecuteClusterDump added in v0.14.0

func ExecuteClusterDump(command string, kubeconfig string, directory string) error

ExecuteClusterDump executes the cluster dump tool. command - The fully quallified cluster dump executable. kubeconfig - The kube config file to use when executing the cluster dump tool. directory - The directory to store the cluster dump within.

func ExecuteClusterDumpWithEnvVarConfig added in v0.14.0

func ExecuteClusterDumpWithEnvVarConfig() error

ExecuteClusterDumpWithEnvVarConfig executes the cluster dump tool using config from environment variables. DUMP_KUBECONFIG - The kube config file to use when executing the cluster dump tool. DUMP_DIRECTORY - The directory to store the cluster dump within. DUMP_COMMAND - The fully quallified cluster dump executable.

func FindAnyLog added in v0.15.0

func FindAnyLog(index string, match []Match, mustNot []Match) bool

FindAnyLog returns true if a log record of any time can be found in the index with matching filters.

func FindLog added in v0.14.0

func FindLog(index string, match []Match, mustNot []Match) bool

FindLog returns true if a recent log record can be found in the index with matching filters.

func FindLogIndexWithPrefix added in v0.14.0

func FindLogIndexWithPrefix(prefix string) []string

FindLogIndexWithPrefix find indices with the specified index name prefix

func FindTestDataFile

func FindTestDataFile(file string) (string, error)

FindTestDataFile finds a test data file by searching up from the working directory looking for a relative file. This is done to simplify the execution of tests in both local and remote environments.

func GetBindingVmiHTTPClient

func GetBindingVmiHTTPClient(bindingName string, kubeconfigPath string) (*retryablehttp.Client, error)

GetBindingVmiHTTPClient returns the VMI client for the prided binding

func GetCertificates

func GetCertificates(url string) ([]*x509.Certificate, error)

GetCertificates will return the server SSL certificates for the given URL.

func GetClusterRole

func GetClusterRole(name string) (*rbacv1.ClusterRole, error)

GetClusterRole returns the cluster role with the given name

func GetClusterRoleBinding

func GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)

GetClusterRoleBinding returns the cluster role with the given name

func GetConfigMap

func GetConfigMap(configMapName string, namespace string) (*corev1.ConfigMap, error)

GetConfigMap returns the config map for the passed in ConfigMap Name and Namespace

func GetDynamicClient added in v0.15.0

func GetDynamicClient() dynamic.Interface

GetDynamicClient returns a dynamic client needed to access Unstructured data

func GetHostnameFromGateway

func GetHostnameFromGateway(namespace string, appConfigName string) string

GetHostnameFromGateway returns the host name from the application gateway that was created by the ingress trait controller

func GetIstioClientset

func GetIstioClientset() *istioClient.Clientset

GetIstioClientset returns the clientset object for Istio

func GetKeycloakHTTPClient

func GetKeycloakHTTPClient(kubeconfigPath string) (*retryablehttp.Client, error)

GetKeycloakHTTPClient returns a retryable Http client configured with the Keycloak CA cert

func GetKubeConfig

func GetKubeConfig() *restclient.Config

GetKubeConfig will get the kubeconfig from the TEST_KUBECONFIG env var if set, then the env var KUBECONFIG, if set, or else from $HOME/.kube/config

func GetKubeConfigGivenPath added in v0.14.0

func GetKubeConfigGivenPath(kubeconfigPath string) *restclient.Config

GetKubeConfig will get the kubeconfig from the given kubeconfigPath

func GetKubeConfigPathFromEnv added in v0.14.0

func GetKubeConfigPathFromEnv() string

GetKubeConfigPathFromEnv returns the path to the default kubernetes config file in use (from the TEST_KUBECONFIG env var if set, then the env var KUBECONFIG, if set, or else from $HOME/.kube/config

func GetKubernetesClientset

func GetKubernetesClientset() *kubernetes.Clientset

GetKubernetesClientset returns the Kubernetes clientset for the cluster set in the environment

func GetKubernetesClientsetForCluster added in v0.14.0

func GetKubernetesClientsetForCluster(kubeconfigPath string) *kubernetes.Clientset

GetKubernetesClientsetForCluster returns the Kubernetes clientset for the cluster whose kubeconfig path is specified

func GetNamespace

func GetNamespace(name string) (*corev1.Namespace, error)

GetNamespace returns a namespace

func GetNamespaceInCluster added in v0.14.0

func GetNamespaceInCluster(name string, kubeconfigPath string) (*corev1.Namespace, error)

GetNamespaceInCluster returns a namespace in the cluster whose kubeconfigPath is specified

func GetPersistentVolumes added in v0.15.1

func GetPersistentVolumes(namespace string) (map[string]*corev1.PersistentVolumeClaim, error)

func GetPodsFromSelector added in v0.15.0

func GetPodsFromSelector(selector *metav1.LabelSelector, namespace string) ([]corev1.Pod, error)

GetPodsFromSelector returns a collection of pods for the given namespace and selector

func GetRancherHTTPClient added in v0.14.0

func GetRancherHTTPClient(kubeconfigPath string) (*retryablehttp.Client, error)

GetRancherHTTPClient returns a retryable Http client configured with the Rancher CA cert

func GetRequiredEnvVarOrFail

func GetRequiredEnvVarOrFail(name string) string

GetRequiredEnvVarOrFail returns the values of the provided environment variable name or fails.

func GetRetryPolicy

func GetRetryPolicy() func(ctx context.Context, resp *http.Response, err error) (bool, error)

GetRetryPolicy returns the standard retry policy

func GetSecret

func GetSecret(namespace string, name string) (*corev1.Secret, error)

GetSecret returns the a secret in a given namespace for the cluster specified in the environment

func GetSecretInCluster added in v0.14.0

func GetSecretInCluster(namespace string, name string, kubeconfigPath string) (*corev1.Secret, error)

GetSecretInCluster returns the secret in a given namespace for the given cluster

func GetServiceAccount added in v0.14.0

func GetServiceAccount(namespace, name string) (*corev1.ServiceAccount, error)

func GetSystemVmiHTTPClient

func GetSystemVmiHTTPClient() (*retryablehttp.Client, error)

GetSystemVmiHTTPClient returns a retryable HTTP client configured with the system vmi CA cert

func GetTokenForServiceAccount added in v0.15.0

func GetTokenForServiceAccount(sa string, namespace string) ([]byte, error)

GetTokenForServiceAccount returns the token associated with service account

func GetVerrazzanoHTTPClient

func GetVerrazzanoHTTPClient(kubeconfigPath string) (*retryablehttp.Client, error)

GetVerrazzanoHTTPClient returns a retryable Http client configured with the verrazzano CA cert

func GetVerrazzanoInstallResourceInCluster added in v0.14.0

func GetVerrazzanoInstallResourceInCluster(kubeconfigPath string) *v1alpha1.Verrazzano

GetVerrazzanoInstallResourceInCluster returns the installed Verrazzano CR in the given cluster (there should only be 1 per cluster)

func GetVerrazzanoManagedClusterClientset added in v0.13.0

func GetVerrazzanoManagedClusterClientset() *vmcClient.Clientset

GetVerrazzanoManagedClusterClientset returns the Kubernetes clientset for the VerrazzanoManagedCluster

func GetVerrazzanoNoRetryHTTPClient

func GetVerrazzanoNoRetryHTTPClient(kubeconfigPath string) (*http.Client, error)

GetVerrazzanoNoRetryHTTPClient returns an Http client configured with the verrazzano CA cert

func GetVerrazzanoPassword

func GetVerrazzanoPassword() string

GetVerrazzanoPassword returns the password credential for the verrazzano secret

func GetVerrazzanoPasswordInCluster added in v0.14.0

func GetVerrazzanoPasswordInCluster(kubeconfigPath string) string

func GetWildcardDNS added in v0.14.0

func GetWildcardDNS(s string) string

Returns well-known wildcard DNS name is used

func HasStatus added in v0.17.0

func HasStatus(expected int) types.GomegaMatcher

HasStatus asserts that an HTTPResponse has a given status.

func HasWildcardDNS added in v0.14.0

func HasWildcardDNS(s string) bool

Returns true if string has DNS wildcard name

func Ingress

func Ingress() string

Ingress returns the ingress address

func IsACMEStagingEnabledInCluster added in v0.15.0

func IsACMEStagingEnabledInCluster(kubeconfigPath string) bool

IsACMEStagingEnabledInCluster returns true if the ACME staging environment is configured

func IsDevProfile added in v0.13.0

func IsDevProfile() bool

IsDevProfile returns true if the deployed resource is a Dev profile

func IsManagedClusterProfile added in v0.13.0

func IsManagedClusterProfile() bool

IsManagedClusterProfile returns true if the deployed resource is a 'managed-cluster' profile

func IsProdProfile added in v0.13.0

func IsProdProfile() bool

IsProdProfile returns true if the deployed resource is a 'prod' profile

func JTq

func JTq(jtext string, path ...string) interface{}

JTq queries JSON text with a JSON path

func Jq

func Jq(node interface{}, path ...string) interface{}

Jq queries JSON nodes with a JSON path

func ListClusterRoleBindings added in v0.14.0

func ListClusterRoleBindings() (*rbacv1.ClusterRoleBindingList, error)

ListClusterRoleBindings returns the list of cluster role bindings for the cluster

func ListDeployments

func ListDeployments(namespace string) (*appsv1.DeploymentList, error)

ListDeployments returns the list of deployments in a given namespace for the cluster

func ListIngresses

func ListIngresses(namespace string) (*extensionsv1beta1.IngressList, error)

ListIngresses lists ingresses in namespace

func ListNamespaces

func ListNamespaces(opts metav1.ListOptions) (*corev1.NamespaceList, error)

ListNamespaces returns a namespace list for the given list options

func ListNamespacesInCluster added in v0.16.0

func ListNamespacesInCluster(opts metav1.ListOptions, kubeconfigPath string) (*corev1.NamespaceList, error)

ListNamespaces returns a namespace list for the given list options in the specified cluster

func ListNodes

func ListNodes() (*corev1.NodeList, error)

ListNodes returns the list of nodes for the cluster

func ListPods

func ListPods(namespace string, opts metav1.ListOptions) (*corev1.PodList, error)

ListPods returns a pod list for the given namespace and list options

func ListPodsInCluster added in v0.14.0

func ListPodsInCluster(namespace string, clientset *kubernetes.Clientset) (*corev1.PodList, error)

ListPodsInCluster returns the list of pods in a given namespace for the cluster

func ListSecrets

func ListSecrets(namespace string) (*corev1.SecretList, error)

ListSecrets returns the list of secrets in a given namespace for the cluster

func ListServices

func ListServices(namespace string) (*corev1.ServiceList, error)

ListServices returns the list of services in a given namespace for the cluster

func Log

func Log(level LogLevel, message string)

Log prints out a log message in a standard format and filters out messages based on the global log level

func LogIndexFound

func LogIndexFound(indexName string) bool

LogIndexFound confirms a named index can be found in Elasticsearch in the cluster specified in the environment

func LogIndexFoundInCluster added in v0.14.0

func LogIndexFoundInCluster(indexName, kubeconfigPath string) bool

LogIndexFoundInCluster confirms a named index can be found in Elasticsearch on the given cluster

func LogRecordFound

func LogRecordFound(indexName string, after time.Time, fields map[string]string) bool

LogRecordFound confirms a recent log record for the index with matching fields can be found in the cluster specified in the environment

func LogRecordFoundInCluster added in v0.14.0

func LogRecordFoundInCluster(indexName string, after time.Time, fields map[string]string, kubeconfigPath string) bool

LogRecordFoundInCluster confirms a recent log record for the index with matching fields can be found in the given cluster

func MetricsExist

func MetricsExist(metricsName, key, value string) bool

MetricsExist is identical to MetricsExistInCluster, except that it uses the cluster specified in the environment

func MetricsExistInCluster added in v0.14.0

func MetricsExistInCluster(metricsName, key, value, kubeconfigPath string) bool

MetricsExist validates the availability of a given metric in the given cluster

func NoLog added in v0.15.0

func NoLog(index string, match []Match, mustNot []Match) bool

NoLog returns true if no matched log record can be found in the index.

func PatchResourceFromFileInCluster added in v0.15.0

func PatchResourceFromFileInCluster(gvr schema.GroupVersionResource, namespace string, name string, patchFile string, kubeconfigPath string) error

PatchResourceFromFileInCluster patches a Kubernetes resource from a given patch file in the specified cluster If the given patch file has a ".yaml" extension, the contents will be converted to JSON This is intended to be equivalent to `kubectl patch`

func PodsNotRunning

func PodsNotRunning(namespace string, namePrefixes []string) bool

PodsNotRunning waits for all the pods in namePrefixes to be terminated

func PodsRunning

func PodsRunning(namespace string, namePrefixes []string) bool

PodsRunning is identical to PodsRunningInCluster, except that it uses the cluster specified in the environment

func PodsRunningInCluster added in v0.14.0

func PodsRunningInCluster(namespace string, namePrefixes []string, kubeconfigPath string) bool

PodsRunning checks if all the pods identified by namePrefixes are ready and running in the given cluster

func PolicyRulesEqual

func PolicyRulesEqual(rule1, rule2 rbacv1.PolicyRule) bool

PolicyRulesEqual compares two RBAC PolicyRules for semantic equality

func QueryMetric

func QueryMetric(metricsName string, kubeconfigPath string) (string, error)

QueryMetric queries a metric from the Prometheus host, derived from the kubeconfig

func SearchLog added in v0.14.0

func SearchLog(index string, query ElasticQuery) map[string]interface{}

SearchLog search recent log records for the index with matching filters.

func SecretsCreated

func SecretsCreated(namespace string, names ...string) bool

SecretsCreated checks if all the secrets identified by names are created

func SliceContainsPolicyRule

func SliceContainsPolicyRule(ruleSlice []rbacv1.PolicyRule, rule rbacv1.PolicyRule) bool

SliceContainsPolicyRule determines if a given rule is in a slice of rules

func SliceContainsString

func SliceContainsString(slice []string, s string) bool

SliceContainsString checks if the input slice (an array of strings) contains an entry which matches the string s

func SlicesContainSameStrings

func SlicesContainSameStrings(strings1, strings2 []string) bool

SlicesContainSameStrings compares two slices and returns true if they contain the same strings in any order

Types

type ACMEStagingCerts added in v0.14.0

type ACMEStagingCerts struct {
	// contains filtered or unexported fields
}

type APIEndpoint

type APIEndpoint struct {
	AccessToken string `json:"access_token"`
	APIURL      string
	HTTPClient  *retryablehttp.Client
}

APIEndpoint contains information needed to access an API

func GetAPIEndpoint

func GetAPIEndpoint(kubeconfigPath string) (*APIEndpoint, error)

GetAPIEndpoint returns the APIEndpoint stub with AccessToken, from the given cluster

func (*APIEndpoint) Delete

func (api *APIEndpoint) Delete(path string) (*HTTPResponse, error)

Delete Invoke DELETE API Request

func (*APIEndpoint) Get

func (api *APIEndpoint) Get(path string) (*HTTPResponse, error)

Get Invoke GET API Request

func (*APIEndpoint) GetElasticURL

func (api *APIEndpoint) GetElasticURL() (string, error)

GetElasticURL fetches ElasticSearch endpoint URL

func (*APIEndpoint) GetIngress

func (api *APIEndpoint) GetIngress(namespace, name string) (*extensionsv1beta1.Ingress, error)

GetIngress fetches ingress from api

func (*APIEndpoint) Patch

func (api *APIEndpoint) Patch(path string, body io.Reader) (*HTTPResponse, error)

Patch Invoke POST API Request

func (*APIEndpoint) Post

func (api *APIEndpoint) Post(path string, body io.Reader) (*HTTPResponse, error)

Post Invoke POST API Request

func (*APIEndpoint) Request

func (api *APIEndpoint) Request(method, path string, body io.Reader) (*HTTPResponse, error)

Request Invoke API

type ElasticQuery added in v0.14.0

type ElasticQuery struct {
	Filters []Match
	MustNot []Match
}

ElasticQuery describes an Elasticsearch Query

type HTTPResponse

type HTTPResponse struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

HTTPResponse represents an HTTP response including the read body

func Delete

func Delete(url string, hostHeader string) (*HTTPResponse, error)

Delete executes an HTTP DELETE

func GetWebPage added in v0.17.0

func GetWebPage(url string, hostHeader string) (*HTTPResponse, error)

GetWebPage makes an HTTP GET request using a retryable client configured with the Verrazzano cert bundle

func GetWebPageWithBasicAuth

func GetWebPageWithBasicAuth(url string, hostHeader string, username string, password string, kubeconfigPath string) (*HTTPResponse, error)

GetWebPageWithBasicAuth gets a web page using basic auth, using a given kubeconfig

func GetWebPageWithClient added in v0.17.0

func GetWebPageWithClient(httpClient *retryablehttp.Client, url string, hostHeader string) (*HTTPResponse, error)

GetWebPageWithClient submits a GET request using the specified client.

func PostWithBasicAuth added in v0.17.0

func PostWithBasicAuth(url, body, username, password, kubeconfigPath string) (*HTTPResponse, error)

PostWithBasicAuth retries POST using basic auth

func PostWithHostHeader

func PostWithHostHeader(url, contentType string, hostHeader string, body io.Reader) (*HTTPResponse, error)

PostWithHostHeader posts a request with a specified Host header

func ProcessHTTPResponse added in v0.17.0

func ProcessHTTPResponse(resp *http.Response) (*HTTPResponse, error)

ProcessHTTPResponse processes the HTTP response by reading and closing the body, then returning the HTTPResponse object. This function is used to prevent file descriptor leaks and other problems. See https://github.com/golang/go/blob/master/src/net/http/response.go

Params

resp: Http response returned by http call
httpErr: Http error returned by the http call

Returns

HttpReponse which has the body and status code.

func PutWithHostHeader

func PutWithHostHeader(url, contentType string, hostHeader string, body io.Reader) (*HTTPResponse, error)

PutWithHostHeader PUTs a request with a specified Host header

type KeycloakRESTClient added in v0.14.0

type KeycloakRESTClient struct {
	// contains filtered or unexported fields
}

func NewKeycloakAdminRESTClient added in v0.15.0

func NewKeycloakAdminRESTClient() (*KeycloakRESTClient, error)

NewKeycloakRESTClient creates a new Keycloak REST client.

func (*KeycloakRESTClient) CreateUser added in v0.14.0

func (c *KeycloakRESTClient) CreateUser(userRealm string, userName string, firstName string, lastName string, password string) (string, error)

CreateUser creates a user in Keycloak curl -v http://localhost:8080/auth/admin/realms/apiv2/users -H "Content-Type: application/json" -H "Authorization: bearer $TOKEN" --data '{"username":"someuser", "firstName":"xyz", "lastName":"xyz", "email":"demo2@gmail.com", "enabled":"true"}'

func (*KeycloakRESTClient) DeleteUser added in v0.14.0

func (c *KeycloakRESTClient) DeleteUser(userRealm string, userID string) error

DeleteUser deletes a user from Keycloak DELETE /auth/admin/realms/<realm>/users/<userID>

func (*KeycloakRESTClient) GetRealm added in v0.14.0

func (c *KeycloakRESTClient) GetRealm(realm string) (map[string]interface{}, error)

GetRealm gets realm data from Keycloak.

func (*KeycloakRESTClient) SetPassword added in v0.14.0

func (c *KeycloakRESTClient) SetPassword(userRealm string, userID string, password string) error

SetPassword sets a user's password in Keycloak PUT /auth/admin/realms/{realm}/users/{id}/reset-password { "type": "password", "temporary": false, "value": "..." }

type LogLevel

type LogLevel int

LogLevel is the logging level used to control log output

const (
	// Error level designates error events that might still allow the application to continue running
	Error LogLevel = 1
	// Info level designates informational messages that highlight the progress of the application at coarse-grained level
	Info LogLevel = 4
	// Debug level designates fine-grained informational events that are most useful to debug an application
	Debug LogLevel = 7
)

type Match added in v0.14.0

type Match struct {
	Key   string
	Value string
}

Match describes a match_phrase in Elasticsearch Query

type UsernamePassword

type UsernamePassword struct {
	Username string
	Password string
}

UsernamePassword - Username and Password credentials

func GetSystemVMICredentials

func GetSystemVMICredentials() (*UsernamePassword, error)

GetSystemVMICredentials - Obtain VMI system credentials

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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