From 9860ff80f9810ca499b99e230fde443f6f055bfc Mon Sep 17 00:00:00 2001 From: Szabolcs Toth Date: Mon, 9 Sep 2024 15:16:10 +0200 Subject: [PATCH] Add to commands --- cli/cli.go | 2 ++ cli/init.go | 2 ++ cli/merge.go | 2 ++ cli/plugin_delete.go | 2 ++ cli/plugin_info.go | 2 ++ cli/plugin_install.go | 2 ++ cli/plugin_list.go | 2 ++ cli/plugin_update.go | 2 ++ cli/preload_steps.go | 4 ++++ cli/run.go | 2 ++ cli/setup.go | 2 ++ cli/share.go | 2 ++ cli/share_audit.go | 4 +++- cli/share_create.go | 2 ++ cli/share_finish.go | 4 +++- cli/share_start.go | 2 ++ cli/tools.go | 2 ++ cli/trigger.go | 2 ++ cli/trigger_check.go | 2 ++ cli/update.go | 2 ++ cli/validate.go | 2 ++ cli/version.go | 2 ++ cli/workflow_list.go | 2 ++ 23 files changed, 50 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 8ba80db04..c3a219a08 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -90,6 +90,8 @@ func Run() { app.Action = func(c *cli.Context) error { pluginName, pluginArgs, isPlugin := plugins.ParseArgs(c.Args()) if isPlugin { + logPluginCommandParameters(pluginName, pluginArgs) + plugin, found, err := plugins.LoadPlugin(pluginName) if err != nil { return fmt.Errorf("Failed to get plugin (%s), error: %s", pluginName, err) diff --git a/cli/init.go b/cli/init.go index 0a7b3185e..8db7de282 100644 --- a/cli/init.go +++ b/cli/init.go @@ -15,6 +15,8 @@ var initCmd = cli.Command{ Aliases: []string{"i"}, Usage: "Init bitrise config.", Action: func(c *cli.Context) error { + logCommandParameters(c) + logger := log.NewLogger(log.GetGlobalLoggerOpts()) if err := initConfig(c); err != nil { diff --git a/cli/merge.go b/cli/merge.go index 00a191f91..d7a5cdd10 100644 --- a/cli/merge.go +++ b/cli/merge.go @@ -27,6 +27,8 @@ var mergeConfigCommand = cli.Command{ } func mergeConfig(c *cli.Context) error { + logCommandParameters(c) + var configPth string if c.Args().Present() { configPth = c.Args().First() diff --git a/cli/plugin_delete.go b/cli/plugin_delete.go index 576168dbe..f9aa823b0 100644 --- a/cli/plugin_delete.go +++ b/cli/plugin_delete.go @@ -14,6 +14,8 @@ var pluginDeleteCommand = cli.Command{ Name: "delete", Usage: "Delete bitrise plugin.", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := pluginDelete(c); err != nil { log.Errorf("Plugin delete failed, error: %s", err) os.Exit(1) diff --git a/cli/plugin_info.go b/cli/plugin_info.go index 543b7fc61..62e2fe24d 100644 --- a/cli/plugin_info.go +++ b/cli/plugin_info.go @@ -15,6 +15,8 @@ var pluginInfoCommand = cli.Command{ Name: "info", Usage: "Installed bitrise plugin's info", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := pluginInfo(c); err != nil { log.Errorf("Plugin info failed, error: %s", err) os.Exit(1) diff --git a/cli/plugin_install.go b/cli/plugin_install.go index 95808c4a8..de18a1b22 100644 --- a/cli/plugin_install.go +++ b/cli/plugin_install.go @@ -13,6 +13,8 @@ var pluginInstallCommand = cli.Command{ Name: "install", Usage: "Install bitrise plugin.", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := pluginInstall(c); err != nil { log.Errorf("Plugin install failed, error: %s", err) os.Exit(1) diff --git a/cli/plugin_list.go b/cli/plugin_list.go index 53a1f4242..f7b416f13 100644 --- a/cli/plugin_list.go +++ b/cli/plugin_list.go @@ -14,6 +14,8 @@ var pluginListCommand = cli.Command{ Name: "list", Usage: "List installed bitrise plugins.", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := pluginList(c); err != nil { log.Errorf("Plugin list failed, error: %s", err) os.Exit(1) diff --git a/cli/plugin_update.go b/cli/plugin_update.go index ad2db4201..6c707847c 100644 --- a/cli/plugin_update.go +++ b/cli/plugin_update.go @@ -14,6 +14,8 @@ var pluginUpdateCommand = cli.Command{ Name: "update", Usage: "Update bitrise plugin. If not specified, every plugin will be updated.", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := pluginUpdate(c); err != nil { log.Errorf("Plugin update failed, error: %s", err) os.Exit(1) diff --git a/cli/preload_steps.go b/cli/preload_steps.go index 6ce9716cf..5066ace42 100644 --- a/cli/preload_steps.go +++ b/cli/preload_steps.go @@ -24,6 +24,8 @@ var stepsCommand = cli.Command{ Name: "list-cached", Usage: "List all the cached steps", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + return listCachedSteps(c) }, Flags: []cli.Flag{ @@ -44,6 +46,8 @@ var stepsCommand = cli.Command{ Usage: "Makes sure that Bitrise CLI can be used in offline mode by preloading Bitrise maintaned Steps.", UsageText: fmt.Sprintf("Use the %s env var to test after preloading steps.", configs.IsSteplibOfflineModeEnvKey), Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := preloadSteps(c); err != nil { log.Errorf("Preload failed: %s", err) os.Exit(1) diff --git a/cli/run.go b/cli/run.go index a174e368b..cf4440f1b 100644 --- a/cli/run.go +++ b/cli/run.go @@ -73,6 +73,8 @@ var runCommand = cli.Command{ } func run(c *cli.Context) error { + logCommandParameters(c) + signalInterruptChan := make(chan os.Signal, 1) signal.Notify(signalInterruptChan, syscall.SIGINT, syscall.SIGTERM) diff --git a/cli/setup.go b/cli/setup.go index 37ae3530d..d655a1bce 100644 --- a/cli/setup.go +++ b/cli/setup.go @@ -12,6 +12,8 @@ var setupCommand = cli.Command{ Name: "setup", Usage: "Setup the current host. Install every required tool to run Workflows.", Action: func(c *cli.Context) error { + logSubcommandParameters(c) + if err := setup(c); err != nil { log.Errorf("Setup failed, error: %s", err) os.Exit(1) diff --git a/cli/share.go b/cli/share.go index 12638e2f5..4b5b179cc 100644 --- a/cli/share.go +++ b/cli/share.go @@ -6,6 +6,8 @@ import ( ) func share(c *cli.Context) error { + logCommandParameters(c) + if err := tools.StepmanShare(); err != nil { failf("Bitrise share failed, error: %s", err) } diff --git a/cli/share_audit.go b/cli/share_audit.go index 45d475ee8..1fb6bfb0a 100644 --- a/cli/share_audit.go +++ b/cli/share_audit.go @@ -5,7 +5,9 @@ import ( "github.com/urfave/cli" ) -func shareAudit(_ *cli.Context) error { +func shareAudit(c *cli.Context) error { + logSubcommandParameters(c) + if err := tools.StepmanShareAudit(); err != nil { failf("Bitrise share audit failed, error: %s", err) } diff --git a/cli/share_create.go b/cli/share_create.go index c968a9a92..fde594f79 100644 --- a/cli/share_create.go +++ b/cli/share_create.go @@ -6,6 +6,8 @@ import ( ) func create(c *cli.Context) error { + logSubcommandParameters(c) + // Input validation tag := c.String(TagKey) if tag == "" { diff --git a/cli/share_finish.go b/cli/share_finish.go index 39e36442f..8b595ef09 100644 --- a/cli/share_finish.go +++ b/cli/share_finish.go @@ -5,7 +5,9 @@ import ( "github.com/urfave/cli" ) -func finish(_ *cli.Context) error { +func finish(c *cli.Context) error { + logSubcommandParameters(c) + if err := tools.StepmanShareFinish(); err != nil { failf("Bitrise share finish failed, error: %s", err) } diff --git a/cli/share_start.go b/cli/share_start.go index d581abf77..35b751bff 100644 --- a/cli/share_start.go +++ b/cli/share_start.go @@ -6,6 +6,8 @@ import ( ) func start(c *cli.Context) error { + logSubcommandParameters(c) + // Input validation collectionURI := c.String(CollectionKey) if collectionURI == "" { diff --git a/cli/tools.go b/cli/tools.go index 684edca92..772cd9459 100644 --- a/cli/tools.go +++ b/cli/tools.go @@ -12,6 +12,8 @@ var envmanCommand = cli.Command{ Usage: "Runs an envman command.", SkipFlagParsing: true, Action: func(c *cli.Context) error { + logCommandParameters(c) + if err := runCommandWith("envman", c); err != nil { failf("Command failed, error: %s", err) } diff --git a/cli/trigger.go b/cli/trigger.go index 82be20aaf..7837ec280 100644 --- a/cli/trigger.go +++ b/cli/trigger.go @@ -65,6 +65,8 @@ func printAvailableTriggerFilters(triggerMap []models.TriggerMapItemModel) { } func trigger(c *cli.Context) error { + logCommandParameters(c) + // Expand cli.Context var prGlobalFlagPtr *bool if c.GlobalIsSet(PRKey) { diff --git a/cli/trigger_check.go b/cli/trigger_check.go index b456260d2..945e0a186 100644 --- a/cli/trigger_check.go +++ b/cli/trigger_check.go @@ -73,6 +73,8 @@ func getPipelineAndWorkflowIDByParamsInCompatibleMode(triggerMap models.TriggerM // -------------------- func triggerCheck(c *cli.Context) error { + logCommandParameters(c) + warnings := []string{} // diff --git a/cli/update.go b/cli/update.go index 894f7f0e9..82cf68ff4 100644 --- a/cli/update.go +++ b/cli/update.go @@ -31,6 +31,8 @@ var updateCommand = cli.Command{ Name: "update", Usage: "Updates the Bitrise CLI.", Action: func(c *cli.Context) error { + logCommandParameters(c) + if err := update(c); err != nil { log.Errorf("Update Bitrise CLI failed, error: %s", err) os.Exit(1) diff --git a/cli/validate.go b/cli/validate.go index 7c1624085..19c63d61f 100644 --- a/cli/validate.go +++ b/cli/validate.go @@ -218,6 +218,8 @@ func runValidate(bitriseConfigPath string, bitriseConfigBase64Data string, inven } func validate(c *cli.Context) error { + logCommandParameters(c) + // Expand cli.Context bitriseConfigBase64Data := c.String(ConfigBase64Key) bitriseConfigPath := c.String(ConfigKey) diff --git a/cli/version.go b/cli/version.go index ad716e973..631d20b86 100644 --- a/cli/version.go +++ b/cli/version.go @@ -22,6 +22,8 @@ type VersionOutputModel struct { } func printVersionCmd(c *cli.Context) error { + logCommandParameters(c) + fullVersion := c.Bool("full") if err := output.ConfigureOutputFormat(c); err != nil { diff --git a/cli/workflow_list.go b/cli/workflow_list.go index 678c6d2d1..65d57daba 100644 --- a/cli/workflow_list.go +++ b/cli/workflow_list.go @@ -17,6 +17,8 @@ var workflowListCommand = cli.Command{ Name: "workflows", Usage: "List of available workflows in config.", Action: func(c *cli.Context) error { + logCommandParameters(c) + if err := workflowList(c); err != nil { log.Errorf("List of available workflows in config failed, error: %s", err) os.Exit(1)