Skip to content

Commit

Permalink
Refactor to DisablePackageValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
mtojek committed Jan 4, 2021
1 parent 4ab173c commit b20850d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func init() {
flag.StringVar(&address, "address", "localhost:8080", "Address of the package-registry service.")
// This flag is experimental and might be removed in the future or renamed
flag.BoolVar(&dryRun, "dry-run", false, "Runs a dry-run of the registry without starting the web service (experimental)")
flag.BoolVar(&util.EnablePackageValidation, "validate", false, "Validate package content")
flag.BoolVar(&util.PackageValidationDisabled, "disable-package-validation", false, "Disable package content validation")
}

type Config struct {
Expand All @@ -62,10 +62,6 @@ func main() {
log.Println("Package registry started.")
defer log.Println("Package registry stopped.")

if dryRun {
util.EnablePackageValidation = true // dry-run enables the package validation
}

config := mustLoadConfig()
packagesBasePaths := getPackagesBasePaths(config)
ensurePackagesAvailable(packagesBasePaths)
Expand Down
2 changes: 1 addition & 1 deletion util/data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func NewDataStream(basePath string, p *Package) (*DataStream, error) {
}

func (d *DataStream) Validate() error {
if !EnablePackageValidation {
if PackageValidationDisabled {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion util/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func collectAssets(pattern string) ([]string, error) {
// Validate is called during Unpack of the manifest.
// The validation here is only related to the fields directly specified in the manifest itself.
func (p *Package) Validate() error {
if !EnablePackageValidation {
if PackageValidationDisabled {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions util/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/pkg/errors"
)

// EnablePackageValidation is a flag which can enable package content validation (package, data streams, assets, etc.).
var EnablePackageValidation = true
// PackageValidationDisabled is a flag which can disable package content validation (package, data streams, assets, etc.).
var PackageValidationDisabled bool

var packageList Packages

Expand Down

0 comments on commit b20850d

Please sign in to comment.