cli

package
v0.0.0-...-7ae124b Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath       = "config.yaml"
	DefaultDaemonOIDCClient = "dns3ld"
	DefaultTimeout          = 60 * time.Second
	DefaultClaimTimeout     = 10 * time.Minute
)
View Source
const (
	DefaultOIDCClientID = "dns3l-api-pub"
)
View Source
const ImplementedAPIVersion = "1.3.0"

ImplementedAPIVersion is the OpenAPI specification version implemented by dns3lcli.

Variables

This section is empty.

Functions

func CertificateMatchesKey

func CertificateMatchesKey(certPEM, keyPEM []byte) (bool, error)

func DecodeJSON

func DecodeJSON[T any](body []byte) (T, error)

func Execute

func Execute() error

func NewRootCommand

func NewRootCommand(out, errOut io.Writer) *cobra.Command

func PrintCA

func PrintCA(out io.Writer, ca apiv1.CAInfo, color bool) error

func PrintCAs

func PrintCAs(out io.Writer, cas []apiv1.CAInfo, color bool) error

func PrintCert

func PrintCert(out io.Writer, cert apiv1.CertInfoWithCA, color, noca bool) error

func PrintCertResources

func PrintCertResources(out io.Writer, resources apiv1.CertResources, check bool, color bool) error

func PrintCerts

func PrintCerts(out io.Writer, footerStr string, certs []apiv1.CertInfoWithCA, color, noca bool) error

func PrintDNSHandlers

func PrintDNSHandlers(out io.Writer, handlers []apiv1.DNSHandlerInfo, color bool) error

func PrintDNSRootzones

func PrintDNSRootzones(out io.Writer, rootzones []apiv1.DNSRootzoneInfo, _ bool) error

func PrintGenericJSON

func PrintGenericJSON(out io.Writer, body []byte, color bool) error

func PrintInfo

func PrintInfo(out io.Writer, info apiv1.ServerInfo, color bool) error

func SupportsColor

func SupportsColor(file *os.File) bool

func ValidatePEM

func ValidatePEM(data []byte) error

func WriteJSON

func WriteJSON(out io.Writer, body []byte) error

func WritePEMDirectory

func WritePEMDirectory(dir string, resources apiv1.CertResources, check bool) error

func WritePEMFile

func WritePEMFile(path string, data []byte, check bool) error

Types

type ChangedFlags

type ChangedFlags map[string]bool

type Client

type Client struct {
	Config       *RuntimeConfig
	HTTPClient   *http.Client
	TokenFetcher *TokenFetcher
}

func NewClient

func NewClient(cfg *RuntimeConfig) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, query url.Values, body any) (*Response, error)

type CommandFactory

type CommandFactory struct {
	Out    io.Writer
	ErrOut io.Writer
	Client func(*RuntimeConfig) *Client
	// contains filtered or unexported fields
}

type FlagOptions

type FlagOptions struct {
	ConfigPath         string
	Server             string
	ADUser             string
	ADPassword         string
	OIDCClientID       string
	OIDCClientSecret   string
	OIDCDaemonClientID string
	Token              string
	APIKey             string
	NoAuth             bool
	JSON               bool
	Debug              bool
	Trace              bool
	Timeout            time.Duration
	TimeoutClaim       time.Duration
	HiddenPaging       uint64
}

type HTTPError

type HTTPError struct {
	StatusCode int
	Message    string
	Body       string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type PagedJSON

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

func (*PagedJSON) Add

func (pj *PagedJSON) Add(body []byte) (uint64, error)

func (*PagedJSON) WriteJSON

func (pj *PagedJSON) WriteJSON(out io.Writer) error

type PaginationInfo

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

func PaginationInfoFromHeaders

func PaginationInfoFromHeaders(header http.Header) *PaginationInfo

func (*PaginationInfo) String

func (p *PaginationInfo) String() string

type Paginator

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

func NewPaginator

func NewPaginator(hidden uint64) *Paginator

func (*Paginator) Page

func (h *Paginator) Page(olimit, ooffset uint64,
	pg func(limit, offset uint64) (*PaginationInfo, uint64, error),
) (*PaginationInfo, uint64, error)

type Response

type Response struct {
	StatusCode  int
	ContentType string
	Headers     http.Header
	Body        []byte
}

type RuntimeConfig

type RuntimeConfig struct {
	Server             string
	ADUser             string
	ADPassword         string
	OIDCClientID       string
	OIDCClientSecret   string
	OIDCDaemonClientID string
	Token              string
	APIKey             string
	NoAuth             bool
	JSON               bool
	Debug              bool
	Trace              bool
	Timeout            time.Duration
	TimeoutClaim       time.Duration
	HiddenPaging       uint64

	APIBaseURL string
	AuthURL    string
}

func ResolveConfig

func ResolveConfig(opts FlagOptions, changed ChangedFlags, requireAuth bool) (*RuntimeConfig, error)

type TokenFetcher

type TokenFetcher struct {
	Client *http.Client
}

func (*TokenFetcher) Fetch

func (f *TokenFetcher) Fetch(ctx context.Context, cfg *RuntimeConfig) (string, error)

Jump to

Keyboard shortcuts

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