github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/pkg/clients/common/controller.go (about) 1 package common 2 3 import ( 4 "fmt" 5 6 "github.com/redhat-appstudio/e2e-tests/pkg/clients/github" 7 "github.com/redhat-appstudio/e2e-tests/pkg/clients/gitlab" 8 kubeCl "github.com/redhat-appstudio/e2e-tests/pkg/clients/kubernetes" 9 "github.com/redhat-appstudio/e2e-tests/pkg/constants" 10 "github.com/redhat-appstudio/e2e-tests/pkg/utils" 11 ) 12 13 // Create the struct for kubernetes and github clients. 14 type SuiteController struct { 15 // Wrap K8S client go to interact with Kube cluster 16 *kubeCl.CustomClient 17 18 // Github client to interact with GH apis 19 Github *github.Github 20 Gitlab *gitlab.GitlabClient 21 } 22 23 /* 24 Create controller for the common kubernetes API crud operations. This controller should be used only to interact with non RHTAP/AppStudio APIS like routes, deployment, pods etc... 25 Check if a github organization env var is set, if not use by default the redhat-appstudio-qe org. See: https://github.com/redhat-appstudio-qe 26 */ 27 func NewSuiteController(kubeC *kubeCl.CustomClient) (*SuiteController, error) { 28 gh, err := github.NewGithubClient(utils.GetEnv(constants.GITHUB_TOKEN_ENV, ""), utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe")) 29 if err != nil { 30 return nil, err 31 } 32 33 gl, err := gitlab.NewGitlabClient(utils.GetEnv(constants.GITLAB_TOKEN_ENV, ""), utils.GetEnv(constants.GITLAB_URL_ENV, "")) 34 if err != nil { 35 return nil, fmt.Errorf("failed to authenticate with GitLab: %w", err) 36 } 37 38 return &SuiteController{ 39 kubeC, 40 gh, 41 gl, 42 }, nil 43 }