Skip to content

Commit

Permalink
leave the cloudevent client under adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelvillard committed Mar 30, 2020
1 parent b4edb82 commit 748bc17
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/adapter/ping/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/robfig/cron"
"go.uber.org/zap"
sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
"knative.dev/pkg/logging"

"knative.dev/eventing/pkg/adapter/v2"
sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
)

type envConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/adapter/ping/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
adaptertest "knative.dev/eventing/pkg/kncloudevents/v2/test"
adaptertest "knative.dev/eventing/pkg/adapter/v2/test"
)

func TestStart_ServeHTTP(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2
package adapter

import (
"context"
"errors"

"knative.dev/eventing/pkg/kncloudevents/v2/metrics"
"knative.dev/eventing/pkg/adapter/v2/metrics"

cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/cloudevents/sdk-go/v2/event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package adapter

import (
"context"
"testing"

cloudevents "github.com/cloudevents/sdk-go/v2"
"knative.dev/eventing/pkg/kncloudevents/v2/test"
"knative.dev/eventing/pkg/adapter/v2/test"
rectesting "knative.dev/eventing/pkg/reconciler/testing"
duckv1 "knative.dev/pkg/apis/duck/v1"
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/adapter/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/kelseyhightower/envconfig"
"go.opencensus.io/stats/view"
"go.uber.org/zap"
kncloudevents "knative.dev/eventing/pkg/kncloudevents/v2"
"knative.dev/pkg/logging"
"knative.dev/pkg/metrics"
"knative.dev/pkg/profiling"
Expand Down Expand Up @@ -107,7 +106,7 @@ func MainWithContext(ctx context.Context, component string, ector EnvConfigConst
logger.Error("Error loading cloudevents overrides", zap.Error(err))
}

eventsClient, err := kncloudevents.NewCloudEventsClient(env.GetSink(), ceOverrides, reporter)
eventsClient, err := NewCloudEventsClient(env.GetSink(), ceOverrides, reporter)
if err != nil {
logger.Fatal("error building cloud event client", zap.Error(err))
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ import (
"context"
"sync"

"knative.dev/pkg/source"

"knative.dev/eventing/pkg/kncloudevents/v2/metrics"

cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/cloudevents/sdk-go/v2/event"
"knative.dev/pkg/source"

"knative.dev/eventing/pkg/adapter/v2/metrics"
)

type TestCloudEventsClient struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/reconciler/pingsource/jobrunner/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"sync"

"knative.dev/eventing/pkg/adapter/v2"

"github.com/robfig/cron"
"go.uber.org/zap"
"knative.dev/pkg/configmap"
Expand All @@ -30,7 +32,6 @@ import (
eventingclient "knative.dev/eventing/pkg/client/injection/client"
pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource"
pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource"
kncloudevents "knative.dev/eventing/pkg/kncloudevents/v2"
"knative.dev/eventing/pkg/tracing"
tracingconfig "knative.dev/pkg/tracing/config"
)
Expand Down Expand Up @@ -71,7 +72,7 @@ func NewController(
logger.Error("error building statsreporter", zap.Error(err))
}

ceClient, err := kncloudevents.NewCloudEventsClient("", nil, reporter)
ceClient, err := adapter.NewCloudEventsClient("", nil, reporter)
if err != nil {
logger.Fatalw("Error setting up trace publishing", zap.Error(err))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pingsource/jobrunner/pingsource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
clientgotesting "k8s.io/client-go/testing"
adaptertesting "knative.dev/eventing/pkg/adapter/v2/test"
sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
eventingclient "knative.dev/eventing/pkg/client/injection/client"
fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
"knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource"
kncetesting "knative.dev/eventing/pkg/kncloudevents/v2/test"
. "knative.dev/eventing/pkg/reconciler/testing"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestAllCases(t *testing.T) {

logger := logtesting.TestLogger(t)
reporter := &MockStatsReporter{}
ce := kncetesting.NewTestClient(reporter)
ce := adaptertesting.NewTestClient(reporter)

table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler {
r := &Reconciler{
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pingsource/jobrunner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"knative.dev/pkg/source"

cloudevents "github.com/cloudevents/sdk-go/v2"
"knative.dev/eventing/pkg/adapter/v2/metrics"
sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
"knative.dev/eventing/pkg/kncloudevents/v2/metrics"
)

type cronJobsRunner struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/reconciler/pingsource/jobrunner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
"testing"
"time"

kncetesting "knative.dev/eventing/pkg/kncloudevents/v2/test"
adaptertesting "knative.dev/eventing/pkg/adapter/v2/test"
rectesting "knative.dev/eventing/pkg/reconciler/testing"
logtesting "knative.dev/pkg/logging/testing"
)

func TestAddRunRemoveSchedule(t *testing.T) {
logger := logtesting.TestLogger(t)
reporter := &rectesting.MockStatsReporter{}
ce := kncetesting.NewTestClient(reporter)
ce := adaptertesting.NewTestClient(reporter)

runner := NewCronJobsRunner(ce, reporter, logger)

Expand Down Expand Up @@ -62,7 +62,7 @@ func TestAddRunRemoveSchedule(t *testing.T) {
func TestStartStopCron(t *testing.T) {
logger := logtesting.TestLogger(t)
reporter := &rectesting.MockStatsReporter{}
ce := kncetesting.NewTestClient(reporter)
ce := adaptertesting.NewTestClient(reporter)

runner := NewCronJobsRunner(ce, reporter, logger)

Expand All @@ -87,7 +87,7 @@ func TestStartStopCron(t *testing.T) {

}

func validateSent(t *testing.T, ce *kncetesting.TestCloudEventsClient, wantData string) {
func validateSent(t *testing.T, ce *adaptertesting.TestCloudEventsClient, wantData string) {
if got := len(ce.Sent()); got != 1 {
t.Errorf("Expected 1 event to be sent, got %d", got)
}
Expand Down

0 comments on commit 748bc17

Please sign in to comment.