cli

package
v0.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CLICmd = &cobra.Command{
	Use:   "cli",
	Short: "Interact with a running Gravity server",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		url, err := url.Parse(apiUrl)
		if err != nil {
			logger.Error("failed to parse API URL", zap.Error(err))
			return
		}

		config := api.NewConfiguration()
		config.Host = url.Host
		config.Scheme = url.Scheme
		if url.Scheme == "unix" {
			config.Scheme = "http"
			config.Host = "socket"
			config.HTTPClient = &http.Client{
				Transport: &http.Transport{
					DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
						return net.Dial("unix", url.Path)
					},
				},
			}
		}
		if apiToken != "" {
			config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", apiToken))
		}
		apiClient = api.NewAPIClient(config)
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL