cmd

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package cmd implements the lagoon-cli command line interface.

Index

Constants

This section is empty.

Variables

View Source
var ListOrganizationUsersCmd = &cobra.Command{
	Use:     "organization-users",
	Aliases: []string{"org-u"},
	Short:   "List users in an organization",
	PreRunE: func(_ *cobra.Command, _ []string) error {
		return validateTokenE(cmdLagoon)
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		debug, err := cmd.Flags().GetBool("debug")
		if err != nil {
			return err
		}
		organizationName, err := cmd.Flags().GetString("organization-name")
		if err != nil {
			return err
		}
		if err := requiredInputCheck("Organization name", organizationName); err != nil {
			return err
		}

		current := lagoonCLIConfig.Current
		token := lagoonCLIConfig.Lagoons[current].Token
		lc := lclient.New(
			lagoonCLIConfig.Lagoons[current].GraphQL,
			lagoonCLIVersion,
			lagoonCLIConfig.Lagoons[current].Version,
			&token,
			debug)
		users, err := lagoon.UsersByOrganizationName(context.TODO(), organizationName, lc)
		if err != nil {
			return err
		}

		data := []output.Data{}
		for _, user := range *users {
			data = append(data, []string{
				returnNonEmptyString(user.ID.String()),
				returnNonEmptyString(user.Email),
				returnNonEmptyString(user.FirstName),
				returnNonEmptyString(user.LastName),
				returnNonEmptyString(user.Comment),
			})
		}
		dataMain := output.Table{
			Header: []string{"ID", "Email", "First Name", "LastName", "Comment"},
			Data:   data,
		}
		r := output.RenderOutput(dataMain, outputOptions)
		fmt.Fprintf(cmd.OutOrStdout(), "%s", r)
		return nil
	},
}

Functions

func Execute

func Execute()

Execute the root command.

func GetInput

func GetInput() string

GetInput reads input from an input buffer and returns the result as a string.

func Prompt

func Prompt(prompt string) string

Prompt gets input with a prompt and returns the input

func VerifyTokenExpiry added in v0.30.0

func VerifyTokenExpiry(lc *lagooncli.Config, lagoon string) bool

VerifyTokenExpiry verfies if the current token is valid or not

Types

type FormatType

type FormatType string

FormatType .

const (
	JSON   FormatType = "JSON"
	YAML   FormatType = "YAML"
	STDOUT FormatType = "STDOUT"
)

. .

type GetFlags

type GetFlags struct {
	Project     string `json:"project,omitempty"`
	Environment string `json:"environment,omitempty"`
	RemoteID    string `json:"remoteid,omitempty"`
}

GetFlags .

type LagoonConfigFlags

type LagoonConfigFlags struct {
	Lagoon    string `json:"lagoon,omitempty"`
	Hostname  string `json:"hostname,omitempty"`
	Port      string `json:"port,omitempty"`
	GraphQL   string `json:"graphql,omitempty"`
	Token     string `json:"token,omitempty"`
	UI        string `json:"ui,omitempty"`
	Kibana    string `json:"kibana,omitempty"`
	SSHKey    string `json:"sshkey,omitempty"`
	SSHPortal bool   `json:"sshportal,omitempty"`
}

LagoonConfigFlags .

type ListFlags

type ListFlags struct {
	Project     string `json:"project,omitempty"`
	Environment string `json:"environment,omitempty"`
	Reveal      bool   `json:"reveal,omitempty"`
}

ListFlags .

type NotificationFlags

type NotificationFlags struct {
	Project             string `json:"project,omitempty"`
	NotificationName    string `json:"name,omitempty"`
	NotificationNewName string `json:"newname,omitempty"`
	NotificationOldName string `json:"old,omitempty"`
	NotificationWebhook string `json:"webhook,omitempty"`
	NotificationChannel string `json:"channel,omitempty"`
}

NotificationFlags .

Jump to

Keyboard shortcuts

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