Repository: apache/camel-k
Pull request #2416 (2021-06-17 09:30:52)

Precise requirements on Minikube instance for development
<!-- Description -->




<!--
Enter your extended release note in the below block. If the PR requires
additional action from users switching to the new release, include the string
"action required". If no release note is required, write "NONE". 

You can (optionally) mark this PR with labels "kind/bug" or "kind/feature" to make sure
the text is added to the right section of the release notes. 
-->

**Release Note**
```release-note
NONE
```



Patch:
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index f2a138639..7ad1b0a5e 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -94,10 +94,10 @@ jobs:
         # Prerequisites
         sudo pip install yq
 
-        export SERVING_VERSION=v0.16.0
-        export EVENTING_VERSION=v0.16.2
-        export KOURIER_VERSION=v0.16.0
-        export SOURCES_VERSION=v0.16.0
+        export SERVING_VERSION=v0.23.1
+        export EVENTING_VERSION=v0.17.9
+        export KOURIER_VERSION=v0.23.0
+        export SOURCES_VERSION=v0.17.8
 
         # Serving
         kubectl apply --filename https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-crds.yaml
@@ -218,10 +218,10 @@ jobs:
           # Prerequisites
           sudo pip install yq
 
-          export SERVING_VERSION=v0.16.0
-          export EVENTING_VERSION=v0.16.2
-          export KOURIER_VERSION=v0.16.0
-          export SOURCES_VERSION=v0.16.0
+          export SERVING_VERSION=v0.23.1
+          export EVENTING_VERSION=v0.17.9
+          export KOURIER_VERSION=v0.23.0
+          export SOURCES_VERSION=v0.17.8
 
           # Serving
           kubectl apply --filename https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-crds.yaml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 986af72af..7b431fb4f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 - Add option to use Nexus repository mirror to speed up e2e testing [\#2387](https://github.com/apache/camel-k/issues/2387)
 - Cannot use camel-util dependency [\#2384](https://github.com/apache/camel-k/issues/2384)
 - Scaling documentation - Add section about knative [\#2380](https://github.com/apache/camel-k/issues/2380)
+- Cannot update integration using kamel run [\#2379](https://github.com/apache/camel-k/issues/2379)
 - Can't set multiline properties in Kamelet bindings [\#2361](https://github.com/apache/camel-k/issues/2361)
 - Maven logs are no longer shown [\#2357](https://github.com/apache/camel-k/issues/2357)
 - examples/RestDSL.java does not work [\#2349](https://github.com/apache/camel-k/issues/2349)
@@ -45,10 +46,14 @@
 - api: provide java bindings [\#2082](https://github.com/apache/camel-k/issues/2082)
 - Kamelet file parameters [\#2080](https://github.com/apache/camel-k/issues/2080)
 - Can't mount secrets with binary data [\#2009](https://github.com/apache/camel-k/issues/2009)
+- Revisit configuration options [\#2003](https://github.com/apache/camel-k/issues/2003)
 - Logging configuration does not affect integrations [\#2000](https://github.com/apache/camel-k/issues/2000)
 - kamelet-binding : suport for error handling [\#1941](https://github.com/apache/camel-k/issues/1941)
+- Add a new configuration type to set build time properties [\#1831](https://github.com/apache/camel-k/issues/1831)
 - builder: use structured logging for maven output [\#1783](https://github.com/apache/camel-k/issues/1783)
 - Add support for podtemplatespec / container in the Integration CRD [\#1657](https://github.com/apache/camel-k/issues/1657)
+- Support custom application.properties for Quarkus builds [\#1534](https://github.com/apache/camel-k/issues/1534)
+- Support adding quarkus.index-dependency entries to scan CDI beans [\#1533](https://github.com/apache/camel-k/issues/1533)
 - Installation on a kind cluster [\#1468](https://github.com/apache/camel-k/issues/1468)
 - Generate CRD documentation for website [\#1137](https://github.com/apache/camel-k/issues/1137)
 - Integration logging configuration [\#580](https://github.com/apache/camel-k/issues/580)
@@ -56,6 +61,11 @@
 
 **Merged pull requests:**
 
+- refactor\(trait\): use bool pointer util functions in knative trait [\#2415](https://github.com/apache/camel-k/pull/2415) ([tadayosi](https://github.com/tadayosi))
+- chore\(build\): Some more go.sum updates [\#2413](https://github.com/apache/camel-k/pull/2413) ([astefanutti](https://github.com/astefanutti))
+- chore\(e2e\): Check Deployment progressing condition after re-run [\#2412](https://github.com/apache/camel-k/pull/2412) ([astefanutti](https://github.com/astefanutti))
+- Doc: new configuration explained [\#2411](https://github.com/apache/camel-k/pull/2411) ([squakez](https://github.com/squakez))
+- fix\(cli\): Use Patch with optimistic lock to update Integration [\#2410](https://github.com/apache/camel-k/pull/2410) ([astefanutti](https://github.com/astefanutti))
 - chore: Upgrade Kubernetes API to v0.20.2 [\#2407](https://github.com/apache/camel-k/pull/2407) ([astefanutti](https://github.com/astefanutti))
 - Update link to video to debug in VS Code [\#2406](https://github.com/apache/camel-k/pull/2406) ([apupier](https://github.com/apupier))
 - chore\(build\): Upgrade Go to version 1.15 [\#2404](https://github.com/apache/camel-k/pull/2404) ([astefanutti](https://github.com/astefanutti))
@@ -80,6 +90,7 @@
 - chore\(doc\): Update high-level architecture diagram [\#2362](https://github.com/apache/camel-k/pull/2362) ([astefanutti](https://github.com/astefanutti))
 - Make it possible to define the container image without IntegrationKit [\#2360](https://github.com/apache/camel-k/pull/2360) ([lburgazzoli](https://github.com/lburgazzoli))
 - Update README to reflect where Sample.java is [\#2359](https://github.com/apache/camel-k/pull/2359) ([bentito](https://github.com/bentito))
+- feat\(cmd/run\): resource option refactoring  [\#2355](https://github.com/apache/camel-k/pull/2355) ([squakez](https://github.com/squakez))
 - Related to \#2165: account for annotations when checking if integratio… [\#2352](https://github.com/apache/camel-k/pull/2352) ([nicolaferraro](https://github.com/nicolaferraro))
 - feat\(cli\): add sub command kamel kamelet for get and delete \#2312 [\#2351](https://github.com/apache/camel-k/pull/2351) ([tadayosi](https://github.com/tadayosi))
 - fix\(cli\): stop printing \<nil\> at the end of kamel describe output [\#2350](https://github.com/apache/camel-k/pull/2350) ([tadayosi](https://github.com/tadayosi))
diff --git a/docs/modules/ROOT/pages/contributing/developers.adoc b/docs/modules/ROOT/pages/contributing/developers.adoc
index 458b0ad95..710f836ef 100644
--- a/docs/modules/ROOT/pages/contributing/developers.adoc
+++ b/docs/modules/ROOT/pages/contributing/developers.adoc
@@ -122,7 +122,7 @@ This command assumes you have an already running Minishift instance.
 
 * Run `make install-minikube`: to build the project and install it in the current namespace on Minikube
 
-This command assumes you have an already running Minikube instance.
+This command assumes you have an already running Minikube instance with registry enabled (can be enabled with `minikube addons enable registry`) and no previous Camel K instance installed.
 
 === For remote Kubernetes/OpenShift clusters
 
diff --git a/pkg/cmd/run_help.go b/pkg/cmd/run_help.go
index 0fe8ee14e..55ea888cc 100644
--- a/pkg/cmd/run_help.go
+++ b/pkg/cmd/run_help.go
@@ -85,7 +85,8 @@ const (
 	ConfigOptionTypeFile configOptionType = "file"
 )
 
-var validConfigRegexp = regexp.MustCompile(`^(configmap|secret|file)\:([\w\.\-\_\:\/@]+)$`)
+var validConfigSecretRegexp = regexp.MustCompile(`^(configmap|secret)\:([\w\.\-\_\:\/@]+)$`)
+var validFileRegexp = regexp.MustCompile(`^file\:([\w\.\-\_\:\/@" ]+)$`)
 var validResourceRegexp = regexp.MustCompile(`^([\w\.\-\_\:]+)(\/([\w\.\-\_\:]+))?(\@([\w\.\-\_\:\/]+))?$`)
 
 func newRunConfigOption(configType configOptionType, value string) *RunConfigOption {
@@ -130,7 +131,7 @@ func ParseResourceOption(item string) (*RunConfigOption, error) {
 	// then replace with parseOption() func directly
 	option, err := parseOption(item)
 	if err != nil {
-		if strings.HasPrefix(err.Error(), "could not match configuration") {
+		if strings.HasPrefix(err.Error(), "could not match config, secret or file configuration") {
 			fmt.Printf("Warn: --resource %s has been deprecated. You should use --resource file:%s instead.\n", item, item)
 			return parseOption("file:" + item)
 		}
@@ -145,24 +146,28 @@ func ParseConfigOption(item string) (*RunConfigOption, error) {
 }
 
 func parseOption(item string) (*RunConfigOption, error) {
-	if !validConfigRegexp.MatchString(item) {
-		return nil, fmt.Errorf("could not match configuration %s, must match %v regular expression", item, validConfigRegexp)
-	}
-	// Parse the regexp groups
-	groups := validConfigRegexp.FindStringSubmatch(item)
 	var cot configOptionType
-	switch groups[1] {
-	case "configmap":
-		cot = ConfigOptionTypeConfigmap
-	case "secret":
-		cot = ConfigOptionTypeSecret
-	case "file":
+	var value string
+	if validConfigSecretRegexp.MatchString(item) {
+		// parse as secret/configmap
+		groups := validConfigSecretRegexp.FindStringSubmatch(item)
+		switch groups[1] {
+		case "configmap":
+			cot = ConfigOptionTypeConfigmap
+		case "secret":
+			cot = ConfigOptionTypeSecret
+		}
+		value = groups[2]
+	} else if validFileRegexp.MatchString(item) {
+		//parse as file
+		groups := validFileRegexp.FindStringSubmatch(item)
 		cot = ConfigOptionTypeFile
-	default:
-		// Should never reach this
-		return nil, fmt.Errorf("invalid config option type %s", groups[1])
+		value = groups[1]
+	} else {
+		return nil, fmt.Errorf("could not match config, secret or file configuration as %s", item)
 	}
-	configurationOption := newRunConfigOption(cot, groups[2])
+
+	configurationOption := newRunConfigOption(cot, value)
 	if err := configurationOption.Validate(); err != nil {
 		return nil, err
 	}
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 8e81f90d5..b8dd94a07 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -107,7 +107,7 @@ func (t *knativeTrait) IsAllowedInProfile(profile v1.TraitProfile) bool {
 }
 
 func (t *knativeTrait) Configure(e *Environment) (bool, error) {
-	if t.Enabled != nil && !*t.Enabled {
+	if util.IsFalse(t.Enabled) {
 		return false, nil
 	}
 
@@ -115,7 +115,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, error) {
 		return false, nil
 	}
 
-	if t.Auto == nil || *t.Auto {
+	if util.IsNilOrTrue(t.Auto) {
 		if len(t.ChannelSources) == 0 {
 			items := make([]string, 0)
 			sources, err := kubernetes.ResolveIntegrationSources(e.C, e.Client, e.Integration, e.Resources)
@@ -211,7 +211,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, error) {
 func (t *knativeTrait) Apply(e *Environment) error {
 	// To be removed when Knative CamelSources < 0.15 will no longer be supported
 	// Older versions of Knative Sources use a loader rather than an interceptor
-	if t.CamelSourceCompat == nil || *t.CamelSourceCompat {
+	if util.IsNilOrTrue(t.CamelSourceCompat) {
 		for i, s := range e.Integration.Spec.Sources {
 			if s.Loader == "knative-source" {
 				s.Loader = ""
@@ -232,7 +232,7 @@ func (t *knativeTrait) Apply(e *Environment) error {
 		}
 	}
 
-	if t.SinkBinding != nil && *t.SinkBinding {
+	if util.IsTrue(t.SinkBinding) {
 		util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.k:camel-k-knative")
 	}
 
@@ -305,7 +305,7 @@ func (t *knativeTrait) configureChannels(e *Environment, env *knativeapi.CamelEn
 				knativeapi.CamelMetaKnativeKind:       ref.Kind,
 				knativeapi.CamelMetaKnativeReply:      "false",
 			}
-			if t.FilterSourceChannels != nil && *t.FilterSourceChannels {
+			if util.IsTrue(t.FilterSourceChannels) {
 				meta[knativeapi.CamelMetaFilterPrefix+knativeHistoryHeader] = loc.Host
 			}
 			svc := knativeapi.CamelServiceDefinition{
@@ -326,7 +326,7 @@ func (t *knativeTrait) configureChannels(e *Environment, env *knativeapi.CamelEn
 		return err
 	}
 
-	if t.SinkBinding == nil || !*t.SinkBinding {
+	if util.IsNilOrFalse(t.SinkBinding) {
 		// Sinks
 		err = t.ifServiceMissingDo(e, env, t.ChannelSinks, knativeapi.CamelServiceTypeChannel, knativeapi.CamelEndpointKindSink,
 			func(ref *corev1.ObjectReference, serviceURI string, urlProvider func() (*url.URL, error)) error {
@@ -386,7 +386,7 @@ func (t *knativeTrait) configureEndpoints(e *Environment, env *knativeapi.CamelE
 	}
 
 	// Sinks
-	if t.SinkBinding == nil || !*t.SinkBinding {
+	if util.IsNilOrFalse(t.SinkBinding) {
 		err := t.ifServiceMissingDo(e, env, t.EndpointSinks, knativeapi.CamelServiceTypeEndpoint, knativeapi.CamelEndpointKindSink,
 			func(ref *corev1.ObjectReference, serviceURI string, urlProvider func() (*url.URL, error)) error {
 				loc, err := urlProvider()
@@ -444,7 +444,7 @@ func (t *knativeTrait) configureEvents(e *Environment, env *knativeapi.CamelEnvi
 	}
 
 	// Sinks
-	if t.SinkBinding == nil || !*t.SinkBinding {
+	if util.IsNilOrFalse(t.SinkBinding) {
 		err = t.ifServiceMissingDo(e, env, t.EventSinks, knativeapi.CamelServiceTypeEvent, knativeapi.CamelEndpointKindSink,
 			func(ref *corev1.ObjectReference, serviceURI string, urlProvider func() (*url.URL, error)) error {
 				loc, err := urlProvider()
@@ -485,7 +485,7 @@ func (t *knativeTrait) isSinkBindingAllowed(e *Environment) bool {
 }
 
 func (t *knativeTrait) configureSinkBinding(e *Environment, env *knativeapi.CamelEnvironment) error {
-	if t.SinkBinding == nil || !*t.SinkBinding {
+	if util.IsNilOrFalse(t.SinkBinding) {
 		return nil
 	}
 	var serviceType knativeapi.CamelServiceType


Test patch:
diff --git a/pkg/cmd/run_help_test.go b/pkg/cmd/run_help_test.go
index 75e02f3d7..a7d92bb11 100644
--- a/pkg/cmd/run_help_test.go
+++ b/pkg/cmd/run_help_test.go
@@ -62,6 +62,7 @@ func TestParseConfigOptionAllParams(t *testing.T) {
 	sec4 := "secret:sec"
 	file1 := "file:/path/to/my-file.txt@/tmp/file.txt"
 	file2 := "file:/path/to/my-file.txt"
+	file3 := "file:/path to/my-file.txt"
 
 	parsedCm1, err := ParseConfigOption(cm1)
 	assert.Nil(t, err)
@@ -132,6 +133,13 @@ func TestParseConfigOptionAllParams(t *testing.T) {
 	assert.Equal(t, "/path/to/my-file.txt", parsedFile2.Name())
 	assert.Equal(t, "", parsedFile2.Key())
 	assert.Equal(t, "", parsedFile2.DestinationPath())
+
+	parsedFile3, err := ParseConfigOption(file3)
+	assert.Nil(t, err)
+	assert.Equal(t, "file", parsedFile3.Type())
+	assert.Equal(t, "/path to/my-file.txt", parsedFile3.Name())
+	assert.Equal(t, "", parsedFile3.Key())
+	assert.Equal(t, "", parsedFile3.DestinationPath())
 }
 
 func TestFilterFileLocation(t *testing.T) {