Documentation
¶
Index ¶
- Variables
- type Content
- type DefaultProfile
- type DockerOptions
- type File
- func (f *File) AddProfile(profile Profile) error
- func (f *File) AddRoutes(name, ip string, hostnames []string) error
- func (f *File) Backup(dst string) (string, error)
- func (f *File) Close()
- func (f *File) Disable(profiles []string) error
- func (f *File) DisableAll() error
- func (f *File) Enable(profiles []string) error
- func (f *File) EnableAll() error
- func (f *File) EnableOnly(profiles []string) error
- func (f *File) Flush() error
- func (f *File) GetDisabled() []string
- func (f *File) GetEnabled() []string
- func (f *File) GetProfile(name string) (*Profile, error)
- func (f *File) GetProfileNames() []string
- func (f *File) GetStatus(profiles []string) map[string]ProfileStatus
- func (f *File) List(opts *ListOptions)
- func (f *File) MergeProfiles(content *Content)
- func (f *File) ProfileStatus(opts *ListOptions)
- func (f *File) RemoveProfile(name string) error
- func (f *File) RemoveProfiles(profiles []string) error
- func (f *File) RemoveRoutes(name string, routes []string) (bool, error)
- func (f *File) ReplaceProfile(p Profile) error
- func (f *File) Restore(from string) error
- func (f *File) Toggle(profiles []string) error
- func (f *File) WriteTo(src string) error
- type ListOptions
- type Profile
- func (p *Profile) AddRoute(ip, hostname string)
- func (p *Profile) AddRoutes(ip string, hostnames []string)
- func (p *Profile) GetAllHostNames() ([]string, error)
- func (p *Profile) GetHostNames(ip string) ([]string, error)
- func (p *Profile) GetStatus() string
- func (p *Profile) RemoveRoutes(hostnames []string)
- func (p *Profile) Render(w io.StringWriter) error
- func (p *Profile) String() string
- type ProfileStatus
- type Route
Constants ¶
This section is empty.
Variables ¶
var DefaultColumns = []string{"profile", "status", "ip", "domain"}
DefaultColumns is the list of default columns to use when showing table list
var DefaultProfileError = errors.New("'default' profile should not be handled by hostctl")
DefaultProfileError when trying to edit default content
var MissingDestError = errors.New("missing destination file")
MissingSourceError when trying to write to a file
var MissingDomainsError = errors.New("no domains provided")
MissingDomainsError when trying to set/add domains and none were given
var MissingProfileError = errors.New("missing profile name")
MissingProfileError when the profile is mandatory
var MissingSourceError = errors.New("missing source file")
MissingSourceError when trying to read from a file
var ProfilesOnlyColumns = []string{"profile", "status"}
ProfilesOnlyColumns are the columns used for profile status list
var UnknownProfileError = errors.New("unknown profile name")
UnknownProfileError when the profile is not present
Functions ¶
This section is empty.
Types ¶
type Content ¶ added in v1.0.0
type Content struct {
DefaultProfile DefaultProfile
ProfileNames []string
Profiles map[string]*Profile
}
type DefaultProfile ¶ added in v1.0.0
type DefaultProfile []*tableRow
func (DefaultProfile) Render ¶ added in v1.0.0
func (d DefaultProfile) Render(w io.StringWriter) error
type DockerOptions ¶ added in v0.7.0
type DockerOptions struct {
Domain string
Network string
ComposeFile string
ProjectName string
KeepPrefix bool
Cli *client.Client
}
DockerOptions contains parameters to sync with docker and docker-compose
type File ¶ added in v1.0.0
type File struct {
// contains filtered or unexported fields
}
func (*File) AddProfile ¶ added in v1.0.0
func (*File) Backup ¶ added in v1.0.0
BackupFile creates a copy of your hosts file to a new location with the date as extension
func (*File) Disable ¶ added in v1.0.0
Disable marks profiles as disable by commenting all hosts lines. The content remains on the file and can be enabled later.
func (*File) DisableAll ¶ added in v1.0.0
DisableAll marks all profiles as disable by commenting all hosts lines. The content remains on the file and can be enabled later.
func (*File) Enable ¶ added in v1.0.0
Enable marks profiles as enable by uncommenting all hosts lines making the routing work again.
func (*File) EnableAll ¶ added in v1.0.0
EnableAll marks all profiles as enable by uncommenting all hosts lines making the routing work again.
func (*File) EnableOnly ¶ added in v1.0.0
EnableOnly marks profiles as enable and disable all other profiles
func (*File) GetDisabled ¶ added in v1.0.0
func (*File) GetEnabled ¶ added in v1.0.0
func (*File) GetProfileNames ¶ added in v1.0.0
func (*File) GetStatus ¶ added in v1.0.0
func (f *File) GetStatus(profiles []string) map[string]ProfileStatus
func (*File) List ¶ added in v1.0.0
func (f *File) List(opts *ListOptions)
List shows a table with profile names status and routing information
func (*File) MergeProfiles ¶ added in v1.0.0
func (*File) ProfileStatus ¶ added in v1.0.0
func (f *File) ProfileStatus(opts *ListOptions)
ProfileStatus shows a table only with profile names status
func (*File) RemoveProfile ¶ added in v1.0.0
func (*File) RemoveProfiles ¶ added in v1.0.0
func (*File) RemoveRoutes ¶ added in v1.0.0
func (*File) ReplaceProfile ¶ added in v1.0.0
func (*File) Restore ¶ added in v1.0.0
Restore overwrite content of a hosts file with the content of a backup.
type ListOptions ¶
type ListOptions struct {
Profiles []string
RawTable bool
Columns []string
ProfilesOnly bool
StatusFilter ProfileStatus
Writer io.Writer
}
ListOptions contains available options for listing.
type Profile ¶ added in v1.0.0
type Profile struct {
Name string
Status ProfileStatus
IPList []string
Routes map[string]*Route
}
func NewProfileFromDocker ¶ added in v1.0.0
func NewProfileFromDocker(ctx context.Context, opts *DockerOptions) (*Profile, error)
func NewProfileFromReader ¶ added in v1.0.0
func (*Profile) GetAllHostNames ¶ added in v1.0.0
func (*Profile) GetHostNames ¶ added in v1.0.0
func (*Profile) RemoveRoutes ¶ added in v1.0.0
type ProfileStatus ¶ added in v0.9.1
type ProfileStatus string
const ( // Enabled marks a profile active on your hosts file. Enabled ProfileStatus = "on" // Disabled marks a profile not active on your hosts file. Disabled ProfileStatus = "off" )