cmd

package
v1.125.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const ENABLED = "true"

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "apigeecli",
	Short: "Utility to work with Apigee APIs.",
	Long:  "This command lets you interact with Apigee APIs.",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		if metadataToken && defaultToken {
			return fmt.Errorf("metadata-token and default-token cannot be used together")
		}
		if defaultToken && (serviceAccount != "" || accessToken != "") {
			return fmt.Errorf("default-token cannot be used with token or account flags")
		}
		if metadataToken && (serviceAccount != "" || accessToken != "") {
			return fmt.Errorf("metadata-token cannot be used with token or account flags")
		}

		if serviceAccount != "" && accessToken != "" {
			return fmt.Errorf("token and account flags cannot be used together")
		}

		if !disableCheck {
			if ok, _ := apiclient.TestAndUpdateLastCheck(); !ok {
				latestVersion, _ := getLatestVersion()
				if cmd.Version == "" {
					clilog.Debug.Println("apigeecli wasn't built with a valid Version tag.")
				} else if latestVersion != "" && cmd.Version != latestVersion {
					clilog.Info.Printf("You are using %s, the latest version %s "+
						"is available for download\n", cmd.Version, latestVersion)
				}
			}
		}

		if !metadataToken && !defaultToken {
			apiclient.SetServiceAccount(serviceAccount)
			apiclient.SetApigeeToken(accessToken)
		}

		if metadataToken {
			return apiclient.GetMetadataAccessToken()
		}

		if defaultToken {
			return apiclient.GetDefaultAccessToken()
		}

		_ = apiclient.SetAccessToken()

		return nil
	},
	SilenceUsage:  getUsageFlag(),
	SilenceErrors: getErrorsFlag(),
}

RootCmd to manage apigeecli

Functions

func Execute

func Execute()

func GetRootCmd

func GetRootCmd() *cobra.Command

GetRootCmd returns the root of the cobra command-tree.

Types

This section is empty.

Jump to

Keyboard shortcuts

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