github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/pkg/clients/has/controller.go (about)

     1  package has
     2  
     3  import (
     4  	"github.com/redhat-appstudio/e2e-tests/pkg/constants"
     5  	"github.com/redhat-appstudio/e2e-tests/pkg/utils"
     6  
     7  	"github.com/redhat-appstudio/e2e-tests/pkg/clients/github"
     8  	kubeCl "github.com/redhat-appstudio/e2e-tests/pkg/clients/kubernetes"
     9  )
    10  
    11  // Factory to initialize the comunication against different API like github or kubernetes.
    12  type HasController struct {
    13  	// A Client manages communication with the GitHub API in a specific Organization.
    14  	Github *github.Github
    15  
    16  	// Generates a kubernetes client to interact with clusters.
    17  	*kubeCl.CustomClient
    18  }
    19  
    20  // Initializes all the clients and return interface to operate with application-service controller.
    21  func NewSuiteController(kube *kubeCl.CustomClient) (*HasController, error) {
    22  	gh, err := github.NewGithubClient(utils.GetEnv(constants.GITHUB_TOKEN_ENV, ""),
    23  		utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"))
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	return &HasController{
    29  		gh,
    30  		kube,
    31  	}, nil
    32  }