Skip to content

Commit 3ef3247

Browse files
committed
chore: address PR feedback
1 parent 357feb1 commit 3ef3247

File tree

9 files changed

+317
-11
lines changed

9 files changed

+317
-11
lines changed

internal/projectconfig/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ImageConfig struct {
4040
// single channel), images may be published to multiple channels simultaneously.
4141
type ImagePublishConfig struct {
4242
// Channels lists the publish channels for this image.
43-
Channels []string `toml:"channels,omitempty" json:"channels,omitempty" jsonschema:"title=Channels,description=List of publish channels for this image"`
43+
Channels []string `toml:"channels,omitempty" json:"channels,omitempty" validate:"dive,required,ne=.,ne=..,excludesall=/\\" jsonschema:"title=Channels,description=List of publish channels for this image"`
4444
}
4545

4646
// ImageCapabilities describes the features and properties of an image. Boolean fields

internal/projectconfig/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func mergePackageGroups(resolvedCfg *ProjectConfig, loadedCfg *ConfigFile) error
260260
func mergeTestSuites(resolvedCfg *ProjectConfig, loadedCfg *ConfigFile) error {
261261
for testName, test := range loadedCfg.TestSuites {
262262
if _, ok := resolvedCfg.TestSuites[testName]; ok {
263-
return fmt.Errorf("%w: %s", ErrDuplicateTests, testName)
263+
return fmt.Errorf("%w: test suite %#q", ErrDuplicateTestSuites, testName)
264264
}
265265

266266
// Fill out fields not explicitly serialized.

internal/projectconfig/loader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ description = "Other smoke tests"
854854
}
855855

856856
_, err := loadAndResolveProjectConfig(ctx.FS(), false, testFiles[0].path)
857-
require.ErrorIs(t, err, ErrDuplicateTests)
857+
require.ErrorIs(t, err, ErrDuplicateTestSuites)
858858
}
859859

860860
func TestLoadAndResolveProjectConfig_ImageWithValidTestRef(t *testing.T) {
@@ -894,6 +894,6 @@ test-suites = [{ name = "nonexistent" }]
894894

895895
_, err := loadAndResolveProjectConfig(ctx.FS(), false, testConfigPath)
896896
require.Error(t, err)
897-
require.ErrorIs(t, err, ErrUndefinedTest)
897+
require.ErrorIs(t, err, ErrUndefinedTestSuite)
898898
assert.Contains(t, err.Error(), "nonexistent")
899899
}

internal/projectconfig/project.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ func validateImageTestReferences(images map[string]ImageConfig, tests map[string
106106
for _, testName := range image.TestNames() {
107107
if _, ok := tests[testName]; !ok {
108108
return fmt.Errorf(
109-
"%w: image %#q references test %#q, which is not defined in [test-suites]",
110-
ErrUndefinedTest, imageName, testName,
109+
"%w: image %#q references test suite %#q, which is not defined in [test-suites]",
110+
ErrUndefinedTestSuite, imageName, testName,
111111
)
112112
}
113113
}

internal/projectconfig/testsuite.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ package projectconfig
66
import "errors"
77

88
var (
9-
// ErrDuplicateTests is returned when duplicate conflicting test definitions are found.
10-
ErrDuplicateTests = errors.New("duplicate test")
11-
// ErrUndefinedTest is returned when an image references a test name that is not defined.
12-
ErrUndefinedTest = errors.New("undefined test reference")
9+
// ErrDuplicateTestSuites is returned when duplicate conflicting test suite definitions are found.
10+
ErrDuplicateTestSuites = errors.New("duplicate test suite")
11+
// ErrUndefinedTestSuite is returned when an image references a test suite name that is not defined.
12+
ErrUndefinedTestSuite = errors.New("undefined test suite reference")
1313
)
1414

1515
// TestSuiteConfig defines a named test suite.

internal/projectconfig/testsuite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestValidateTestSuiteReferences(t *testing.T) {
106106
}
107107
err := cfg.Validate()
108108
require.Error(t, err)
109-
require.ErrorIs(t, err, projectconfig.ErrUndefinedTest)
109+
require.ErrorIs(t, err, projectconfig.ErrUndefinedTestSuite)
110110
assert.Contains(t, err.Error(), "nonexistent")
111111
})
112112

scenario/__snapshots__/TestSnapshotsContainer_config_generate-schema_stdout_1.snap

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@
342342
"type": "object",
343343
"title": "Package groups",
344344
"description": "Definitions of package groups for shared binary package configuration"
345+
},
346+
"test-suites": {
347+
"additionalProperties": {
348+
"$ref": "#/$defs/TestSuiteConfig"
349+
},
350+
"type": "object",
351+
"title": "Test Suites",
352+
"description": "Definitions of test suites for this project"
345353
}
346354
},
347355
"additionalProperties": false,
@@ -465,6 +473,32 @@
465473
"release-ver"
466474
]
467475
},
476+
"ImageCapabilities": {
477+
"properties": {
478+
"machine-bootable": {
479+
"type": "boolean",
480+
"title": "Machine bootable",
481+
"description": "Whether the image can be booted on a machine (bare metal or VM)"
482+
},
483+
"container": {
484+
"type": "boolean",
485+
"title": "Container",
486+
"description": "Whether the image can be run on an OCI container host"
487+
},
488+
"systemd": {
489+
"type": "boolean",
490+
"title": "Systemd",
491+
"description": "Whether the image runs systemd as its init system"
492+
},
493+
"runtime-package-management": {
494+
"type": "boolean",
495+
"title": "Runtime package management",
496+
"description": "Whether the image supports installing or removing packages at runtime"
497+
}
498+
},
499+
"additionalProperties": false,
500+
"type": "object"
501+
},
468502
"ImageConfig": {
469503
"properties": {
470504
"description": {
@@ -476,6 +510,21 @@
476510
"$ref": "#/$defs/ImageDefinition",
477511
"title": "Definition",
478512
"description": "Identifies where to find the definition for this image"
513+
},
514+
"capabilities": {
515+
"$ref": "#/$defs/ImageCapabilities",
516+
"title": "Capabilities",
517+
"description": "Features and properties of this image"
518+
},
519+
"tests": {
520+
"$ref": "#/$defs/ImageTestsConfig",
521+
"title": "Tests",
522+
"description": "Test configuration for this image"
523+
},
524+
"publish": {
525+
"$ref": "#/$defs/ImagePublishConfig",
526+
"title": "Publish settings",
527+
"description": "Publishing settings for this image"
479528
}
480529
},
481530
"additionalProperties": false,
@@ -513,6 +562,34 @@
513562
"additionalProperties": false,
514563
"type": "object"
515564
},
565+
"ImagePublishConfig": {
566+
"properties": {
567+
"channels": {
568+
"items": {
569+
"type": "string"
570+
},
571+
"type": "array",
572+
"title": "Channels",
573+
"description": "List of publish channels for this image"
574+
}
575+
},
576+
"additionalProperties": false,
577+
"type": "object"
578+
},
579+
"ImageTestsConfig": {
580+
"properties": {
581+
"test-suites": {
582+
"items": {
583+
"$ref": "#/$defs/TestSuiteRef"
584+
},
585+
"type": "array",
586+
"title": "Test Suites",
587+
"description": "List of test suite references that apply to this image"
588+
}
589+
},
590+
"additionalProperties": false,
591+
"type": "object"
592+
},
516593
"Origin": {
517594
"properties": {
518595
"type": {
@@ -729,6 +806,31 @@
729806
"type"
730807
]
731808
},
809+
"TestSuiteConfig": {
810+
"properties": {
811+
"description": {
812+
"type": "string",
813+
"title": "Description",
814+
"description": "Description of this test suite"
815+
}
816+
},
817+
"additionalProperties": false,
818+
"type": "object"
819+
},
820+
"TestSuiteRef": {
821+
"properties": {
822+
"name": {
823+
"type": "string",
824+
"title": "Name",
825+
"description": "Name of the test suite (must match a key in [test-suites])"
826+
}
827+
},
828+
"additionalProperties": false,
829+
"type": "object",
830+
"required": [
831+
"name"
832+
]
833+
},
732834
"ToolsConfig": {
733835
"properties": {
734836
"imageCustomizer": {

scenario/__snapshots__/TestSnapshots_config_generate-schema_stdout_1.snap

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@
342342
"type": "object",
343343
"title": "Package groups",
344344
"description": "Definitions of package groups for shared binary package configuration"
345+
},
346+
"test-suites": {
347+
"additionalProperties": {
348+
"$ref": "#/$defs/TestSuiteConfig"
349+
},
350+
"type": "object",
351+
"title": "Test Suites",
352+
"description": "Definitions of test suites for this project"
345353
}
346354
},
347355
"additionalProperties": false,
@@ -465,6 +473,32 @@
465473
"release-ver"
466474
]
467475
},
476+
"ImageCapabilities": {
477+
"properties": {
478+
"machine-bootable": {
479+
"type": "boolean",
480+
"title": "Machine bootable",
481+
"description": "Whether the image can be booted on a machine (bare metal or VM)"
482+
},
483+
"container": {
484+
"type": "boolean",
485+
"title": "Container",
486+
"description": "Whether the image can be run on an OCI container host"
487+
},
488+
"systemd": {
489+
"type": "boolean",
490+
"title": "Systemd",
491+
"description": "Whether the image runs systemd as its init system"
492+
},
493+
"runtime-package-management": {
494+
"type": "boolean",
495+
"title": "Runtime package management",
496+
"description": "Whether the image supports installing or removing packages at runtime"
497+
}
498+
},
499+
"additionalProperties": false,
500+
"type": "object"
501+
},
468502
"ImageConfig": {
469503
"properties": {
470504
"description": {
@@ -476,6 +510,21 @@
476510
"$ref": "#/$defs/ImageDefinition",
477511
"title": "Definition",
478512
"description": "Identifies where to find the definition for this image"
513+
},
514+
"capabilities": {
515+
"$ref": "#/$defs/ImageCapabilities",
516+
"title": "Capabilities",
517+
"description": "Features and properties of this image"
518+
},
519+
"tests": {
520+
"$ref": "#/$defs/ImageTestsConfig",
521+
"title": "Tests",
522+
"description": "Test configuration for this image"
523+
},
524+
"publish": {
525+
"$ref": "#/$defs/ImagePublishConfig",
526+
"title": "Publish settings",
527+
"description": "Publishing settings for this image"
479528
}
480529
},
481530
"additionalProperties": false,
@@ -513,6 +562,34 @@
513562
"additionalProperties": false,
514563
"type": "object"
515564
},
565+
"ImagePublishConfig": {
566+
"properties": {
567+
"channels": {
568+
"items": {
569+
"type": "string"
570+
},
571+
"type": "array",
572+
"title": "Channels",
573+
"description": "List of publish channels for this image"
574+
}
575+
},
576+
"additionalProperties": false,
577+
"type": "object"
578+
},
579+
"ImageTestsConfig": {
580+
"properties": {
581+
"test-suites": {
582+
"items": {
583+
"$ref": "#/$defs/TestSuiteRef"
584+
},
585+
"type": "array",
586+
"title": "Test Suites",
587+
"description": "List of test suite references that apply to this image"
588+
}
589+
},
590+
"additionalProperties": false,
591+
"type": "object"
592+
},
516593
"Origin": {
517594
"properties": {
518595
"type": {
@@ -729,6 +806,31 @@
729806
"type"
730807
]
731808
},
809+
"TestSuiteConfig": {
810+
"properties": {
811+
"description": {
812+
"type": "string",
813+
"title": "Description",
814+
"description": "Description of this test suite"
815+
}
816+
},
817+
"additionalProperties": false,
818+
"type": "object"
819+
},
820+
"TestSuiteRef": {
821+
"properties": {
822+
"name": {
823+
"type": "string",
824+
"title": "Name",
825+
"description": "Name of the test suite (must match a key in [test-suites])"
826+
}
827+
},
828+
"additionalProperties": false,
829+
"type": "object",
830+
"required": [
831+
"name"
832+
]
833+
},
732834
"ToolsConfig": {
733835
"properties": {
734836
"imageCustomizer": {

0 commit comments

Comments
 (0)