Skip to content

extsvc: Reduce use of raw servicetype strings

Administrator requested to merge servicetype-constants into master

Created by: ryanslade

This change moves all `codehost.ServiceType' constants into the 'extsvc' package.

internal/extsvc/awscodecommit.ServiceType -> extsvc.TypeAWSCodeCommit internal/extsvc/bitbucketserver.ServiceType -> extsvc.TypeBitbucketServer internal/extsvc/bitbucketcloud.ServiceType -> extsvc.TypeABitbucketCloud internal/extsvc/github.ServiceType -> extsvc.TypeGitHub internal/extsvc/gitlab.ServiceType -> extsvc.TypeGitLab

They needed to move in order to avoid circular references.

Added these constants:

extsvc.TypeGitolite extsvc.TypePhabricator extsvc.TypeOther

Replaces all occurrences of raw strings to constants where the strings were used to reference service type.

Also cleaned up a few occurrences of 'Kind' constants (https://github.com/sourcegraph/sourcegraph/blob/5ef91549cc209d09a532d3328b28e9cd02d6bee6/internal/extsvc/types.go#L72-L79) that I missed in the previous refactor (https://github.com/sourcegraph/sourcegraph/pull/11290)

NOTE: One outstanding issue that I'll address in another PR is that both bitbucket server and bitbucket cloud have case sensitive constants defined ('bitbucketServer' and 'bitbucketCloud') which will need a bit more work to refactor as some code assumed lowercase.

I'd rather get this merged before working on that as this change touches a lot of code and I want to avoid merge conflicts.

Part of: https://github.com/sourcegraph/sourcegraph/issues/10296

Merge request reports

Loading