core

package
v0.0.0-...-2eb1f2f Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName           = "ntui"
	ShortDesc         = "A graphical CLI for your Hashicorp Nomad Cluster Management"
	LongDesc          = "Ntui is a CLI to view and manage your Hashicorp Nomad Clusters."
	DefaultConfigDir  = "." + AppName
	DefaultConfigFile = "config.toml"
	DefaultLogDir     = "logs"
	DefaultLogFile    = "/ntui.log"
)
View Source
const (
	LOG_STDOUT = "stdout"
	LOG_STDERR = "stderr"
)

Variables

View Source
var EnvVars = map[string]string{
	"NOMAD_ADDR":  "NomadBaseUrl",
	"NOMAD_SKIP":  "NomadSkipVerify",
	"NOMAD_TOKEN": "NomadToken",
}

Functions

func BindAppKeys

func BindAppKeys(app *App)

func GetValue

func GetValue(c *Config, key string) string

func SetConfigValues

func SetConfigValues(c *Config, flags Flags)

Types

type Alert

type Alert struct {
	App *App
}

func NewAlert

func NewAlert(app *App) *Alert

func (*Alert) Listen

func (a *Alert) Listen()

type Allocations

type Allocations struct {
	*views.Allocations
	App           *App
	Listener      *utils.Listener
	SelectedValue map[string]string
	TaskGroup     map[string]string
	SelectedAlloc models.Allocations
	Data          []models.Allocations
}

func NewAllocations

func NewAllocations(app *App) *Allocations

func (*Allocations) GetAllocationData

func (a *Allocations) GetAllocationData(id string) (models.Allocations, bool)

func (*Allocations) HandleButtonResponse

func (a *Allocations) HandleButtonResponse(index int, label string)

func (*Allocations) InitRestartModal

func (a *Allocations) InitRestartModal()

func (*Allocations) OnBlur

func (a *Allocations) OnBlur()

func (*Allocations) OnFocus

func (a *Allocations) OnFocus()

func (*Allocations) OnRowSelected

func (a *Allocations) OnRowSelected(row, col int)

func (*Allocations) Refresher

func (a *Allocations) Refresher()

func (*Allocations) Render

func (a *Allocations) Render(data map[string]string)

func (*Allocations) SetSelectedRow

func (a *Allocations) SetSelectedRow()

func (*Allocations) UpdateTable

func (a *Allocations) UpdateTable(data map[string]string)

type App

type App struct {
	Config      *Config
	Version     string
	Layout      *Layout
	NomadClient *nomad.Nomad
	Primitives  PrimitivesX
	Alert       *utils.Alert
	Logger      *utils.Logger
}

func NewApp

func NewApp(version string, config *Config, logger *utils.Logger) (*App, error)

func (*App) Init

func (app *App) Init() error

func (*App) OpenModal

func (app *App) OpenModal(data string, handlerFn func(*tcell.EventKey) *tcell.EventKey)

func (*App) RunX

func (app *App) RunX() error

func (*App) StopX

func (app *App) StopX()

type Config

type Config struct {
	AppName         string `toml:"App_Name"`
	HomeDir         string `toml:"Home_Dir"`
	LogLevel        string `toml:"Log_Level"`
	LogDir          string `toml:"Log_Dir"`
	RefreshRate     int    `toml:"Refresh_Rate"`
	NomadBaseUrl    string `toml:"Nomad_Server_Base_Url"`
	NomadHttpAuth   string `toml:"Nomad_Http_Auth"`
	NomadToken      string `toml:"Nomad_Token"`
	Region          string `toml:"Nomad_Region"`
	Namespace       string `toml:"Nomad_Namespace"`
	NomadCaCert     string `toml:"Nomad_Cacert"`
	NomadCaPath     string `toml:"Nomad_Capath"`
	NomadClientCert string `toml:"Nomad_Client_Cert"`
	NomadClientKey  string `toml:"Nomad_Client_Key"`
	NomadTlsServer  string `toml:"Nomad_Tls_Server"`
	NomadSkipVerify bool   `toml:"Nomad_Skip_Verify"`
}

func NewConfig

func NewConfig() *Config

func (*Config) GetNamespace

func (c *Config) GetNamespace() string

func (*Config) GetRegion

func (c *Config) GetRegion() string

func (*Config) IsRegionInConfig

func (c *Config) IsRegionInConfig() bool

func (*Config) Load

func (c *Config) Load(flags Flags) (*Config, error)

func (*Config) SetNamespace

func (c *Config) SetNamespace(ns string)

func (*Config) SetRegion

func (c *Config) SetRegion(region string)

func (*Config) UpdateConfigFile

func (c *Config) UpdateConfigFile(key, newValue, oldValue string)

type CustomModal

type CustomModal struct {
	*tview.Grid
	Modal1     *widgets.Modal1
	App        *App
	Title      string
	Buttons    []string
	Data       string
	ResponseFn func(int, string)
}

func NewCustomModal

func NewCustomModal(app *App) *CustomModal

func (*CustomModal) GetPageTitle

func (cm *CustomModal) GetPageTitle() string

