resources

package
v0.0.0-...-58b7b8b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ThreeScalePingUrl          = "%v/p/admin/applications"
	ThreeScaleProductCreateUrl = "%v/apiconfig/services"
	ThreeScaleProductDeleteUrl = "%v/apiconfig/services/%v"
	ThreeScaleClient           = "3scale"
	ThreeScaleUserInviteUrl    = "%v/p/admin/account/invitations/"
)
View Source
const (
	OpenshiftPathListProjects = "/api/kubernetes/apis/project.openshift.io/v1/projects"
	OpenshiftPathGetProject   = "/api/kubernetes/apis/project.openshift.io/v1/projects/%v"
	OpenshiftPathListPods     = "/api/kubernetes/api/v1/namespaces/%v/pods"
	OpenshiftPathGetSecret    = "/api/kubernetes/api/v1/namespaces/%s/secrets"
	PathListRHMI              = "/apis/integreatly.org/v1alpha1/namespaces/%s/rhmis"
	PathGetRHMI               = "/apis/integreatly.org/v1alpha1/namespaces/%s/rhmis/%s"
	PathGetRoute              = "/apis/route.openshift.io/v1/namespaces/%s/routes/%s"
)

#nosec G101 -- This is a false positive

View Source
const (
	OpenshiftAuthenticationNamespace = "openshift-authentication"
	OpenshiftOAuthRouteName          = "oauth-openshift"

	PathProjectRequests = "/apis/project.openshift.io/v1/projectrequests"
	PathProjects        = "/api/kubernetes/apis/apis/project.openshift.io/v1/projects"
)

Variables

This section is empty.

Functions

func Auth3Scale

func Auth3Scale(client *http.Client, redirectUrl, keycloakHost, clientId, secret string) (string, error)

func DoAuthOpenshiftUser

func DoAuthOpenshiftUser(authPageURL string, username string, password string, httpClient *http.Client, idp string, l SimpleLogger) error

doAuthOpenshiftUser this function expects users and IDP to be created via `./scripts/setup-sso-idp.sh`

func OpenshiftClientSubmitForm

func OpenshiftClientSubmitForm(browser *browser.Browser, username, password string, idp string, l SimpleLogger) error

openshiftOAuthProxyLogin Retrieve a cookie by logging in through the OpenShift OAuth Proxy

func OpenshiftUserReconcileCheck

func OpenshiftUserReconcileCheck(openshiftClient *OpenshiftClient, k8sclient dynclient.Client, namespacePrefix, username string) error

Checks if openshift user has been reconciled to the openshift realm in keycloak

func ParseHtmlResponse

func ParseHtmlResponse(r *http.Response) (*goquery.Document, error)

func ProxyOAuth

func ProxyOAuth(client *http.Client, host string, username string, password string) (*http.Client, error)

Login a user through the oauth proxy

Types

type CallbackOptions

type CallbackOptions struct {
	Response string `url:"response_type"`
	Scope    string `url:"scope"`
	State    string `url:"state"`
}

CallbackOptions used to create and parse url callback options

type LoginOptions

type LoginOptions struct {
	Client string `url:"client_id"`
	IDP    string `url:"idp"`
}

LoginOptions used to create and parse url login options

type OpenshiftClient

type OpenshiftClient struct {
	HTTPClient *http.Client
	MasterUrl  string
	ApiUrl     string
}

func NewOpenshiftClient

func NewOpenshiftClient(httpClient *http.Client, masterUrl string) *OpenshiftClient

func (*OpenshiftClient) DoOpenshiftCreatePodInANamespace

func (oc *OpenshiftClient) DoOpenshiftCreatePodInANamespace(namespace string, podCR *corev1.Pod) error

func (*OpenshiftClient) DoOpenshiftCreateProject

func (oc *OpenshiftClient) DoOpenshiftCreateProject(projectCR *projectv1.ProjectRequest) error

func (*OpenshiftClient) DoOpenshiftCreateServiceInANamespace

func (oc *OpenshiftClient) DoOpenshiftCreateServiceInANamespace(namespace string, serviceCR *corev1.Service) error

func (*OpenshiftClient) DoOpenshiftDeleteRequest

func (oc *OpenshiftClient) DoOpenshiftDeleteRequest(path string) (*http.Response, error)

