Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gh check failing due to missing github organization #462

Merged
merged 2 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func getProjectPrompts(projectName string, modules map[string]moduleconfig.Modul
"GithubRootOrg": {
Parameter: moduleconfig.Parameter{
Field: "GithubRootOrg",
Label: "What's the root of the github org to create repositories in?",
Label: "What's the root of the github organization that will own these repositories?",
Info: "This should be github.com/<your-organization-name>",
Default: "github.com/",
},
Condition: KeyMatchCondition("ShouldPushRepositories", "y"),
Validate: NoValidation,
Condition: NoCondition,
Validate: ValidateOrganizationName,
},
}

Expand Down
15 changes: 15 additions & 0 deletions internal/init/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ func ValidateProjectName(input string) error {
return nil
}

// ValidateOrganizationName validates Organization Name field user input.
func ValidateOrganizationName(input string) error {
// the first 62 char out of base64 and -
var organizationName = strings.TrimLeft(input, "github.com/")
var oName = regexp.MustCompile(`^[A-Za-z0-9-]{1,39}$`)
if !oName.MatchString(organizationName) {
// error if char len is greater than 39
if len(organizationName) > constants.MaxPnameLength {
sachinsmc marked this conversation as resolved.
Show resolved Hide resolved
return errors.New("Invalid, Organization Name: (cannot exceed a max length of 39)")
}
return errors.New("Invalid, Organization Name: (can only contain alphanumeric chars & '-')")
}
return nil
}

const infoBoxHeight = 4

var currentLine int = infoBoxHeight
Expand Down