blob: b0b2ad2c407ac6aef6b43d6cbd6f0af82b74affd [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package tasks
import (
"fmt"
"strings"
"github.com/maruel/subcommands"
"go.chromium.org/luci/auth/client/authcli"
skycmdlib "infra/cmd/skylab/internal/cmd/cmdlib"
"infra/cmd/skylab/internal/site"
"infra/cmdsupport/cmdlib"
)
// Repair subcommand: Repair hosts.
var Repair = &subcommands.Command{
UsageLine: "repair [HOST...]",
ShortDesc: "create repair tasks",
LongDesc: `Create repair tasks.
This command does not wait for the task to start running.`,
CommandRun: func() subcommands.CommandRun {
c := &repairRun{}
c.authFlags.Register(&c.Flags, site.DefaultAuthOptions)
c.envFlags.Register(&c.Flags)
c.Flags.IntVar(&c.expirationMins, "expiration-mins", 10, "The expiration minutes of the repair request.")
return c
},
}
type repairRun struct {
subcommands.CommandRunBase
authFlags authcli.Flags
envFlags skycmdlib.EnvFlags
expirationMins int
}
func (c *repairRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
if err := c.innerRun(a, args, env); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
func (c *repairRun) innerRun(a subcommands.Application, args []string, env subcommands.Env) error {
hosts := args
if len(args) == 0 {
hosts = []string{"host1", "host2", "..."}
}
return cmdlib.NewUsageError(
c.Flags,
"skylab repair has been removed! Please use:\n\nshivas repair-duts "+strings.Join(hosts, " ")+"\n",
)
}