You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/12/14 07:46:17 UTC

[GitHub] [camel-k] astefanutti commented on a change in pull request #1861: WIP: Add podTrait to specify customPodTemplateSpec

astefanutti commented on a change in pull request #1861:
URL: https://github.com/apache/camel-k/pull/1861#discussion_r542171432



##########
File path: pkg/trait/pod.go
##########
@@ -0,0 +1,94 @@
+/*
+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 trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	source "github.com/apache/camel-k/pkg/util/source"
+	jsonpatch "github.com/evanphx/json-patch"
+	v12 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/util/json"
+	"k8s.io/apimachinery/pkg/util/yaml"
+
+	//"github.com/ghodss/yaml"
+	//	cmd "github.com/apache/camel-k/pkg/cmd"
+
+	appsv1 "k8s.io/api/apps/v1"
+)
+
+// The Pod trait allows to configure the custom PodTemplateSpec resource for the Integration pods.
+//
+// +camel-k:trait=pdb
+type podTrait struct {
+	BaseTrait `property:",squash"`
+	Template  string `property:"template"`
+	source    source.Source
+}
+
+func newPodTrait() Trait {
+	return &podTrait{
+		BaseTrait: NewBaseTrait("pod", 1800),
+	}
+}
+
+func (t *podTrait) Configure(e *Environment) (bool, error) {
+	if t.Enabled == nil || !*t.Enabled {
+		return false, nil
+	}
+
+	if t.Template == "" {
+		return false, fmt.Errorf("template must be specified")
+	}
+
+	return e.IntegrationInPhase(
+		v1.IntegrationPhaseRunning,

Review comment:
       My understanding is that the template should also be applied during the `IntegrationPhaseDeploying` phase also.

##########
File path: pkg/trait/pod.go
##########
@@ -0,0 +1,94 @@
+/*
+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 trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	source "github.com/apache/camel-k/pkg/util/source"
+	jsonpatch "github.com/evanphx/json-patch"
+	v12 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/util/json"
+	"k8s.io/apimachinery/pkg/util/yaml"
+
+	//"github.com/ghodss/yaml"
+	//	cmd "github.com/apache/camel-k/pkg/cmd"
+
+	appsv1 "k8s.io/api/apps/v1"
+)
+
+// The Pod trait allows to configure the custom PodTemplateSpec resource for the Integration pods.
+//
+// +camel-k:trait=pdb
+type podTrait struct {
+	BaseTrait `property:",squash"`
+	Template  string `property:"template"`
+	source    source.Source
+}
+
+func newPodTrait() Trait {
+	return &podTrait{
+		BaseTrait: NewBaseTrait("pod", 1800),
+	}
+}
+
+func (t *podTrait) Configure(e *Environment) (bool, error) {
+	if t.Enabled == nil || !*t.Enabled {
+		return false, nil
+	}
+
+	if t.Template == "" {
+		return false, fmt.Errorf("template must be specified")
+	}
+
+	return e.IntegrationInPhase(
+		v1.IntegrationPhaseRunning,
+	), nil
+}
+
+func (t *podTrait) Apply(e *Environment) error {
+	src, err := source.ResolveSources(t.Ctx, []string{t.Template}, false)

Review comment:
       My understanding is that the resolution of the source should be done by the CLI, and the content should either be included in the Integration or a ConfigMap, referenced from the Integration. The reconciliation should not rely on local nor remote file, and should be idempotent.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org