From cc45a0fbb9b1575adfda222c8fe55862debddeed Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 30 Jul 2020 00:21:38 +0200 Subject: [PATCH 1/5] Fix binary name when using `go get` and fix homebrew release procedure. Fixes: https://github.com/humio/cli/issues/27 Fixes: https://github.com/humio/cli/issues/30 --- .github/workflows/release.yml | 3 +- .goreleaser.yaml | 28 ++- CHANGELOG.md | 1 + CHANGES | 175 ------------------ Dockerfile | 5 - Makefile | 19 +- README.md | 9 + VERSION | 1 - cmd/{ => humioctl}/alerts.go | 2 +- cmd/{ => humioctl}/alerts_export.go | 2 +- cmd/{ => humioctl}/alerts_install.go | 2 +- cmd/{ => humioctl}/alerts_list.go | 2 +- cmd/{ => humioctl}/alerts_remove.go | 2 +- cmd/{ => humioctl}/cluster.go | 2 +- cmd/{ => humioctl}/cluster_nodes.go | 2 +- cmd/{ => humioctl}/cluster_nodes_list.go | 2 +- cmd/{ => humioctl}/cluster_nodes_show.go | 2 +- .../cluster_nodes_unregister.go | 2 +- cmd/{ => humioctl}/cluster_show.go | 2 +- cmd/{ => humioctl}/completion.go | 2 +- cmd/{ => humioctl}/health.go | 2 +- cmd/{ => humioctl}/ingest.go | 2 +- cmd/{ => humioctl}/ingest_tokens.go | 2 +- cmd/{ => humioctl}/ingest_tokens_add.go | 2 +- cmd/{ => humioctl}/ingest_tokens_list.go | 2 +- cmd/{ => humioctl}/ingest_tokens_remove.go | 2 +- cmd/{ => humioctl}/ingest_tokens_show.go | 2 +- cmd/{ => humioctl}/ingest_tokens_update.go | 2 +- cmd/{ => humioctl}/license.go | 2 +- cmd/{ => humioctl}/license_install.go | 2 +- cmd/{ => humioctl}/license_show.go | 2 +- cmd/{ => humioctl}/notifiers.go | 2 +- cmd/{ => humioctl}/notifiers_export.go | 2 +- cmd/{ => humioctl}/notifiers_install.go | 2 +- cmd/{ => humioctl}/notifiers_list.go | 2 +- cmd/{ => humioctl}/notifiers_remove.go | 2 +- cmd/{ => humioctl}/notifiers_show.go | 2 +- cmd/{ => humioctl}/output.go | 2 +- cmd/{ => humioctl}/parsers.go | 2 +- cmd/{ => humioctl}/parsers_export.go | 2 +- cmd/{ => humioctl}/parsers_install.go | 2 +- cmd/{ => humioctl}/parsers_list.go | 2 +- cmd/{ => humioctl}/parsers_remove.go | 2 +- cmd/{ => humioctl}/profiles.go | 2 +- cmd/{ => humioctl}/profiles_add.go | 2 +- cmd/{ => humioctl}/profiles_remove.go | 2 +- cmd/{ => humioctl}/profiles_set_default.go | 2 +- cmd/{ => humioctl}/repos.go | 2 +- cmd/{ => humioctl}/repos_create.go | 2 +- cmd/{ => humioctl}/repos_delete.go | 2 +- cmd/{ => humioctl}/repos_list.go | 2 +- cmd/{ => humioctl}/repos_show.go | 2 +- cmd/{ => humioctl}/repos_update.go | 2 +- cmd/{ => humioctl}/root.go | 21 +-- cmd/{ => humioctl}/search.go | 2 +- cmd/{ => humioctl}/status.go | 2 +- cmd/{ => humioctl}/users.go | 2 +- cmd/{ => humioctl}/users_add.go | 2 +- cmd/{ => humioctl}/users_list.go | 2 +- cmd/{ => humioctl}/users_remove.go | 2 +- cmd/{ => humioctl}/users_show.go | 2 +- cmd/{ => humioctl}/users_update.go | 2 +- cmd/{ => humioctl}/util.go | 27 +-- cmd/{ => humioctl}/version.go | 2 +- cmd/{ => humioctl}/views.go | 2 +- cmd/{ => humioctl}/views_list.go | 2 +- cmd/{ => humioctl}/views_show.go | 2 +- cmd/{ => humioctl}/welcome.go | 2 +- main.go | 28 --- main_test.go | 4 - scripts/bump_version.sh | 49 ----- scripts/dist.sh | 13 -- 72 files changed, 113 insertions(+), 386 deletions(-) delete mode 100644 CHANGES delete mode 100644 Dockerfile delete mode 100644 VERSION rename cmd/{ => humioctl}/alerts.go (98%) rename cmd/{ => humioctl}/alerts_export.go (99%) rename cmd/{ => humioctl}/alerts_install.go (99%) rename cmd/{ => humioctl}/alerts_list.go (99%) rename cmd/{ => humioctl}/alerts_remove.go (98%) rename cmd/{ => humioctl}/cluster.go (98%) rename cmd/{ => humioctl}/cluster_nodes.go (98%) rename cmd/{ => humioctl}/cluster_nodes_list.go (99%) rename cmd/{ => humioctl}/cluster_nodes_show.go (99%) rename cmd/{ => humioctl}/cluster_nodes_unregister.go (98%) rename cmd/{ => humioctl}/cluster_show.go (99%) rename cmd/{ => humioctl}/completion.go (99%) rename cmd/{ => humioctl}/health.go (99%) rename cmd/{ => humioctl}/ingest.go (99%) rename cmd/{ => humioctl}/ingest_tokens.go (98%) rename cmd/{ => humioctl}/ingest_tokens_add.go (99%) rename cmd/{ => humioctl}/ingest_tokens_list.go (99%) rename cmd/{ => humioctl}/ingest_tokens_remove.go (99%) rename cmd/{ => humioctl}/ingest_tokens_show.go (99%) rename cmd/{ => humioctl}/ingest_tokens_update.go (99%) rename cmd/{ => humioctl}/license.go (99%) rename cmd/{ => humioctl}/license_install.go (99%) rename cmd/{ => humioctl}/license_show.go (98%) rename cmd/{ => humioctl}/notifiers.go (98%) rename cmd/{ => humioctl}/notifiers_export.go (99%) rename cmd/{ => humioctl}/notifiers_install.go (99%) rename cmd/{ => humioctl}/notifiers_list.go (99%) rename cmd/{ => humioctl}/notifiers_remove.go (98%) rename cmd/{ => humioctl}/notifiers_show.go (99%) rename cmd/{ => humioctl}/output.go (98%) rename cmd/{ => humioctl}/parsers.go (98%) rename cmd/{ => humioctl}/parsers_export.go (99%) rename cmd/{ => humioctl}/parsers_install.go (99%) rename cmd/{ => humioctl}/parsers_list.go (99%) rename cmd/{ => humioctl}/parsers_remove.go (98%) rename cmd/{ => humioctl}/profiles.go (99%) rename cmd/{ => humioctl}/profiles_add.go (99%) rename cmd/{ => humioctl}/profiles_remove.go (98%) rename cmd/{ => humioctl}/profiles_set_default.go (99%) rename cmd/{ => humioctl}/repos.go (99%) rename cmd/{ => humioctl}/repos_create.go (98%) rename cmd/{ => humioctl}/repos_delete.go (99%) rename cmd/{ => humioctl}/repos_list.go (99%) rename cmd/{ => humioctl}/repos_show.go (98%) rename cmd/{ => humioctl}/repos_update.go (99%) rename cmd/{ => humioctl}/root.go (96%) rename cmd/{ => humioctl}/search.go (99%) rename cmd/{ => humioctl}/status.go (99%) rename cmd/{ => humioctl}/users.go (99%) rename cmd/{ => humioctl}/users_add.go (99%) rename cmd/{ => humioctl}/users_list.go (98%) rename cmd/{ => humioctl}/users_remove.go (98%) rename cmd/{ => humioctl}/users_show.go (98%) rename cmd/{ => humioctl}/users_update.go (99%) rename cmd/{ => humioctl}/util.go (94%) rename cmd/{ => humioctl}/version.go (98%) rename cmd/{ => humioctl}/views.go (99%) rename cmd/{ => humioctl}/views_list.go (98%) rename cmd/{ => humioctl}/views_show.go (98%) rename cmd/{ => humioctl}/welcome.go (99%) delete mode 100644 main.go delete mode 100644 main_test.go delete mode 100755 scripts/bump_version.sh delete mode 100755 scripts/dist.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1ac990..a4e9494 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: goreleaser on: push: tags: - - '*' + - 'v*' jobs: goreleaser: @@ -40,6 +40,7 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} - name: Clear if: always() diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ba321d7..f37d9be 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -2,6 +2,7 @@ project_name: humioctl builds: - binary: humioctl + main: ./cmd/humioctl goos: - windows - darwin @@ -16,16 +17,18 @@ release: owner: humio name: cli -#brews: -# - -# github: -# owner: humio -# name: homebrew-humio -# folder: Formula -# homepage: https://humio.com/ -# description: Manage and Stream Logs to Humio -# test: | -# system "echo DONE" +brews: + - + tap: + owner: humio + name: homebrew-humio + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + url_template: "https://github.com/humio/homebrew-humio/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + folder: Formula + homepage: https://humio.com/ + description: Manage and Stream Logs to Humio + test: | + system "echo DONE" archives: - @@ -91,8 +94,3 @@ snapcrafts: # things they allow: # https://snapcraft.io/docs/reference/interfaces. plugs: ["home", "network"] - -#dockers: -# - image_templates: -# - humio/cli:latest -# - humio/cli:{{ .Tag }} diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..eeb44ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +See [https://github.com/humio/cli/releases](https://github.com/humio/cli/releases). diff --git a/CHANGES b/CHANGES deleted file mode 100644 index 8728e36..0000000 --- a/CHANGES +++ /dev/null @@ -1,175 +0,0 @@ -Version 0.23.0: - - Update usage string - -Version 0.22.0: - - Don't print the Humio Address on every command. - -Version 0.21.0: - - Fix issue so the default output is not stderr - -Version 0.20.0: - - Rename examples - - Change name to humioctl - -Version 0.19.0: - - Fix conflicting flags, user profile is not -u - - Fix makefile - -Version 0.18.1: - - -Version 0.18.0: - - Try to fix snap channel - -Version 0.17.3: - - Try to fix snap channel - -Version 0.17.2: - - -Version 0.17.1: - - Fix grade for snap - -Version 0.17.0: - - Add support for distributing on snap - -Version 0.16.0: - - Remove SHA1 Hash of license, ID does the job - -Version 0.15.1: - - style status output - -Version 0.15.0: - - Add status command - - Improve view listing - -Version 0.14.0: - - Allow specifying profile name as a flag - -Version 0.13.0: - - Redo profiles implementation - - Better listing of repos - - cleanup - -Version 0.12.0: - - Show more license info - - Don't show help on fatal error - - Use the cmd.Println for prompt as well - - Use cmd.Println to ensure wirght Out Writer - -Version 0.11.0: - - Add command for listing views - -Version 0.10.0: - - Allow multiple accounts to be saved in config - -Version 0.9.0: - - Add license command - -Version 0.8.0: - - Add --quiet flag to not print to stdout on ingest - -Version 0.7.0: - - Fix docs string - - Version bump to 0.6.0 - - Version bump to 0.5.0 - - Incompatible comment - - Missing styling - - Version bump to 0.6.0 - - Version bump to 0.5.0 - -Version 0.6.0: - - -Version 0.5.0: - - Add token-file flag - - Make autocomplete work - - Nicify login experience - - Remove old iteration - - Basic support for views - - Support showing roles - - Implement remove user - -Version 0.4.1: - - Add changelog to make build happy - -Version 0.4.0: - - WIP for update users - - Convert to Cobra yay - - Read from config - - Introduce humio login command - -Version 0.3.0: - - Improve docs - - Fix bugs - - Align file names with commands - - Convert users - - Tokens converted - - Align export command - - WIP - - Convert to hashicorp cli - - Rename push -> install - - Implement installing parsers from github - - Work on dashboards and parsers in files - - Add list users - - Add user command - -Version 0.2.1: - - Fix compile error - - Add commands for parsers and root management - - WIP - - Fix linter errors - - Merge pull request #4 from humio/add-humio-parsers - - Updated the README - - Enhance arg validation + started on an ingesttoken list command - - Add query-file parameter to parsers - - Add env file support - - Add ingesttokens and parser subcommands - - Remove .gitkeep from removed vendor dir - - Remove vendor folder - - Mention that we plan for search functionality as well. - - Improve Logo - -Version 0.15.0: - - Add makefile - -Version 0.14.1: - - Add makefile - - Add makefile - - Add makefile - -Version 0.13.0: - - Add makefile - -Version 0.12.0: - - Add makefile - -Version 0.11.0: - - -Version 0.6.0: - - Add makefile - -Version 0.5.0: - - Add makefile - -Version 0.4.0: - - Add makefile - -Version 0.3.0: - - Add makefile - - Add makefile - -Version 0.2.0: - - Add makefile - - Add makefile - - Add makefile - - Try to fix makefile - - Make logo align - - Make logo align - - Make logo align - - Add Logo - - Add Makefile - - Add makefile - - first commit - diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1a9654d..0000000 --- a/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM scratch - -COPY humioctl /humioctl - -ENTRYPOINT ["/humioctl"] diff --git a/Makefile b/Makefile index dfd050e..d8f05c1 100644 --- a/Makefile +++ b/Makefile @@ -10,30 +10,23 @@ all: build $(BIN_PATH): FORCE @echo "--> Building Humio CLI" - go build -o $(BIN_PATH) main.go + go build -o $(BIN_PATH) cmd/humioctl/*.go build: $(BIN_PATH) -get: - @echo "--> Fetching dependencies" - go get - -test: - @echo "--> Testing" - go test - clean: @echo "--> Cleaning" go clean @rm -rf bin/ -dist: clean - @echo "--> Tagging Git & Releasing" - ./scripts/dist.sh +snapshot: + @echo "--> Building snapshot" + goreleaser build --rm-dist --snapshot + @rm -rf bin/ run: $(BIN_PATH) $(BIN_PATH) $(CLI_COMMAND) -.PHONY: build get clean dist run FORCE +.PHONY: build clean snapshot run FORCE FORCE: diff --git a/README.md b/README.md index 8f1f0c5..ac0dd2a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,15 @@ $ sudo snap install humioctl ```bash $ nix-env -i humioctl ``` +### Any OS (via Go) + +```bash +$ go get github.com/humio/cli/cmd/humioctl +``` + +### Manual installation + +Download the latest release archive from the [releases](https://github.com/humio/cli/releases) page, unpack and enjoy! ## Usage diff --git a/VERSION b/VERSION deleted file mode 100644 index ca222b7..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.23.0 diff --git a/cmd/alerts.go b/cmd/humioctl/alerts.go similarity index 98% rename from cmd/alerts.go rename to cmd/humioctl/alerts.go index added08..beb987c 100644 --- a/cmd/alerts.go +++ b/cmd/humioctl/alerts.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/alerts_export.go b/cmd/humioctl/alerts_export.go similarity index 99% rename from cmd/alerts_export.go rename to cmd/humioctl/alerts_export.go index 052a342..c6fb045 100644 --- a/cmd/alerts_export.go +++ b/cmd/humioctl/alerts_export.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/alerts_install.go b/cmd/humioctl/alerts_install.go similarity index 99% rename from cmd/alerts_install.go rename to cmd/humioctl/alerts_install.go index 18a1f67..8b7384b 100644 --- a/cmd/alerts_install.go +++ b/cmd/humioctl/alerts_install.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/alerts_list.go b/cmd/humioctl/alerts_list.go similarity index 99% rename from cmd/alerts_list.go rename to cmd/humioctl/alerts_list.go index d14aa68..acc8d27 100644 --- a/cmd/alerts_list.go +++ b/cmd/humioctl/alerts_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/alerts_remove.go b/cmd/humioctl/alerts_remove.go similarity index 98% rename from cmd/alerts_remove.go rename to cmd/humioctl/alerts_remove.go index 3c40758..e95ccfb 100644 --- a/cmd/alerts_remove.go +++ b/cmd/humioctl/alerts_remove.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/cluster.go b/cmd/humioctl/cluster.go similarity index 98% rename from cmd/cluster.go rename to cmd/humioctl/cluster.go index 8a29a9c..26a510b 100644 --- a/cmd/cluster.go +++ b/cmd/humioctl/cluster.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/cluster_nodes.go b/cmd/humioctl/cluster_nodes.go similarity index 98% rename from cmd/cluster_nodes.go rename to cmd/humioctl/cluster_nodes.go index 0813705..a3953c6 100644 --- a/cmd/cluster_nodes.go +++ b/cmd/humioctl/cluster_nodes.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/cluster_nodes_list.go b/cmd/humioctl/cluster_nodes_list.go similarity index 99% rename from cmd/cluster_nodes_list.go rename to cmd/humioctl/cluster_nodes_list.go index fc6c750..458b189 100644 --- a/cmd/cluster_nodes_list.go +++ b/cmd/humioctl/cluster_nodes_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "sort" diff --git a/cmd/cluster_nodes_show.go b/cmd/humioctl/cluster_nodes_show.go similarity index 99% rename from cmd/cluster_nodes_show.go rename to cmd/humioctl/cluster_nodes_show.go index 15d4623..1f16f99 100644 --- a/cmd/cluster_nodes_show.go +++ b/cmd/humioctl/cluster_nodes_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/cluster_nodes_unregister.go b/cmd/humioctl/cluster_nodes_unregister.go similarity index 98% rename from cmd/cluster_nodes_unregister.go rename to cmd/humioctl/cluster_nodes_unregister.go index ea7aace..a176fa1 100644 --- a/cmd/cluster_nodes_unregister.go +++ b/cmd/humioctl/cluster_nodes_unregister.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "strconv" diff --git a/cmd/cluster_show.go b/cmd/humioctl/cluster_show.go similarity index 99% rename from cmd/cluster_show.go rename to cmd/humioctl/cluster_show.go index 20ebe25..6386029 100644 --- a/cmd/cluster_show.go +++ b/cmd/humioctl/cluster_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/humio/cli/api" diff --git a/cmd/completion.go b/cmd/humioctl/completion.go similarity index 99% rename from cmd/completion.go rename to cmd/humioctl/completion.go index 7cdf1ef..7fb8e39 100644 --- a/cmd/completion.go +++ b/cmd/humioctl/completion.go @@ -19,7 +19,7 @@ The project is released under the same Apache 2.0 license, the original work is copyright of the Helm Authorer. */ -package cmd +package main import ( "bytes" diff --git a/cmd/health.go b/cmd/humioctl/health.go similarity index 99% rename from cmd/health.go rename to cmd/humioctl/health.go index e58997d..a59de71 100644 --- a/cmd/health.go +++ b/cmd/humioctl/health.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "encoding/json" diff --git a/cmd/ingest.go b/cmd/humioctl/ingest.go similarity index 99% rename from cmd/ingest.go rename to cmd/humioctl/ingest.go index 2d834c4..ae502c2 100644 --- a/cmd/ingest.go +++ b/cmd/humioctl/ingest.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "bufio" diff --git a/cmd/ingest_tokens.go b/cmd/humioctl/ingest_tokens.go similarity index 98% rename from cmd/ingest_tokens.go rename to cmd/humioctl/ingest_tokens.go index e5bca53..7c4a4ca 100644 --- a/cmd/ingest_tokens.go +++ b/cmd/humioctl/ingest_tokens.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/ingest_tokens_add.go b/cmd/humioctl/ingest_tokens_add.go similarity index 99% rename from cmd/ingest_tokens_add.go rename to cmd/humioctl/ingest_tokens_add.go index 67499a8..e8236d8 100644 --- a/cmd/ingest_tokens_add.go +++ b/cmd/humioctl/ingest_tokens_add.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/ingest_tokens_list.go b/cmd/humioctl/ingest_tokens_list.go similarity index 99% rename from cmd/ingest_tokens_list.go rename to cmd/humioctl/ingest_tokens_list.go index 5aefd5d..e57012a 100644 --- a/cmd/ingest_tokens_list.go +++ b/cmd/humioctl/ingest_tokens_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/ingest_tokens_remove.go b/cmd/humioctl/ingest_tokens_remove.go similarity index 99% rename from cmd/ingest_tokens_remove.go rename to cmd/humioctl/ingest_tokens_remove.go index a70d8aa..662cad0 100644 --- a/cmd/ingest_tokens_remove.go +++ b/cmd/humioctl/ingest_tokens_remove.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/ingest_tokens_show.go b/cmd/humioctl/ingest_tokens_show.go similarity index 99% rename from cmd/ingest_tokens_show.go rename to cmd/humioctl/ingest_tokens_show.go index d7d503f..1abe305 100644 --- a/cmd/ingest_tokens_show.go +++ b/cmd/humioctl/ingest_tokens_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/ingest_tokens_update.go b/cmd/humioctl/ingest_tokens_update.go similarity index 99% rename from cmd/ingest_tokens_update.go rename to cmd/humioctl/ingest_tokens_update.go index 7048af0..3ebf0bf 100644 --- a/cmd/ingest_tokens_update.go +++ b/cmd/humioctl/ingest_tokens_update.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/license.go b/cmd/humioctl/license.go similarity index 99% rename from cmd/license.go rename to cmd/humioctl/license.go index 98983a6..3f5ea9d 100644 --- a/cmd/license.go +++ b/cmd/humioctl/license.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/license_install.go b/cmd/humioctl/license_install.go similarity index 99% rename from cmd/license_install.go rename to cmd/humioctl/license_install.go index 9d0f7b4..255b6d8 100644 --- a/cmd/license_install.go +++ b/cmd/humioctl/license_install.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/license_show.go b/cmd/humioctl/license_show.go similarity index 98% rename from cmd/license_show.go rename to cmd/humioctl/license_show.go index 3942425..b0f04a4 100644 --- a/cmd/license_show.go +++ b/cmd/humioctl/license_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/notifiers.go b/cmd/humioctl/notifiers.go similarity index 98% rename from cmd/notifiers.go rename to cmd/humioctl/notifiers.go index 118a5fb..4f2bb0f 100644 --- a/cmd/notifiers.go +++ b/cmd/humioctl/notifiers.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/notifiers_export.go b/cmd/humioctl/notifiers_export.go similarity index 99% rename from cmd/notifiers_export.go rename to cmd/humioctl/notifiers_export.go index 8a3d085..43a42e3 100644 --- a/cmd/notifiers_export.go +++ b/cmd/humioctl/notifiers_export.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/notifiers_install.go b/cmd/humioctl/notifiers_install.go similarity index 99% rename from cmd/notifiers_install.go rename to cmd/humioctl/notifiers_install.go index 2b9018c..1043952 100644 --- a/cmd/notifiers_install.go +++ b/cmd/humioctl/notifiers_install.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/notifiers_list.go b/cmd/humioctl/notifiers_list.go similarity index 99% rename from cmd/notifiers_list.go rename to cmd/humioctl/notifiers_list.go index c70e413..10668f8 100644 --- a/cmd/notifiers_list.go +++ b/cmd/humioctl/notifiers_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/notifiers_remove.go b/cmd/humioctl/notifiers_remove.go similarity index 98% rename from cmd/notifiers_remove.go rename to cmd/humioctl/notifiers_remove.go index dd217a4..6da477b 100644 --- a/cmd/notifiers_remove.go +++ b/cmd/humioctl/notifiers_remove.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/notifiers_show.go b/cmd/humioctl/notifiers_show.go similarity index 99% rename from cmd/notifiers_show.go rename to cmd/humioctl/notifiers_show.go index 1088639..ac853a3 100644 --- a/cmd/notifiers_show.go +++ b/cmd/humioctl/notifiers_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/output.go b/cmd/humioctl/output.go similarity index 98% rename from cmd/output.go rename to cmd/humioctl/output.go index 02bfb42..35769a9 100644 --- a/cmd/output.go +++ b/cmd/humioctl/output.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "fmt" diff --git a/cmd/parsers.go b/cmd/humioctl/parsers.go similarity index 98% rename from cmd/parsers.go rename to cmd/humioctl/parsers.go index 2bdcb02..21eb1c2 100644 --- a/cmd/parsers.go +++ b/cmd/humioctl/parsers.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/parsers_export.go b/cmd/humioctl/parsers_export.go similarity index 99% rename from cmd/parsers_export.go rename to cmd/humioctl/parsers_export.go index 7ead427..fc80ca9 100644 --- a/cmd/parsers_export.go +++ b/cmd/humioctl/parsers_export.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/parsers_install.go b/cmd/humioctl/parsers_install.go similarity index 99% rename from cmd/parsers_install.go rename to cmd/humioctl/parsers_install.go index 78b6994..2832ff6 100644 --- a/cmd/parsers_install.go +++ b/cmd/humioctl/parsers_install.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/parsers_list.go b/cmd/humioctl/parsers_list.go similarity index 99% rename from cmd/parsers_list.go rename to cmd/humioctl/parsers_list.go index f3db6c2..62d6f3f 100644 --- a/cmd/parsers_list.go +++ b/cmd/humioctl/parsers_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/parsers_remove.go b/cmd/humioctl/parsers_remove.go similarity index 98% rename from cmd/parsers_remove.go rename to cmd/humioctl/parsers_remove.go index 568f45a..893a20a 100644 --- a/cmd/parsers_remove.go +++ b/cmd/humioctl/parsers_remove.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/profiles.go b/cmd/humioctl/profiles.go similarity index 99% rename from cmd/profiles.go rename to cmd/humioctl/profiles.go index 0f1ca6c..e06a7d3 100644 --- a/cmd/profiles.go +++ b/cmd/humioctl/profiles.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "fmt" diff --git a/cmd/profiles_add.go b/cmd/humioctl/profiles_add.go similarity index 99% rename from cmd/profiles_add.go rename to cmd/humioctl/profiles_add.go index 04b8855..f6e425d 100644 --- a/cmd/profiles_add.go +++ b/cmd/humioctl/profiles_add.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "fmt" diff --git a/cmd/profiles_remove.go b/cmd/humioctl/profiles_remove.go similarity index 98% rename from cmd/profiles_remove.go rename to cmd/humioctl/profiles_remove.go index 0a19b6a..89541aa 100644 --- a/cmd/profiles_remove.go +++ b/cmd/humioctl/profiles_remove.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "os" diff --git a/cmd/profiles_set_default.go b/cmd/humioctl/profiles_set_default.go similarity index 99% rename from cmd/profiles_set_default.go rename to cmd/humioctl/profiles_set_default.go index e2ae481..e75d6df 100644 --- a/cmd/profiles_set_default.go +++ b/cmd/humioctl/profiles_set_default.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "fmt" diff --git a/cmd/repos.go b/cmd/humioctl/repos.go similarity index 99% rename from cmd/repos.go rename to cmd/humioctl/repos.go index b809a2b..2d7d097 100644 --- a/cmd/repos.go +++ b/cmd/humioctl/repos.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/repos_create.go b/cmd/humioctl/repos_create.go similarity index 98% rename from cmd/repos_create.go rename to cmd/humioctl/repos_create.go index 20bc802..089ebcb 100644 --- a/cmd/repos_create.go +++ b/cmd/humioctl/repos_create.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/repos_delete.go b/cmd/humioctl/repos_delete.go similarity index 99% rename from cmd/repos_delete.go rename to cmd/humioctl/repos_delete.go index f23b32b..ac4f039 100644 --- a/cmd/repos_delete.go +++ b/cmd/humioctl/repos_delete.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/repos_list.go b/cmd/humioctl/repos_list.go similarity index 99% rename from cmd/repos_list.go rename to cmd/humioctl/repos_list.go index 50bf570..dee2ef3 100644 --- a/cmd/repos_list.go +++ b/cmd/humioctl/repos_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "sort" diff --git a/cmd/repos_show.go b/cmd/humioctl/repos_show.go similarity index 98% rename from cmd/repos_show.go rename to cmd/humioctl/repos_show.go index e39cca9..4fff8da 100644 --- a/cmd/repos_show.go +++ b/cmd/humioctl/repos_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/repos_update.go b/cmd/humioctl/repos_update.go similarity index 99% rename from cmd/repos_update.go rename to cmd/humioctl/repos_update.go index adb5352..13e8105 100644 --- a/cmd/repos_update.go +++ b/cmd/humioctl/repos_update.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/root.go b/cmd/humioctl/root.go similarity index 96% rename from cmd/root.go rename to cmd/humioctl/root.go index ea8f74d..fb103f3 100644 --- a/cmd/root.go +++ b/cmd/humioctl/root.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" @@ -35,15 +35,6 @@ var printVersion bool // rootCmd represents the base command when called without any subcommands var rootCmd *cobra.Command -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) - } -} - func init() { rootCmd = &cobra.Command{ Use: "humioctl [subcommand] [flags] [arguments]", @@ -72,7 +63,7 @@ Common Management Commands: Run: func(cmd *cobra.Command, args []string) { if printVersion { - fmt.Println("humioctl ", version) + fmt.Println(fmt.Sprintf("humioctl %s (%s on %s)", version, commit, date)) os.Exit(0) } @@ -225,3 +216,11 @@ func newApiClientE(cmd *cobra.Command) (*api.Client, error) { return api.NewClient(config) } + +func main() { + SetVersion(version, commit, date) + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cmd/search.go b/cmd/humioctl/search.go similarity index 99% rename from cmd/search.go rename to cmd/humioctl/search.go index 6911255..00ce1f5 100644 --- a/cmd/search.go +++ b/cmd/humioctl/search.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "context" diff --git a/cmd/status.go b/cmd/humioctl/status.go similarity index 99% rename from cmd/status.go rename to cmd/humioctl/status.go index 63427a8..e807de9 100644 --- a/cmd/status.go +++ b/cmd/humioctl/status.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/users.go b/cmd/humioctl/users.go similarity index 99% rename from cmd/users.go rename to cmd/humioctl/users.go index 997823d..364b28f 100644 --- a/cmd/users.go +++ b/cmd/humioctl/users.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/users_add.go b/cmd/humioctl/users_add.go similarity index 99% rename from cmd/users_add.go rename to cmd/humioctl/users_add.go index f317d96..e145e61 100644 --- a/cmd/users_add.go +++ b/cmd/humioctl/users_add.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/users_list.go b/cmd/humioctl/users_list.go similarity index 98% rename from cmd/users_list.go rename to cmd/humioctl/users_list.go index aa88517..ff2dfef 100644 --- a/cmd/users_list.go +++ b/cmd/humioctl/users_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/users_remove.go b/cmd/humioctl/users_remove.go similarity index 98% rename from cmd/users_remove.go rename to cmd/humioctl/users_remove.go index 61eb088..64d6a31 100644 --- a/cmd/users_remove.go +++ b/cmd/humioctl/users_remove.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/users_show.go b/cmd/humioctl/users_show.go similarity index 98% rename from cmd/users_show.go rename to cmd/humioctl/users_show.go index bd56818..e2d4dfe 100644 --- a/cmd/users_show.go +++ b/cmd/humioctl/users_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/users_update.go b/cmd/humioctl/users_update.go similarity index 99% rename from cmd/users_update.go rename to cmd/humioctl/users_update.go index 13926f4..74eb84f 100644 --- a/cmd/users_update.go +++ b/cmd/humioctl/users_update.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/humio/cli/api" diff --git a/cmd/util.go b/cmd/humioctl/util.go similarity index 94% rename from cmd/util.go rename to cmd/humioctl/util.go index 4a6a6b4..2b50993 100644 --- a/cmd/util.go +++ b/cmd/humioctl/util.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "errors" @@ -11,6 +11,19 @@ import ( "github.com/spf13/cobra" ) +// GoReleaser will override these when building: https://goreleaser.com/customization/build/ +var ( + commit = "none" + date = "unknown" + version = "master" +) + +func SetVersion(v, c, d string) { + version = v + commit = c + date = d +} + func check(err error) { if err != nil { log.Fatal(err) @@ -24,18 +37,6 @@ func exitOnError(cmd *cobra.Command, err error, message string) { } } -var ( - commit = "none" - date = "unknown" - version = "master" -) - -func SetVersion(v, c, d string) { - version = v - commit = c - date = d -} - type stringPtrFlag struct { value *string } diff --git a/cmd/version.go b/cmd/humioctl/version.go similarity index 98% rename from cmd/version.go rename to cmd/humioctl/version.go index 1bef362..201b58b 100644 --- a/cmd/version.go +++ b/cmd/humioctl/version.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/views.go b/cmd/humioctl/views.go similarity index 99% rename from cmd/views.go rename to cmd/humioctl/views.go index 119570c..43059b2 100644 --- a/cmd/views.go +++ b/cmd/humioctl/views.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "fmt" diff --git a/cmd/views_list.go b/cmd/humioctl/views_list.go similarity index 98% rename from cmd/views_list.go rename to cmd/humioctl/views_list.go index a0d4aa3..96fd212 100644 --- a/cmd/views_list.go +++ b/cmd/humioctl/views_list.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/olekukonko/tablewriter" diff --git a/cmd/views_show.go b/cmd/humioctl/views_show.go similarity index 98% rename from cmd/views_show.go rename to cmd/humioctl/views_show.go index c215de7..49ba7c1 100644 --- a/cmd/views_show.go +++ b/cmd/humioctl/views_show.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cmd +package main import ( "github.com/spf13/cobra" diff --git a/cmd/welcome.go b/cmd/humioctl/welcome.go similarity index 99% rename from cmd/welcome.go rename to cmd/humioctl/welcome.go index 213de83..9f94c03 100644 --- a/cmd/welcome.go +++ b/cmd/humioctl/welcome.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "fmt" diff --git a/main.go b/main.go deleted file mode 100644 index 38080a0..0000000 --- a/main.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright © 2018 Humio Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import "github.com/humio/cli/cmd" - -var ( - version = "master" - commit = "none" - date = "unknown" -) - -func main() { - cmd.SetVersion(version, commit, date) - cmd.Execute() -} diff --git a/main_test.go b/main_test.go deleted file mode 100644 index 6cadb73..0000000 --- a/main_test.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -// This file is intentionally empty to force early versions of Go -// to test compilation for tests. diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh deleted file mode 100755 index bc88fb3..0000000 --- a/scripts/bump_version.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -if [ -f VERSION ]; then - BASE_STRING=`cat VERSION` - BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`) - V_MAJOR=${BASE_LIST[0]} - V_MINOR=${BASE_LIST[1]} - V_PATCH=${BASE_LIST[2]} - echo "Current version : $BASE_STRING" - V_MINOR=$((V_MINOR + 1)) - V_PATCH=0 - SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH" - read -p "Enter a version number [$SUGGESTED_VERSION]: " INPUT_STRING - if [ "$INPUT_STRING" = "" ]; then - INPUT_STRING=$SUGGESTED_VERSION - fi - echo "Will set new version to be $INPUT_STRING" - echo $INPUT_STRING > VERSION - echo "Version $INPUT_STRING:" > tmpfile - git log --pretty=format:" - %s" "v$BASE_STRING"...HEAD >> tmpfile - echo "" >> tmpfile - echo "" >> tmpfile - cat CHANGES >> tmpfile - mv tmpfile CHANGES - git add CHANGES VERSION - git commit -m "Version bump to $INPUT_STRING" - git tag -a -m "Tagging version $INPUT_STRING" "v$INPUT_STRING" - git push origin --tags -else - echo "Could not find a VERSION file" - read -p "Do you want to create a version file and start from scratch? [y]" RESPONSE - if [ "$RESPONSE" = "" ]; then RESPONSE="y"; fi - if [ "$RESPONSE" = "Y" ]; then RESPONSE="y"; fi - if [ "$RESPONSE" = "Yes" ]; then RESPONSE="y"; fi - if [ "$RESPONSE" = "yes" ]; then RESPONSE="y"; fi - if [ "$RESPONSE" = "YES" ]; then RESPONSE="y"; fi - if [ "$RESPONSE" = "y" ]; then - echo "0.1.0" > VERSION - echo "Version 0.1.0" > CHANGES - git log --pretty=format:" - %s" >> CHANGES - echo "" >> CHANGES - echo "" >> CHANGES - git add VERSION CHANGES - git commit -m "Added VERSION and CHANGES files, Version bump to v0.1.0" - git tag -a -m "Tagging version 0.1.0" "v0.1.0" - git push origin --tags - fi - -fi diff --git a/scripts/dist.sh b/scripts/dist.sh deleted file mode 100755 index 4c810cd..0000000 --- a/scripts/dist.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -e - -read -p "Releasing. Are you sure? [y/N]" -n 1 -r -echo # (optional) move to a new line -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell -fi - -scripts/bump_version.sh -goreleaser --rm-dist From e48d37b66269795f0f97367bb2ff36e986b8bac2 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 30 Jul 2020 00:39:45 +0200 Subject: [PATCH 2/5] Add workflow for running CI builds. --- .github/workflows/ci.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c19eda7 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,10 @@ +name: CI + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cedrickring/golang-action@1.5.1 From c19155fb989c7547c96197ca1ba4eb2d4c0000fb Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 30 Jul 2020 00:40:13 +0200 Subject: [PATCH 3/5] Make linter happy and display build states in README --- README.md | 4 +++ cmd/humioctl/cluster_nodes_show.go | 44 +++++++++++++++--------------- cmd/humioctl/ingest.go | 2 +- cmd/humioctl/repos.go | 12 ++++---- cmd/humioctl/search.go | 16 +++++------ cmd/humioctl/users.go | 14 +++++----- cmd/humioctl/views.go | 2 +- 7 files changed, 49 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index ac0dd2a..de588ee 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ # Humio CLI +[![Build Status](https://github.com/humio/cli/workflows/CI/badge.svg)](https://github.com/humio/cli/actions?query=workflow%3ACI) +[![Release Status](https://github.com/humio/cli/workflows/goreleaser/badge.svg)](https://github.com/humio/cli/actions?query=workflow%3Agoreleaser) +[![Go Report Card](https://goreportcard.com/badge/github.com/humio/cli)](https://goreportcard.com/report/github.com/humio/cli) + A CLI for managing and sending data to Humio. _This repository also contains Humio GoLang API client you can diff --git a/cmd/humioctl/cluster_nodes_show.go b/cmd/humioctl/cluster_nodes_show.go index 1f16f99..708b977 100644 --- a/cmd/humioctl/cluster_nodes_show.go +++ b/cmd/humioctl/cluster_nodes_show.go @@ -46,28 +46,28 @@ func newClusterNodesShowCmd() *cobra.Command { func printClusterNodeInfo(cmd *cobra.Command, node api.ClusterNode) { data := [][]string{ - []string{"ID", strconv.Itoa(node.Id)}, - []string{"Name", node.Name}, - []string{"URI", node.Uri}, - []string{"UUID", node.Uuid}, - []string{"Cluster info age (Seconds)", fmt.Sprintf("%.3f", node.ClusterInfoAgeSeconds)}, - []string{"Inbound segment (Size)", ByteCountDecimal(int64(node.InboundSegmentSize))}, - []string{"Outbound segment (Size)", ByteCountDecimal(int64(node.OutboundSegmentSize))}, - []string{"Storage Divergence (Size)", ByteCountDecimal(int64(node.StorageDivergence))}, - []string{"Can be safely unregistered", strconv.FormatBool(node.CanBeSafelyUnregistered)}, - []string{"Current size", ByteCountDecimal(int64(node.CurrentSize))}, - []string{"Primary size", ByteCountDecimal(int64(node.PrimarySize))}, - []string{"Secondary size", ByteCountDecimal(int64(node.SecondarySize))}, - []string{"Total size of primary", ByteCountDecimal(int64(node.TotalSizeOfPrimary))}, - []string{"Total size of secondary", ByteCountDecimal(int64(node.TotalSizeOfSecondary))}, - []string{"Free on primary", ByteCountDecimal(int64(node.FreeOnPrimary))}, - []string{"Free on secondary", ByteCountDecimal(int64(node.FreeOnSecondary))}, - []string{"WIP size", ByteCountDecimal(int64(node.WipSize))}, - []string{"Target size", ByteCountDecimal(int64(node.TargetSize))}, - []string{"Reapply target size", ByteCountDecimal(int64(node.Reapply_targetSize))}, - []string{"Solitary segment size", ByteCountDecimal(int64(node.SolitarySegmentSize))}, - []string{"Is available", strconv.FormatBool(node.IsAvailable)}, - []string{"Last heartbeat", node.LastHeartbeat}, + {"ID", strconv.Itoa(node.Id)}, + {"Name", node.Name}, + {"URI", node.Uri}, + {"UUID", node.Uuid}, + {"Cluster info age (Seconds)", fmt.Sprintf("%.3f", node.ClusterInfoAgeSeconds)}, + {"Inbound segment (Size)", ByteCountDecimal(int64(node.InboundSegmentSize))}, + {"Outbound segment (Size)", ByteCountDecimal(int64(node.OutboundSegmentSize))}, + {"Storage Divergence (Size)", ByteCountDecimal(int64(node.StorageDivergence))}, + {"Can be safely unregistered", strconv.FormatBool(node.CanBeSafelyUnregistered)}, + {"Current size", ByteCountDecimal(int64(node.CurrentSize))}, + {"Primary size", ByteCountDecimal(int64(node.PrimarySize))}, + {"Secondary size", ByteCountDecimal(int64(node.SecondarySize))}, + {"Total size of primary", ByteCountDecimal(int64(node.TotalSizeOfPrimary))}, + {"Total size of secondary", ByteCountDecimal(int64(node.TotalSizeOfSecondary))}, + {"Free on primary", ByteCountDecimal(int64(node.FreeOnPrimary))}, + {"Free on secondary", ByteCountDecimal(int64(node.FreeOnSecondary))}, + {"WIP size", ByteCountDecimal(int64(node.WipSize))}, + {"Target size", ByteCountDecimal(int64(node.TargetSize))}, + {"Reapply target size", ByteCountDecimal(int64(node.Reapply_targetSize))}, + {"Solitary segment size", ByteCountDecimal(int64(node.SolitarySegmentSize))}, + {"Is available", strconv.FormatBool(node.IsAvailable)}, + {"Last heartbeat", node.LastHeartbeat}, } w := tablewriter.NewWriter(cmd.OutOrStdout()) diff --git a/cmd/humioctl/ingest.go b/cmd/humioctl/ingest.go index ae502c2..29769c4 100644 --- a/cmd/humioctl/ingest.go +++ b/cmd/humioctl/ingest.go @@ -129,7 +129,7 @@ func sendLine(line string) { func sendBatch(client *api.Client, repo string, messages []string, fields map[string]string, parserName string) { lineJSON, err := json.Marshal([1]eventList{ - eventList{ + { Type: parserName, Fields: fields, Messages: messages, diff --git a/cmd/humioctl/repos.go b/cmd/humioctl/repos.go index 2d7d097..0309593 100644 --- a/cmd/humioctl/repos.go +++ b/cmd/humioctl/repos.go @@ -40,12 +40,12 @@ func newReposCmd() *cobra.Command { func printRepoTable(cmd *cobra.Command, repo api.Repository) { data := [][]string{ - []string{"Name", repo.Name}, - []string{"Description", repo.Description}, - []string{"Space Used", ByteCountDecimal(repo.SpaceUsed)}, - []string{"Ingest Retention (Size)", ByteCountDecimal(int64(repo.IngestRetentionSizeGB * 1e9))}, - []string{"Storage Retention (Size)", ByteCountDecimal(int64(repo.StorageRetentionSizeGB * 1e9))}, - []string{"Retention (Days)", fmt.Sprintf("%d", int64(repo.RetentionDays))}, + {"Name", repo.Name}, + {"Description", repo.Description}, + {"Space Used", ByteCountDecimal(repo.SpaceUsed)}, + {"Ingest Retention (Size)", ByteCountDecimal(int64(repo.IngestRetentionSizeGB * 1e9))}, + {"Storage Retention (Size)", ByteCountDecimal(int64(repo.StorageRetentionSizeGB * 1e9))}, + {"Retention (Days)", fmt.Sprintf("%d", int64(repo.RetentionDays))}, } w := tablewriter.NewWriter(cmd.OutOrStdout()) diff --git a/cmd/humioctl/search.go b/cmd/humioctl/search.go index 00ce1f5..581fd33 100644 --- a/cmd/humioctl/search.go +++ b/cmd/humioctl/search.go @@ -41,10 +41,10 @@ func newSearchCmd() *cobra.Command { // run in lambda func to be able to defer and delete the query job err := func() error { id, err := client.QueryJobs().Create(repository, api.Query{ - QueryString: queryString, - Start: start, - End: end, - Live: live, + QueryString: queryString, + Start: start, + End: end, + Live: live, ShowQueryEventDistribution: true, }) @@ -155,10 +155,10 @@ func contextCancelledOnInterrupt(ctx context.Context) context.Context { } type queryResultProgressBar struct { - bar *prompt.ProgressBar - epsValue float64 - bpsValue float64 - hits uint64 + bar *prompt.ProgressBar + epsValue float64 + bpsValue float64 + hits uint64 } func newQueryResultProgressBar() *queryResultProgressBar { diff --git a/cmd/humioctl/users.go b/cmd/humioctl/users.go index 364b28f..c60a41b 100644 --- a/cmd/humioctl/users.go +++ b/cmd/humioctl/users.go @@ -46,13 +46,13 @@ func formatSimpleAccount(account api.User) string { func printUserTable(cmd *cobra.Command, user api.User) { data := [][]string{ - []string{"Username", user.Username}, - []string{"Name", user.FullName}, - []string{"Is Root", yesNo(user.IsRoot)}, - []string{"Email", user.Email}, - []string{"Created At", user.CreatedAt}, - []string{"Country Code", user.CountryCode}, - []string{"Company", user.Company}, + {"Username", user.Username}, + {"Name", user.FullName}, + {"Is Root", yesNo(user.IsRoot)}, + {"Email", user.Email}, + {"Created At", user.CreatedAt}, + {"Country Code", user.CountryCode}, + {"Company", user.Company}, } w := tablewriter.NewWriter(cmd.OutOrStdout()) diff --git a/cmd/humioctl/views.go b/cmd/humioctl/views.go index 43059b2..d19b2ba 100644 --- a/cmd/humioctl/views.go +++ b/cmd/humioctl/views.go @@ -38,7 +38,7 @@ func newViewsCmd() *cobra.Command { func printViewTable(view *api.View) { data := [][]string{ - []string{"Name", view.Name}, + {"Name", view.Name}, } w := tablewriter.NewWriter(os.Stdout) From 1e7701a3d98917e0f52d7baae189361eda0ca074 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 30 Jul 2020 00:49:45 +0200 Subject: [PATCH 4/5] Use goreleaser to build snapshot instead of invoking go build --- .github/workflows/ci.yaml | 18 ++++++++++++++++-- .github/workflows/release.yml | 5 ++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c19eda7..cacbf6f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,5 +6,19 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: cedrickring/golang-action@1.5.1 + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + - + name: Build snapshot with GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: build --rm-dist --snapshot diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4e9494..d1e3f78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,8 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - - name: Unshallow - run: git fetch --prune --unshallow + with: + fetch-depth: 0 - name: Install Snapcraft uses: samuelmeuli/action-snapcraft@v1 From 7ee6bd1134f079b166095645fd259563ac0f0788 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 30 Jul 2020 10:03:44 +0200 Subject: [PATCH 5/5] Update README section about environment variables --- README.md | 42 ++++++++++++++++++---------- cmd/humioctl/profiles_add.go | 2 +- cmd/humioctl/profiles_set_default.go | 4 +-- cmd/humioctl/root.go | 6 ++-- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index de588ee..b677231 100644 --- a/README.md +++ b/README.md @@ -109,28 +109,40 @@ $ humioctl ingest -label=work-related -tail=/var/log/mysql.log `@session` is a unique id that is generated for each execution of the `humio` binary. This allows you to find results for this session and nothing else. -## Environment Variables +## Profiles and Environment Variables -When use `humio login` it will write your API token and server address -into `.humioconfig` in your home dir. +To make it easier to switch between different Humio clusters, you can +configure a profile for each cluster. The configuration file, containing the +API token and server address for all profiles will be default be saved in +`$HOME/.humio/config.yaml`. -The CLI will always have environment variables take precedence over -values form your `~/.humioconfig` file. +Adding a profile and making it the new default can be done using: + +```bash +$ humioctl profiles add my-profile +$ humioctl profiles set-default my-profile + +It is also possible to use environment variables, and these will take +precendence over the default profile. ```bash # Your account API token. You can find your token in Humio's UI under # 'Your Account' in the account menu. -HUMIO_API_TOKEN= - -# A file containing the auth token to use for authorization -# useful in conjunction with Humio's generated root token file. -# If this is set it takes precedence over HUMIO_API_TOKEN. -HUMIO_TOKEN_FILE= +HUMIO_TOKEN= # The address of the Humio server. E.g. https://cloud.humio.com/, # or http://localhost:8080/ -HUMIO_ADDR= - -# Disable color in terminal output -HUMIO_CLI_NO_COLOR= +HUMIO_ADDRESS= + +# If access to the Humio server requires trusting a specific Certificate Authority, +# for validating the certificate, you can specify CA certificate in PEM format. +# You can either point to a file with the certificate or provide it directly. +HUMIO_CA_CERTIFICATE= + +# If access to the Humio server uses an untrusted certificate and you +# are unable to provide a CA certificate, you can disable TLS certificate verification. +# NB: This should only ever be used on test/sandbox clusters where you are in full +# control of the involved systems and underlying network. +# Do not use this for prodution use-cases. +HUMIO_INSECURE= ``` diff --git a/cmd/humioctl/profiles_add.go b/cmd/humioctl/profiles_add.go index f6e425d..88e5d86 100644 --- a/cmd/humioctl/profiles_add.go +++ b/cmd/humioctl/profiles_add.go @@ -65,7 +65,7 @@ func addAccount(out *prompt.Prompt, newName string, profile *login) { "address": profile.address, "token": profile.token, "username": profile.username, - "ca-certificate": string(profile.caCertificate), + "ca_certificate": string(profile.caCertificate), "insecure": strconv.FormatBool(profile.insecure), } diff --git a/cmd/humioctl/profiles_set_default.go b/cmd/humioctl/profiles_set_default.go index e75d6df..2497b66 100644 --- a/cmd/humioctl/profiles_set_default.go +++ b/cmd/humioctl/profiles_set_default.go @@ -22,7 +22,7 @@ func newProfilesSetDefaultCmd() *cobra.Command { exitOnError(cmd, loadErr, "profile not found") viper.Set("address", profile.address) viper.Set("token", profile.token) - viper.Set("ca-certificate", string(profile.caCertificate)) + viper.Set("ca_certificate", string(profile.caCertificate)) viper.Set("insecure", strconv.FormatBool(profile.insecure)) saveErr := saveConfig() @@ -55,7 +55,7 @@ func loadProfile(profileName string) (*login, error) { profile := login{ address: getMapKey(profileData, "address"), token: getMapKey(profileData, "token"), - caCertificate: []byte(getMapKey(profileData, "ca-certificate")), + caCertificate: []byte(getMapKey(profileData, "ca_certificate")), insecure: insecure, } diff --git a/cmd/humioctl/root.go b/cmd/humioctl/root.go index fb103f3..a4b7b46 100644 --- a/cmd/humioctl/root.go +++ b/cmd/humioctl/root.go @@ -166,7 +166,7 @@ func initConfig() { viper.Set("token", profile.token) } if caCertificateFile == "" { - viper.Set("ca-certificate", profile.caCertificate) + viper.Set("ca_certificate", profile.caCertificate) } if insecure { viper.Set("insecure", strconv.FormatBool(insecure)) @@ -188,7 +188,7 @@ func initConfig() { fmt.Println(fmt.Sprintf("error loading CA certificate file: %s", caCertificateFileErr)) os.Exit(1) } - viper.Set("ca-certificate", string(caCertificateFileContent)) + viper.Set("ca_certificate", string(caCertificateFileContent)) } if insecure { @@ -211,7 +211,7 @@ func newApiClientE(cmd *cobra.Command) (*api.Client, error) { config := api.DefaultConfig() config.Address = viper.GetString("address") config.Token = viper.GetString("token") - config.CACertificate = []byte(viper.GetString("ca-certificate")) + config.CACertificate = []byte(viper.GetString("ca_certificate")) config.Insecure = viper.GetBool("insecure") return api.NewClient(config)