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

Allow the short syntax in knative endpoints #1458

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/cmd/modeline.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
*/

package cmd

import (
"context"
"fmt"
"path"
"path/filepath"

"github.com/apache/camel-k/pkg/util/modeline"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"path/filepath"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/modeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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
Expand All @@ -20,12 +19,12 @@ package cmd

import (
"context"
"io/ioutil"
"os"
"path"
"testing"

"github.com/stretchr/testify/assert"
"io/ioutil"
)

func TestModelineRunSimple(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/trait/knative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) {
"channel-sinks": "channel-sink-1",
"endpoint-sources": "endpoint-source-1",
"endpoint-sinks": "endpoint-sink-1,endpoint-sink-2",
"event-sources": "knative:event",
"event-sinks": "knative:event",
},
},
},
Expand Down Expand Up @@ -141,6 +143,12 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) {
eSink2 := ne.FindService("endpoint-sink-2", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
assert.NotNil(t, eSink2)
assert.Equal(t, "endpoint-sink-2.host", eSink2.Host)

eEventSource := ne.FindService("default", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEvent, "eventing.knative.dev/v1alpha1", "Broker")
assert.NotNil(t, eEventSource)
eEventSink := ne.FindService("default", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEvent, "eventing.knative.dev/v1alpha1", "Broker")
assert.NotNil(t, eEventSink)
assert.Equal(t, "broker-default.host", eEventSink.Host)
}

func TestKnativeEnvConfigurationFromSource(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/knative/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
v1 "k8s.io/api/core/v1"
)

var uriRegexp = regexp.MustCompile(`^knative:[/]*(channel|endpoint|event)/([A-Za-z0-9.-]+)(?:[/?].*|$)`)
var uriRegexp = regexp.MustCompile(`^knative:[/]*(channel|endpoint|event)(?:$|/([A-Za-z0-9.-]+)(?:[/?].*|$))`)
var plainNameRegexp = regexp.MustCompile(`^[A-Za-z0-9.-]+$`)

const (
Expand Down