Add -force-overwrite command flag. #90

This commit is contained in:
Andrey Smirnov
2014-08-05 15:47:38 +04:00
parent 38ea595c9a
commit d558791070
4 changed files with 25 additions and 3 deletions
+1
View File
@@ -40,6 +40,7 @@ Example:
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("origin", "", "origin name to publish")
cmd.Flag.String("label", "", "label to publish") cmd.Flag.String("label", "", "label to publish")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
return cmd return cmd
} }
+8 -1
View File
@@ -130,7 +130,13 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to initialize GPG signer: %s", err) return fmt.Errorf("unable to initialize GPG signer: %s", err)
} }
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool)
if forceOverwrite {
context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " +
"the same package pool.")
}
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite)
if err != nil { if err != nil {
return fmt.Errorf("unable to publish: %s", err) return fmt.Errorf("unable to publish: %s", err)
} }
@@ -196,6 +202,7 @@ Example:
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
cmd.Flag.String("origin", "", "origin name to publish") cmd.Flag.String("origin", "", "origin name to publish")
cmd.Flag.String("label", "", "label to publish") cmd.Flag.String("label", "", "label to publish")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
return cmd return cmd
} }
+8 -1
View File
@@ -79,7 +79,13 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to initialize GPG signer: %s", err) return fmt.Errorf("unable to initialize GPG signer: %s", err)
} }
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool)
if forceOverwrite {
context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " +
"the same package pool.")
}
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite)
if err != nil { if err != nil {
return fmt.Errorf("unable to publish: %s", err) return fmt.Errorf("unable to publish: %s", err)
} }
@@ -127,6 +133,7 @@ Example:
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)") cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
return cmd return cmd
} }
+8 -1
View File
@@ -48,7 +48,13 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
return fmt.Errorf("unable to initialize GPG signer: %s", err) return fmt.Errorf("unable to initialize GPG signer: %s", err)
} }
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress()) forceOverwrite := context.flags.Lookup("force-overwrite").Value.Get().(bool)
if forceOverwrite {
context.Progress().Printf("WARNING: force overwrite mode enabled, aptly might corrupt other published repositories sharing " +
"the same package pool.")
}
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, context.Progress(), forceOverwrite)
if err != nil { if err != nil {
return fmt.Errorf("unable to publish: %s", err) return fmt.Errorf("unable to publish: %s", err)
} }
@@ -93,6 +99,7 @@ Example:
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)") cmd.Flag.Var(&keyRingsFlag{}, "keyring", "GPG keyring to use (instead of default)")
cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)") cmd.Flag.String("secret-keyring", "", "GPG secret keyring to use (instead of default)")
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG") cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
return cmd return cmd
} }