Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add base support for Knative eventing #215

Merged
merged 3 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 76 additions & 3 deletions Gopkg.lock

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

13 changes: 13 additions & 0 deletions deploy/operator-role-knative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ rules:
- patch
- update
- watch
- apiGroups:
- eventing.knative.dev
resources:
- "*"
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
13 changes: 13 additions & 0 deletions deploy/resources.go

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

22 changes: 22 additions & 0 deletions pkg/metadata/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ limitations under the License.
package metadata

import (
"regexp"
"sort"
"strings"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/util/camel"
)

var (
additionalDependencies = map[string]string {
".*JsonLibrary\\.Jackson.*": "camel:jackson",
}
)

// discoverDependencies returns a list of dependencies required by the given source code
func discoverDependencies(source v1alpha1.SourceSpec, fromURIs []string, toURIs []string) []string {
candidateMap := make(map[string]bool)
Expand All @@ -37,6 +44,10 @@ func discoverDependencies(source v1alpha1.SourceSpec, fromURIs []string, toURIs
candidateMap[candidateComp] = true
}
}
additional := findAdditionalDependencies(source)
for _, dep := range additional {
candidateMap[dep] = true
}
// Remove duplicates and sort
candidateComponents := make([]string, 0, len(candidateMap))
for cmp := range candidateMap {
Expand All @@ -61,3 +72,14 @@ func decodeComponent(uri string) string {
}
return ""
}

func findAdditionalDependencies(source v1alpha1.SourceSpec) []string {
additional := make([]string, 0)
for pattern, dep := range additionalDependencies {
pat := regexp.MustCompile(pattern)
if pat.MatchString(source.Content) {
additional = append(additional, dep)
}
}
return additional
}