MCPcopy Create free account
hub / github.com/cloudbase/garm / CreateGithubEndpoint

Method CreateGithubEndpoint

database/sql/github.go:30–64  ·  view source on GitHub ↗
(_ context.Context, param params.CreateGithubEndpointParams)

Source from the content-addressed store, hash-verified

28)
29
30func (s *sqlDatabase) CreateGithubEndpoint(_ context.Context, param params.CreateGithubEndpointParams) (ghEndpoint params.ForgeEndpoint, err error) {
31 defer func() {
32 if err == nil {
33 s.sendNotify(common.GithubEndpointEntityType, common.CreateOperation, ghEndpoint)
34 }
35 }()
36 var endpoint GithubEndpoint
37 err = s.conn.Transaction(func(tx *gorm.DB) error {
38 if err := tx.Where("name = ?", param.Name).First(&endpoint).Error; err == nil {
39 return fmt.Errorf("error github endpoint already exists: %w", runnerErrors.ErrDuplicateEntity)
40 }
41 endpoint = GithubEndpoint{
42 Name: param.Name,
43 Description: param.Description,
44 APIBaseURL: param.APIBaseURL,
45 BaseURL: param.BaseURL,
46 UploadBaseURL: param.UploadBaseURL,
47 CACertBundle: param.CACertBundle,
48 EndpointType: params.GithubEndpointType,
49 }
50
51 if err := tx.Create(&endpoint).Error; err != nil {
52 return fmt.Errorf("error creating github endpoint: %w", err)
53 }
54 return nil
55 })
56 if err != nil {
57 return params.ForgeEndpoint{}, fmt.Errorf("error creating github endpoint: %w", err)
58 }
59 ghEndpoint, err = s.sqlToCommonGithubEndpoint(endpoint)
60 if err != nil {
61 return params.ForgeEndpoint{}, fmt.Errorf("error converting github endpoint: %w", err)
62 }
63 return ghEndpoint, nil
64}
65
66func (s *sqlDatabase) ListGithubEndpoints(_ context.Context) ([]params.ForgeEndpoint, error) {
67 var endpoints []GithubEndpoint

Callers 2

ensureGithubEndpointMethod · 0.95

Calls 2

sendNotifyMethod · 0.95

Tested by

no test coverage detected