-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow backend timeout to be configurable
Update config commands to allow getting/setting timeout Update basic config tests to show read/write success Update command tests to show getting/setting timeout Update changelog Signed-off-by: naemono <[email protected]>
- Loading branch information
Showing
17 changed files
with
264 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/sensu/sensu-go/cli" | ||
"github.com/sensu/sensu-go/cli/commands/hooks" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// SetTimeoutCommand given argument changes timeout for active profile | ||
func SetTimeoutCommand(cli *cli.SensuCli) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "set-timeout [TIMEOUT]", | ||
Short: "Set timeout for active profile in duration format (ex: 15s)", | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
_ = cmd.Help() | ||
return errors.New("invalid argument(s) received") | ||
} | ||
|
||
newTimeout := args[0] | ||
newTimeoutDuration, err := time.ParseDuration(newTimeout) | ||
if err != nil { | ||
fmt.Fprintf( | ||
cmd.OutOrStderr(), | ||
"Unable to parse new timeout with error: %s\n", | ||
err, | ||
) | ||
return err | ||
} | ||
if err := cli.Config.SaveTimeout(newTimeoutDuration); err != nil { | ||
fmt.Fprintf( | ||
cmd.OutOrStderr(), | ||
"Unable to write new configuration file with error: %s\n", | ||
err, | ||
) | ||
} | ||
|
||
fmt.Fprintln(cmd.OutOrStdout(), "Updated") | ||
return nil | ||
}, | ||
Annotations: map[string]string{ | ||
// We want to be able to run this command regardless of whether the CLI | ||
// has been configured. | ||
hooks.ConfigurationRequirement: hooks.ConfigurationNotRequired, | ||
}, | ||
} | ||
} |
Oops, something went wrong.