fix: remove employer field entirely
This commit is contained in:
parent
45640689e4
commit
c731a5c64e
@ -21,12 +21,11 @@ type contributorProfileFrontmatter struct {
|
|||||||
GithubUsername string `yaml:"github"`
|
GithubUsername string `yaml:"github"`
|
||||||
// Script assumes that if value is nil, the Registry site build step will
|
// Script assumes that if value is nil, the Registry site build step will
|
||||||
// backfill the value with the user's GitHub avatar URL
|
// backfill the value with the user's GitHub avatar URL
|
||||||
AvatarURL *string `yaml:"avatar"`
|
AvatarURL *string `yaml:"avatar"`
|
||||||
LinkedinURL *string `yaml:"linkedin"`
|
LinkedinURL *string `yaml:"linkedin"`
|
||||||
WebsiteURL *string `yaml:"website"`
|
WebsiteURL *string `yaml:"website"`
|
||||||
SupportEmail *string `yaml:"support_email"`
|
SupportEmail *string `yaml:"support_email"`
|
||||||
EmployerGithubUsername *string `yaml:"employer_github"`
|
ContributorStatus *string `yaml:"status"`
|
||||||
ContributorStatus *string `yaml:"status"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type contributorProfile struct {
|
type contributorProfile struct {
|
||||||
@ -47,29 +46,6 @@ func validateContributorGithubUsername(githubUsername string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateContributorEmployerGithubUsername(employerGithubUsername *string, githubUsername string) []error {
|
|
||||||
if employerGithubUsername == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
errs := []error{}
|
|
||||||
if *employerGithubUsername == "" {
|
|
||||||
errs = append(errs, errors.New("company_github field is defined but has empty value"))
|
|
||||||
return errs
|
|
||||||
}
|
|
||||||
|
|
||||||
lower := strings.ToLower(*employerGithubUsername)
|
|
||||||
if uriSafe := url.PathEscape(lower); uriSafe != lower {
|
|
||||||
errs = append(errs, fmt.Errorf("gitHub company username %q is not a valid URL path segment", *employerGithubUsername))
|
|
||||||
}
|
|
||||||
|
|
||||||
if *employerGithubUsername == githubUsername {
|
|
||||||
errs = append(errs, fmt.Errorf("cannot list own GitHub name (%q) as employer", githubUsername))
|
|
||||||
}
|
|
||||||
|
|
||||||
return errs
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateContributorDisplayName(displayName string) error {
|
func validateContributorDisplayName(displayName string) error {
|
||||||
if displayName == "" {
|
if displayName == "" {
|
||||||
return fmt.Errorf("missing display_name")
|
return fmt.Errorf("missing display_name")
|
||||||
@ -211,9 +187,6 @@ func validateContributorYaml(yml contributorProfile) []error {
|
|||||||
allErrs = append(allErrs, addFilePathToError(yml.filePath, err))
|
allErrs = append(allErrs, addFilePathToError(yml.filePath, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, err := range validateContributorEmployerGithubUsername(yml.frontmatter.EmployerGithubUsername, yml.frontmatter.GithubUsername) {
|
|
||||||
allErrs = append(allErrs, addFilePathToError(yml.filePath, err))
|
|
||||||
}
|
|
||||||
for _, err := range validateContributorSupportEmail(yml.frontmatter.SupportEmail) {
|
for _, err := range validateContributorSupportEmail(yml.frontmatter.SupportEmail) {
|
||||||
allErrs = append(allErrs, addFilePathToError(yml.filePath, err))
|
allErrs = append(allErrs, addFilePathToError(yml.filePath, err))
|
||||||
}
|
}
|
||||||
@ -264,7 +237,6 @@ func parseContributorFiles(readmeEntries []readme) (map[string]contributorProfil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
employeeGithubGroups := map[string][]string{}
|
|
||||||
yamlValidationErrors := []error{}
|
yamlValidationErrors := []error{}
|
||||||
for _, p := range profilesByUsername {
|
for _, p := range profilesByUsername {
|
||||||
errors := validateContributorYaml(p)
|
errors := validateContributorYaml(p)
|
||||||
@ -272,19 +244,6 @@ func parseContributorFiles(readmeEntries []readme) (map[string]contributorProfil
|
|||||||
yamlValidationErrors = append(yamlValidationErrors, errors...)
|
yamlValidationErrors = append(yamlValidationErrors, errors...)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.frontmatter.EmployerGithubUsername != nil {
|
|
||||||
employeeGithubGroups[*p.frontmatter.EmployerGithubUsername] = append(
|
|
||||||
employeeGithubGroups[*p.frontmatter.EmployerGithubUsername],
|
|
||||||
p.frontmatter.GithubUsername,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for companyName, group := range employeeGithubGroups {
|
|
||||||
if _, found := profilesByUsername[companyName]; found {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
yamlValidationErrors = append(yamlValidationErrors, fmt.Errorf("%q: company %q does not exist but is referenced by these profiles: [%s]", rootRegistryPath, companyName, strings.Join(group, ", ")))
|
|
||||||
}
|
}
|
||||||
if len(yamlValidationErrors) != 0 {
|
if len(yamlValidationErrors) != 0 {
|
||||||
return nil, validationPhaseError{
|
return nil, validationPhaseError{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user