config

package
v3.0.0-beta.20240904 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config contains the configuration for the bk CLI

Configuration can come from files or environment variables. File based configuration works similar to unix config file hierarchy where there is a "user" config file found under $HOME, and also a local config in the current repository root (referred to as "local" config)

Index

Constants

View Source
const (
	DefaultGraphQLEndpoint = "https://graphql.buildkite.com/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config contains the configuration for the currently selected organization to operate on with the CLI application

config file format (yaml):

selected_org: buildkite
organizations:
  buildkite:
    api_token: <token>
  buildkite-oss:
    api_token: <token>
pipelines: # (only in local config)
  - first-pipeline
  - second-pipeline

func New

func New(fs afero.Fs, repo *git.Repository) *Config

func (*Config) APIToken

func (conf *Config) APIToken() string

APIToken gets the API token configured for the currently selected organization

func (*Config) ConfiguredOrganizations

func (conf *Config) ConfiguredOrganizations() []string

func (*Config) GetOpenAIToken

func (conf *Config) GetOpenAIToken() string

GetOpenAIToken reads the user's OpenAI token from the user config file

func (*Config) HasConfiguredOrganization

func (conf *Config) HasConfiguredOrganization(slug string) bool

func (*Config) OrganizationSlug

func (conf *Config) OrganizationSlug() string

OrganizationSlug gets the slug for the currently selected organization. This can be configured locally or per user. This will search for configuration in that order.

func (*Config) PreferredPipelines

func (conf *Config) PreferredPipelines() []pipeline.Pipeline

PreferredPipelines will retrieve the list of pipelines from local configuration

func (*Config) SelectOrganization

func (conf *Config) SelectOrganization(org string) error

SelectOrganization sets the selected organization in the local configuration file

func (*Config) SetOpenAIToken

func (conf *Config) SetOpenAIToken(token string) error

SetOpenAIToken sets the user's OpenAI token in the user config file

func (*Config) SetPreferredPipelines

func (conf *Config) SetPreferredPipelines(pipelines []pipeline.Pipeline) error

SetPreferredPipelines will write the provided list of pipelines to local configuration

func (*Config) SetTokenForOrg

func (conf *Config) SetTokenForOrg(org, token string) error

SetTokenForOrg sets the token for the given org in the user configuration file. Tokens are not stored in the local configuration file to reduce the likelihood of tokens being committed to VCS

Jump to

Keyboard shortcuts

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