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

test: validate package #2569

Merged
merged 37 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cfd59ee
reasonable time to commit
AustinAbro321 May 30, 2024
d510ae8
manifests validate
AustinAbro321 May 30, 2024
9600972
refactoring validate and messaging
AustinAbro321 May 31, 2024
f953ec0
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 May 31, 2024
f0f82fe
docs and schema
AustinAbro321 May 31, 2024
25b1e20
testing
AustinAbro321 May 31, 2024
e18d12c
testing
AustinAbro321 May 31, 2024
4bd856a
testing?
AustinAbro321 May 31, 2024
f304a8e
refactor tests
AustinAbro321 May 31, 2024
49a710b
refactor
AustinAbro321 May 31, 2024
d74cc6e
refactor
AustinAbro321 May 31, 2024
08f4965
test chart
AustinAbro321 May 31, 2024
6f4950e
action set actions
AustinAbro321 May 31, 2024
45b796f
component validate test
AustinAbro321 May 31, 2024
e073960
group default check
AustinAbro321 May 31, 2024
6003939
refactor to elements match
AustinAbro321 May 31, 2024
c302b7b
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 May 31, 2024
58a66d2
comment
AustinAbro321 May 31, 2024
6d5034f
Merge branch 'run-schema-on-create-2485' of github.com:defenseunicorn…
AustinAbro321 May 31, 2024
d9edf5b
comment
AustinAbro321 May 31, 2024
d450545
specify
AustinAbro321 May 31, 2024
1c52d09
test names
AustinAbro321 May 31, 2024
691403e
test names
AustinAbro321 May 31, 2024
e9dda96
fix flake
AustinAbro321 Jun 3, 2024
c7577e7
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 3, 2024
20fa460
parallel
AustinAbro321 Jun 3, 2024
d971f11
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 3, 2024
95d879f
downgrade version + rename
AustinAbro321 Jun 3, 2024
8bd8082
parrallel
AustinAbro321 Jun 3, 2024
95b48e3
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 3, 2024
e7353ac
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 3, 2024
26c9287
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 3, 2024
0482523
change err joining
AustinAbro321 Jun 4, 2024
19dc9f1
Merge branch 'run-schema-on-create-2485' of github.com:defenseunicorn…
AustinAbro321 Jun 4, 2024
7b4a42b
fix component action validation
AustinAbro321 Jun 4, 2024
40f4f28
more errors.join things
AustinAbro321 Jun 4, 2024
83796fc
Merge branch 'main' into run-schema-on-create-2485
AustinAbro321 Jun 5, 2024
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
12 changes: 6 additions & 6 deletions src/config/lang/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ const (
PkgValidateErrActionClusterNetwork = "a single wait action must contain only one of cluster or network"
PkgValidateErrChart = "invalid chart definition: %w"
PkgValidateErrChartName = "chart %q exceed the maximum length of %d characters"
PkgValidateErrChartNameMissing = "chart %q must include a name"
PkgValidateErrChartNameMissing = "chart must include a name"
PkgValidateErrChartNameNotUnique = "chart name %q is not unique"
PkgValidateErrChartNamespaceMissing = "chart %q must include a namespace"
PkgValidateErrChartURLOrPath = "chart %q must have either a url or localPath"
Expand All @@ -715,17 +715,17 @@ const (
PkgValidateErrManifest = "invalid manifest definition: %w"
PkgValidateErrManifestFileOrKustomize = "manifest %q must have at least one file or kustomization"
PkgValidateErrManifestNameLength = "manifest %q exceed the maximum length of %d characters"
PkgValidateErrManifestNameMissing = "manifest %q must include a name"
PkgValidateErrManifestNameMissing = "manifest must include a name"
PkgValidateErrManifestNameNotUnique = "manifest name %q is not unique"
PkgValidateErrName = "invalid package name: %w"
PkgValidateErrPkgConstantName = "constant name %q must be all uppercase and contain no special characters except _"
PkgValidateErrPkgConstantPattern = "provided value for constant %q does not match pattern %q"
PkgValidateErrPkgName = "package name %q must be all lowercase and contain no special characters except '-' and cannot start with a '-'"
PkgValidateErrVariable = "invalid package variable: %w"
PkgValidateErrYOLONoArch = "cluster architecture not allowed"
PkgValidateErrYOLONoDistro = "cluster distros not allowed"
PkgValidateErrYOLONoGit = "git repos not allowed"
PkgValidateErrYOLONoOCI = "OCI images not allowed"
PkgValidateErrYOLONoArch = "cluster architecture not allowed in YOLO"
PkgValidateErrYOLONoDistro = "cluster distros not allowed in YOLO"
PkgValidateErrYOLONoGit = "git repos not allowed in YOLO"
PkgValidateErrYOLONoOCI = "OCI images not allowed in YOLO"
)

// Collection of reusable error messages.
Expand Down
10 changes: 9 additions & 1 deletion src/pkg/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,15 @@ func Paragraph(format string, a ...any) string {

// Paragraphn formats text into an n column paragraph
func Paragraphn(n int, format string, a ...any) string {
return pterm.DefaultParagraph.WithMaxWidth(n).Sprintf(format, a...)
// Split the text to keep pterm formatting but add newlines
lines := strings.Split(fmt.Sprintf(format, a...), "\n")

formattedLines := make([]string, len(lines))
for i, line := range lines {
formattedLines[i] = pterm.DefaultParagraph.WithMaxWidth(n).Sprintf(line)
}

return strings.Join(formattedLines, "\n")
}

// PrintDiff prints the differences between a and b with a as original and b as new
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/composer/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func NewImportChain(head types.ZarfComponent, index int, originalPackageName, ar
}

// TODO: stuff like this should also happen in linting
if err := node.ZarfComponent.ValidateImportDefinition(); err != nil {
if err := node.ZarfComponent.Validate(); err != nil {
return ic, err
}

Expand Down
3 changes: 1 addition & 2 deletions src/pkg/packager/sources/new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ func TestPackageSource(t *testing.T) {
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

// TODO once our messaging is thread safe, re-parallelize this test
opts := &types.ZarfPackageOptions{
PackageSource: tt.src,
Shasum: tt.shasum,
Expand Down
2 changes: 1 addition & 1 deletion src/types/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// ZarfComponent is the primary functional grouping of assets to deploy by Zarf.
type ZarfComponent struct {
// Name is the unique identifier for this component
Name string `json:"name" jsonschema:"description=The name of the component,pattern=^[a-z0-9\\-]*[a-z0-9]$"`
Name string `json:"name" jsonschema:"description=The name of the component,pattern=^[a-z0-9][a-z0-9\\-]*$"`

// Description is a message given to a user when deciding to enable this component or not
Description string `json:"description,omitempty" jsonschema:"description=Message to include during package deploy describing the purpose of this component"`
Expand Down
2 changes: 1 addition & 1 deletion src/types/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (pkg ZarfPackage) IsSBOMAble() bool {

// ZarfMetadata lists information about the current ZarfPackage.
type ZarfMetadata struct {
Name string `json:"name" jsonschema:"description=Name to identify this Zarf package,pattern=^[a-z0-9\\-]*[a-z0-9]$"`
Name string `json:"name" jsonschema:"description=Name to identify this Zarf package,pattern=^[a-z0-9][a-z0-9\\-]*$"`
Description string `json:"description,omitempty" jsonschema:"description=Additional information about this package"`
Version string `json:"version,omitempty" jsonschema:"description=Generic string set by a package author to track the package version (Note: ZarfInitConfigs will always be versioned to the CLIVersion they were created with)"`
URL string `json:"url,omitempty" jsonschema:"description=Link to package information when online"`
Expand Down
Loading
Loading