Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides configuration management for gitcode-cli

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeTrustedHost

func NormalizeTrustedHost(host string) (string, error)

NormalizeTrustedHost validates and normalizes a GitCode hostname.

func SecureWriteFile added in v0.10.0

func SecureWriteFile(path string, data []byte, perm os.FileMode) error

SecureWriteFile is the exported hardened-write helper for sibling packages (e.g. pkg/larkcli) that persist credential-adjacent state under the gc config directory. It delegates to the platform-specific secureWriteFile so that symlink redirection and permission hardening stay consistent across the codebase.

Types

type AuthConfig

type AuthConfig interface {
	// ActiveToken returns the active token for a host
	ActiveToken(hostname string) (string, string)
	// StoredToken returns the stored token for a host without environment overrides
	StoredToken(hostname string) (string, string)
	// HasActiveToken checks if a token exists for a host
	HasActiveToken(hostname string) bool
	// ActiveUser returns the active user for a host
	ActiveUser(hostname string) (string, error)
	// Hosts returns all configured hosts
	Hosts() []string
	// DefaultHost returns the default host
	DefaultHost() (string, string)
	// Login creates or updates authentication for a host
	Login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error)
	// Logout removes authentication for a host
	Logout(hostname, username string) error
	// SwitchUser switches the active user for a host
	SwitchUser(hostname, user string) error
}

AuthConfig interface defines authentication operations

type Config

type Config interface {
	// Get retrieves a configuration value
	Get(host, key string) (string, error)
	// Set stores a configuration value
	Set(host, key, value string) error

	// GitProtocol returns the preferred git protocol
	GitProtocol(host string) ConfigEntry
	// Editor returns the preferred editor
	Editor(host string) ConfigEntry
	// Browser returns the preferred browser
	Browser(host string) ConfigEntry
	// Pager returns the preferred pager
	Pager(host string) ConfigEntry

	// Authentication returns authentication configuration
	Authentication() AuthConfig

	// Write persists the configuration
	Write() error
}

Config interface defines configuration operations

func New

func New() Config

New creates a new Config

type ConfigEntry

type ConfigEntry struct {
	Value  string
	Source string // "environment", "config", "default"
}

ConfigEntry represents a configuration value with its source

Source Files

  • auth_config.go
  • config.go
  • securewrite_export.go
  • securewrite_unix.go

Jump to

Keyboard shortcuts

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