Commit graph

544 commits

Author SHA1 Message Date
Gabriel
385a00ef9d
Merge pull request #167 from ionutbalutoiu/refactor-e2e-tests
Refactor integration E2E tests
2023-08-24 15:56:12 +03:00
Ionut Balutoiu
318bc52b57 Refactor integration E2E tests
* General cleanup of the integration tests Golang code. Move the
  `e2e.go` codebase into its own package and separate files.
* Reduce the overall log spam from the integration tests output.
* Add final GitHub workflow step that stops GARM server, and does the
  GitHub cleanup of any orphaned resources.
* Add `TODO` to implement cleanup of the orphaned GitHub webhooks.
  This is useful, if the uninstall of the webhooks failed.
* Add `TODO` for extra missing checks on the GitHub webhooks
  install / uninstall logic.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-24 15:22:46 +03:00
Gabriel
789644c27f
Merge pull request #166 from gabriel-samfira/fix-gh-client-tls-bug
Fix TLS client bug
2023-08-23 14:33:30 +03:00
Gabriel
e263db16c1
Merge pull request #165 from gabriel-samfira/fix-cli-nil-pointer-dereference
Fix nil pointer dereference
2023-08-23 14:28:45 +03:00
Gabriel Adrian Samfira
073ea1175e Fix TLS client bug
The CA bundle must be set on RootCAs to properly validate the remote server.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-23 11:27:18 +00:00
Gabriel Adrian Samfira
fb2bb7fb08 Fix nil pointer dereference
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-23 11:21:15 +00:00
Gabriel
bc0a34bae9
Merge pull request #164 from gabriel-samfira/use-apg-for-password
Use apg to generate passwords
2023-08-22 22:32:40 +03:00
Gabriel Adrian Samfira
6e98c3e088 Use apg to generate passwords
It appears that in some cases, generating passwords by reading /dev/urandom
and piping to tr, fails. Use apg.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 19:32:15 +00:00
Gabriel
348058baf1
Merge pull request #161 from mihaelabalutoiu/add-webhooks-integration-tests
Add webhooks integration tests for `organization` and `repository`
2023-08-22 22:03:45 +03:00
Mihaela Balutoiu
300ad110f0 Add webhooks integration tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-22 21:23:56 +03:00
Gabriel
153df36066
Merge pull request #162 from ionutbalutoiu/fix-e2e-secrets-generation
Fix e2e secrets generation
2023-08-22 11:55:41 +03:00
Ionut Balutoiu
5ced5c4b1c Fix spacing
Remove extra spaces from the `integration-tests.yml` file.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-22 11:47:48 +03:00
Ionut Balutoiu
3d3ce2922d Silence tr stderr output
This seems to be related to the distribution used by the GitHub
`ubuntu-latest` runners, as I can't reproduce it locally on my
Ubuntu 22.04 server.

An useful discussion on this topic:
https://stackoverflow.com/questions/48725875/is-there-a-workaround-for-this-broken-pipe-error

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-22 11:43:06 +03:00
Ionut Balutoiu
8900de7a1b [integration-tests] Update randomStringGenerator bash function
Some integration tests workflows failed with:
```
Error: Invalid format 'ORG_WEBHOOK_SECRET=***'
```
or
```
Error: Invalid format 'GARM_PASSWORD=***'
```

Workflow runs logs:
* https://github.com/cloudbase/garm/actions/runs/5920389694/job/16051606203#step:7:26
* https://github.com/cloudbase/garm/actions/runs/5908193226/job/16027297143#step:7:26

This is a transient error, as it only happens sometimes.

I suspect that sometimes there is some illegal sequence of characters
in the random generated strings. Thus, the GitHub actions logic to
parse the environment fails.

This change removes the special characters that would have a special
meaning in bash, from the `randomStringGenerator` function, in hopes
to fix the transient issue.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-22 11:17:43 +03:00
Gabriel
9a7fbde025
Merge pull request #154 from gabriel-samfira/add-webhook-configuration
Add webhook management for repositories and organizations
2023-08-22 09:48:47 +03:00
Gabriel Adrian Samfira
3b651afe07
Add optional --install-webhook flag when creating repo/org
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
93bfb6fe07
ping the webhook after creation
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
7bd3e0b6f7
Add ping hook functions to client
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
64d3da4034
Update comment on option
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
d57e488f12
Return details in case PAT does not have access
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
c641e1d596
Fixup field name
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
1c0ff85a0d
Add flag to toggle webhook management
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
c00048e128
Add optional keepWebhook flag when removing an entity
The user can opt to not delete the webhook (if installed) when removing
the entity from garm. Garm will only ever try to remove a webhook that
exactly matches the URL that is composed of the base webhook URL configured
in the config.toml file and the unique controller ID that is generated
when the controller is first installed. It should be safe to remove the
webhook when the entity is removed.

Of course, this behavior can be disabled.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:02 +03:00
Gabriel Adrian Samfira
bb6ee9c668
Add keepWebhook flag when deleting entities
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
763eb705d8
Remove webhook when removing an entity & cmd fixes
* When removing a repo or org, we uninstall the webhook as well.
  * Upgrade cobra command and mark "webhook-secret" and "random-webhook-secret"
    as MarkFlagsOneRequired()

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
779afe980e
Add webhook show, return info and some fixes
* Added a webhook show command. This gives us info about the webhook and
    if it is installed.
  * Return webhook info when installing the webhook
  * Small typo fixes.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
6051fa016c
Return bad request if hook already installed
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
dbd41f518d
Add CLI webhook enablement
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
7ce3f007b0
Add functions to (un)install webhooks for orgs and repos
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel Adrian Samfira
f2796f1d5a
Add admin required middleware and webhook endpoint
* Add a new middleware that tests for admin access
  * Add a new controller ID suffixed webhook endpoint. This will be used
    to accept webhook events on a webhook URL that is suffixed with our own
    controller ID.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-22 09:39:01 +03:00
Gabriel
aa2b42fddb
Merge pull request #156 from gabriel-samfira/build-windows
Enable Windows builds
2023-08-18 17:52:29 +03:00
Gabriel Adrian Samfira
af54b55cea Enable Windows builds
This change adds the needed bits to enable Windows builds. This also adds
a new make target to create the release files that will be uploaded as part
of new releases.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-18 14:46:00 +00:00
Gabriel
c9cf114d92
Merge pull request #153 from mihaelabalutoiu/fix-doc-typo
Small fixes for the docs
2023-08-14 16:05:40 +03:00
Mihaela Balutoiu
93c2368c55 Small fixes for the docs
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-14 15:46:26 +03:00
Gabriel
10cc209105
Merge pull request #152 from mihaelabalutoiu/fix-timeout-logic
Fix timeout logic
2023-08-14 14:47:38 +03:00
Mihaela Balutoiu
6b77979ab5 Fix timeout logic
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-14 14:35:07 +03:00
Gabriel
bf509ad9c9
Merge pull request #151 from mihaelabalutoiu/add-timeout
Log `orgPool/repoPool` details on timeout exceeded
2023-08-14 12:33:12 +03:00
Mihaela Balutoiu
475cc6425b Add log orgPool/repoPool details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-14 11:45:10 +03:00
Gabriel
e2b617e12e
Merge pull request #150 from gabriel-samfira/add-controller-info
Add controller info
2023-08-13 02:03:31 +03:00
Gabriel Adrian Samfira
99539edde7 Add controller info
This change adds a new controller info endpoint and associated client and
CLI command. The controller info endpoint returns information about controller
status and configuration.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-12 22:47:50 +00:00
Gabriel
63d2764ddd
Merge pull request #149 from mihaelabalutoiu/add-cleanup-runners
Cleaning up leftover runners for `org/repo`
2023-08-09 17:26:43 +03:00
Mihaela Balutoiu
aa956ae939 Cleaning up leftover runners for org/repo
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-09 16:31:50 +03:00
Gabriel
1a07073820
Merge pull request #148 from mihaelabalutoiu/fix-handle-error
Set pipefail to the script and log org/repo details on timeout exceeded
2023-08-07 12:43:06 +03:00
Mihaela Balutoiu
191d44fb3f Log org/repo details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-07 12:37:09 +03:00
Mihaela Balutoiu
1bd288f56d Set pipefail to the script
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-07 12:37:09 +03:00
Gabriel
29660c0b2c
Merge pull request #147 from gabriel-samfira/add-workflow-dispatch
Add workflow dispatch trigger
2023-08-07 12:35:07 +03:00
Gabriel Adrian Samfira
8c82864e11
Add workflow dispatch trigger
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-07 10:30:50 +03:00
Gabriel
a4bd45bedd
Merge pull request #146 from mihaelabalutoiu/add-upload-artifacts
Add upload artifacts and log instance details on timeout exceeded
2023-08-05 02:06:46 +03:00
Mihaela Balutoiu
97d1202225 Log instance details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-04 23:28:26 +03:00
Mihaela Balutoiu
a7198a7d51 Add upload artifacts
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-04 23:24:43 +03:00