-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic in PAC controller on delete tag event in gitlab
fixed panic in PAC controller when a tag delete event occurs in a repository on gitlab. E2E test is added as well to confirm this behaviour. https://issues.redhat.com/browse/SRVKP-6636 Signed-off-by: Zaki Shaikh <[email protected]>
- Loading branch information
Showing
4 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
package test | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/openshift-pipelines/pipelines-as-code/test/pkg/cctx" | ||
tgitlab "github.com/openshift-pipelines/pipelines-as-code/test/pkg/gitlab" | ||
twait "github.com/openshift-pipelines/pipelines-as-code/test/pkg/wait" | ||
"github.com/tektoncd/pipeline/pkg/names" | ||
"github.com/xanzy/go-gitlab" | ||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestGitlabDeleteTagEvent(t *testing.T) { | ||
targetNS := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-ns") | ||
ctx := context.Background() | ||
runcnx, opts, glprovider, err := tgitlab.Setup(ctx) | ||
assert.NilError(t, err) | ||
ctx, err = cctx.GetControllerCtxInfo(ctx, runcnx) | ||
assert.NilError(t, err) | ||
runcnx.Clients.Log.Info("Testing with Gitlab") | ||
|
||
projectinfo, resp, err := glprovider.Client.Projects.GetProject(opts.ProjectID, nil) | ||
assert.NilError(t, err) | ||
if resp != nil && resp.StatusCode == http.StatusNotFound { | ||
t.Errorf("Repository %s not found in %s", opts.Organization, opts.Repo) | ||
} | ||
defer tgitlab.TearDown(ctx, t, runcnx, glprovider, -1, "", targetNS, opts.ProjectID) | ||
|
||
err = tgitlab.CreateCRD(ctx, projectinfo, runcnx, targetNS, nil) | ||
assert.NilError(t, err) | ||
|
||
tagName := "v1.0-test" | ||
err = tgitlab.CreateTag(glprovider.Client, projectinfo.ID, tagName) | ||
assert.NilError(t, err) | ||
runcnx.Clients.Log.Infof("Created Tag %s in %s repository", tagName, projectinfo.Name) | ||
|
||
err = tgitlab.DeleteTag(glprovider.Client, projectinfo.ID, tagName) | ||
assert.NilError(t, err) | ||
runcnx.Clients.Log.Infof("Deleted Tag %s in %s repository", tagName, projectinfo.Name) | ||
|
||
reg := regexp.MustCompile("event Delete Tag Push Hook is not supported*") | ||
err = twait.RegexpMatchingInControllerLog(ctx, runcnx, *reg, 10, "controller", gitlab.Ptr(int64(20))) | ||
assert.NilError(t, err) | ||
} | ||
|
||
// Local Variables: | ||
// compile-command: "go test -tags=e2e -v -run TestGitlabDeleteTagEvent$ ." | ||
// End: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters