(exit.Error).Wrap => (exit.Error).WrapError
This commit moves from the deprecated (exit.Error).Wrap function to the (exit.Error).WrapError instead.
This commit is contained in:
parent
7763644ebe
commit
d268728f7d
20 changed files with 49 additions and 49 deletions
|
|
@ -83,10 +83,10 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
{
|
||||
logging.LogMessage(context.Stderr, "Creating root deployment directory")
|
||||
if err := umaskfree.MkdirAll(root, umaskfree.DefaultDirPerm); err != nil {
|
||||
return errBootstrapFailedToCreateDirectory.WithMessageF(root).Wrap(err)
|
||||
return errBootstrapFailedToCreateDirectory.WithMessageF(root).WrapError(err)
|
||||
}
|
||||
if err := cli.WriteBaseDirectory(root); err != nil {
|
||||
return errBootstrapFailedToSaveDirectory.WithMessageF(root).Wrap(err)
|
||||
return errBootstrapFailedToSaveDirectory.WithMessageF(root).WrapError(err)
|
||||
}
|
||||
context.Println(root)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
|
||||
// and use thge defaults
|
||||
if err := tpl.SetDefaults(); err != nil {
|
||||
return errBootstrapWriteConfig.Wrap(err)
|
||||
return errBootstrapWriteConfig.WrapError(err)
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
{
|
||||
isFile, err := fsx.IsRegular(cfgPath, false)
|
||||
if err != nil {
|
||||
return errBootstrapWriteConfig.Wrap(err)
|
||||
return errBootstrapWriteConfig.WrapError(err)
|
||||
}
|
||||
if !isFile {
|
||||
// generate the configuration from the template
|
||||
|
|
@ -150,7 +150,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
|
||||
return nil
|
||||
}, context.Stderr, "Creating custom config files"); err != nil {
|
||||
return errBootstrapCreateFile.Wrap(err)
|
||||
return errBootstrapCreateFile.WrapError(err)
|
||||
}
|
||||
|
||||
// Validate configuration file!
|
||||
|
|
@ -176,7 +176,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
return err
|
||||
}
|
||||
}, context.Stderr, "Installing primary configuration file"); err != nil {
|
||||
return errBootstrapWriteConfig.Wrap(err)
|
||||
return errBootstrapWriteConfig.WrapError(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,13 +186,13 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
logging.LogMessage(context.Stderr, "Configuration is now complete")
|
||||
f, err := os.Open(cfgPath)
|
||||
if err != nil {
|
||||
return errBootstrapOpenConfig.Wrap(err)
|
||||
return errBootstrapOpenConfig.WrapError(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var cfg config.Config
|
||||
if err := cfg.Unmarshal(f); err != nil {
|
||||
return errBootstrapOpenConfig.Wrap(err)
|
||||
return errBootstrapOpenConfig.WrapError(err)
|
||||
}
|
||||
context.Println(cfg)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func (cfg cfg) Run(context wisski_distillery.Context) error {
|
|||
return nil
|
||||
}
|
||||
if err := context.Environment.Config.Marshal(context.Stdout); err != nil {
|
||||
return errMarshalConfig.Wrap(err)
|
||||
return errMarshalConfig.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@ var errNoKey = exit.Error{
|
|||
func (ds disSSH) parseOpts(context wisski_distillery.Context) (user *auth.AuthUser, key gossh.PublicKey, err error) {
|
||||
user, err = context.Environment.Auth().User(context.Context, ds.Positionals.User)
|
||||
if err != nil {
|
||||
return nil, nil, errSSHManageFailed.Wrap(err)
|
||||
return nil, nil, errSSHManageFailed.WrapError(err)
|
||||
}
|
||||
|
||||
content, err := os.ReadFile(ds.Positionals.Path)
|
||||
if err != nil {
|
||||
return nil, nil, errSSHManageFailed.Wrap(err)
|
||||
return nil, nil, errSSHManageFailed.WrapError(err)
|
||||
}
|
||||
|
||||
pk, _, _, _, err := gossh.ParseAuthorizedKey(content)
|
||||
|
|
@ -99,7 +99,7 @@ func (ds disSSH) runAdd(context wisski_distillery.Context) error {
|
|||
}
|
||||
|
||||
if err := context.Environment.Keys().Add(context.Context, user.User.User, ds.Comment, key); err != nil {
|
||||
return errSSHManageFailed.Wrap(err)
|
||||
return errSSHManageFailed.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ func (ds disSSH) runRemove(context wisski_distillery.Context) error {
|
|||
}
|
||||
|
||||
if err := context.Environment.Keys().Remove(context.Context, user.User.User, key); err != nil {
|
||||
return errSSHManageFailed.Wrap(err)
|
||||
return errSSHManageFailed.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,19 +47,19 @@ var errSettingWissKI = exit.Error{
|
|||
func (ds setting) Run(context wisski_distillery.Context) error {
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, ds.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errSettingWissKI.Wrap(err)
|
||||
return errSettingWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
if ds.Positionals.Value == "" {
|
||||
// get the setting
|
||||
value, err := instance.Settings().Get(context.Context, nil, ds.Positionals.Setting)
|
||||
if err != nil {
|
||||
return errSettingGet.Wrap(err)
|
||||
return errSettingGet.WrapError(err)
|
||||
}
|
||||
|
||||
// and print it
|
||||
if err := json.NewEncoder(context.Stdout).Encode(value); err != nil {
|
||||
return errSettingGet.Wrap(err)
|
||||
return errSettingGet.WrapError(err)
|
||||
}
|
||||
|
||||
// finish with a newline
|
||||
|
|
@ -70,12 +70,12 @@ func (ds setting) Run(context wisski_distillery.Context) error {
|
|||
// serialize the setting into json
|
||||
var data any
|
||||
if err := json.Unmarshal([]byte(ds.Positionals.Value), &data); err != nil {
|
||||
return errSettingSet.Wrap(err)
|
||||
return errSettingSet.WrapError(err)
|
||||
}
|
||||
|
||||
// set the serialized value!
|
||||
if err := instance.Settings().Set(context.Context, nil, ds.Positionals.Setting, data); err != nil {
|
||||
return errSettingSet.Wrap(err)
|
||||
return errSettingSet.WrapError(err)
|
||||
}
|
||||
|
||||
// and we're done
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ var errInstanceLockWissKI = exit.Error{
|
|||
func (l instanceLock) Run(context wisski_distillery.Context) error {
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, l.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errInstanceLockWissKI.Wrap(err)
|
||||
return errInstanceLockWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
if l.Unlock {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ var errInstancePauseWissKI = exit.Error{
|
|||
func (i instancepause) Run(context wisski_distillery.Context) error {
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, i.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errInstancePauseWissKI.Wrap(err)
|
||||
return errInstancePauseWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
if i.Stop {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var errLsWissKI = exit.Error{
|
|||
func (l ls) Run(context wisski_distillery.Context) error {
|
||||
instances, err := context.Environment.Instances().Load(context.Context, l.Positionals.Slug...)
|
||||
if err != nil {
|
||||
return errLsWissKI.Wrap(err)
|
||||
return errLsWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
for _, instance := range instances {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func (mb makeBlock) Run(context wisski_distillery.Context) error {
|
|||
// get the wisski
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, mb.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errPathbuilderWissKI.Wrap(err)
|
||||
return errPathbuilderWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
// get the footer (if any)
|
||||
|
|
@ -81,7 +81,7 @@ func (mb makeBlock) Run(context wisski_distillery.Context) error {
|
|||
zerolog.Ctx(context.Context).Info().Msg("checking for footer")
|
||||
region, err := instance.Blocks().GetFooterRegion(context.Context, nil)
|
||||
if err != nil {
|
||||
return errBlocksFooterFailed.Wrap(err)
|
||||
return errBlocksFooterFailed.WrapError(err)
|
||||
}
|
||||
if region == "" {
|
||||
return errBlocksNoFooter
|
||||
|
|
@ -96,7 +96,7 @@ func (mb makeBlock) Run(context wisski_distillery.Context) error {
|
|||
// read the content
|
||||
content, err := io.ReadAll(context.Stdin)
|
||||
if err != nil {
|
||||
return errBlocksNoContent.Wrap(err)
|
||||
return errBlocksNoContent.WrapError(err)
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,17 +46,17 @@ func (mma makeMysqlAccount) Run(context wisski_distillery.Context) error {
|
|||
context.Printf("Username>")
|
||||
username, err := context.ReadLine()
|
||||
if err != nil {
|
||||
return errUnableToReadUsername.Wrap(err)
|
||||
return errUnableToReadUsername.WrapError(err)
|
||||
}
|
||||
|
||||
context.Printf("Password>")
|
||||
password, err := context.ReadPassword()
|
||||
if err != nil {
|
||||
return errUnableToReadPassword.Wrap(err)
|
||||
return errUnableToReadPassword.WrapError(err)
|
||||
}
|
||||
|
||||
if err := dis.SQL().CreateSuperuser(context.Context, username, password, false); err != nil {
|
||||
return errUnableToMakeAccount.Wrap(err)
|
||||
return errUnableToMakeAccount.WrapError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ func (pb pathbuilders) Run(context wisski_distillery.Context) error {
|
|||
// get the wisski
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, pb.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errPathbuilderWissKI.Wrap(err)
|
||||
return errPathbuilderWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
// get all of the pathbuilders
|
||||
if pb.Positionals.Name == "" {
|
||||
names, err := instance.Pathbuilder().All(context.Context, nil)
|
||||
if err != nil {
|
||||
return errPathbuilders.Wrap(err)
|
||||
return errPathbuilders.WrapError(err)
|
||||
}
|
||||
for _, name := range names {
|
||||
context.Println(name)
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ var errPrefixesWissKI = exit.Error{
|
|||
func (p prefixes) Run(context wisski_distillery.Context) error {
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, p.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errPrefixesWissKI.Wrap(err)
|
||||
return errPrefixesWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
prefixes, err := instance.Prefixes().All(context.Context, nil)
|
||||
if err != nil {
|
||||
return errPrefixesGeneric.Wrap(err)
|
||||
return errPrefixesGeneric.WrapError(err)
|
||||
}
|
||||
|
||||
for _, p := range prefixes {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (p purge) Run(context wisski_distillery.Context) error {
|
|||
|
||||
// do the purge!
|
||||
if err := dis.Purger().Purge(context.Context, context.Stdout, slug); err != nil {
|
||||
return errPurgeFailed.Wrap(err)
|
||||
return errPurgeFailed.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func (r reserve) Run(context wisski_distillery.Context) (err error) {
|
|||
logging.LogMessage(context.Stderr, "Checking that base directory %s does not exist", instance.FilesystemBase)
|
||||
exists, err := fsx.Exists(instance.FilesystemBase)
|
||||
if err != nil {
|
||||
return errProvisionGeneric.Wrap(err)
|
||||
return errProvisionGeneric.WrapError(err)
|
||||
}
|
||||
if exists {
|
||||
return errReserveAlreadyExists.WithMessageF(slug)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func (s server) Run(context wisski_distillery.Context) error {
|
|||
// if the caller requested a trigger, just trigger the cron tasks
|
||||
if s.Trigger {
|
||||
if err := dis.Control().Trigger(context.Context); err != nil {
|
||||
return errServerTrigger.Wrap(err)
|
||||
return errServerTrigger.WrapError(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ func (s server) Run(context wisski_distillery.Context) error {
|
|||
// and start the server
|
||||
public, internal, err := dis.Control().Server(context.Context, context.Stderr)
|
||||
if err != nil {
|
||||
return errServerGeneric.Wrap(err)
|
||||
return errServerGeneric.WrapError(err)
|
||||
}
|
||||
|
||||
// start the public listener
|
||||
|
|
@ -95,7 +95,7 @@ func (s server) Run(context wisski_distillery.Context) error {
|
|||
zerolog.Ctx(context.Context).Info().Str("bind", s.InternalBind).Msg("listening internal server")
|
||||
internalL, err := net.Listen("tcp", s.InternalBind)
|
||||
if err != nil {
|
||||
return errServerListen.Wrap(err)
|
||||
return errServerListen.WrapError(err)
|
||||
}
|
||||
defer internalS.Shutdown(context.Context)
|
||||
go func() {
|
||||
|
|
@ -111,5 +111,5 @@ func (s server) Run(context wisski_distillery.Context) error {
|
|||
internalS.Shutdown(context.Context)
|
||||
}()
|
||||
|
||||
return errServerListen.Wrap(errors.Join(<-internalC, <-publicC, err))
|
||||
return errServerListen.WrapError(errors.Join(<-internalC, <-publicC, err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var errShellWissKI = exit.Error{
|
|||
func (sh shell) Run(context wisski_distillery.Context) error {
|
||||
instance, err := context.Environment.Instances().WissKI(context.Context, sh.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errShellWissKI.Wrap(err)
|
||||
return errShellWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func (sn snapshot) Run(context wisski_distillery.Context) error {
|
|||
// find the instance!
|
||||
instance, err := dis.Instances().WissKI(context.Context, sn.Positionals.Slug)
|
||||
if err != nil {
|
||||
return errSnapshotWissKI.Wrap(err)
|
||||
return errSnapshotWissKI.WrapError(err)
|
||||
}
|
||||
|
||||
// do a snapshot of it!
|
||||
|
|
@ -72,7 +72,7 @@ func (sn snapshot) Run(context wisski_distillery.Context) error {
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
return errSnapshotFailed.Wrap(err)
|
||||
return errSnapshotFailed.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func (s ssh) Run(context wisski_distillery.Context) error {
|
|||
dis := context.Environment
|
||||
server, err := dis.SSH().Server(context.Context, s.PrivateKeyPath, context.Stderr)
|
||||
if err != nil {
|
||||
return errSSHServer.Wrap(err)
|
||||
return errSSHServer.WrapError(err)
|
||||
}
|
||||
|
||||
context.Printf("Listening on %s\n", s.Bind)
|
||||
|
|
@ -48,7 +48,7 @@ func (s ssh) Run(context wisski_distillery.Context) error {
|
|||
// make a new listener
|
||||
listener, err := net.Listen("tcp", s.Bind)
|
||||
if err != nil {
|
||||
return errSSHListen.Wrap(err)
|
||||
return errSSHListen.WrapError(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
|
@ -58,5 +58,5 @@ func (s ssh) Run(context wisski_distillery.Context) error {
|
|||
|
||||
// and serve that listener
|
||||
err = server.Serve(listener)
|
||||
return errServerListen.Wrap(err)
|
||||
return errServerListen.WrapError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var errStatusGeneric = exit.Error{
|
|||
func (s cStatus) Run(context wisski_distillery.Context) error {
|
||||
status, _, err := context.Environment.Info().Status(context.Context, true)
|
||||
if err != nil {
|
||||
return errStatusGeneric.Wrap(err)
|
||||
return errStatusGeneric.WrapError(err)
|
||||
}
|
||||
|
||||
if s.JSON {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
|
|||
} {
|
||||
context.Println(d)
|
||||
if err := umaskfree.MkdirAll(d, umaskfree.DefaultDirPerm); err != nil {
|
||||
return errBoostrapFailedToCreateDirectory.WithMessageF(d).Wrap(err)
|
||||
return errBoostrapFailedToCreateDirectory.WithMessageF(d).WrapError(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
|
|||
logging.LogMessage(context.Stderr, "Checking that the 'docker' api is reachable")
|
||||
ping, err := dis.Docker().Ping(context.Context)
|
||||
if err != nil {
|
||||
return errDockerUnreachable.Wrap(err)
|
||||
return errDockerUnreachable.WrapError(err)
|
||||
}
|
||||
context.Printf("API Version: %s (experimental: %t)\nBuilder Version: %s\n", ping.APIVersion, ping.Experimental, ping.BuilderVersion)
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
|
|||
for _, name := range dis.Config.Docker.Networks() {
|
||||
id, existed, err := dis.Docker().CreateNetwork(context.Context, name)
|
||||
if err != nil {
|
||||
return errNetworkCreateFailed.Wrap(err)
|
||||
return errNetworkCreateFailed.WrapError(err)
|
||||
}
|
||||
if existed {
|
||||
context.Printf("Network %s (id %s) already existed\n", name, id)
|
||||
|
|
@ -213,7 +213,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
|
|||
}
|
||||
return item.Update(context.Context, context.Stderr)
|
||||
}, context.Stderr, "Updating Component: %s", name); err != nil {
|
||||
return errBootstrapComponent.WithMessageF(name).Wrap(err)
|
||||
return errBootstrapComponent.WithMessageF(name).WrapError(err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func (instances *Instances) Update(ctx context.Context, progress io.Writer) erro
|
|||
fmt.Fprintf(progress, "[copy] %s\n", dst)
|
||||
})
|
||||
if err != nil {
|
||||
return errBootstrapFailedRuntime.Wrap(err)
|
||||
return errBootstrapFailedRuntime.WrapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue