Skip to content

Commit

Permalink
pack: add error on impossible flags combination
Browse files Browse the repository at this point in the history
If the "--with-integrity-check" and "--without-binaries" flags was
provided simultaneously `tt pack` works correctly.

After the patch this combination of flags became impossible due to
safety reasons.

Part of tarantool/tt-ee#210
  • Loading branch information
themilchenko authored and oleg-jukovec committed Jul 28, 2024
1 parent b4b0bf3 commit 727412c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cli/cmd/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ func internalPackModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
return err
}

checkFlags(packCtx)
if err := checkFlags(packCtx); err != nil {
return err
}

if packCtx.UseDocker {
return pack.PackInDocker(cmdCtx, packCtx, *cliOpts, os.Args)
Expand All @@ -128,7 +130,7 @@ func internalPackModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
return nil
}

func checkFlags(packCtx *pack.PackCtx) {
func checkFlags(packCtx *pack.PackCtx) error {
switch pack.PackageType(packCtx.Type) {
case pack.Tgz:
if len(packCtx.RpmDeb.Deps) > 0 {
Expand All @@ -149,4 +151,11 @@ func checkFlags(packCtx *pack.PackCtx) {
" but you are not packaging a tarball. Flag will be ignored")
}
}
// Check if --with-integrity-check and --without-binaries flags are provided
// simultaneously. If this is the case, return an error for safety reasons.
if packCtx.IntegrityPrivateKey != "" && packCtx.WithoutBinaries {
return fmt.Errorf("impossible combination of --with-integrity-check" +
" and --without-binaries flags")
}
return nil
}

0 comments on commit 727412c

Please sign in to comment.