Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Moving Github Source to contrib folder (#456)
Browse files Browse the repository at this point in the history
* Adding knative-sources namespace to gcppubsub's ServiceAccount.

* Fixing bug introduced during a refactor.
GitHub webhooks cannot be created otherwise.

* moving gh to contrib

* adding namespace to others

* adding serving scheme to github source.
updating kafka types to not depend on a github type.

* updating development README

* updating README

* fixing tests

* sockpuppet

* fixing uts

* removing e2e tests infra suggested by chi, this is not working
  • Loading branch information
nachocano authored and knative-prow-robot committed Jun 11, 2019
1 parent ab19511 commit f8b5ed8
Show file tree
Hide file tree
Showing 70 changed files with 160 additions and 325 deletions.
26 changes: 10 additions & 16 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ follows.

## Installing Sources

Once you've [setup your development environment](#getting-started), install
sources _Github Source_ and _AWS SQS Source_ with:

```shell
ko apply -f config/
```

or install a single source _Camel Source_, _Gcppubsub Source_, _Kafka Source_
with
Once you've [setup your development environment](#getting-started), install any of the sources
_Github Source_, _AWS SQS Source_, _Camel Source_, _Gcppubsub Source_, _Kafka Source_
with:

```
ko apply -f contrib/<source_name>/
Expand All @@ -74,18 +68,18 @@ ko apply -f contrib/<source_name>/
These commands are idempotent, so you can run them at any time to update your
deployment.

You can see things running with:
If you applied the _GitHub Source_, you can see things running with:

```shell
$ kubectl -n knative-sources get pods
NAME READY STATUS RESTARTS AGE
controller-manager-0 1/1 Running 0 2h
NAME READY STATUS RESTARTS AGE
github-controller-manager-0 1/1 Running 0 2h
```

You can access the Eventing Manager's logs with:
You can access the Github eventing manager's logs with:

```shell
kubectl -n knative-sources logs $(kubectl -n knative-sources get pods -l control-plane=controller-manager -o name)
kubectl -n knative-sources logs $(kubectl -n knative-sources get pods -l control-plane=github-controller-manager -o name)
```

_See
Expand All @@ -100,7 +94,7 @@ As you make changes to the code-base:

- **If you change a package's deps** (including adding external dep), then you
must run [`./hack/update-deps.sh`](./hack/update-deps.sh).
- **If you change a type definition ([pkg/apis/](./pkg/apis/.)),** then you must
- **If you change a type definition (contrib/<source_name>/pkg/apis/),** then you must
run [`./hack/update-codegen.sh`](./hack/update-codegen.sh). _This also runs
[`./hack/update-deps.sh`](./hack/update-deps.sh)._

Expand Down Expand Up @@ -131,7 +125,7 @@ Running tests as you make changes to the code-base is pretty simple. See
You can delete `Knative Sources` with:

```shell
ko delete -f config/
ko delete -f contrib/<source_name>/config/
```

<!--
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The Knative Eventing Contrib project provides source implementations that:

- Integrate with GitHub
- Integrate with Pub/Sub
- Integrate with Kafka
- Integrate with AWS SQS
- Integrate with Camel K
- Integrate with Websockets
- Expose an ingress

Expand Down
2 changes: 0 additions & 2 deletions contrib/camel/pkg/reconciler/camelsource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
camelv1alpha1 "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
sourcesv1alpha1 "github.com/knative/eventing-contrib/contrib/camel/pkg/apis/sources/v1alpha1"
"github.com/knative/eventing-contrib/contrib/camel/pkg/reconciler/resources"
genericv1alpha1 "github.com/knative/eventing-contrib/pkg/apis/sources/v1alpha1"
controllertesting "github.com/knative/eventing-contrib/pkg/controller/testing"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
"go.uber.org/zap"
Expand Down Expand Up @@ -65,7 +64,6 @@ func init() {
v1.AddToScheme,
corev1.AddToScheme,
sourcesv1alpha1.SchemeBuilder.AddToScheme,
genericv1alpha1.SchemeBuilder.AddToScheme,
duckv1alpha1.AddToScheme,
camelv1alpha1.SchemeBuilder.AddToScheme,
)
Expand Down
File renamed without changes.
11 changes: 4 additions & 7 deletions cmd/manager/main.go → contrib/github/cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ package main
import (
"log"

"github.com/knative/eventing-contrib/pkg/apis"
_ "github.com/knative/eventing-contrib/pkg/apis/eventing/v1alpha1"
_ "github.com/knative/eventing-contrib/pkg/apis/serving/v1alpha1"
"github.com/knative/eventing-contrib/pkg/controller"
"github.com/knative/eventing-contrib/contrib/github/pkg/apis"
controller "github.com/knative/eventing-contrib/contrib/github/pkg/reconciler"
"github.com/knative/pkg/logging/logkey"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
Expand All @@ -36,7 +33,7 @@ func main() {
logCfg := zap.NewProductionConfig()
logCfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
logger, err := logCfg.Build()
logger = logger.With(zap.String(logkey.ControllerType, "controller-manager"))
logger = logger.With(zap.String(logkey.ControllerType, "github-controller-manager"))
if err != nil {
log.Fatal(err)
}
Expand All @@ -61,7 +58,7 @@ func main() {
}

// Setup all Controllers
if err := controller.AddToManager(mgr, logger.Sugar()); err != nil {
if err := controller.Add(mgr, logger.Sugar()); err != nil {
log.Fatal(err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"net/http"
"os"

"github.com/knative/eventing-contrib/pkg/adapter/github"
github "github.com/knative/eventing-contrib/contrib/github/pkg/adapter"
gh "gopkg.in/go-playground/webhooks.v5/github"
)

Expand Down
18 changes: 18 additions & 0 deletions contrib/github/config/100-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

apiVersion: v1
kind: Namespace
metadata:
name: knative-sources
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: controller-manager
name: github-controller-manager
namespace: knative-sources
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: eventing-sources-controller
name: eventing-sources-github-controller
rules:
# Sources admin
- apiGroups:
Expand All @@ -31,15 +31,6 @@ rules:
- patch
- delete

# ContainerSource from eventing
- apiGroups:
- sources.eventing.knative.dev
resources:
- containersources
- containersources/status
- containersources/finalizers
verbs: *everything

# Sources finalizer
- apiGroups:
- sources.eventing.knative.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: eventing-sources-controller
name: eventing-sources-github-controller
subjects:
- kind: ServiceAccount
name: controller-manager
name: github-controller-manager
namespace: knative-sources
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: eventing-sources-controller
name: eventing-sources-github-controller

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: eventing-sources-addressable-resolver
name: eventing-sources-github-addressable-resolver
subjects:
- kind: ServiceAccount
name: controller-manager
name: github-controller-manager
namespace: knative-sources
# An aggregated ClusterRole for all Addressable CRDs.
# Ref: https://github.com/knative/eventing/blob/master/config/200-addressable-resolvers-clusterrole.yaml
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
apiVersion: v1
kind: Service
metadata:
name: controller
name: github-controller
namespace: knative-sources
labels:
control-plane: controller-manager
control-plane: github-controller-manager
spec:
selector:
control-plane: controller-manager
control-plane: github-controller-manager
ports:
- port: 443
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: controller-manager
name: github-controller-manager
namespace: knative-sources
labels:
control-plane: controller-manager
control-plane: github-controller-manager
spec:
selector:
matchLabels: &labels
control-plane: controller-manager
serviceName: controller-manager
control-plane: github-controller-manager
serviceName: github-controller-manager
template:
metadata:
labels: *labels
spec:
serviceAccountName: controller-manager
serviceAccountName: github-controller-manager
containers:
- image: github.com/knative/eventing-contrib/cmd/manager
- image: github.com/knative/eventing-contrib/contrib/github/cmd/controller
name: manager
env:
- name: GH_RA_IMAGE
value: github.com/knative/eventing-contrib/cmd/github_receive_adapter
value: github.com/knative/eventing-contrib/contrib/github/cmd/receive_adapter
resources:
requests:
cpu: 100m
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package github
package adapter

import (
"context"
Expand All @@ -25,7 +25,7 @@ import (
"strings"

cloudevents "github.com/cloudevents/sdk-go"
sourcesv1alpha1 "github.com/knative/eventing-contrib/pkg/apis/sources/v1alpha1"
sourcesv1alpha1 "github.com/knative/eventing-contrib/contrib/github/pkg/apis/sources/v1alpha1"
"github.com/knative/eventing-contrib/pkg/kncloudevents"
gh "gopkg.in/go-playground/webhooks.v5/github"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package github
package adapter

import (
"bytes"
Expand All @@ -27,7 +27,7 @@ import (
"strings"
"testing"

"github.com/knative/eventing-contrib/pkg/apis/sources/v1alpha1"
"github.com/knative/eventing-contrib/contrib/github/pkg/apis/sources/v1alpha1"

"github.com/google/go-cmp/cmp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package apis

import (
"github.com/knative/eventing-contrib/pkg/apis"
eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
sourcesv1alpha1 "github.com/knative/eventing/pkg/apis/sources/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
apis.AddToSchemes = append(apis.AddToSchemes, sourcesv1alpha1.SchemeBuilder.AddToScheme)
apis.AddToSchemes = append(apis.AddToSchemes, eventingv1alpha1.SchemeBuilder.AddToScheme)
AddToSchemes = append(AddToSchemes, eventingv1alpha1.SchemeBuilder.AddToScheme)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2018 The Knative Authors
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,14 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package apis

import (
"github.com/knative/eventing-contrib/pkg/apis"
servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
apis.AddToSchemes = append(apis.AddToSchemes, servingv1alpha1.SchemeBuilder.AddToScheme)
AddToSchemes = append(AddToSchemes, servingv1alpha1.SchemeBuilder.AddToScheme)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2018 The Knative Authors
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@ limitations under the License.

package apis

import "github.com/knative/eventing-contrib/pkg/apis/sources/v1alpha1"
import "github.com/knative/eventing-contrib/contrib/github/pkg/apis/sources/v1alpha1"

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/apis.go → contrib/github/pkg/apis/apis.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2018 The Knative Authors
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@ limitations under the License.
*/

// Generate deepcopy for apis
//go:generate go run ../../vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./... -h ../../hack/boilerplate.go.txt
//go:generate go run ../../../../vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./... -h ../../../../hack/boilerplate.go.txt

// Package apis contains Kubernetes API groups.
package apis
Expand Down
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f8b5ed8

Please sign in to comment.