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:
parent
bb6ee9c668
commit
c00048e128
7 changed files with 108 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue