Simone Gotti
810abaaab8
git-save: return commitSHA
2019-06-11 15:04:34 +02:00
Simone Gotti
853082d4f5
git-save: make ref prefix configurable
...
and add a method to return it
2019-06-11 15:04:01 +02:00
Simone Gotti
f7faab353e
git util: fix Get/SetConfig error reporting
2019-06-11 12:46: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
fafcf3a623
gitsource: add new methods to handle refs and commits
...
Add new methods to handle refs and commits and related urls
2019-06-11 11:07:39 +02:00
Simone Gotti
47b7c5040f
gitsource: add repoinfo HTMLURL
2019-06-11 11:07:12 +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
580746d7f1
gitsource: update gitea client
2019-06-11 10:29:06 +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
863277af2d
runservice types: refactor unmarshal
...
* Don't use a complex UnmarshalJSON for RunConfigTask and ExecutorTask but
introduce a Steps type as a slice of Step (where Step is an empty interface)
and declare an UnmarshalJSON method on the Step type.
2019-06-08 16:30:36 +02:00
Simone Gotti
96c0fa9aea
config: refactor config unmarshal
...
* Don't use a complex UnmarshalJSON for Task but use specific UnmarshalJSON for
every type that requires custom unmarshaling
2019-06-08 16:07:15 +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
22bd181fc8
datamanager: implement data files splitting
...
split data files in multiple files of a max size (default 10Mib)
In this way every data snapshot will change only the datafiles that have some
changes instead of the whole single file.
2019-06-03 16:17:27 +02:00
Simone Gotti
8e4555373d
objectstorage: honor write size in posix objectstorage
2019-06-05 14:56:56 +02:00
Simone Gotti
6d095cbe50
readdb: ensure that we apply only etcd committed wals
...
Ensure that we apply only etcd commited wals to avoid doing an unuseful insert
when the wal becomes committed storage.
2019-06-03 18:02:09 +02:00
Luigi Leoni
51a5594c89
gitlab: check getFile exists before content encoding
2019-05-29 15:51:34 +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
42f578a0b5
config: add more validations to task steps
2019-05-24 11:57:10 +02:00
Simone Gotti
7658c44694
config: make runtime type pod the default
...
In this way users are not forced to always set it in the config file.
2019-05-23 23:23:54 +02:00
Simone Gotti
c0a165de31
runservice: fix query when grouping by path
...
When grouping by group path we have to apply the filter to the group by using
HAVING and not using WHERE
2019-05-23 23:21:45 +02:00
Simone Gotti
03a0d38b10
gateway: update and log errors on remoterepo api
2019-05-23 17:30:20 +02:00
Simone Gotti
51945513bf
gitsources: list only repo with enough permissions
...
ListUserRepos will return only repos where the user has enough permissions to
create webhooks and deploy keys
2019-05-23 16:58: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
b8bdd096fe
gitea: don't check webhook signature if not sent
...
old versions of gitea doesn't provide a webhook signature but just the secret in
the payload
TODO(sgotti) check the payload secret in this case
2019-05-22 11:39:27 +02:00
Simone Gotti
b3867fb7ca
objectstorage: add posix standard storage
...
rename the previous posix storage to posixflat and make it currently not user
selectable (since I'm not sure it's really worth using it).
The new posix storage uses the filesystem without any escaping so it's not a
real flat namespace.
This isn't a real issue since also minio is not a flat namespace and we are so
forced to use it like a hierarchycal filesystem.
2019-05-21 15:17:53 +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
c02ed89d6e
webbundle: give preference to generated config.js
2019-05-16 10:05:32 +02:00
Simone Gotti
30f398e361
gateway: move login/oauth endpoints under /api
...
In this way, when bundling the web interface inside the agola binaries, oauth2
redirect to the web interfaces will be served by the webbundle handler and
return the web SPA and not resolve directly the /oauth2/callback api call.
2019-05-16 10:05:21 +02:00
Simone Gotti
b22c197fef
gitsources: add github gitsource
2019-05-15 23:46:21 +02:00
Simone Gotti
eabf6c8a92
gateway: fix wrong error message
2019-05-15 23:22:05 +02:00
Simone Gotti
faded9b809
docker driver: handle already deleted containers
...
don't expect that all the containers of a pod are available. Some could be
already be removed. Improve the logic of sorting containers by their index.
2019-05-15 15:55:08 +02:00
Simone Gotti
821e371cd8
executor: don't start task if max tasks limit has been reached
2019-05-15 15:06:46 +02:00
Simone Gotti
e2bee03a06
gateway api: return if run is stopping
2019-05-15 14:49:46 +02:00
Simone Gotti
bda7a3eb8b
*: add run cancel action
...
and remove unused change phase to finished
2019-05-15 14:42:50 +02:00
Simone Gotti
9cafc36a0d
notification service: initial implementation
2019-05-15 10:17:20 +02:00
Simone Gotti
2d6ddd0e74
gitsources: add commit status of type error
2019-05-15 11:26:50 +02:00
Simone Gotti
81d557d785
runservice: add runEvents handler
2019-05-15 09:46:21 +02:00
Simone Gotti
ac893f1c91
runservice: trigger run event in change run phase action
2019-05-15 09:41:56 +02:00
Simone Gotti
846567b96a
etcd: add WatchKey function
2019-05-15 09:41:06 +02:00
Simone Gotti
b95fb98f3c
runservice: move RunEvent to types
2019-05-15 09:40:32 +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
21e706a150
configstore: add get org members api/action
2019-05-14 12:57:53 +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
a7ecfee795
gitea: use custom http request for get tokens
...
Since the get tokens gitea api is used to do auth by username password we need
to know the api status code to detect if it's an unauthorized error (wrong
username/password) or another error.
Since the gitea client doesn't return the http response to inspect the status
code we'll use our own api call.
2019-05-13 14:21:41 +02:00
Simone Gotti
8331c43a18
util errors: add ErrUnauthorized
2019-05-13 14:20:31 +02:00
Simone Gotti
4a8d86ae76
gateway: implement projectgroup delete
2019-05-13 00:24:16 +02:00
Simone Gotti
d551dcb820
configstore: implement projectgroup delete
2019-05-13 00:23:57 +02:00
Simone Gotti
5c15eb4db7
configstore: move getvariables to action
2019-05-13 00:23:08 +02:00
Simone Gotti
295ed6e39a
configstore: move get secret(s) to action
2019-05-13 00:22:23 +02:00
Simone Gotti
0f9445aabe
configstore: move get projecgroup projects/subgroups to action
2019-05-13 00:21:10 +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
4c35c88b32
fix auth
2019-05-12 23:19:56 +02:00
Simone Gotti
8e70c6b1b9
gateway: use authOptionalHandle with logHandler
...
or it'll fail when fetching logs on user runs since the logged in userid is not
set in the context
2019-05-12 00:28:50 +02:00
Simone Gotti
55b4a94281
gateway api: remove unused exposedURL variable
2019-05-12 00:28:11 +02:00
Simone Gotti
caa9d74b72
runservice: implement additional service containers
...
This was already defined in the config but not implemented in the executor and
drivers.
All the containers defined in the runtime after the first one will be "service"
containers. They will share the same network namespace with the other containers
in the "pod" so they can communicate between themself on loopback
2019-05-10 17:31:23 +02:00
Simone Gotti
7adca3ea30
runservice drivers: define ExecConfig AttachStdin
2019-05-10 16:50:31 +02:00
Simone Gotti
ba5399b97e
config/runconfig: add global docker registries auth
2019-05-10 11:45:00 +02:00
Simone Gotti
59e4a1f0ba
runservice: update runconfig group comment
2019-05-10 11:16:57 +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
c9fb7258ec
configstore: fix delete remote source action
2019-05-10 00:02:37 +02:00
Simone Gotti
da224c7580
executor: make docker driver logger sugared
2019-05-09 23:44:41 +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
e1d0318c9b
configstore: add UpdateProject api
2019-05-09 15:33:57 +02:00
Simone Gotti
79c1a60a36
configstore: update CreateProject action
...
* move validation to ValidateProject function
* remove wrong project group check
2019-05-09 15:32:27 +02:00
Simone Gotti
92de7591da
gitsources: implement gitea oauth2 auth
...
As from https://github.com/go-gitea/gitea/pull/5378 gitea is an oauth2 provider.
2019-05-09 14:14:13 +02:00
Simone Gotti
4e785e4851
runservice: build and use multiple toolboxes per architecture
2019-05-09 12:36:30 +02:00
Simone Gotti
ce7924d7fd
runservice: use the path escaped cache key
...
Use the path escaped cache key so we can also handle cache keys with slashes
inside.
2019-05-08 12:15:17 +02:00
Simone Gotti
bec9476d6c
runservice: store related runid with logs and archives
...
Logs and archives can be shared by multiple runs. So removing a run doesn't
imply that we could also remote the logs and archives since they could be
"referenced" by another run.
Store also the runids as specific objects along with the logs and archives so,
we'll remove them only when no runids objects exist.
2019-05-08 12:11:46 +02:00
Simone Gotti
43341f2cba
*: rename GitServer to Gitserver
2019-05-08 15:23:13 +02:00
Simone Gotti
1e34dca95d
runservice: split and simplify scheduler and executor naming
...
Also if they are logically part of the runservice the names runserviceExecutor
and runserviceScheduler are long and quite confusing for an external user
Simplify them separating both the code parts and updating the names:
runserviceScheduler -> runservice
runserviceExecutor -> executor
2019-05-07 23:56:10 +02:00
Simone Gotti
44d5b0f25a
*: rename ConfigStore to Configstore
2019-05-07 23:42:42 +02:00
Simone Gotti
e4e7de4ad2
runservice/gateway: return run on run action
2019-05-07 23:23:58 +02:00
Simone Gotti
83273489e0
jwt: unify token generation functions
2019-05-07 18:30:20 +02:00
Simone Gotti
649c42f75b
gitsources: create secret and webhook secret
...
Use the webhook secret on webhook creation and check it and webhook receive
2019-05-07 18:29:31 +02:00
Simone Gotti
2675aee333
configstore: generate User and Project secret
2019-05-07 17:16:42 +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
Simone Gotti
a590c21127
runservice api: get run from readdb
2019-05-06 15:18:49 +02:00
Simone Gotti
3139ef38d9
runservice readdb: get run from ost db if it's not in run db
2019-05-06 14:55:10 +02:00
Simone Gotti
a04dd62e91
gateway: initial authorization
2019-05-03 23:19:23 +02:00
Simone Gotti
081ac8a44f
gateway: move webhook genGroup to common as GenRunGroup
2019-05-05 23:58:40 +02:00
Simone Gotti
6ef5649b21
gateway: set user admin value in context
2019-05-05 17:30:38 +02:00
Simone Gotti
6dfb789e77
gateway: project(group) create: rename parentID to parentRef
2019-05-05 17:19:23 +02:00
Simone Gotti
05ae46a72d
gateway: move run logic from api to actions
2019-05-06 00:00:45 +02:00
Simone Gotti
6b5bd40417
gateway: move remaining remotesource logic from api to actions
2019-05-05 14:54:16 +02:00
Simone Gotti
42184d0b5b
gateway: move remaining user logic from api to actions
2019-05-05 14:45:19 +02:00
Simone Gotti
96918e9bad
gateway: move remaining org logic from api to actions
2019-05-05 14:36:14 +02:00
Simone Gotti
c889c2c1c2
gateway: move remaining project(group) logic from api to actions
2019-05-05 14:27:22 +02:00
Simone Gotti
64044df94d
gateway: move secret logic from api to actions
2019-05-05 14:11:29 +02:00
Simone Gotti
f73f0ba434
gateway: move variable logic from api to actions
2019-05-04 15:16:49 +02:00
Simone Gotti
cb78ea48bc
runservice: rename command(handler) to action(handler)
...
Since we're going to migrate all actions (also queries that now are implemented
in the api handlers) there
2019-05-03 23:59:21 +02:00
Simone Gotti
3f7e554f04
gateway: rename command(handler) to action(handler)
...
Since we're going to migrate all actions (also queries that now are implemented
in the api handlers) there
2019-05-03 23:48:49 +02:00
Simone Gotti
ca5b5f3a7e
configstore: rename command(handler) to action(handler)
...
Since we're going to migrate all actions (also queries that now are implemented
in the api handlers) there
2019-05-03 23:35:25 +02:00
Simone Gotti
5a50a2681d
util/errors: add ErrForbidden
2019-05-03 23:18:51 +02:00
Simone Gotti
af67198dec
configstore: report project/projectgroup owners
...
Return project and projectgroup owner type (user or org) and their id.
2019-05-03 23:17:07 +02:00
Simone Gotti
81d656b7a3
configstore: implement organization members
2019-05-03 17:40:07 +02:00
Simone Gotti
a269347c9d
types: add Admin field to User
2019-05-03 17:38:12 +02:00
Simone Gotti
041e8867f8
*: add creatorUserID and cretedAt to organization
2019-05-03 14:24:18 +02:00
Simone Gotti
c30707528f
configstore: split commands in multiple files
2019-05-03 12:47:22 +02:00
Simone Gotti
60feff5cef
configstore: add more validations
...
All the validation must be done inside the configstore since it's the source of
truth.
The gateway could also do some validation to avoid bad requests to the
configstore when needed or when the logic resides outside the configstore (like
project setup or user registration)
2019-05-03 12:41:49 +02:00
Simone Gotti
1f09eea949
project: add remote repository config type
...
RemoteRepositoryConfigType defines how a remote repository is configured and
managed. Currently only "remotesource" is supported.
In future other config types (like a fully manual config) could be supported.
2019-05-03 12:21:44 +02:00
Simone Gotti
ea02eed2d9
* api: accept both ids or names in the same endpoint
...
Simplify api to accept both ids or names in the same endpoint
2019-05-03 11:07:53 +02:00
Simone Gotti
6943c10dc9
types: add RemoteSourceID to Project
...
In future we may support specifying a remote source for a project without a
linked account and thus use a user provided token (saved in the project) or
other ways to define a remote repo (like standard git repos over ssh).
2019-05-03 09:55:37 +02:00
Simone Gotti
b9db3137ad
gateway api: return user linked accounts
2019-05-03 09:54:47 +02:00
Simone Gotti
9349728997
configstore: add update user
2019-05-03 09:53:38 +02:00
Simone Gotti
ab7e4b8a4b
gateway: add user remote repos API
2019-05-03 00:11:11 +02:00
Simone Gotti
0471bf0c30
validation: make uuid like names not valid
...
names that are valid uuids are not valid. This is needed to accept both names or
uuid in rest APIs without using a special syntax to distinguish them
2019-05-02 23:40:28 +02:00
Simone Gotti
bad18bf814
*: report objects size for objectstorage.WriteObject
2019-05-02 09:49:55 +02:00
Simone Gotti
34cfdfeb3b
objectstorage: add size option to WriteObject
...
On s3 limit the max object size to 1GiB when the size is not provided (-1) or
the minio client will calculate a big part size since it tries to use the
maximum object size (5TiB) and will allocate a very big buffer in ram. Also
leave as commented out the previous hack that was firstly creating the file
locally to calculate the size and then put it (for future reference).
2019-05-02 09:47:38 +02:00
Simone Gotti
e964aa3537
objectstorage: add persist option to WriteObject
...
This options is a noop on s3 but on the posix implementation it becomes useful
when there isn't the need to have a persistent file, thus avoiding some fsync
calls.
2019-05-01 15:06:47 +02:00
Simone Gotti
68e6bd5bdf
configstore: add project/projectgroup visibility
2019-04-30 17:09:26 +02:00
Simone Gotti
b1c9892378
configstore: report project/projectgroup path
...
and also parent path
2019-04-30 17:09:26 +02:00
Simone Gotti
c7585a6152
configstore: resolve also org and user paths
2019-05-03 13:48:19 +02:00
Simone Gotti
2215aaebfa
configstore: rename GetParentPath to GetPath
...
and rename file from parent.go to resolve.go
2019-04-30 17:06:44 +02:00
Simone Gotti
984efb539e
configstore: use augmented types for vars/secrets dynamic values
2019-04-30 16:28:01 +02:00
Simone Gotti
da2ac0ab38
util: add path functions
...
add IsParentPath and IsSameOrParent path functions and related tests
2019-04-30 16:24:04 +02:00
Simone Gotti
27f84738d6
runservice: simplify workspace restore
2019-04-30 14:00:34 +02:00
Simone Gotti
1820e7c477
types: rename user UserName field to Name
2019-04-30 12:56:43 +02:00
Simone Gotti
1e1152cb1a
gateway: set agolaid query parameter in webhook url
2019-04-30 12:13:51 +02:00
Simone Gotti
fefa2819c9
gateway: use agola ID in gitsource tokenname
2019-04-30 12:13:12 +02:00
Simone Gotti
e970e217e2
config: add global agola id field
2019-04-30 12:08:59 +02:00
Simone Gotti
559a389b59
gitsources: add ListUserRepos method
2019-04-29 17:36:29 +02:00
Simone Gotti
507a9edb87
gitsources: add CreateCommitStatus method
2019-04-29 17:35:07 +02:00
Simone Gotti
2fab8ad85b
configstore: check token name is not empty
2019-04-29 16:59:09 +02:00
Simone Gotti
cbd971619b
gateway: refresh oauth2 token when needed
...
refresh the oauth2 access token when needed and update the related linked
account.
2019-04-29 15:42:10 +02:00
Simone Gotti
9393830207
gitsource: add RefreshOauth2Token method to Oauth2Source
2019-04-29 15:39:59 +02:00
Simone Gotti
95e73e66a0
oauth2: correctly populate token expiry data
...
* Populate the field when needed
* Convert it to a time instead of a duration
2019-04-29 14:57:07 +02:00
Simone Gotti
52bcf096c7
gitea source: add custom http transport
2019-04-29 11:24:03 +02:00