(ctx context.Context, param params.CreateGithubEndpointParams)
| 25 | ) |
| 26 | |
| 27 | func (r *Runner) CreateGithubEndpoint(ctx context.Context, param params.CreateGithubEndpointParams) (params.ForgeEndpoint, error) { |
| 28 | if !auth.IsAdmin(ctx) { |
| 29 | return params.ForgeEndpoint{}, runnerErrors.ErrUnauthorized |
| 30 | } |
| 31 | if len(param.CACertBundle) > 0 { |
| 32 | // deduplicate before storing. |
| 33 | sanitized, err := util.SanitizeCABundle(param.CACertBundle) |
| 34 | if err != nil { |
| 35 | return params.ForgeEndpoint{}, fmt.Errorf("failed to sanitize CA bundle: %w", err) |
| 36 | } |
| 37 | param.CACertBundle = sanitized |
| 38 | } |
| 39 | |
| 40 | if err := param.Validate(); err != nil { |
| 41 | return params.ForgeEndpoint{}, fmt.Errorf("error failed to validate github endpoint params: %w", err) |
| 42 | } |
| 43 | |
| 44 | ep, err := r.store.CreateGithubEndpoint(ctx, param) |
| 45 | if err != nil { |
| 46 | return params.ForgeEndpoint{}, fmt.Errorf("failed to create github endpoint: %w", err) |
| 47 | } |
| 48 | |
| 49 | return ep, nil |
| 50 | } |
| 51 | |
| 52 | func (r *Runner) GetGithubEndpoint(ctx context.Context, name string) (params.ForgeEndpoint, error) { |
| 53 | if !auth.IsAdmin(ctx) { |
nothing calls this directly
no test coverage detected