*: rename user local run to user direct run
This commit is contained in:
parent
98c2f76f5d
commit
cff6b8d531
|
@ -18,11 +18,11 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdLocalRun = &cobra.Command{
|
var cmdDirectRun = &cobra.Command{
|
||||||
Use: "localrun",
|
Use: "directrun",
|
||||||
Short: "localrun",
|
Short: "directrun",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmdAgola.AddCommand(cmdLocalRun)
|
cmdAgola.AddCommand(cmdDirectRun)
|
||||||
}
|
}
|
|
@ -25,17 +25,17 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdLocalRunStart = &cobra.Command{
|
var cmdDirectRunStart = &cobra.Command{
|
||||||
Use: "start",
|
Use: "start",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := localRunStart(cmd, args); err != nil {
|
if err := directRunStart(cmd, args); err != nil {
|
||||||
log.Fatalf("err: %v", err)
|
log.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Short: "executes a run from a local repository",
|
Short: "executes a run from a local git repository",
|
||||||
}
|
}
|
||||||
|
|
||||||
type localRunStartOptions struct {
|
type directRunStartOptions struct {
|
||||||
statusFilter []string
|
statusFilter []string
|
||||||
labelFilter []string
|
labelFilter []string
|
||||||
limit int
|
limit int
|
||||||
|
@ -44,22 +44,22 @@ type localRunStartOptions struct {
|
||||||
ignored bool
|
ignored bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var localRunStartOpts localRunStartOptions
|
var directRunStartOpts directRunStartOptions
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flags := cmdLocalRunStart.PersistentFlags()
|
flags := cmdDirectRunStart.PersistentFlags()
|
||||||
|
|
||||||
flags.StringSliceVarP(&localRunStartOpts.statusFilter, "status", "s", nil, "filter runs matching the provided status. This option can be repeated multiple times")
|
flags.StringSliceVarP(&directRunStartOpts.statusFilter, "status", "s", nil, "filter runs matching the provided status. This option can be repeated multiple times")
|
||||||
flags.StringArrayVarP(&localRunStartOpts.labelFilter, "label", "l", nil, "filter runs matching the provided label. This option can be repeated multiple times, in this case only runs matching all the labels will be returned")
|
flags.StringArrayVarP(&directRunStartOpts.labelFilter, "label", "l", nil, "filter runs matching the provided label. This option can be repeated multiple times, in this case only runs matching all the labels will be returned")
|
||||||
flags.IntVar(&localRunStartOpts.limit, "limit", 10, "max number of runs to show")
|
flags.IntVar(&directRunStartOpts.limit, "limit", 10, "max number of runs to show")
|
||||||
flags.StringVar(&localRunStartOpts.start, "start", "", "starting run id (excluded) to fetch")
|
flags.StringVar(&directRunStartOpts.start, "start", "", "starting run id (excluded) to fetch")
|
||||||
flags.BoolVar(&localRunStartOpts.untracked, "untracked", true, "push untracked files")
|
flags.BoolVar(&directRunStartOpts.untracked, "untracked", true, "push untracked files")
|
||||||
flags.BoolVar(&localRunStartOpts.ignored, "ignored", false, "push ignored files")
|
flags.BoolVar(&directRunStartOpts.ignored, "ignored", false, "push ignored files")
|
||||||
|
|
||||||
cmdLocalRun.AddCommand(cmdLocalRunStart)
|
cmdDirectRun.AddCommand(cmdDirectRunStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
func localRunStart(cmd *cobra.Command, args []string) error {
|
func directRunStart(cmd *cobra.Command, args []string) error {
|
||||||
gwclient := api.NewClient(gatewayURL, token)
|
gwclient := api.NewClient(gatewayURL, token)
|
||||||
|
|
||||||
user, _, err := gwclient.GetCurrentUser(context.TODO())
|
user, _, err := gwclient.GetCurrentUser(context.TODO())
|
||||||
|
@ -68,13 +68,13 @@ func localRunStart(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
gs := gitsave.NewGitSave(logger, &gitsave.GitSaveConfig{
|
gs := gitsave.NewGitSave(logger, &gitsave.GitSaveConfig{
|
||||||
AddUntracked: localRunStartOpts.untracked,
|
AddUntracked: directRunStartOpts.untracked,
|
||||||
AddIgnored: localRunStartOpts.ignored,
|
AddIgnored: directRunStartOpts.ignored,
|
||||||
})
|
})
|
||||||
|
|
||||||
branch := "gitsavebranch-" + uuid.NewV4().String()
|
branch := "gitsavebranch-" + uuid.NewV4().String()
|
||||||
|
|
||||||
if err := gs.Save("agola local run", branch); err != nil {
|
if err := gs.Save("agola direct run", branch); err != nil {
|
||||||
log.Fatalf("err: %v", err)
|
log.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ func (h *ActionHandler) CanGetRun(ctx context.Context, runGroup string) (bool, e
|
||||||
ownerID = p.OwnerID
|
ownerID = p.OwnerID
|
||||||
visibility = p.GlobalVisibility
|
visibility = p.GlobalVisibility
|
||||||
case common.GroupTypeUser:
|
case common.GroupTypeUser:
|
||||||
// user local runs
|
// user direct runs
|
||||||
ownerType = types.ConfigTypeUser
|
ownerType = types.ConfigTypeUser
|
||||||
ownerID = groupID
|
ownerID = groupID
|
||||||
visibility = types.VisibilityPrivate
|
visibility = types.VisibilityPrivate
|
||||||
|
@ -224,7 +224,7 @@ func (h *ActionHandler) CanDoRunActions(ctx context.Context, runGroup string) (b
|
||||||
ownerType = p.OwnerType
|
ownerType = p.OwnerType
|
||||||
ownerID = p.OwnerID
|
ownerID = p.OwnerID
|
||||||
case common.GroupTypeUser:
|
case common.GroupTypeUser:
|
||||||
// user local runs
|
// user direct runs
|
||||||
ownerType = types.ConfigTypeUser
|
ownerType = types.ConfigTypeUser
|
||||||
ownerID = groupID
|
ownerID = groupID
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (n *NotificationService) updateCommitStatus(ctx context.Context, ev *rstype
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore user local runs
|
// ignore user direct runs
|
||||||
if groupType == common.GroupTypeUser {
|
if groupType == common.GroupTypeUser {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue