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>
This commit is contained in:
Gabriel Adrian Samfira 2023-08-16 10:02:22 +00:00
parent bb6ee9c668
commit c00048e128
No known key found for this signature in database
GPG key ID: 7D073DCC2C074CB5
7 changed files with 108 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewDeleteRepoParams creates a new DeleteRepoParams object,
@ -61,6 +62,12 @@ DeleteRepoParams contains all the parameters to send to the API endpoint
*/
type DeleteRepoParams struct {
/* KeepWebhook.
If true and a webhook is installed for this repo, it will not be removed.
*/
KeepWebhook *bool
/* RepoID.
ID of the repository to delete.
@ -120,6 +127,17 @@ func (o *DeleteRepoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithKeepWebhook adds the keepWebhook to the delete repo params
func (o *DeleteRepoParams) WithKeepWebhook(keepWebhook *bool) *DeleteRepoParams {
o.SetKeepWebhook(keepWebhook)
return o
}
// SetKeepWebhook adds the keepWebhook to the delete repo params
func (o *DeleteRepoParams) SetKeepWebhook(keepWebhook *bool) {
o.KeepWebhook = keepWebhook
}
// WithRepoID adds the repoID to the delete repo params
func (o *DeleteRepoParams) WithRepoID(repoID string) *DeleteRepoParams {
o.SetRepoID(repoID)
@ -139,6 +157,23 @@ func (o *DeleteRepoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re
}
var res []error
if o.KeepWebhook != nil {
// query param keepWebhook
var qrKeepWebhook bool
if o.KeepWebhook != nil {
qrKeepWebhook = *o.KeepWebhook
}
qKeepWebhook := swag.FormatBool(qrKeepWebhook)
if qKeepWebhook != "" {
if err := r.SetQueryParam("keepWebhook", qKeepWebhook); err != nil {
return err
}
}
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err