Rename GitHub specific types

This change renames a lot of variables, types and functions to be more
generic. The goal is to allow GARM to add more forges in the future.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2025-05-12 21:47:13 +00:00
parent 4890eb4732
commit 40e6581a75
72 changed files with 896 additions and 700 deletions

View file

@ -77,7 +77,7 @@ func updateGithubCredentials(apiCli *client.GarmAPI, apiAuthToken runtime.Client
return &updateCredentialsResponse.Payload, nil
}
func createGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointParams params.CreateGithubEndpointParams) (*params.GithubEndpoint, error) {
func createGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointParams params.CreateGithubEndpointParams) (*params.ForgeEndpoint, error) {
createEndpointResponse, err := apiCli.Endpoints.CreateGithubEndpoint(
clientEndpoints.NewCreateGithubEndpointParams().WithBody(endpointParams),
apiAuthToken)
@ -87,7 +87,7 @@ func createGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAut
return &createEndpointResponse.Payload, nil
}
func listGithubEndpoints(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter) (params.GithubEndpoints, error) {
func listGithubEndpoints(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter) (params.ForgeEndpoints, error) {
listEndpointsResponse, err := apiCli.Endpoints.ListGithubEndpoints(
clientEndpoints.NewListGithubEndpointsParams(),
apiAuthToken)
@ -97,7 +97,7 @@ func listGithubEndpoints(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuth
return listEndpointsResponse.Payload, nil
}
func getGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointName string) (*params.GithubEndpoint, error) {
func getGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointName string) (*params.ForgeEndpoint, error) {
getEndpointResponse, err := apiCli.Endpoints.GetGithubEndpoint(
clientEndpoints.NewGetGithubEndpointParams().WithName(endpointName),
apiAuthToken)
@ -113,7 +113,7 @@ func deleteGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAut
apiAuthToken)
}
func updateGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointName string, endpointParams params.UpdateGithubEndpointParams) (*params.GithubEndpoint, error) {
func updateGithubEndpoint(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter, endpointName string, endpointParams params.UpdateGithubEndpointParams) (*params.ForgeEndpoint, error) {
updateEndpointResponse, err := apiCli.Endpoints.UpdateGithubEndpoint(
clientEndpoints.NewUpdateGithubEndpointParams().WithName(endpointName).WithBody(endpointParams),
apiAuthToken)

View file

@ -25,7 +25,7 @@ func (suite *GarmSuite) TestGithubCredentialsErrorOnDuplicateCredentialsName() {
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
PAT: params.GithubPAT{
OAuth2Token: "dummy",
},
@ -68,7 +68,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailsOnInvalidAuthType() {
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthType("invalid"),
AuthType: params.ForgeAuthType("invalid"),
PAT: params.GithubPAT{
OAuth2Token: "dummy",
},
@ -87,7 +87,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailsWhenAuthTypeParamsAreIncorrect
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
App: params.GithubApp{
AppID: 123,
InstallationID: 456,
@ -107,7 +107,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailsWhenAuthTypeParamsAreMissing()
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypeApp,
AuthType: params.ForgeAuthTypeApp,
}
_, err := createGithubCredentials(suite.cli, suite.authToken, createCredsParams)
suite.Error(err, "expected error when creating credentials with missing auth type params")
@ -147,7 +147,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailWhenAppKeyIsInvalid() {
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypeApp,
AuthType: params.ForgeAuthTypeApp,
App: params.GithubApp{
AppID: 123,
InstallationID: 456,
@ -166,7 +166,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailWhenEndpointDoesntExist() {
Name: dummyCredentialsName,
Endpoint: "iDontExist.example.com",
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
PAT: params.GithubPAT{
OAuth2Token: "dummy",
},
@ -189,7 +189,7 @@ func (suite *GarmSuite) TestGithubCredentialsFailsOnDuplicateName() {
Name: dummyCredentialsName,
Endpoint: defaultEndpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
PAT: params.GithubPAT{
OAuth2Token: "dummy",
},
@ -204,7 +204,7 @@ func (suite *GarmSuite) createDummyCredentials(name, endpointName string) (*para
Name: name,
Endpoint: endpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
PAT: params.GithubPAT{
OAuth2Token: "dummy",
},

View file

@ -8,7 +8,7 @@ import (
"github.com/cloudbase/garm/params"
)
func checkEndpointParamsAreEqual(a, b params.GithubEndpoint) error {
func checkEndpointParamsAreEqual(a, b params.ForgeEndpoint) error {
if a.Name != b.Name {
return fmt.Errorf("endpoint name mismatch")
}

View file

@ -163,7 +163,7 @@ func (suite *GarmSuite) MustDefaultGithubEndpoint() {
suite.Equal(ep.Name, "github.com", "default GitHub endpoint name mismatch")
}
func (suite *GarmSuite) GetGithubEndpoint(name string) *params.GithubEndpoint {
func (suite *GarmSuite) GetGithubEndpoint(name string) *params.ForgeEndpoint {
t := suite.T()
t.Log("Get GitHub endpoint")
endpoint, err := getGithubEndpoint(suite.cli, suite.authToken, name)
@ -172,7 +172,7 @@ func (suite *GarmSuite) GetGithubEndpoint(name string) *params.GithubEndpoint {
return endpoint
}
func (suite *GarmSuite) CreateGithubEndpoint(params params.CreateGithubEndpointParams) (*params.GithubEndpoint, error) {
func (suite *GarmSuite) CreateGithubEndpoint(params params.CreateGithubEndpointParams) (*params.ForgeEndpoint, error) {
t := suite.T()
t.Log("Create GitHub endpoint")
endpoint, err := createGithubEndpoint(suite.cli, suite.authToken, params)
@ -190,7 +190,7 @@ func (suite *GarmSuite) DeleteGithubEndpoint(name string) error {
return nil
}
func (suite *GarmSuite) ListGithubEndpoints() params.GithubEndpoints {
func (suite *GarmSuite) ListGithubEndpoints() params.ForgeEndpoints {
t := suite.T()
t.Log("List GitHub endpoints")
endpoints, err := listGithubEndpoints(suite.cli, suite.authToken)
@ -199,7 +199,7 @@ func (suite *GarmSuite) ListGithubEndpoints() params.GithubEndpoints {
return endpoints
}
func (suite *GarmSuite) createDummyEndpoint(name string) (*params.GithubEndpoint, error) {
func (suite *GarmSuite) createDummyEndpoint(name string) (*params.ForgeEndpoint, error) {
endpointParams := params.CreateGithubEndpointParams{
Name: name,
Description: "Dummy endpoint",

View file

@ -22,7 +22,7 @@ func (suite *GarmSuite) EnsureTestCredentials(name string, oauthToken string, en
Name: name,
Endpoint: endpointName,
Description: "GARM test credentials",
AuthType: params.GithubAuthTypePAT,
AuthType: params.ForgeAuthTypePAT,
PAT: params.GithubPAT{
OAuth2Token: oauthToken,
},