Commit Graph

105 Commits

Author SHA1 Message Date
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
34d36e9e24 gateway: implement secret update 2019-07-08 10:32:45 +02:00
Simone Gotti
49c1c263fd gateway: implement variable update 2019-07-06 15:25:45 +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
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
c5abbee3d8 gateway: fix linter errors
Fix errors reported by default golangci-lint linters
2019-07-02 15:35:14 +02:00
Simone Gotti
8d67844cc4 *: use vanity url
use agola.io domain
2019-07-01 11:40:20 +02:00
Simone Gotti
5e21089baa *: remove unneeded logging
remove many log.Info entries that where old debugging entries and move some of
them to the Debug level.
2019-06-14 11:28:00 +02:00
Simone Gotti
48411f4c64 gateway: move webhook inside api package 2019-06-11 17:07:08 +02:00
Simone Gotti
2a95c93f0d gateway: add UserCreateRun api and related action
add an api to execute a user direct run. This method will replace the current
custom webhook way to create a direct run.
2019-06-11 15:09:41 +02:00
Simone Gotti
98c2f76f5d gateway: add manual run creation
Add an API and related action to manually create a run from a git branch/tag/ref
with optional commitSHA.

Currently only branches and tags are supported (no pull requests).
If not commitSHA is provided the commit sha referenced by the provided branch/tag/ref is
used.
2019-06-11 11:08:40 +02:00
Simone Gotti
6e8d467c80 util: add ErrInternal
ErrInternal is an internal error that should be provided to the user (http api
will return a 500 with the error message)

It'll be used for any kind of error that are not auth or bad requests (like
errors to communicate to another service)
2019-06-11 10:59:21 +02:00
Simone Gotti
8242dc3a9d gateway: move create run to own action
* Move all run creation logic to the action handler.
* Cleanup webhook to use it
2019-06-11 09:31:12 +02:00
Simone Gotti
03a0d38b10 gateway: update and log errors on remoterepo api 2019-05-23 17:30:20 +02:00
Simone Gotti
4d7605a86b gateway: improve ErrFromRemote handling
Don't create an ErrFromRemote wrapping the returned error but
wrap the ErrFromRemote

Also use xerrors Is/As to get the underlying error to return to api clients
while maintaining context for logging
2019-05-23 12:59:11 +02:00
Simone Gotti
9b2ce717c7 *: migrate to "golang.org/x/xerrors"
Just a raw replace of "github.com/pkg/errors".

Next steps will improve errors (like remote errors, api errors, not exist errors
etc...) to leverage its functionalities
2019-05-23 11:23:14 +02:00
Simone Gotti
8f1225da76 *: implement remote source update 2019-05-23 10:29:03 +02:00
Simone Gotti
933dfae658 cmd/api: add skipVerify remote source option
Add an option to set skipVerify on remote source to disable tls cert
verification on remote source api endpoint
2019-05-22 16:28:42 +02:00
Simone Gotti
0e10a406f9 *: remove server sent events from logs handlers
Just use basic http streaming and send all the data as it's available without
splitting by new lines
2019-05-19 14:35:04 +02:00
Simone Gotti
e2bee03a06 gateway api: return if run is stopping 2019-05-15 14:49:46 +02:00
Simone Gotti
02e0deec15 service: move gateway/common to common
Yes, I know that common and utils are bad package names...
2019-05-15 09:38:27 +02:00
Simone Gotti
6c11ab0596 *: implement update projectgroup 2019-05-14 17:53:48 +02:00
Simone Gotti
7d6223ccd4 gateway: add get org members api/action 2019-05-14 12:58:29 +02:00
Simone Gotti
8f959c4500 cmd: add org member add/remove commands 2019-05-14 11:25:12 +02:00
Simone Gotti
aeda922a7d *: rename deleteOrgMember to removeOrgMember 2019-05-14 11:20:09 +02:00
Simone Gotti
c5cdf01332 *: add organizations visibility 2019-05-14 10:56:17 +02:00
Simone Gotti
c41de71694 gateway api: return linked account id 2019-05-13 23:12:48 +02:00
Simone Gotti
a4744ab7f4 gateway: return right error when remotesource login fails
If the remote source username/password based login fails return the right error
code: 401 (unauthorized) on wrong username/password or a 500 on other errors.
2019-05-13 14:23:41 +02:00
Simone Gotti
4a8d86ae76 gateway: implement projectgroup delete 2019-05-13 00:24:16 +02:00
Simone Gotti
5dfe7f8ce9 gateway api: return projectgroup visibility 2019-05-12 23:24:48 +02:00
Simone Gotti
d2d1a5fb65 gateway api: return project visibility 2019-05-12 23:23:30 +02:00
Simone Gotti
83f6ebe95f gateway: implement updateProject
Update project currently handles updating project name and visibility. In future
we'll add additional update logic.
2019-05-12 23:22:18 +02:00
Simone Gotti
55b4a94281 gateway api: remove unused exposedURL variable 2019-05-12 00:28:11 +02:00
Simone Gotti
0c94386149 gateway: add badges endpoint
Currently we generate badges only for projects branches. In future this could be
extended to also generate badges for tags and PRs
2019-05-10 11:08:24 +02:00
Simone Gotti
c523bcba4e gateway: add delete remote source handler 2019-05-10 00:03:03 +02:00
Simone Gotti
b0fe7e4115 *: implement delete organization member 2019-05-09 17:05:13 +02:00
Simone Gotti
d0309db97f types: add RemoteUserAvatarURL to User 2019-05-09 16:49:02 +02:00
Simone Gotti
b37eddbe8b gateway: remove omitempty json struct tag from UserResponse 2019-05-09 16:48:28 +02:00
Simone Gotti
620bae68df *: implement add/update org member 2019-05-09 16:47:22 +02:00
Simone Gotti
8069063e0d gateway: add project update repo linked account api
Change the project repo linked account to the one of the current user
2019-05-09 15:36:47 +02:00
Simone Gotti
a43be4a6be gateway: update CreateProject api
remove currentuserid since we can get it directly in the action
2019-05-09 15:34:58 +02:00
Simone Gotti
e4e7de4ad2 runservice/gateway: return run on run action 2019-05-07 23:23:58 +02:00
Simone Gotti
4154be3370 *: set sshhostkey and skip check on remote source 2019-05-07 15:59:08 +02:00
Simone Gotti
afae185e11 *: rework run approval and annotations
* runservice: use generic task annotations instead of approval annotations
* runservice: add method to set task annotations

* gateway: when an user call the run task approval action, it will set in the
task annotations the approval users ids. The task won't be approved.

* scheduler: when the number of approvers meets the required minimum number
(currently 1) call the runservice to approve the task

In this way we could easily implement some approval features like requiring a
minimum number of approvers (saved in the task annotations) before marking the
run as approved in the runservice.
2019-05-06 15:19:29 +02:00