config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// Dir is the jt config directory.
	Dir = "jt"
	// FileName is the jt config file name.
	FileName = "config"
	// FileType is the jt config file extension.
	FileType = "yml"
)
View Source
const (
	// KeyProjects holds the named projects.
	KeyProjects = "projects"
	// KeyCurrentProject is the active project name.
	KeyCurrentProject = "current_project"
	// KeyPreviousProject is the project active before the last switch, used by `project -`.
	KeyPreviousProject = "previous_project"
	// KeyAliases holds user-defined command aliases.
	KeyAliases = "aliases"
	// KeySavedQueries holds named JQL queries.
	KeySavedQueries = "saved_queries"
)

Variables

View Source
var (
	// ErrSkip is returned when a user skips the config generation.
	ErrSkip = fmt.Errorf("skipping config generation")
	// ErrUnexpectedResponseFormat is returned if the response data is in unexpected format.
	ErrUnexpectedResponseFormat = fmt.Errorf("unexpected response format")
)
View Source
var ErrNoConfig = errors.New("config file not found, run 'jt init' to create one")

ErrNoConfig is returned when no config file exists at the resolved path.

Functions

func ActiveProject

func ActiveProject(v *viper.Viper, override string) string

ActiveProject returns the project to use: override (flag/env) if set, otherwise current_project from the config.

func ApplyProject

func ApplyProject(v *viper.Viper, name string) error

ApplyProject overlays projects.<name> onto the top-level config so every existing command (which reads project.key, board.id, issue.types, ...) transparently uses the project. Project keys replace the top-level keys wholesale rather than deep-merging, so a project without e.g. board.type does not inherit the default board's type. The overlay is loaded into viper's config layer, so command-line flags such as --project still win.

func DefaultProjectName

func DefaultProjectName(projectKey string) string

DefaultProjectName derives a project name from a project key.

func Exists

func Exists(file string) bool

Exists checks if the file exist.

func GenerateProject

func GenerateProject(client *jira.Client, project, board string) (map[string]any, error)

GenerateProject resolves a project (and optionally a board) against the server and returns the value to store under contexts.<name>. Empty project or board values are asked for interactively, reusing the init pickers.

func Path

func Path(flagValue string) (string, error)

Path resolves the config file location: explicit flag value first, then JT_CONFIG_FILE (or JIRA_CONFIG_FILE), then ~/.config/jt/config.yml.

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName rejects names that would not round-trip as YAML keys or that collide with the `project -` shorthand.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File is a YAML config file edited in place. It works on the yaml.Node tree so that comments and key order written by the user survive a Save.

func LoadCurrent

func LoadCurrent() (*File, error)

LoadCurrent loads the config file in use by this invocation (as resolved by the root command), falling back to the default location.

func LoadFile

func LoadFile(path string) (*File, error)

LoadFile reads the config file at path.

func (*File) Delete

func (f *File) Delete(keys ...string) bool

Delete removes the key path. It reports whether anything was removed.

func (*File) DeleteProject

func (f *File) DeleteProject(name string) error

DeleteProject removes a project. Deleting the current project clears current_project so commands fall back to the top-level project.

func (*File) Get

func (f *File) Get(keys ...string) *yaml.Node

Get returns the node at the given key path, or nil.

func (*File) GetString

func (f *File) GetString(keys ...string) string

GetString returns the scalar at the given key path, or "".

func (*File) HasProject

func (f *File) HasProject(name string) bool

HasProject reports whether name is defined.

func (*File) Keys

func (f *File) Keys(keys ...string) []string

Keys returns the sorted keys of the mapping at the given path.

func (*File) Path

func (f *File) Path() string

Path returns the file location.

func (*File) Projects

func (f *File) Projects() []SavedProject

Projects lists the saved projects defined in the file.

func (*File) RenameProject

func (f *File) RenameProject(from, to string) error

RenameProject renames a project, keeping current/previous pointers valid.

func (*File) Resolve

func (f *File) Resolve(selector string) string

Resolve maps a selector to a saved project name: an exact name wins, then a case-insensitive Jira key match. It returns "" if nothing matches.

func (*File) Save

func (f *File) Save() error

Save writes the file atomically (temp file + rename), keeping it 0600 because it lives next to credentials-adjacent settings.

func (*File) Set

func (f *File) Set(value any, keys ...string) error

Set stores value at the key path, creating intermediate mappings.

func (*File) StringMap

func (f *File) StringMap(keys ...string) map[string]string

StringMap returns the mapping at the given path as key/scalar pairs.

func (*File) UseProject

func (f *File) UseProject(name string) (string, error)

UseProject makes name the current project and remembers the previous one. The special name "-" swaps back to the previous project.

type JiraCLIConfig

type JiraCLIConfig struct {
	Installation string
	Server       string
	AuthType     string
	Login        string
	Project      string
	Board        string
	Force        bool
	Insecure     bool
	MTLS         JiraCLIMTLSConfig
}

JiraCLIConfig is a Jira CLI config.

type JiraCLIConfigGenerator

type JiraCLIConfigGenerator struct {
	// contains filtered or unexported fields
}

JiraCLIConfigGenerator is a Jira CLI config generator.

func NewJiraCLIConfigGenerator

func NewJiraCLIConfigGenerator(cfg *JiraCLIConfig) *JiraCLIConfigGenerator

NewJiraCLIConfigGenerator creates a new Jira CLI config.

func (*JiraCLIConfigGenerator) Generate

func (c *JiraCLIConfigGenerator) Generate() (string, error)

Generate generates the config file.

type JiraCLIMTLSConfig

type JiraCLIMTLSConfig struct {
	CaCert     string
	ClientCert string
	ClientKey  string
}

JiraCLIMTLSConfig is an authtype specific config.

type SavedProject

type SavedProject struct {
	Name      string
	Key       string // Jira project key
	Board     string
	BoardID   string
	BoardType string
	Current   bool
}

SavedProject is a summary of a configured project.

Jump to

Keyboard shortcuts

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