Documentation
¶
Index ¶
- Variables
- func AddFromArgs(opts *AddFromArgsOptions) error
- func AddFromDocker(ctx context.Context, opts *AddFromDockerOptions) error
- func AddFromFile(opts *AddFromFileOptions) error
- func AddFromReader(reader io.Reader, opts *AddFromFileOptions) error
- func BackupFile(src, dstPath string) (string, error)
- func Disable(dst, profile string) error
- func Enable(dst, profile string) error
- func EnableLine(line string) string
- func EnableOnly(dst, profile string) error
- func IsDisabled(line string) bool
- func IsHostLine(line string) bool
- func ListProfiles(src string, opts *ListOptions) error
- func Read(r io.Reader, strict bool) (*hostFile, error)
- func ReadFromArgs(domains []string, ip string) *hostFile
- func ReadHostFile(file string) (*hostFile, error)
- func ReadHostFileStrict(file string) (*hostFile, error)
- func RemoveDomains(dst, profile string, domains []string) error
- func RemoveProfile(dst, profile string) error
- func RestoreFile(src, dst string) error
- func Toggle(dst, profile string) error
- func WriteToFile(f *os.File, h *hostFile) error
- type AddFromArgsOptions
- type AddFromDockerOptions
- type AddFromFileOptions
- type DockerOptions
- type ListOptions
- type ProfileStatus
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 ¶
func AddFromArgs ¶ added in v0.4.0
func AddFromArgs(opts *AddFromArgsOptions) error
func AddFromDocker ¶ added in v0.7.0
func AddFromDocker(ctx context.Context, opts *AddFromDockerOptions) error
func AddFromFile ¶
func AddFromFile(opts *AddFromFileOptions) error
AddFromFile reads content from a file and adds it as a profile into your hosts file. If you pass reset=true it will delete all previous content of the profile.
func AddFromReader ¶ added in v0.6.0
func AddFromReader(reader io.Reader, opts *AddFromFileOptions) error
func BackupFile ¶
BackupFile creates a copy of your hosts file to a new location with the date as extension
func Disable ¶
Disable marks a profile as disable by commenting all hosts lines. The content remains on the file and can be enabled later.
func Enable ¶
Enable marks a profile as enable by uncommenting all hosts lines making the routing work again.
func EnableLine ¶
EnableLine removes the # comment marker of the line.
func EnableOnly ¶ added in v0.8.0
EnableOnly marks a profile as enable and disable all other profiles
func IsDisabled ¶
IsDisabled check if a line starts with a # comment marker.
func IsHostLine ¶
IsHostLine checks if a line is a host line or a comment line.
func ListProfiles ¶
func ListProfiles(src string, opts *ListOptions) error
ListProfiles shows a table with profile names status and routing information
func Read ¶
Read returns hosts file content grouped by profiles. If you pass strict=true it would remove all comments.
func ReadFromArgs ¶ added in v0.4.0
ReadFromArgs read arguments into a hostFile struct
func ReadHostFile ¶
ReadHostFile open a file an read content into a hostFile struct
func ReadHostFileStrict ¶
ReadHostFileStrict open a file an read content into a hostFile struct. removes all comments.
func RemoveDomains ¶ added in v0.5.2
RemoveDomains removes domains from a hosts file.
func RemoveProfile ¶ added in v0.5.2
RemoveProfile removes a profile from a hosts file.
func RestoreFile ¶
RestoreFile overwrite content of a hosts file with the content of a backup.
func WriteToFile ¶
WriteToFile write hosts content to file
Types ¶
type AddFromArgsOptions ¶ added in v0.4.0
AddFromArgsOptions contains available options for adding from arguments.
type AddFromDockerOptions ¶ added in v0.7.0
type AddFromDockerOptions struct {
Dst string
Domain string
Profile string
Watch bool
Docker *DockerOptions
}
AddFromFileOptions contains available options for adding from file.
type AddFromFileOptions ¶ added in v0.4.0
AddFromFileOptions contains available options for adding from file.
type DockerOptions ¶ added in v0.7.0
DockerOptions contains parameters to sync with docker and docker-compose
type ListOptions ¶
type ListOptions struct {
Profile string
RawTable bool
Columns []string
ProfilesOnly bool
StatusFilter ProfileStatus
}
ListOptions contains available options for listing.
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" )