Skip to content

Commit 333d962

Browse files
committed
make each phase type string explicitly an instance the validationPhase type
Signed-off-by: Callum Styan <[email protected]>
1 parent 11e4da3 commit 333d962

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

cmd/readmevalidation/coderresources.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func parseCoderResourceReadmeFiles(resourceType string, rms []readme) (map[strin
246246
}
247247
if len(yamlParsingErrs) != 0 {
248248
return nil, validationPhaseError{
249-
phase: validationPhaseReadmeParsing,
249+
phase: readmeParsing,
250250
errors: yamlParsingErrs,
251251
}
252252
}
@@ -260,7 +260,7 @@ func parseCoderResourceReadmeFiles(resourceType string, rms []readme) (map[strin
260260
}
261261
if len(yamlValidationErrors) != 0 {
262262
return nil, validationPhaseError{
263-
phase: validationPhaseReadmeParsing,
263+
phase: readmeParsing,
264264
errors: yamlValidationErrors,
265265
}
266266
}
@@ -318,7 +318,7 @@ func aggregateCoderResourceReadmeFiles(resourceType string) ([]readme, error) {
318318

319319
if len(errs) != 0 {
320320
return nil, validationPhaseError{
321-
phase: validationPhaseFileLoad,
321+
phase: fileLoad,
322322
errors: errs,
323323
}
324324
}

cmd/readmevalidation/contributors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func parseContributorFiles(readmeEntries []readme) (map[string]contributorProfil
209209
}
210210
if len(yamlParsingErrors) != 0 {
211211
return nil, validationPhaseError{
212-
phase: validationPhaseReadmeParsing,
212+
phase: readmeParsing,
213213
errors: yamlParsingErrors,
214214
}
215215
}
@@ -223,7 +223,7 @@ func parseContributorFiles(readmeEntries []readme) (map[string]contributorProfil
223223
}
224224
if len(yamlValidationErrors) != 0 {
225225
return nil, validationPhaseError{
226-
phase: validationPhaseReadmeParsing,
226+
phase: readmeParsing,
227227
errors: yamlValidationErrors,
228228
}
229229
}
@@ -261,7 +261,7 @@ func aggregateContributorReadmeFiles() ([]readme, error) {
261261

262262
if len(errs) != 0 {
263263
return nil, validationPhaseError{
264-
phase: validationPhaseFileLoad,
264+
phase: fileLoad,
265265
errors: errs,
266266
}
267267
}
@@ -300,7 +300,7 @@ func validateContributorRelativeURLs(contributors map[string]contributorProfileR
300300
return nil
301301
}
302302
return validationPhaseError{
303-
phase: validationPhaseAssetCrossReference,
303+
phase: assetCrossReference,
304304
errors: errs,
305305
}
306306
}

cmd/readmevalidation/readmefiles.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,32 @@ import (
88
"strings"
99
)
1010

11+
// validationPhase represents a specific phase during README validation. It is expected that each phase is discrete, and
12+
// errors during one will prevent a future phase from starting.
13+
type validationPhase string
14+
1115
const (
1216
rootRegistryPath = "./registry"
1317

14-
// validationPhaseFileStructureValidation indicates when the entire Registry
18+
// --- validationPhases ---
19+
// fileStructureValidation indicates when the entire Registry
1520
// directory is being verified for having all files be placed in the file
1621
// system as expected.
17-
validationPhaseFileStructureValidation validationPhase = "File structure validation"
22+
fileStructureValidation validationPhase = "File structure validation"
1823

19-
// validationPhaseFileLoad indicates when README files are being read from
24+
// fileLoad indicates when README files are being read from
2025
// the file system.
21-
validationPhaseFileLoad = "Filesystem reading"
26+
fileLoad validationPhase = "Filesystem reading"
2227

23-
// validationPhaseReadmeParsing indicates when a README's frontmatter is
28+
// readmeParsing indicates when a README's frontmatter is
2429
// being parsed as YAML. This phase does not include YAML validation.
25-
validationPhaseReadmeParsing = "README parsing"
30+
readmeParsing validationPhase = "README parsing"
2631

27-
// validationPhaseAssetCrossReference indicates when a README's frontmatter
32+
// assetCrossReference indicates when a README's frontmatter
2833
// is having all its relative URLs be validated for whether they point to
2934
// valid resources.
30-
validationPhaseAssetCrossReference = "Cross-referencing relative asset URLs"
35+
assetCrossReference validationPhase = "Cross-referencing relative asset URLs"
36+
// --- end of validationPhases ---
3137
)
3238

3339
var (
@@ -36,10 +42,6 @@ var (
3642
readmeHeaderRe = regexp.MustCompile(`^(#{1,})(\s*)`)
3743
)
3844

39-
// validationPhase represents a specific phase during README validation. It is expected that each phase is discrete, and
40-
// errors during one will prevent a future phase from starting.
41-
type validationPhase string
42-
4345
// readme represents a single README file within the repo (usually within the top-level "/registry" directory).
4446
type readme struct {
4547
filePath string

cmd/readmevalidation/repostructure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func validateRepoStructure() error {
127127

128128
if len(errs) != 0 {
129129
return validationPhaseError{
130-
phase: validationPhaseFileStructureValidation,
130+
phase: fileStructureValidation,
131131
errors: errs,
132132
}
133133
}

0 commit comments

Comments
 (0)