40 Commits

Author SHA1 Message Date
Michael Stapelberg
ce2433aa1a gok: move code to internal/gok 2023-01-29 19:30:23 +01:00
Michael Stapelberg
d5f9cee29d gok: use config.NewStruct()
related to https://github.com/gokrazy/tools/issues/43
2023-01-17 19:05:43 +01:00
Michael Stapelberg
45ce7ad200 implement 'gok get' subcommand
fixes https://github.com/gokrazy/gokrazy/issues/162
2023-01-15 18:27:02 +01:00
Michael Stapelberg
d9681ee8cb gok run, logs: remove --update flag in favor of --instance 2023-01-15 17:15:52 +01:00
Michael Stapelberg
bdb14f7080 use new httpclient.For() instead of GetHTTPClientForInstance() 2023-01-15 16:41:49 +01:00
Michael Stapelberg
c61213349c provide a programmatic entry point to the gok CLI
This interfaces with spf13/cobra without typing ourselves to its types, and
exerting control (for better of for worse) about what aspects one can control.

With this, we can move the code in cmd to internal/
2023-01-15 15:55:51 +01:00
Michael Stapelberg
10ba0192aa gok new: generate a machine-id(5) by default 2023-01-15 14:44:44 +01:00
Michael Stapelberg
a84f008488 identify gokrazy packer vs. gok in log output 2023-01-10 20:41:41 +01:00
Michael Stapelberg
444a52a283 gok add: store go.mod at package level for local disk additions
This way, non-local and local operate at the same hierarchy level, which means
you can switch from non-local to local override.
2023-01-07 18:50:11 +01:00
Michael Stapelberg
12d755c6e9 gok run: read instance config to set build flags/tags 2023-01-07 16:16:46 +01:00
Michael Stapelberg
7d22eb8e32 add integration test for gokr-packer and its migration path 2023-01-07 16:16:46 +01:00
Michael Stapelberg
2b958254f0 gok add: copy replace directives from local go.mod
This fixes the build of github.com/evcc-io/evcc, which doesn’t build without
the replace directives from its go.mod file.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
e3e0c0fb2a gok add: create go.mod in non-local mode, too
The go tool needs a go.mod to function.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
1b8e74f331 gok add: use go mod edit instead of go get for adding require line
Adding the require line using `go get` does not work for
https://github.com/evcc-io/evcc as of commit
504ed7172efdd6e849985280a21feccbbf455b9d:

panic: internal error: can't find reason for requirement on
github.com/rogpeppe/go-internal@v1.6.1.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
1194a73d20 group commands in gok help output 2023-01-07 16:01:39 +01:00
Michael Stapelberg
d4fa52f791 uppercase HTTP(S) 2023-01-07 16:01:39 +01:00
Michael Stapelberg
ec011de8da gok new: create config.json with 0600 permissions
The instance config contains the device password.
2023-01-07 16:01:39 +01:00
Michael Stapelberg
c72e5e19f4 rename instance_dir to parent_dir, to make its role clearer 2023-01-07 16:01:39 +01:00
Michael Stapelberg
dc4131ed8b implement gok add 2023-01-07 16:01:39 +01:00
Michael Stapelberg
a2832b7d25 move left-over flags 2023-01-07 16:01:39 +01:00
Michael Stapelberg
3a96e0840b implement gok edit 2023-01-07 16:01:39 +01:00
Michael Stapelberg
e8957193c6 implement gok new 2023-01-07 16:01:39 +01:00
Michael Stapelberg
c3a5ed85c0 remove hook calling TODO (design doc has been updated)
It is cleaner to have this happen outside of the gok tool.
That way, users can see the config, as the tool will read it,
using `cat config.json` before calling gok.
2023-01-07 16:01:39 +01:00
Michael Stapelberg
64ebf287f9 gok: long help output 2023-01-07 16:01:39 +01:00
Michael Stapelberg
492ee69a2e wire up gok version 2023-01-07 16:01:39 +01:00
Michael Stapelberg
86312ca8d8 move config package to gokrazy/internal 2023-01-07 16:01:39 +01:00
Michael Stapelberg
038a9233cf add gok overwrite subcommand 2023-01-07 16:01:39 +01:00
Michael Stapelberg
434e942c97 refactor packer code into internal/packer, add gok update entrypoint
related to https://github.com/gokrazy/gokrazy/issues/147
2023-01-07 16:01:35 +01:00
Michael Stapelberg
52922bae3e register --instance flag on root command for --help 2023-01-07 15:59:17 +01:00
Michael Stapelberg
d3bc434581 implement gok --version 2023-01-07 15:59:17 +01:00
Mark Dietzer
01edd60bd7 Use shared helper to build http client for log and run. (#39) 2022-09-14 08:41:31 +02:00
Michael Stapelberg
2e1812da69 make packer.BuildDir function configurable, fix gok run
related to https://github.com/gokrazy/tools/pull/39
2022-09-13 20:44:38 +02:00
Michael Stapelberg
d873acb6b7 cobra: context and error plumbing
This will make an integration test way easier.
2022-09-13 19:26:40 +02:00
Michael Stapelberg
49d3ee847d update flag is called -update in gokr-packer and gok
related to https://github.com/gokrazy/breakglass/issues/13
2022-04-30 21:26:27 +02:00
Michael Stapelberg
4fe1051453 revert GOFLAGS, add buildtags per-package config, add osusergo/netgo
The GOFLAGS handling is the opposite of how the Go tool handles it, where
GOFLAGS provides default values that the command line then overwrites. I think
it’s better to match that behavior.

Instead, allow extending gokr-packer’s list of build tags via the buildtags/
per-package config directive.

Also, add osusergo and netgo build tags by default so that even when cgo is
enabled, gokrazy code results in statically linked binaries.

related to https://github.com/stapelberg/scan2drive/issues/18
2022-04-21 21:17:36 +02:00
Michael Stapelberg
05a69a38cd gok: read host-specific http-port.txt 2022-03-26 19:39:32 +01:00
Michael Stapelberg
a33ad86c63 gok run: automatically follow logs after uploading
related to https://github.com/gokrazy/gokrazy/issues/88
2021-12-15 14:52:22 +01:00
Michael Stapelberg
07d209a9ed implement gok logs command for streaming logs
Log streaming was implemented in https://github.com/gokrazy/gokrazy/pull/100

related to https://github.com/gokrazy/gokrazy/issues/88
2021-12-15 14:32:03 +01:00
Michael Stapelberg
688793dda2 better error message when the binary was not installed 2021-11-21 21:53:20 +01:00
Michael Stapelberg
34f3ddd1ac introduce gok CLI
This is a subcommand based CLI for gokrazy.

Its first subcommand is “run”, to be used like so:

  cd ~/scan2drive/cmd/scan2drive
  gok run --instance=scan2drive

related to https://github.com/gokrazy/gokrazy/issues/88
2021-11-21 17:01:03 +01:00