func (*CustomModal) SetData

func (cm *CustomModal) SetData(data string)

func (*CustomModal) SetInputHandler

func (cm *CustomModal) SetInputHandler(handler func(event *tcell.EventKey) *tcell.EventKey)

func (*CustomModal) SetTitle

func (cm *CustomModal) SetTitle(title string)

type Flags

type Flags struct {
	ConfigPath  string
	RefreshRate int
	HomeDir     string
	LogLevel    string
	Region      string
	Namespace   string
	Host        string
	Token       string
	SkipVerify  bool
}

func (*Flags) ParseCommand

func (f *Flags) ParseCommand(cmd *cobra.Command) *Flags

type JobDefinition

type JobDefinition struct {
	*views.JobDefinition
	App  *App
	Data map[string]string
}

func NewJobDefinition

func NewJobDefinition(app *App) *JobDefinition

func (*JobDefinition) OnBlur

func (jd *JobDefinition) OnBlur()

func (*JobDefinition) OnFocus

func (jd *JobDefinition) OnFocus()

func (*JobDefinition) UpdateTable

func (jd *JobDefinition) UpdateTable()

type Jobs

type Jobs struct {
	*views.Jobs
	App           *App
	Listener      *utils.Listener
	SelectedValue map[string]string
}

func NewJobs

func NewJobs(app *App) *Jobs

func (*Jobs) GoToDefinitions

func (j *Jobs) GoToDefinitions()

func (*Jobs) HandleStartModalResponse

func (j *Jobs) HandleStartModalResponse(index int, label string)

func (*Jobs) HandleStopModalResponse

func (j *Jobs) HandleStopModalResponse(index int, label string)

func (*Jobs) OnBlur

func (j *Jobs) OnBlur()

func (*Jobs) OnFocus

func (j *Jobs) OnFocus()

func (*Jobs) OnRowSelected

func (j *Jobs) OnRowSelected(row, col int)

func (*Jobs) OnSelectionChanged

func (j *Jobs) OnSelectionChanged(row, col int)

func (*Jobs) Refresher

func (j *Jobs) Refresher()

func (*Jobs) StartModal

func (j *Jobs) StartModal()

func (*Jobs) StopModal

func (j *Jobs) StopModal()

func (*Jobs) UpdateTable

func (j *Jobs) UpdateTable()

type Layout

type Layout struct {
	*views.App
	Pages      *tview.Pages
	MainLayout *tview.Flex
	Splash     *views.Splash
	Header     *views.Header
	Body       *widgets.Pages
	Footer     *views.Footer
}

func NewLayout

func NewLayout(version string) *Layout

func (*Layout) ChangeFocusX

func (l *Layout) ChangeFocusX(p tview.Primitive)

func (*Layout) GetActivePage

func (l *Layout) GetActivePage() string

func (*Layout) GoBack

func (l *Layout) GoBack()

func (*Layout) OpenPage

func (l *Layout) OpenPage(name string, addHistory bool)

func (*Layout) Run

func (l *Layout) Run(app *App) error

type Log

type Log struct {
	*views.Log
	App           *App
	SelectedAlloc models.Allocations
	DefaultType   string
	Follow        bool
	StopLogChan   chan struct{}
	PageSource    *string
}

func NewLog

func NewLog(app *App) *Log

func (*Log) BindInputCapture

func (l *Log) BindInputCapture()

func (*Log) FetchLog

func (l *Log) FetchLog()

func (*Log) FetchStdErrLog

func (l *Log) FetchStdErrLog()

func (*Log) FetchStdOutLog

func (l *Log) FetchStdOutLog()

func (*Log) OnBlur

func (l *Log) OnBlur()

func (*Log) OnFocus

func (l *Log) OnFocus()

func (*Log) SetFollow

func (l *Log) SetFollow(follow bool)

func (*Log) SetLog

func (l *Log) SetLog(data []byte)

func (*Log) SetLogType

func (l *Log) SetLogType(logType string)

func (*Log) SetPageSource

func (l *Log) SetPageSource(s string)

func (*Log) ShowFullScreen

func (l *Log) ShowFullScreen(fs bool)

func (*Log) StartLogStream

func (l *Log) StartLogStream(logChan <-chan *api.StreamFrame, errChan <-chan error)

func (*Log) StopLogStream

func (l *Log) StopLogStream()

func (*Log) UpdateMenu

func (l *Log) UpdateMenu()

type Main

type Main struct {
	*tview.Flex
	App   *App
	Title string
}

func NewMain

func NewMain(app *App) *Main

func (*Main) GetTitle

func (m *Main) GetTitle() string
type Modal struct {
	*widgets.Modal
	App        *App
	Title      string
	Buttons    []string
	Data       map[string]string
	ResponseFn func(int, string)
}

func NewModal

func NewModal(app *App) *Modal

func (*Modal) AddButtons

func (m *Modal) AddButtons(buttons []string)

func (*Modal) SetData

func (m *Modal) SetData(data map[string]string)

func (*Modal) SetResponseFunc

func (m *Modal) SetResponseFunc(fn func(int, string))

