MCPcopy Create free account
hub / github.com/encoder-run/operator / gitAuth

Function gitAuth

cmd/repositoryembedder/main.go:444–463  ·  view source on GitHub ↗
(c client.Client, r *v1alpha1.Repository)

Source from the content-addressed store, hash-verified

442}
443
444func gitAuth(c client.Client, r *v1alpha1.Repository) (githttp.AuthMethod, error) {
445 switch r.Spec.Type {
446 case v1alpha1.RepositoryTypeGithub:
447 // get the secret
448 secret := &corev1.Secret{}
449 if err := c.Get(context.TODO(), client.ObjectKey{Name: r.Name, Namespace: r.Namespace}, secret); err != nil {
450 return nil, err
451 }
452
453 tokenBytes, ok := secret.Data["token"]
454 if !ok {
455 return nil, errors.New("token not found in secret")
456 }
457 token := string(tokenBytes)
458
459 return &githttp.BasicAuth{Username: "encoder-run", Password: token}, nil
460 default:
461 return nil, fmt.Errorf("unsupported repository type: %s", r.Spec.Type)
462 }
463}
464
465func postgresStorageStorer(c client.Client, s *v1alpha1.Storage, nsPrefix string) (storage.Storer, *gorm.DB, error) {
466 // get the password from the postgres secret

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected