diff --git a/enterprise/internal/campaigns/reconciler/util.go b/enterprise/internal/campaigns/reconciler/util.go index 1235e7c28af..9af1f76e631 100644 --- a/enterprise/internal/campaigns/reconciler/util.go +++ b/enterprise/internal/campaigns/reconciler/util.go @@ -5,28 +5,14 @@ import ( "github.com/pkg/errors" - "github.com/sourcegraph/sourcegraph/internal/api" "github.com/sourcegraph/sourcegraph/internal/database" "github.com/sourcegraph/sourcegraph/internal/types" "github.com/sourcegraph/sourcegraph/schema" ) // TODO: copy-pasted -type RepoStore interface { - Get(ctx context.Context, id api.RepoID) (*types.Repo, error) -} - -// TODO: copy-pasted -type ExternalServiceStore interface { - List(context.Context, database.ExternalServicesListOptions) ([]*types.ExternalService, error) -} - -// TODO: copy-pasted -func loadExternalService(ctx context.Context, esStore ExternalServiceStore, repo *types.Repo) (*types.ExternalService, error) { - var externalService *types.ExternalService - args := database.ExternalServicesListOptions{IDs: repo.ExternalServiceIDs()} - - es, err := esStore.List(ctx, args) +func loadExternalService(ctx context.Context, esStore *database.ExternalServiceStore, repo *types.Repo) (*types.ExternalService, error) { + es, err := esStore.List(ctx, database.ExternalServicesListOptions{IDs: repo.ExternalServiceIDs()}) if err != nil { return nil, err } @@ -40,25 +26,18 @@ func loadExternalService(ctx context.Context, esStore ExternalServiceStore, repo switch cfg := cfg.(type) { case *schema.GitHubConnection: if cfg.Token != "" { - externalService = e + return e, nil } case *schema.BitbucketServerConnection: if cfg.Token != "" { - externalService = e + return e, nil } case *schema.GitLabConnection: if cfg.Token != "" { - externalService = e + return e, nil } } - if externalService != nil { - break - } } - if externalService == nil { - return nil, errors.Errorf("no external services found for repo %q", repo.Name) - } - - return externalService, nil + return nil, errors.Errorf("no external services found for repo %q", repo.Name) }