diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..d443901 --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,41 @@ +name: github pages + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + ref: docs + with: + submodules: true + + - name: Get contributors + uses: actions/checkout@v2 + run: | + git checkout master -- .all-contributorsrc + cp .all-contributorsrc docs/data/contributors.json + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.68.3' + extended: true + + - name: Build + run: | + cd docs + hugo --minify --enableGitInfo + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/public + force_orphan: true + enable_jekyll: true + publish_branch: gh-pages diff --git a/.gitignore b/.gitignore index e14d466..46347de 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ dist hostctl hostctl.exe -homebrew-tap +.etchosts +docs/public diff --git a/README.md b/README.md index f7c62b9..86a4fb1 100644 --- a/README.md +++ b/README.md @@ -17,86 +17,6 @@ This tool gives you more control over the use of your `hosts` file. You can have It is a tedious task to handle the `hosts` file by editing manually. With this tool you can automate some aspects to do it cleaner and quick. -## Table of content -
-expand - - - - - -- [Sample Usage](#sample-usage) -- [Installation](#installation) - - [Pre-built binary](#pre-built-binary) - - [Arch Linux](#arch-linux) - - [HomeBrew](#homebrew) - - [Snap](#snap) - - [Scoop](#scoop) -- [Features](#features) -- [Linux/Mac/Windows and permissions](#linuxmacwindows-and-permissions) -- [Usage](#usage) - - [List profiles](#list-profiles) - - [Add new profile from a file](#add-new-profile-from-a-file) - - [Add new profile from cli](#add-new-profile-from-cli) - - [Enable/Disable profile](#enabledisable-profile) - - [Remove a profile](#remove-a-profile) - - [Backup hosts file](#backup-hosts-file) - - [Restore a hosts file](#restore-a-hosts-file) - - [TODO](#todo) - - [References](#references) -- [Contributing](#contributing) -- [Contributors ✨](#contributors-) -- [LICENSE](#license) -- [Author(s)](#authors) - - -
- - -## Sample Usage -![sample usage](docs/hostctl.gif) - - -## Installation - -### Pre-built binary - -Go to [release page](https://github.com/guumaster/hostctl/releases) and download the binary you need. - - -### Arch Linux - -`hostctl` has an AUR package: . -You can install it using your [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers) of choice. - -Example: -```bash -yay -Sy hostctl -``` - - -### HomeBrew - -`brew install guumaster/tap/hostctl` - - -### Snap - -**WARNING**: Still working out a permission issue * [ hostctl snap - store-requests](https://forum.snapcraft.io/t/plugs-system-files-for-hostctl-snap/16199/5) - -`[sudo] snap install hostctl` - - -### Scoop - -``` -scoop bucket add hostctl https://github.com/guumaster/hostctl.git -scoop install hostctl -``` - -*NOTE*: If you also installed `sudo` with Scoop, you can run the examples below with `sudo` instead of starting your terminal as administrator. - - ## Features @@ -106,212 +26,34 @@ scoop install hostctl * add profiles directly from a `.etchosts` file that you can add to your vcs. -## Linux/Mac/Windows and permissions +## Documentation -The tool recognize your system and use the right hosts file, it will use `/etc/hosts` on Linux/Mac and `C:/Windows/System32/Drivers/etc/hosts` on Windows. +Read the [Getting started guide](http://guumaster.github.io/hostctl/getting-started) +or check full documentation [here](http://guumaster.github.io/hostctl). -**SUDO/ADMIN**: You will need permissions for any action that modify hosts file, add `sudo` to the commands below when needed. If you are on windows, make sure you run it as administrator. -**WARNING**: it should work on any system. It's tested on Ubuntu and Windows 10. If you can confirm it works on other system, please let me know [here](https://github.com/guumaster/hostctl/issues/new). - - - -## Usage - -``` - _ _ _____ _______ _______ _______ _______ - |_____| | | |______ | | | | - | | |_____| ______| | |_____ | |_____ - -hostctl is a CLI tool to manage your hosts file with ease. -You can have multiple profiles, enable/disable exactly what -you need each time with a simple interface. - -Usage: - hostctl [command] - -Available Commands: - add Add content to a profile in your hosts file. - backup Creates a backup copy of your hosts file - disable Disable a profile from your hosts file. - enable Enable a profile on your hosts file. - help Help about any command - list Shows a detailed list of profiles on your hosts file. - remove Remove a profile from your hosts file. - restore Restore hosts file content from a backup file. - set Set content to a profile in your hosts file. - -Flags: - -h, --help help for hostctl - --host-file string Hosts file path (default "/etc/hosts") - -p, --profile string Choose a profile - -Use "hostctl [command] --help" for more information about a command. -``` - -### List profiles - -`$> hostctl list` - -``` -// Output: -+---------+--------+----------------+----------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+----------------+----------------------------+ -| default | on | 127.0.0.1 | localhost | -| default | on | 127.0.1.1 | some-existing.local | -| default | on | ::1 | ip6-localhost | -+---------+--------+----------------+----------------------------+ -| lite | on | 192.168.1.51 | jupyter.toolkit-lite.local | -+---------+--------+----------------+----------------------------+ -| toolkit | on | 192.168.99.119 | app.toolkit.local | -| toolkit | on | 192.168.99.119 | gitea.toolkit.local | -| toolkit | on | 192.168.99.119 | jupyter.toolkit.local | -+---------+--------+----------------+----------------------------+ -``` - -### Add new profile from a file - -You can store routing as a separate file and add it to the global hosts file when you need. - -Say you have this routing file on any of your projects: - -``` -# File stored in /path/to/some/project/.etchosts -127.0.0.1 web.my-awesome-project.local -127.0.0.1 api.my-awesome-project.local -``` - -You can add that content as a profile with this command: - -`$>hostctl set -p awesome --from /path/to/some/project/.etchosts ` - -``` -// Output: -+---------+--------+----------------+------------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+----------------+------------------------------+ -| default | on | 127.0.0.1 | localhost | -| default | on | 127.0.1.1 | some-existing.local | -| default | on | ::1 | ip6-localhost | -+---------+--------+----------------+------------------------------+ -| another | on | 192.168.1.51 | jupyter.toolkit-lite.local | -+---------+--------+----------------+------------------------------+ -| awesome | on | 127.0.0.1 | web.my-awesome-project.local | -| awesome | on | 127.0.0.1 | api.my-awesome-project.local | -+---------+--------+----------------+------------------------------+ -``` - -### Add new profile from cli - -You can add a new profile or add new domain to a specific profile directly from the cli: - -You can add that content as a profile with this command: - -`$>hostctl -p test add domains test.com --ip 123.123.123.123 ` - -``` -// Output: -+---------+--------+-----------------+------------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+-----------------+------------------------------+ -| default | on | 127.0.0.1 | localhost | -| default | on | 127.0.1.1 | some-existing.local | -| default | on | ::1 | ip6-localhost | -+---------+--------+-----------------+------------------------------+ -| another | on | 192.168.1.51 | jupyter.toolkit-lite.local | -+---------+--------+-----------------+------------------------------+ -| test | on | 123.123.123.123 | test.com | -+---------+--------+-----------------+------------------------------+ -``` - -### Enable/Disable profile - -You can enable/disable any profile, the routing will react to it state. -Disabling a profile does not remove the content from the hosts file, this way you can re-enable it later on. - -`$> hostctl disable -p awesome` -``` -// Output: -+---------+--------+----------------+------------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+----------------+------------------------------+ -... -+---------+--------+----------------+------------------------------+ -| awesome | off | 127.0.0.1 | web.my-awesome-project.local | -| awesome | off | 127.0.0.1 | api.my-awesome-project.local | -+---------+--------+----------------+------------------------------+ -``` - -`$> hostctl enable -p awesome` -``` -// Output: -+---------+--------+----------------+------------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+----------------+------------------------------+ -... -+---------+--------+----------------+------------------------------+ -| awesome | on | 127.0.0.1 | web.my-awesome-project.local | -| awesome | on | 127.0.0.1 | api.my-awesome-project.local | -+---------+--------+----------------+------------------------------+ -``` - -### Remove a profile - -If you want to completely remove a profile from the hosts file you can run: - -`$> hostctl remove -p awesome` - -``` -// Output: -+---------+--------+----------------+------------------------------+ -| PROFILE | STATUS | IP | DOMAIN | -+---------+--------+----------------+------------------------------+ -| default | on | 127.0.0.1 | localhost | -| default | on | 127.0.1.1 | some-existing.local | -| default | on | ::1 | ip6-localhost | -+---------+--------+----------------+------------------------------+ -| another | off | 192.168.1.51 | jupyter.toolkit-lite.local | -+---------+--------+----------------+------------------------------+ -``` - -### Backup hosts file - -You can save a copy of your hosts file with this command: - -`hostctl backup --path /tmp/` - -It would create a file `/tmp/hosts.20200314` with the content of your hosts file. +## Sample Usage +![sample usage](docs/hostctl.gif) -### Restore a hosts file +## Installation -You can restore a previous backup of your hosts file with this command: - -`hostctl restore --from /tmp/hosts.20200314` +Go to [release page](https://github.com/guumaster/hostctl/releases) and download the binary you need. -It would **overwrite** your hosts file with the content of your backup. +Or read how to install on your system [here](http://guumaster.github.io/hostctl/installation/) -### References +## Linux/Mac/Windows and permissions -* Dependencies: - * [spf13/cobra](https://github.com/spf13/cobra) - * [guumaster/tablewriter](https://github.com/guumaster/tablewriter) +The tool recognize your system and use the right hosts file, it will use `/etc/hosts` on Linux/Mac and `C:/Windows/System32/Drivers/etc/hosts` on Windows. -* Inspiration: - * [txn2/txeh: CLI for /etc/hosts management](https://github.com/txn2/txeh) +**SUDO/ADMIN**: You will need permissions for any action that modify hosts file, add `sudo` to the commands below when needed. If you are on windows, make sure you run it as administrator. +**WARNING**: it should work on any system. It's tested on Ubuntu and Windows 10. If you can confirm it works on other system, please let me know [here](https://github.com/guumaster/hostctl/issues/new). ## Contributing Be sure to read [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md). - -Pull requests are welcome. - -For major changes, please open an issue first to discuss what you would like to change. - -Please make sure to update tests if your code affects existing tests. ## Contributors ✨ @@ -338,14 +80,15 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! -## LICENSE +## Author(s) - [MIT license](LICENSE) +* [guumaster](https://github.com/guumaster) -## Author(s) +## LICENSE + + [MIT license](LICENSE) -* [guumaster](https://github.com/guumaster) diff --git a/go.mod b/go.mod index 951906a..919ef34 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/guumaster/hostctl go 1.14 require ( - github.com/guumaster/tablewriter v0.0.4-separator - github.com/mattn/go-runewidth v0.0.8 // indirect - github.com/spf13/cobra v0.0.6 + github.com/guumaster/tablewriter v0.0.6 + github.com/spf13/cobra v0.0.7 ) diff --git a/go.sum b/go.sum index a564bc0..59036b8 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,4 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -15,11 +14,9 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -39,9 +36,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/guumaster/tablewriter v0.0.4-separator h1:5RdZdX8ZiAnuGZY9OZ6rQdBJ6tS+Rkh3xED1/kvnPc8= -github.com/guumaster/tablewriter v0.0.4-separator/go.mod h1:9B1xy1BLPtcVAeYjC1EXPxcklqnzk7dU2c3ywGbUnKY= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/guumaster/tablewriter v0.0.6 h1:s2n2YeOJn8dmH9RvrHPwxVOrZjPdwzWJhT5tzJJqnUk= +github.com/guumaster/tablewriter v0.0.6/go.mod h1:9B1xy1BLPtcVAeYjC1EXPxcklqnzk7dU2c3ywGbUnKY= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -51,27 +47,19 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0= -github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -88,19 +76,15 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= -github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/cobra v0.0.7 h1:FfTH+vuMXOas8jmfb5/M7dzEYx7LpcLb7a0LPe34uOU= +github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -127,9 +111,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -141,7 +123,6 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/pkg/host/add.go b/pkg/host/add.go index 98b7d4c..eda8ff8 100644 --- a/pkg/host/add.go +++ b/pkg/host/add.go @@ -1,6 +1,7 @@ package host import ( + "fmt" "os" ) @@ -34,7 +35,10 @@ func AddFromFile(opts *AddFromFileOptions) error { if opts.From == "" { return MissingSourceError } - newData, _ := ReadHostFileStrict(opts.From) + newData, err := ReadHostFileStrict(opts.From) + if err != nil { + return fmt.Errorf("ERROR READING FILE: %w", err) + } return add(newData, &commonAddOptions{ opts.Dst,