Commit Graph

96 Commits

Author SHA1 Message Date
Simone Gotti
d2b09d854f *: use new errors handling library
Implement a new error handling library based on pkg/errors. It provides
stack saving on wrapping and exports some function to add stack saving
also to external errors.
It also implements custom zerolog error formatting without adding too
much verbosity by just printing the chain error file:line without a full
stack trace of every error.

* Add a --detailed-errors options to print error with they full chain
* Wrap all error returns. Use errors.WithStack to wrap without adding a
  new messsage and error.Wrap[f] to add a message.
* Add golangci-lint wrapcheck to check that external packages errors are
  wrapped. This won't check that internal packages error are wrapped.
  But we want also to ensure this case so we'll have to find something
  else to check also these.
2022-02-28 12:49:13 +01:00
Simone Gotti
d1b4ab4296 *: use zerolog for logging
Replace zap with zerolog.

zerolog has a cleaner interface and can be easily configured with custom
error chain printing using a new error handling library that will be
implemented in another PR.
2022-02-28 10:40:55 +01:00
Simone Gotti
87f182a0c9 *: use errors.Is/errors.As to handle wrapped error checking
Enable golangci-lint errorlint linter to check proper use of errors.Is
and error.As instead of direct comparison or error type casting.
2022-02-24 17:07:29 +01:00
Simone Gotti
576c09775f go.mod: replace https://github.com/satori/go.uuid
Replace https://github.com/satori/go.uuid with maintained version at
https://github.com/gofrs/uuid

Since the new version uuid.NewV4 returns an error when failing to read
from the random source reader we use uuid.Must to panic on error since
it's considered an unrecoverable error.

In future, if needed, we could handle the error instead of panicking.
2022-02-21 09:43:32 +01:00
Simone Gotti
75541ad730 cmd: remotesource create don't force github defaults
Use default public github api only if no api-url is provided.
Use default public github ssh host key only if the public github api url is
provided and no ssh host key is provided.
2020-02-10 09:58:08 +01:00
Carlo Mandelli
182eb14b20 cmd: project option to disable passing variables to PR from forked repo 2020-01-28 09:02:37 +01:00
Carlo Mandelli
806c516ac7 cmd: fix token create help message 2020-01-16 11:30:37 +01:00
Simone Gotti
2de91549a3 tests: improve services logging
During tests provide a zaptest Logger so all services output will be redirected
to golang testing logger.

When multiple services of the same type are provided add a unique name field to
distinguish them.
2020-01-15 12:30:34 +01:00
Carlo Mandelli
8bbdc0a36e cmd: add TaskID to run list output 2019-12-02 08:51:11 +01:00
Carlo Mandelli
a15a769610 cmd: add details to run list 2019-11-29 14:52:04 +01:00
Carlo Mandelli
8aade1859b cmd: add log get and delete subcommands 2019-11-28 13:39:00 +01:00
Carlo Mandelli
42e302df50 cmd: fix project visibility switch 2019-11-21 14:44:50 +01:00
Carlo Mandelli
aab2321d58 services: check config only for enabled services 2019-11-05 09:25:22 +01:00
Simone Gotti
98912f1187 cmd: add run create command
Add a run create command to manually create a run providing the project ref, the
branch/tag/ref and an optional commit sha.
2019-10-22 10:47:20 +02:00
Carlo Mandelli
4fc8f3ebed cmd: add version command 2019-10-05 12:11:18 +02:00
Simone Gotti
9588394b42
Merge pull request #133 from camandel/cmd_add_completion
cmd: add completion command
2019-10-02 10:58:15 +02:00
Simone Gotti
eec25e6069
Merge pull request #132 from sgotti/cmd_projectgroup_delete
cmd: add project group delete command
2019-10-02 09:27:29 +02:00
Carlo Mandelli
761a777969 cmd: add completion command 2019-10-01 16:01:17 +02:00
Simone Gotti
d18aadaf5c cmd: add project group update command 2019-10-01 15:39:29 +02:00
Simone Gotti
85b8888f76 cmd: add project group delete command 2019-10-01 10:33:56 +02:00
Simone Gotti
ddfc5f41c0 cmd: add project update command 2019-09-30 13:30:13 +02:00
Carlo Mandelli
8df96757e3 fix typos in online help 2019-09-27 08:22:41 +02:00
Carlo Mandelli
229b4c511d Add variable/secret list subcommand 2019-09-26 09:33:24 +02:00
Simone Gotti
70eeddb719 types: use a global When type
Currently we are using different `When` types for every service and convert
between them. This is a good approach if we want to keep isolated all the
services (like if we were using different repos for every service instead of the
current monorepo).

