Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func setupBuildCommand() *cobraext.Command {
}
cmd.Flags().Bool(cobraext.BuildZipFlagName, true, cobraext.BuildZipFlagDescription)
cmd.Flags().Bool(cobraext.SignPackageFlagName, false, cobraext.SignPackageFlagDescription)
cmd.Flags().Bool(cobraext.BuildSkipValidationFlagName, false, cobraext.BuildSkipValidationFlagDescription)
return cobraext.NewCommand(cmd, cobraext.ContextPackage)
}

Expand Down
20 changes: 15 additions & 5 deletions internal/builder/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const builtPackagesFolder = "packages"
type BuildOptions struct {
PackageRoot string

CreateZip bool
SignPackage bool
CreateZip bool
SignPackage bool
SkipValidation bool
}

// BuildDirectory function locates the target build directory. If the directory doesn't exist, it will create it.
Expand Down Expand Up @@ -172,6 +173,11 @@ func BuildPackage(options BuildOptions) (string, error) {
return buildZippedPackage(options, destinationDir)
}

if options.SkipValidation {
logger.Debug("Skip validation of the built package")
return destinationDir, nil
}

err = validator.ValidateFromPath(destinationDir)
if err != nil {
return "", errors.Wrap(err, "invalid content found in built package")
Expand All @@ -191,9 +197,13 @@ func buildZippedPackage(options BuildOptions, destinationDir string) (string, er
return "", errors.Wrapf(err, "can't compress the built package (compressed file path: %s)", zippedPackagePath)
}

err = validator.ValidateFromZip(zippedPackagePath)
if err != nil {
return "", errors.Wrapf(err, "invalid content found in built zip package")
if options.SkipValidation {
logger.Debug("Skip validation of the built .zip package")
} else {
err = validator.ValidateFromZip(zippedPackagePath)
if err != nil {
return "", errors.Wrapf(err, "invalid content found in built zip package")
}
}

if options.SignPackage {
Expand Down
3 changes: 3 additions & 0 deletions internal/cobraext/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const (
AgentPolicyFlagName = "agent-policy"
AgentPolicyDescription = "name of the agent policy"

BuildSkipValidationFlagName = "skip-validation"
BuildSkipValidationFlagDescription = "skip validation of the built package, use only if all validation issues have been acknowledged"

BuildZipFlagName = "zip"
BuildZipFlagDescription = "archive the built package"

Expand Down