Skip to content

Commit

Permalink
Use v1beta1 Pipeline types for Params and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom committed Mar 20, 2020
1 parent 7e61331 commit 7543317
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 122 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/triggers/v1alpha1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"fmt"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/triggers/v1alpha1/event_listener_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"net/http"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"k8s.io/apimachinery/pkg/util/validation"
"knative.dev/pkg/apis"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/triggers/v1alpha1/trigger_binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1

import (
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/triggers/v1alpha1/trigger_binding_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"context"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"knative.dev/pkg/apis"
)

Expand All @@ -36,7 +36,7 @@ func (s *TriggerBindingSpec) Validate(ctx context.Context) *apis.FieldError {
return nil
}

func validateParams(params []v1alpha1.Param) *apis.FieldError {
func validateParams(params []v1beta1.Param) *apis.FieldError {
// Ensure there aren't multiple params with the same name.
seen := map[string]struct{}{}
for _, param := range params {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/triggers/v1alpha1/trigger_template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func init() {

// TriggerTemplateSpec holds the desired state of TriggerTemplate
type TriggerTemplateSpec struct {
Params []pipelinev1alpha1.ParamSpec `json:"params,omitempty"`
ResourceTemplates []TriggerResourceTemplate `json:"resourcetemplates,omitempty"`
Params []pipelinev1beta1.ParamSpec `json:"params,omitempty"`
ResourceTemplates []TriggerResourceTemplate `json:"resourcetemplates,omitempty"`
}

// TriggerResourceTemplate describes a resource to create
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/triggers/v1alpha1/trigger_template_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"regexp"
"strings"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/apis/validate"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion pkg/interceptors/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"net/url"
"time"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/triggers/pkg/interceptors"
corev1 "k8s.io/api/core/v1"

Expand Down
2 changes: 1 addition & 1 deletion pkg/interceptors/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
corev1 "k8s.io/api/core/v1"
)
Expand Down
54 changes: 27 additions & 27 deletions pkg/sink/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"

"github.com/gorilla/mux"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/logging"
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
dynamicclientset "github.com/tektoncd/triggers/pkg/client/dynamic/clientset"
Expand Down Expand Up @@ -63,7 +63,7 @@ func init() {
}

// Compare two PipelineResources for sorting purposes
func comparePR(x, y pipelinev1.PipelineResource) bool {
func comparePR(x, y pipelinev1alpha1.PipelineResource) bool {
return x.GetName() < y.GetName()
}

Expand Down Expand Up @@ -93,14 +93,14 @@ func getSinkAssets(t *testing.T, resources test.Resources, elName string) (Sink,
}

// getCreatedPipelineResources returns the pipeline resources that were created from the given actions
func getCreatedPipelineResources(t *testing.T, actions []ktesting.Action) []pipelinev1.PipelineResource {
func getCreatedPipelineResources(t *testing.T, actions []ktesting.Action) []pipelinev1alpha1.PipelineResource {
t.Helper()
prs := []pipelinev1.PipelineResource{}
prs := []pipelinev1alpha1.PipelineResource{}
for i := range actions {
obj := actions[i].(ktesting.CreateAction).GetObject()
// Since we use dynamic client, we cannot directly get the concrete type
uns := obj.(*unstructured.Unstructured).Object
pr := pipelinev1.PipelineResource{}
pr := pipelinev1alpha1.PipelineResource{}
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(uns, &pr); err != nil {
t.Errorf("failed to get created pipeline resource: %v", err)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestHandleEvent(t *testing.T) {
eventBody := json.RawMessage(`{"head_commit": {"id": "testrevision"}, "repository": {"url": "testurl"}, "foo": "bar\t\r\nbaz昨"}`)
numTriggers := 10

pipelineResource := pipelinev1.PipelineResource{
pipelineResource := pipelinev1alpha1.PipelineResource{
TypeMeta: metav1.TypeMeta{
APIVersion: "tekton.dev/v1alpha1",
Kind: "PipelineResource",
Expand All @@ -147,9 +147,9 @@ func TestHandleEvent(t *testing.T) {
"type": "$(params.type)",
},
},
Spec: pipelinev1.PipelineResourceSpec{
Type: pipelinev1.PipelineResourceTypeGit,
Params: []pipelinev1.ResourceParam{
Spec: pipelinev1alpha1.PipelineResourceSpec{
Type: pipelinev1alpha1.PipelineResourceTypeGit,
Params: []pipelinev1alpha1.ResourceParam{
{Name: "url", Value: "$(params.url)"},
{Name: "revision", Value: "$(params.revision)"},
},
Expand Down Expand Up @@ -209,9 +209,9 @@ func TestHandleEvent(t *testing.T) {

checkSinkResponse(t, resp, el.Name)
// Check right resources were created.
var wantPrs []pipelinev1.PipelineResource
var wantPrs []pipelinev1alpha1.PipelineResource
for i := 0; i < numTriggers; i++ {
wantResource := pipelinev1.PipelineResource{
wantResource := pipelinev1alpha1.PipelineResource{
TypeMeta: metav1.TypeMeta{
APIVersion: "tekton.dev/v1alpha1",
Kind: "PipelineResource",
Expand All @@ -227,9 +227,9 @@ func TestHandleEvent(t *testing.T) {
eventIDLabel: eventID,
},
},
Spec: pipelinev1.PipelineResourceSpec{
Type: pipelinev1.PipelineResourceTypeGit,
Params: []pipelinev1.ResourceParam{
Spec: pipelinev1alpha1.PipelineResourceSpec{
Type: pipelinev1alpha1.PipelineResourceTypeGit,
Params: []pipelinev1alpha1.ResourceParam{
{Name: "url", Value: "testurl"},
{Name: "revision", Value: "testrevision"},
},
Expand All @@ -247,7 +247,7 @@ func TestHandleEvent(t *testing.T) {
func TestHandleEventWithInterceptors(t *testing.T) {
eventBody := json.RawMessage(`{"head_commit": {"id": "testrevision"}, "repository": {"url": "testurl"}, "foo": "bar\t\r\nbaz昨"}`)

pipelineResource := pipelinev1.PipelineResource{
pipelineResource := pipelinev1alpha1.PipelineResource{
TypeMeta: metav1.TypeMeta{
APIVersion: "tekton.dev/v1alpha1",
Kind: "PipelineResource",
Expand All @@ -256,9 +256,9 @@ func TestHandleEventWithInterceptors(t *testing.T) {
Name: "my-pipelineresource",
Namespace: namespace,
},
Spec: pipelinev1.PipelineResourceSpec{
Type: pipelinev1.PipelineResourceTypeGit,
Params: []pipelinev1.ResourceParam{{
Spec: pipelinev1alpha1.PipelineResourceSpec{
Type: pipelinev1alpha1.PipelineResourceTypeGit,
Params: []pipelinev1alpha1.ResourceParam{{
Name: "url",
Value: "$(params.url)",
}},
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestHandleEventWithInterceptors(t *testing.T) {
}
checkSinkResponse(t, resp, el.Name)

wantResource := []pipelinev1.PipelineResource{{
wantResource := []pipelinev1alpha1.PipelineResource{{
TypeMeta: metav1.TypeMeta{
APIVersion: "tekton.dev/v1alpha1",
Kind: "PipelineResource",
Expand All @@ -353,9 +353,9 @@ func TestHandleEventWithInterceptors(t *testing.T) {
eventIDLabel: eventID,
},
},
Spec: pipelinev1.PipelineResourceSpec{
Type: pipelinev1.PipelineResourceTypeGit,
Params: []pipelinev1.ResourceParam{
Spec: pipelinev1alpha1.PipelineResourceSpec{
Type: pipelinev1alpha1.PipelineResourceTypeGit,
Params: []pipelinev1alpha1.ResourceParam{
{Name: "url", Value: "testurl"},
},
},
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestHandleEventWithWebhookInterceptors(t *testing.T) {
eventBody := json.RawMessage(`{}`)
numTriggers := 10

resourceTemplate := pipelinev1.PipelineResource{
resourceTemplate := pipelinev1alpha1.PipelineResource{
TypeMeta: metav1.TypeMeta{
APIVersion: "tekton.dev/v1alpha1",
Kind: "PipelineResource",
Expand All @@ -403,8 +403,8 @@ func TestHandleEventWithWebhookInterceptors(t *testing.T) {
Name: "$(params.name)",
Namespace: namespace,
},
Spec: pipelinev1.PipelineResourceSpec{
Type: pipelinev1.PipelineResourceTypeGit,
Spec: pipelinev1alpha1.PipelineResourceSpec{
Type: pipelinev1alpha1.PipelineResourceTypeGit,
},
}
resourceTemplateBytes, err := json.Marshal(resourceTemplate)
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestHandleEventWithWebhookInterceptors(t *testing.T) {
Interceptors: []*triggersv1.EventInterceptor{{
Webhook: &triggersv1.WebhookInterceptor{
ObjectRef: interceptorObjectRef,
Header: []pipelinev1.Param{bldr.Param("Name", fmt.Sprintf("my-resource-%d", i))},
Header: []pipelinev1alpha1.Param{bldr.Param("Name", fmt.Sprintf("my-resource-%d", i))},
},
}},
}
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestHandleEventWithWebhookInterceptors(t *testing.T) {
}
checkSinkResponse(t, resp, el.Name)

var wantPRs []pipelinev1.PipelineResource
var wantPRs []pipelinev1alpha1.PipelineResource
for i := 0; i < numTriggers; i++ {
wantResource := resourceTemplate.DeepCopy()
wantResource.ObjectMeta.Name = fmt.Sprintf("my-resource-%d", i)
Expand Down
2 changes: 1 addition & 1 deletion pkg/template/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"net/http"
"strings"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/template/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
"github.com/tektoncd/triggers/test"
bldr "github.com/tektoncd/triggers/test/builder"
Expand Down
2 changes: 1 addition & 1 deletion pkg/template/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"fmt"
"strings"

pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down
Loading

0 comments on commit 7543317

Please sign in to comment.