Commit Graph

171 Commits

Author SHA1 Message Date
Simone Gotti e18794764e go.mod: update dependencies
Update all the updatable dependencies
2019-10-29 09:31:38 +01:00
Simone Gotti 446e626f9f gateway: fix project create run http method
Make it a POST instead of a PUT.
2019-10-22 09:50:01 +02:00
Simone Gotti fa4b41ab74 when: match only the current ref type
Only match the current ref type, ie: don't match a branch when the ref type is a
tag or pull request.

Ref is always matched because it's not related to a specific ref type.
2019-10-14 17:08:44 +02:00
Carlo Mandelli 4fc8f3ebed cmd: add version command 2019-10-05 12:11:18 +02:00
Simone Gotti 11da186913 gateway: add parentRef field to project group update api
and make all the request fields optional
2019-10-01 14:39:45 +02:00
Simone Gotti 8b9464486d gateway: add parentRef field to project update api
and make all the request fields optional
2019-09-27 17:10:04 +02:00
Simone Gotti f5c0e91f39 gateway: api implement get secrets removeoverridden
Implement missing removeoverridden option for get secrets.
2019-09-20 15:39:21 +02:00
Carlo Mandelli 436aa8f1de skip run with special commit 2019-09-18 11:53:22 +02:00
Simone Gotti 9cfb21d365 gateway: run api return more step data
For every step return the step type.

For a run step also return the shell and exit status.
2019-09-17 17:43:48 +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 db742a6cd6 config: add run when field
Don't create a run if a when condition is defined and it doesn't match.
2019-08-05 16:07:47 +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 bd035e9840 util: use context in backoff 2019-07-26 10:36:11 +02:00
Simone Gotti b8c2b4020a db: use context functions
Use the go sql context functions (ExecContext, QueryContext etc...)

The context is saved inside Tx so the library users should only pass it one time
to the db.Do function.
2019-07-25 14:49:53 +02:00
Simone Gotti 86d822a247 service: handle cors config and use it only on gateway
* Don't make cors enabled on all (*) by default.
* Handle related web.allowedOrigins options
* Only the gateway api should be called by a browser so setup the cors handler
only on it
2019-07-13 23:15:00 +02:00
Simone Gotti 5483620fb0 gateway: return project if the project is public
If the project is public don't require the user to be logged in to show the
project.
2019-07-12 23:41:34 +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 04ef20464d runservice: add getruns filter by result 2019-07-05 10:32:51 +02:00
Simone Gotti 929a6fb654 service/*: log error only if nil 2019-07-04 15:50:37 +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 5c2bf8642f gateway: show run/tasks/steps if the project is public
If the project is public don't require the user to be logged in to show the
run/tasks/logs
2019-07-01 16:40:02 +02:00
Simone Gotti 8d67844cc4 *: use vanity url
use agola.io domain
2019-07-01 11:40:20 +02:00
Simone Gotti 0c30839f5c gateway: cleanup remote repo on project delete 2019-06-14 15:17:19 +02:00
Simone Gotti f2be16ce4d gateway: cleanup project if remote setup fails
If the remote setup steps fails (create webhook and deploy key) try to delete
project and cleanup remote repo.
2019-06-14 14:57:59 +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 369f116bfc gateway webhook: remove handling of user direct runs 2019-06-11 15:17: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 cff6b8d531 *: rename user local run to user direct run 2019-06-11 12:09:57 +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 5b22ebc2d3 webhook: add run creation trigger type 2019-06-10 17:04:50 +02:00
Simone Gotti 1938c2daaf webhook: use runRefType instead of webhook Event 2019-06-10 16:52:51 +02:00
Simone Gotti 28ddfb1781 webhook: add runRefType and convert webhook event
Introduce a runRefType that represent the ref type of the Run (branch/tag/PR)
Convert the webhook event type to the runRefType and use it to generate the run
group.
2019-06-10 16:49:39 +02:00
Simone Gotti 38b54b092c webhook: remove annotation virtual branch 2019-06-10 16:37:32 +02:00
Simone Gotti aad661adc8 gateway: don't use maxBytesHandler in gitserver proxy handler
a git object could much be greater than 1MiB.
2019-06-08 16:26:22 +02:00
Simone Gotti 5c4dff0fd9 webhook: export git branch and tag env vars
export AGOLA_GIT_BRANCH and AGOLA_GIT_TAG env vars. They will be mutually empty
if on a branch or tag.
2019-05-24 16:17:00 +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