Skip to content

Commit 58db8b9

Browse files
consolidate allowed-os checks
1 parent 65da601 commit 58db8b9

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

cmd/localtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func readLocalCLIData(path string) (api.CLIData, error) {
105105

106106
func validateAllowedOS(data api.CLIData) error {
107107
if len(data.AllowedOperatingSystems) == 0 {
108-
return nil
108+
return errors.New("lesson does not specify any allowed operating systems")
109109
}
110110

111111
if slices.Contains(data.AllowedOperatingSystems, runtime.GOOS) {

cmd/submit.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8-
"runtime"
98
"time"
109

1110
"github.com/bootdotdev/bootdev/checks"
@@ -55,16 +54,8 @@ func submissionHandler(cmd *cobra.Command, args []string) error {
5554
}
5655

5756
data := lesson.Lesson.LessonDataCLI.CLIData
58-
59-
isAllowedOS := false
60-
for _, system := range data.AllowedOperatingSystems {
61-
if system == runtime.GOOS {
62-
isAllowedOS = true
63-
}
64-
}
65-
66-
if !isAllowedOS {
67-
return fmt.Errorf("lesson is not supported for your operating system (%s); try again with one of the following: %v", runtime.GOOS, data.AllowedOperatingSystems)
57+
if err := validateAllowedOS(data); err != nil {
58+
return err
6859
}
6960

7061
overrideBaseURL := viper.GetString("override_base_url")

0 commit comments

Comments
 (0)