libcfg

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProjectRoot

func FindProjectRoot() (string, error)

FindProjectRoot discovers the nearest parent directory that contains go.mod.

Types

type AuthHeader

type AuthHeader struct {
	Name   string
	Prefix string
}

AuthHeader describes one generated auth-token header.

func EffectiveAuthHeaders

func EffectiveAuthHeaders(mode AuthMode, headers []AuthHeader) ([]AuthHeader, error)

EffectiveAuthHeaders returns the validated auth headers used by token-based auth modes.

func NormalizeAuthHeaders

func NormalizeAuthHeaders(headers []AuthHeader) ([]AuthHeader, error)

NormalizeAuthHeaders validates and canonicalizes user-provided auth headers.

type AuthMode

type AuthMode uint8

AuthMode controls generated API auth wiring.

const (
	AuthModeUnknown AuthMode = iota
	AuthModeNone
	AuthModeServiceToken
	AuthModePerCallToken
)

func ParseAuthMode

func ParseAuthMode(raw string) (AuthMode, error)

ParseAuthMode parses user input into AuthMode.

func (AuthMode) IsValid

func (m AuthMode) IsValid() bool

IsValid reports whether auth mode is one of supported values.

func (AuthMode) MarshalJSON

func (m AuthMode) MarshalJSON() ([]byte, error)

MarshalJSON encodes auth mode as string.

func (AuthMode) MarshalText

func (m AuthMode) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (AuthMode) String

func (m AuthMode) String() string

String returns auth mode name.

func (*AuthMode) UnmarshalJSON

func (m *AuthMode) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes auth mode from string.

func (*AuthMode) UnmarshalText

func (m *AuthMode) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Config

type Config struct {
	RootDir     string
	ModulePath  string
	ProfileName string

	SpecPath  string
	APIOutDir string

	RawClientModels bool
	ModelsMode      Mode
	WrapperMode     Mode
	AuthMode        AuthMode
	AuthHeaders     []AuthHeader

	WrapperOutputPath string
	WrapperPackage    string

	AttachmentRedactedFields       []string
	AttachmentRedactionReplacement string
}

type DomainProfile

type DomainProfile struct {
	// Optional. If empty, registry key is used as domain.
	Domain   string
	SpecPath string

	// Optional overrides.
	APIOutDir         string
	WrapperOutputPath string
	WrapperPackage    string
	RawClientModels   bool
	ModelsMode        Mode
	AuthMode          AuthMode
	AuthHeaders       []AuthHeader

	AttachmentRedactedFields       []string
	AttachmentRedactionReplacement string
}

DomainProfile is a compact profile format: only domain + spec are required, the rest is derived by convention.

func NewDomainProfile

func NewDomainProfile(domain, specPath string) DomainProfile

NewDomainProfile creates compact domain profile with required domain and spec path.

func (DomainProfile) ToProfile

func (p DomainProfile) ToProfile() (Profile, error)

ToProfile converts compact profile to full profile using its own Domain field.

type Mode

type Mode uint8

Mode controls generation behavior for entity and wrapper artifacts.

const (
	ModeUnknown Mode = iota
	ModeSkip
	ModeInit
	ModeForce
)

func ParseMode

func ParseMode(raw string) (Mode, error)

ParseMode parses user input into Mode.

func (Mode) IsValid

func (m Mode) IsValid() bool

IsValid reports whether mode is one of supported values.

func (Mode) MarshalJSON

func (m Mode) MarshalJSON() ([]byte, error)

MarshalJSON encodes mode as string.

func (Mode) MarshalText

func (m Mode) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Mode) String

func (m Mode) String() string

String returns mode name.

func (*Mode) UnmarshalJSON

func (m *Mode) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes mode from string.

func (*Mode) UnmarshalText

func (m *Mode) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Profile

type Profile struct {
	// Paths are relative to project root.
	SpecPath  string
	APIOutDir string

	WrapperOutputPath string
	WrapperPackage    string
	RawClientModels   bool
	ModelsMode        Mode
	AuthMode          AuthMode
	AuthHeaders       []AuthHeader

	AttachmentRedactedFields       []string
	AttachmentRedactionReplacement string
}

type Registry

type Registry struct {
	DefaultProfile string
	Profiles       map[string]Profile
}

func BuildRegistryFromDomainProfiles

func BuildRegistryFromDomainProfiles(defaultProfile string, profiles map[string]DomainProfile) (Registry, error)

BuildRegistryFromDomainProfiles resolves compact profiles to full registry profiles.

func (Registry) AvailableProfiles

func (r Registry) AvailableProfiles() []string

AvailableProfiles returns known registry profiles in deterministic order.

func (Registry) Load

func (r Registry) Load(profileName string) (Config, error)

Load builds runtime config for a selected profile and resolves absolute paths.

Jump to

Keyboard shortcuts

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