confutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package confutil contains utility types and functions which help with configuration loading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertPool

type CertPool x509.CertPool

CertPool is a set of X.509 certificates.

func (*CertPool) UnmarshalJSON

func (p *CertPool) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals CertPool from a JSON array of encoded Certificates.

type Certificate

type Certificate x509.Certificate

Certificate is a single X.509 certificate.

func (*Certificate) UnmarshalJSON

func (c *Certificate) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals Certificate from a JSON string containing the PEM-encoding of the X.509 certificate.

type Date

type Date struct {
	time.Time
}

Date is a time.Time which is represented as ISO date (yyyy-mm-dd) in JSON representations.

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate parses Date from a string value.

func (Date) At

func (d Date) At(hh, mm, ss int) Date

At returns a new date value with the same date, but time set to 'hh:mm:ss' in local TZ.

func (Date) AtEndOfDay

func (d Date) AtEndOfDay() Date

AtEndOfDay if date represents zero time, returns it's value, otherwise returns the date value at time '23:59:59' in local TZ.

func (Date) Equal

func (d Date) Equal(other interface{}) bool

Equal checks if the d is equal with a given Date or time.Time.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Date to string.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals Date from a JSON string.

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a time.Time which is represented as ISO datetime (yyyy-mm-ddTHH:MM:SSZ07:00) in JSON representations. It is needed as a wrapper around time.Time to marshal the zero time as an empty string.

func ParseDateTime

func ParseDateTime(s string) (DateTime, error)

ParseDateTime parses DateTime from a string value.

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals the DateTime to string.

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals DateTime from a JSON string.

type Duration

type Duration struct {
	time.Duration
}

Duration is a time.Time which is represented as ISO date (yyyy-mm-dd) in JSON representations.

func ParseDuration

func ParseDuration(s string) (Duration, error)

ParseDuration parses Duration from a string value.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Duration to string.

func (*Duration) Or

func (d *Duration) Or(def time.Duration) time.Duration

Or returns the time.Duration represented by d or def if s is zero.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals Duration from a JSON string.

type Seconds

type Seconds time.Duration

Seconds is a time.Duration which is represented in configuration files as a whole number of seconds.

func (*Seconds) Or

func (s *Seconds) Or(def time.Duration) time.Duration

Or returns the time.Duration represented by s or def if s is zero.

func (Seconds) String

func (s Seconds) String() string

String returns the duration formatted as a string.

func (*Seconds) UnmarshalJSON

func (s *Seconds) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals Seconds from a JSON number.

type TLS

type TLS tls.Certificate

TLS is a TLS certificate chain and private key.

func (*TLS) UnmarshalJSON

func (t *TLS) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals TLS from a {"chain": "string", "key": "string"} JSON object where

  • "chain" contains the concatenated PEM-encodings of X.509 certificates (leaf certificate first) and

  • "key" the PEM-encoding of the PKCS #8 private key for the leaf.

type Time

type Time struct {
	time.Time
}

Time is a time.Time which is represented as clock (HH:MM) in JSON representations.

func ParseTime

func ParseTime(s string) (Time, error)

ParseTime parses Time from a string value.

func (Time) MarshalJSON

func (d Time) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Time to string.

func (*Time) UnmarshalJSON

func (d *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals Time from a JSON string.

type URL

type URL struct {
	Raw string
	URL *url.URL
}

URL is an absolute URL. It has the original string and a parsed structure.

func (*URL) String

func (u *URL) String() string

String returns the raw original URL string.

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals URL from a JSON string. The URL must be absolute.

Jump to

Keyboard shortcuts

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