profile

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageLength = 50 // DefaultPageLength is the default number of items per page to retrieve from Bitbucket
)

Variables

View Source
var Command = &cobra.Command{
	Use:   "profile",
	Short: "Manage profiles",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Profile requires a subcommand:")
		for _, command := range cmd.Commands() {
			fmt.Println(command.Name())
		}
	},
}

Command represents this folder's command

View Source
var Profiles profiles

Profiles is the collection of profiles

Functions

func GetAll

func GetAll[T any](context context.Context, cmd *cobra.Command, uripath string) (resources []T, err error)

GetAllResources gets all resources of the given type

The Current profile will be set to the profile of the command

func ValidProfileNames

func ValidProfileNames(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

ValidProfileNames gets the valid profile names

Types

type BitBucketError

type BitBucketError struct {
	Type    string              `json:"type"`
	Message string              `json:"-"`
	Detail  string              `json:"-"`
	Fields  map[string][]string `json:"-"`
}

BitBucketError represents an error returned by the BitBucket API

See: https://developer.atlassian.com/cloud/bitbucket/rest/intro/#standardized-error-responses

func (*BitBucketError) Error

func (bberr *BitBucketError) Error() string

func (*BitBucketError) UnmarshalJSON

func (bberr *BitBucketError) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON unmarshals the JSON

type Credential

type Credential struct {
	Username string
	Password string
}

Credential represents a user credential for authentication.

func (*Credential) AsHTTPBasicAuth

func (credential *Credential) AsHTTPBasicAuth() *http.BasicAuth

AsHTTPBasicAuth returns the credential as an HTTP BasicAuth structure.

type PaginatedResources

type PaginatedResources[T any] struct {
	Values   []T    `json:"values"`
	Page     int    `json:"page"`
	PageSize int    `json:"pagelen"`
	Size     int    `json:"size"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
}

type Profile

type Profile struct {
	Name              string                 `json:"name"                        mapstructure:"name"`
	Description       string                 `json:"description,omitempty"       mapstructure:"description,omitempty"       yaml:",omitempty"`
	Default           bool                   `json:"default"                     mapstructure:"default"                     yaml:",omitempty"`
	APIRoot           *url.URL               `json:"apiRoot,omitempty"           mapstructure:"apiRoot,omitempty"           yaml:",omitempty"`
	DefaultWorkspace  string                 `json:"defaultWorkspace,omitempty"  mapstructure:"defaultWorkspace,omitempty"  yaml:",omitempty"`
	DefaultProject    string                 `json:"defaultProject,omitempty"    mapstructure:"defaultProject,omitempty"    yaml:",omitempty"`
	ErrorProcessing   common.ErrorProcessing `json:"errorProcessing,omitempty"   mapstructure:"errorProcessing,omitempty"   yaml:",omitempty"`
	DefaultPageLength int                    `json:"defaultPageLength,omitempty" mapstructure:"defaultPageLength,omitempty" yaml:",omitempty"`
	OutputFormat      string                 `json:"outputFormat,omitempty"      mapstructure:"outputFormat,omitempty"      yaml:",omitempty"`
	Progress          bool                   `json:"progress,omitempty"          mapstructure:"progress,omitempty"          yaml:",omitempty"`
	VaultKey          string                 `json:"vaultKey,omitempty"          mapstructure:"vaultKey,omitempty"          yaml:",omitempty"`
	User              string                 `json:"user,omitempty"              mapstructure:"user"                        yaml:",omitempty"`
	Password          string                 `json:"password,omitempty"          mapstructure:"password"                    yaml:",omitempty"`
	ClientID          string                 `json:"clientID,omitempty"          mapstructure:"clientID"                    yaml:",omitempty"`
	ClientSecret      string                 `json:"clientSecret,omitempty"      mapstructure:"clientSecret"                yaml:",omitempty"`
	CallbackPort      uint16                 `json:"callbackPort,omitempty"      mapstructure:"callbackPort"                yaml:",omitempty"`
	AccessToken       string                 `json:"accessToken,omitempty"       mapstructure:"accessToken"                 yaml:",omitempty"`
	RefreshToken      string                 `json:"-"                           mapstructure:"refreshToken"                yaml:"-"`
	TokenExpires      time.Time              `json:"-"                           mapstructure:"tokenExpires"                yaml:"-"`
	TokenScopes       []string               `json:"-"                           mapstructure:"tokenScopes"                 yaml:"-"`
	CloneProtocol     string                 `json:"cloneProtocol,omitempty"     mapstructure:"cloneProtocol,omitempty"     yaml:",omitempty"`
	CloneUser         string                 `json:"cloneUser,omitempty"         mapstructure:"cloneUser,omitempty"         yaml:",omitempty"`
}

Profile describes the configuration needed to connect to BitBucket

var Current *Profile

Current is the current profile

func GetProfileFromCommand

func GetProfileFromCommand(context context.Context, cmd *cobra.Command) (profile *Profile, err error)

GetProfileFromCommand gets the profile from the command line

If the profile is not given, it will use the current profile

func (*Profile) CodeGrantCallback

func (profile *Profile) CodeGrantCallback(resultchan chan error) http.Handler

func (*Profile) Delete

func (profile *Profile) Delete(context context.Context, cmd *cobra.Command, uripath string, response interface{}) (err error)

Delete deletes a resource

func (Profile) DeleteCredentialFromVault

func (profile Profile) DeleteCredentialFromVault(service, username string) error

DeleteCredentialFromVault removes the credential from the Windows Credential Manager or Linux/macOS keychain.

func (*Profile) Download

func (profile *Profile) Download(context context.Context, cmd *cobra.Command, uripath, destination string) (err error)

Download downloads a resource to a destination folder

The destination folder is the current folder if not specified

If the profile has its Progress flag set to true, it will show a progress bar. Otherwise, if the command has a flag --progress, it will show a progress bar.

func (*Profile) Get

func (profile *Profile) Get(context context.Context, cmd *cobra.Command, uripath string, response interface{}) (err error)

Get gets a resource

func (Profile) GetCredentialFromVault

func (profile Profile) GetCredentialFromVault(service, username string) (credential *Credential, err error)

GetCredentialFromVault retrieves the credential for the given key from the Windows Credential Manager or Linux/macOS keychain.

func (Profile) GetHeaders

func (profile Profile) GetHeaders(cmd *cobra.Command) []string

GetHeaders gets the header for a table

implements common.Tableable

func (*Profile) GetRaw

func (profile *Profile) GetRaw(context context.Context, cmd *cobra.Command, uripath string) (raw io.Reader, err error)

GetRaw gets a resource without unmarshaling it

func (Profile) GetRow

func (profile Profile) GetRow(headers []string) []string

GetRow gets the row for a table

implements common.Tableable

func (Profile) MarshalJSON

func (profile Profile) MarshalJSON() ([]byte, error)

MarshalJSON marshals this profile to JSON

implements json.Marshaler

func (*Profile) Patch

func (profile *Profile) Patch(context context.Context, cmd *cobra.Command, uripath string, body interface{}, response interface{}) (err error)

Patch patches a resource

func (*Profile) Post

func (profile *Profile) Post(context context.Context, cmd *cobra.Command, uripath string, body interface{}, response interface{}) (err error)

Post posts a resource

func (*Profile) PostWithResult

func (profile *Profile) PostWithResult(context context.Context, cmd *cobra.Command, uripath string, body interface{}) (result *request.Content, err error)

PostWithResult posts a resource and returns the raw result

func (Profile) Print

func (profile Profile) Print(context context.Context, cmd *cobra.Command, payload any) error

Print prints the given payload to the console

func (Profile) PrintCSV

func (profile Profile) PrintCSV(context context.Context, cmd *cobra.Command, payload any) error

PrintCSV prints the given payload to the console as CSV

func (Profile) PrintJSON

func (profile Profile) PrintJSON(context context.Context, cmd *cobra.Command, payload any) error

PrintJSON prints the given payload to the console as JSON

func (Profile) PrintTSV

func (profile Profile) PrintTSV(context context.Context, cmd *cobra.Command, payload any) error

PrintTSV prints the given payload to the console as TSV

func (Profile) PrintTable

func (profile Profile) PrintTable(context context.Context, cmd *cobra.Command, payload any) error

PrintTable prints the given payload to the console as a table

func (Profile) PrintYAML

func (profile Profile) PrintYAML(context context.Context, cmd *cobra.Command, payload any) error

PrintYAML prints the given payload to the console as YAML

func (*Profile) Put

func (profile *Profile) Put(context context.Context, cmd *cobra.Command, uripath string, body interface{}, response interface{}) (err error)

Put puts/updates a resource

func (Profile) Redact

func (profile Profile) Redact() any

Redact redacts sensitive information from the profile

implements logger.Redactable

func (Profile) SetCredentialInVault

func (profile Profile) SetCredentialInVault(service, username, password string) error

SetCredentialInVault stores the credential in the Windows Credential Manager or Linux/macOS keychain.

func (Profile) ShouldIgnoreErrors

func (profile Profile) ShouldIgnoreErrors(cmd *cobra.Command) bool

ShouldIgnoreErrors tells if the command should ignore errors

func (Profile) ShouldStopOnError

func (profile Profile) ShouldStopOnError(cmd *cobra.Command) bool

ShouldStopOnError tells if the command should stop on error

func (Profile) ShouldWarnOnError

func (profile Profile) ShouldWarnOnError(cmd *cobra.Command) bool

ShouldWarnOnError tells if the command should warn on error

func (Profile) String

func (profile Profile) String() string

String gets a string representation of this profile

implements fmt.Stringer

func (*Profile) UnmarshalJSON

func (profile *Profile) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals this profile from JSON

implements json.Unmarshaler

func (*Profile) Update

func (profile *Profile) Update(other Profile) error

Update updates this profile with the given one

func (*Profile) Upload

func (profile *Profile) Upload(context context.Context, cmd *cobra.Command, uripath, source string) (err error)

Upload uploads a resource from a source file

If the profile has its Progress flag set to true, it will show a progress bar. Otherwise, if the command has a flag --progress, it will show a progress bar.

func (*Profile) Validate

func (profile *Profile) Validate() error

Validate validates a Profile

Jump to

Keyboard shortcuts

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