But currently, since When is identical between all the services, simplify this by
using a common When type.
2019-09-05 09:37:27 +02:00
Simone Gotti
53dad95cd0 cmd: fix variable create/update
In c1ff28ef9f we exported various types. Unfortunately the types used by cmd
variable create/update are the wrong types and marshalling fails. Fix it using
the right type. In future this internal types should be exported.
2019-08-29 16:38:19 +02:00
Simone Gotti
2676770336 userdirectrun: add options to define variables
Add a --var and --var-file options (repeatable multiple times) to define the
variables to be used in the run.
2019-08-06 16:58:00 +02:00
Simone Gotti
4ec0b33eb4 userdirectrun: allow setting destination branch/tag/ref
Allow setting the destination branch/tag/ref so users can test the run
conditions based on the branch/tag/ref.

To simulate a pull request an user can define a ref that matches one of these
regular expressions: `refs/pull/(\d+)/head`, `refs/merge-requests/(\d+)/head`
2019-08-05 14:45:34 +02:00
Simone Gotti
c1ff28ef9f *: export clients and related types
Export clients and related packages.

The main rule is to not import internal packages from exported packages.

The gateway client and related types are totally decoupled from the gateway
service (not shared types between the client and the server).

Instead the configstore and the runservice client currently share many types
that are now exported (decoupling them will require that a lot of types must be
duplicated and the need of functions to convert between them, this will be done
in future when the APIs will be declared as stable).
2019-08-02 12:02:01 +02:00
Simone Gotti
fd26e617b3 configstore: move configstore types inside configstore package
Since they're not types common to all the services but belongs to the
configstore.

Next step will be to make them local to the configstore and not directly used by
other services since these types are also stored.
2019-08-02 10:05:47 +02:00
Simone Gotti
f61a6068c2 cmd/serve: don't make --config required 2019-07-12 17:26:00 +02:00
Simone Gotti
378ee352c0 cmd: implement secret update 2019-07-08 10:32:59 +02:00
Simone Gotti
6508fd2b53 secret create: read values from yaml file/stdin 2019-07-08 09:58:11 +02:00
Simone Gotti
8c2f37d47c cmd: implement variable update 2019-07-06 15:25:57 +02:00
Simone Gotti
c7aca42f1f variable create: read values from yaml file/stdin 2019-07-05 18:34:40 +02:00
Simone Gotti
ee5c829653 *: add remote source option to disable registration/login
* Make the new fields RegistrationEnabled/LoginEnabled in types.RemoteSource
bool pointers (since they are new fields that don't exist in previously saved
remote sources) and default them to true if null when unmarshaling (or existing
remotesources will have registration and login disabled)

* Add options to cmd remotesource create/update to set the registration/login
disabled.
2019-07-05 13:33:29 +02:00
Simone Gotti
e7864d0d84 gateway: add getruns filter by result 2019-07-05 10:42:45 +02:00
Simone Gotti
9d71f32368 cmd: don't set remotesourcecreate api-url flag as required
check it later since for github it could not be provided and will default to
"https://api.github.com"
2019-07-05 10:16:37 +02:00
Simone Gotti
f861e2a647 cmd: fix run list 2019-07-04 16:22:11 +02:00
Simone Gotti
abab40c6f5 gateway/cmd: generate CacheGroup for user direct runs
Since the user direct runs all belong to the same run group (the user id) all
the user direct runs will share the same caches. To distinguish between the
different caches we need to use something in addition to the user id. In this
case we are usin the local repo uuid generated by the direct run start command.
2019-07-03 15:19:52 +02:00
Simone Gotti
2859c3144a cmd: fix linter errors
Fix errors reported by default golangci-lint linters
2019-07-02 16:22:24 +02:00
Simone Gotti
ced6108963 cmd toolbox: handle missing error checks 2019-07-02 14:27:32 +02:00
Simone Gotti
b849e2c07e agola cmd: check MarkFlagRequired errors 2019-07-02 13:49:10 +02:00
Simone Gotti
d8a92ba0d1 agola cmd: check possible Help function error 2019-07-02 13:44:43 +02:00
Simone Gotti
540f5888d2 agola cmd: return exit code 1 on bad command 2019-07-02 13:32:27 +02:00
Simone Gotti
88b7ea3de6 serve: rename all to all-base excluding executor
since the executor are usually run separately from the other "base" components,
make this explicit removing "all" and adding an "all-base" virtual component
that will start all the components except the executor.
2019-07-02 10:54:11 +02:00
Simone Gotti
8d67844cc4 *: use vanity url
use agola.io domain
2019-07-01 11:40:20 +02:00
Simone Gotti
5a74ebf9d8 *: remove agola git hook
* Delete the command and it's rule in the Makefile
* Don't use it inside gitserver and remove related config option (also from
examples)
* Remove webhook parsing from agolagit gitsource
2019-06-11 15:30:09 +02:00
Simone Gotti
a27721c5b1 directrunstart: use new user create run api
* Push the local custom ref to a branch ref (refs/heads/branch)
* After the push create the run calling the user create run api
2019-06-11 15:15:14 +02:00
Simone Gotti
810abaaab8 git-save: return commitSHA 2019-06-11 15:04:34 +02:00
Simone Gotti
f92bcee73b directrun: setup local repo uuid and use it as remote repo name 2019-06-11 12:46:02 +02:00