make a delete request, expects a path

func (*OpenshiftClient) DoOpenshiftGetRequest

func (oc *OpenshiftClient) DoOpenshiftGetRequest(path string) (*http.Response, error)

makes a get request, expects a path

func (*OpenshiftClient) DoOpenshiftPostRequest

func (oc *OpenshiftClient) DoOpenshiftPostRequest(path string, data []byte) (*http.Response, error)

makes a post request, expects a path and the body

func (*OpenshiftClient) DoOpenshiftPutRequest

func (oc *OpenshiftClient) DoOpenshiftPutRequest(path string, data []byte) (*http.Response, error)

makes a put request, expects a path and the body

func (*OpenshiftClient) GetProject

func (oc *OpenshiftClient) GetProject(projectName string) (*projectv1.Project, error)

returns a project

func (*OpenshiftClient) GetRequest

func (oc *OpenshiftClient) GetRequest(path string) (*http.Response, error)

makes a get request to the specified openshift api endpoint

func (*OpenshiftClient) ListPods

func (oc *OpenshiftClient) ListPods(projectName string) (*corev1.PodList, error)

returns all pods in a namesapce

func (*OpenshiftClient) ListProjects

func (oc *OpenshiftClient) ListProjects() (*projectv1.ProjectList, error)

returns all projects

func (*OpenshiftClient) PerformRequest

func (oc *OpenshiftClient) PerformRequest(req *http.Request) (*http.Response, error)

Common function for setting auth headers on request and performing the request

type SimpleLogger

type SimpleLogger interface {
	Log(...interface{})
}

type ThreeScaleAPIClient

type ThreeScaleAPIClient interface {
	Ping() error
	LoginOpenshift(masterUrl, username, password, namespacePrefix string) error
	Login3Scale(clientSecret string) error
	CreateProduct(name string) (string, error)
	DeleteProduct(href string) error
	SendUserInvitation(name string) (string, error)
	SetUserAsAdmin(username string, email string, userID string) error
	GetUserId(username string) (string, error)
	VerifyUserIsAdmin(userID string) (bool, error)
}

func NewThreeScaleAPIClient

func NewThreeScaleAPIClient(host, keycloakHost, redirectUrl string, client *http.Client, kubeClient k8sclient.Client, logger SimpleLogger) ThreeScaleAPIClient

type ThreeScaleAPIClientImpl

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

func (*ThreeScaleAPIClientImpl) CreateProduct

func (r *ThreeScaleAPIClientImpl) CreateProduct(name string) (string, error)

Create a 3Scale product

func (*ThreeScaleAPIClientImpl) DeleteProduct

func (r *ThreeScaleAPIClientImpl) DeleteProduct(id string) error

Delete a 3Scale product by id

func (*ThreeScaleAPIClientImpl) GetUserId

func (r *ThreeScaleAPIClientImpl) GetUserId(username string) (string, error)

func (*ThreeScaleAPIClientImpl) Login3Scale

func (r *ThreeScaleAPIClientImpl) Login3Scale(clientSecret string) error

func (*ThreeScaleAPIClientImpl) LoginOpenshift

func (r *ThreeScaleAPIClientImpl) LoginOpenshift(masterUrl, username, password, namespacePrefix string) error

func (*ThreeScaleAPIClientImpl) Ping

func (r *ThreeScaleAPIClientImpl) Ping() error

Call the applications endpoint of 3Scale to make sure it is available and the user has permissions to retrieve the list of applications

func (*ThreeScaleAPIClientImpl) SendUserInvitation

func (r *ThreeScaleAPIClientImpl) SendUserInvitation(name string) (string, error)

Create a 3Scale user invite

func (*ThreeScaleAPIClientImpl) SetUserAsAdmin

func (r *ThreeScaleAPIClientImpl) SetUserAsAdmin(username string, email string, userID string) error

func (*ThreeScaleAPIClientImpl) VerifyUserIsAdmin

func (r *ThreeScaleAPIClientImpl) VerifyUserIsAdmin(userID string) (bool, error)

type User

type User struct {
	Username string `url:"username"`
	Password string `url:"password"`
}

User used to create url user query

Jump to

Keyboard shortcuts

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