func (*Modal) SetTitle

func (m *Modal) SetTitle(title string)

type Namespaces

type Namespaces struct {
	*views.Namespaces
	App           *App
	SelectedValue map[string]string
}

func NewNamespaces

func NewNamespaces(app *App) *Namespaces

func (*Namespaces) OnRowSelected

func (n *Namespaces) OnRowSelected(row, col int)

func (*Namespaces) OnTabPress

func (n *Namespaces) OnTabPress()

func (*Namespaces) UpdateTable

func (n *Namespaces) UpdateTable()

type Nodes

type Nodes struct {
	*views.Nodes
	App           *App
	Listener      *utils.Listener
	JobId         string
	SelectedValue map[string]string
}

func NewNodes

func NewNodes(app *App) *Nodes

func (*Nodes) OnBlur

func (n *Nodes) OnBlur()

func (*Nodes) OnFocus

func (n *Nodes) OnFocus()

func (*Nodes) UpdateTable

func (n *Nodes) UpdateTable()

type PrimitivesX

type PrimitivesX struct {
	Regions       *Regions
	Namespaces    *Namespaces
	Main          *Main
	Jobs          *Jobs
	TaskGroups    *TaskGroups
	Allocations   *Allocations
	Tasks         *Tasks
	Log           *Log
	Versions      *Versions
	VersionDiff   *VersionDiff
	Nodes         *Nodes
	Modal         *Modal
	CustomModal   *CustomModal
	JobDefinition *JobDefinition
	RunJob        *RunJob
}

type Regions

type Regions struct {
	*views.Regions
	App           *App
	SelectedValue map[string]string
}

func NewRegions

func NewRegions(app *App) *Regions

func (*Regions) OnRowSelected

func (reg *Regions) OnRowSelected(row, col int)

func (*Regions) OnTabPress

func (reg *Regions) OnTabPress()

func (*Regions) UpdateTable

func (reg *Regions) UpdateTable()

type RunJob

type RunJob struct {
	*views.RunJob
	App    *App
	Data   map[string]string
	DryRan bool
}

func NewRunJob

func NewRunJob(app *App) *RunJob

func (*RunJob) BindKeys

func (rj *RunJob) BindKeys()

func (*RunJob) DryRun

func (rj *RunJob) DryRun()

func (*RunJob) OnBlur

func (rj *RunJob) OnBlur()

func (*RunJob) OnFocus

func (rj *RunJob) OnFocus()

func (*RunJob) SubmitJob

func (rj *RunJob) SubmitJob(job *api.Job)

type Splash

type Splash struct {
	*views.Splash
	App *App
}

func NewSplash

func NewSplash(app *App) *Splash

type TaskGroups

type TaskGroups struct {
	*views.TaskGroups
	App           *App
	Listener      *utils.Listener
	JobId         string
	SelectedValue map[string]string
}

func NewTaskGroups

func NewTaskGroups(app *App) *TaskGroups

func (*TaskGroups) OnBlur

func (tg *TaskGroups) OnBlur()

func (*TaskGroups) OnFocus

func (tg *TaskGroups) OnFocus()

func (*TaskGroups) OnRowSelected

func (tg *TaskGroups) OnRowSelected(row, col int)

func (*TaskGroups) Refresher

func (tg *TaskGroups) Refresher()

func (*TaskGroups) UpdateTable

func (tg *TaskGroups) UpdateTable(jobId string)

type Tasks

type Tasks struct {
	*views.Tasks
	App           *App
	Listener      *utils.Listener
	SelectedValue models.Allocations
}

func NewTasks

func NewTasks(app *App) *Tasks

func (*Tasks) OnBlur

func (t *Tasks) OnBlur()

func (*Tasks) OnFocus

func (t *Tasks) OnFocus()

func (*Tasks) RefreshUsageStats

func (t *Tasks) RefreshUsageStats()

func (*Tasks) Refresher

func (t *Tasks) Refresher()

type VersionDiff

type VersionDiff struct {
	*views.VersionDiff
	App      *App
	Listener *utils.Listener
	JobId    string
	Data     map[string]string
}

func NewVersionDiff

func NewVersionDiff(app *App) *VersionDiff

func (*VersionDiff) Render

func (vd *VersionDiff) Render(jobId string, row map[string]string, diff models.JobVersionDiff)

type Versions

type Versions struct {
	*views.Versions
	App           *App
	Listener      *utils.Listener
	JobId         string
	SelectedValue map[string]string
	Diffs         []models.JobVersionDiff
}

func NewVersions

func NewVersions(app *App) *Versions

func (*Versions) ConfirmModal

func (v *Versions) ConfirmModal()

func (*Versions) HandleModalResponse

func (v *Versions) HandleModalResponse(index int, label string)

func (*Versions) OnBlur

func (v *Versions) OnBlur()

func (*Versions) OnFocus

func (v *Versions) OnFocus()

func (*Versions) OnRowSelected

func (v *Versions) OnRowSelected(row, col int)

func (*Versions) UpdateTable

func (v *Versions) UpdateTable()

Jump to

Keyboard shortcuts

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