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 all commits
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
1 change: 1 addition & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
// prompt constants

MaxPnameLength = 16
MaxOnameLength = 39
RegexValidation = "regex"
FunctionValidation = "function"
ZeroReleaseURL = "https://github.com/commitdev/zero/releases"
Expand Down
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}$`)
// error if char len is greater than 39
if len(organizationName) > constants.MaxOnameLength {
return errors.New("Invalid, Organization Name: (cannot exceed a max length of 39)")
}
if !oName.MatchString(organizationName) {
return errors.New("Invalid, Organization Name: (can only contain alphanumeric chars & '-')")
}
return nil
}

const infoBoxHeight = 4

var currentLine int = infoBoxHeight
Expand Down