@@ -24,17 +24,20 @@ const ManifestName = "Gopkg.toml"
24
24
25
25
// Errors
26
26
var (
27
- errInvalidConstraint = errors .Errorf ("%q must be a TOML array of tables" , "constraint" )
28
- errInvalidOverride = errors .Errorf ("%q must be a TOML array of tables" , "override" )
29
- errInvalidRequired = errors .Errorf ("%q must be a TOML list of strings" , "required" )
30
- errInvalidIgnored = errors .Errorf ("%q must be a TOML list of strings" , "ignored" )
31
- errInvalidPrune = errors .Errorf ("%q must be a TOML table of booleans" , "prune" )
32
-
33
- errInvalidProjectRoot = errors .New ("ProjectRoot name validation failed" )
34
- errInvalidPruneValue = errors .New ("prune options values must be booleans" )
27
+ errInvalidConstraint = errors .Errorf ("%q must be a TOML array of tables" , "constraint" )
28
+ errInvalidOverride = errors .Errorf ("%q must be a TOML array of tables" , "override" )
29
+ errInvalidRequired = errors .Errorf ("%q must be a TOML list of strings" , "required" )
30
+ errInvalidIgnored = errors .Errorf ("%q must be a TOML list of strings" , "ignored" )
31
+ errInvalidPrune = errors .Errorf ("%q must be a TOML table of booleans" , "prune" )
35
32
errInvalidPruneProject = errors .Errorf ("%q must be a TOML array of tables" , "prune.project" )
36
- errPruneSubProject = errors .New ("prune projects should not contain sub projects " )
33
+ errInvalidMetadata = errors .New ("metadata should be a TOML table " )
37
34
35
+ errInvalidProjectRoot = errors .New ("ProjectRoot name validation failed" )
36
+
37
+ errInvalidPruneValue = errors .New ("prune options values must be booleans" )
38
+ errPruneSubProject = errors .New ("prune projects should not contain sub projects" )
39
+
40
+ errRootPruneContainsName = errors .Errorf ("%q should not include a name" , "prune" )
38
41
errInvalidRootPruneValue = errors .New ("root prune options must be omitted instead of being set to false" )
39
42
errInvalidPruneProjectName = errors .Errorf ("%q in %q must be a string" , "name" , "prune.project" )
40
43
)
@@ -115,7 +118,7 @@ func validateManifest(s string) ([]error, error) {
115
118
case "metadata" :
116
119
// Check if metadata is of Map type
117
120
if reflect .TypeOf (val ).Kind () != reflect .Map {
118
- warns = append (warns , errors . New ( "metadata should be a TOML table" ) )
121
+ warns = append (warns , errInvalidMetadata )
119
122
}
120
123
case "constraint" , "override" :
121
124
valid := true
@@ -215,7 +218,7 @@ func validatePruneOptions(val interface{}, root bool) (warns []error, err error)
215
218
}
216
219
case "name" :
217
220
if root {
218
- warns = append (warns , errors . Errorf ( "%q should not include a name" , "prune" ) )
221
+ warns = append (warns , errRootPruneContainsName )
219
222
} else if _ , ok := value .(string ); ! ok {
220
223
return warns , errInvalidPruneProjectName
221
224
}
0 commit comments