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



##########
File path: addons/keda/keda.go
##########
@@ -0,0 +1,551 @@
+/*
+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 keda
+
+import (
+       "bytes"
+       "encoding/json"
+       "fmt"
+       "sort"
+       "strings"
+       "text/template"
+
+       kedav1alpha1 "github.com/apache/camel-k/addons/keda/duck/v1alpha1"
+       camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+       camelv1alpha1 "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+       "github.com/apache/camel-k/pkg/kamelet/repository"
+       "github.com/apache/camel-k/pkg/metadata"
+       "github.com/apache/camel-k/pkg/platform"
+       "github.com/apache/camel-k/pkg/trait"
+       "github.com/apache/camel-k/pkg/util"
+       "github.com/apache/camel-k/pkg/util/kubernetes"
+       "github.com/apache/camel-k/pkg/util/property"
+       "github.com/apache/camel-k/pkg/util/source"
+       "github.com/apache/camel-k/pkg/util/uri"
+       "github.com/pkg/errors"
+       scase "github.com/stoewer/go-strcase"
+       v1 "k8s.io/api/core/v1"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+       ctrl "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+const (
+       // kameletURNMetadataPrefix allows binding Kamelet properties to KEDA 
metadata.
+       kameletURNMetadataPrefix = "urn:keda:metadata:"
+       // kameletURNAuthenticationPrefix allows binding Kamelet properties to 
KEDA authentication options.
+       kameletURNAuthenticationPrefix = "urn:keda:authentication:"
+       // kameletURNRequiredTag is used to mark properties required by KEDA.
+       kameletURNRequiredTag = "urn:keda:required"
+
+       // kameletAnnotationType indicates the scaler type associated to a 
Kamelet.
+       kameletAnnotationType = "camel.apache.org/keda.type"
+       // kameletAnnotationMetadataPrefix is used to define virtual metadata 
fields computed from Kamelet properties.
+       kameletAnnotationMetadataPrefix = "camel.apache.org/keda.metadata."
+       // kameletAnnotationAuthenticationPrefix is used to define virtual 
authentication fields computed from Kamelet properties.
+       kameletAnnotationAuthenticationPrefix = 
"camel.apache.org/keda.authentication."
+)
+
+// The KEDA trait can be used for automatic integration with KEDA autoscalers.
+// The trait can be either manually configured using the `triggers` option or 
automatically configured
+// via markers in the Kamelets.
+//
+// For information on how to use KEDA enabled Kamelets with the KEDA trait, 
refer to
+// xref:ROOT:kamelets/kamelets-user.adoc#kamelet-keda-user[the KEDA section in 
the Kamelets user guide].
+// If you want to create Kamelets that contain KEDA metadata, refer to
+// xref:ROOT:kamelets/kamelets-dev.adoc#kamelet-keda-dev[the KEDA section in 
the Kamelets development guide].
+//
+// The KEDA trait is disabled by default.
+//
+// +camel-k:trait=keda.
+type kedaTrait struct {
+       trait.BaseTrait `property:",squash"`
+       // Enables automatic configuration of the trait. Allows the trait to 
infer KEDA triggers from the Kamelets.
+       Auto *bool `property:"auto" json:"auto,omitempty"`
+       // Convert metadata properties to camelCase (needed because Camel K 
trait properties use kebab-case from command line). Disabled by default.
+       CamelCaseConversion *bool `property:"camel-case-conversion" 
json:"camelCaseConversion,omitempty"`
+       // Set the spec->replicas field on the top level controller to an 
explicit value if missing, to allow KEDA to recognize it as a scalable resource.

Review comment:
       > If we don't know the number of replicas in the moment when we create 
the ScaledObject, we don't know the value that should be used to restore the 
replicas count, once ScaledObject is deleted.
   
   For that case, it was not set, so it could be unset. It may be a dubious 
parallel, but it's like a pointer in Golang, when it's needed to differentiate 
between the default value for the type, and not initialised.




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

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


Reply via email to