Skip to content

Commit

Permalink
apply some feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
JorTurFer committed Jun 24, 2024
1 parent ce7ae4e commit 6286ab0
Show file tree
Hide file tree
Showing 15 changed files with 721 additions and 730 deletions.
642 changes: 322 additions & 320 deletions config/crd/bases/http.keda.sh_clusterhttpscalingsets.yaml

Large diffs are not rendered by default.

639 changes: 320 additions & 319 deletions config/crd/bases/http.keda.sh_httpscalingsets.yaml

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions operator/apis/http/v1alpha1/httpscalingset_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,123 +27,123 @@ var (
scalerImage = fmt.Sprintf("ghcr.io/kedacore/http-add-on-scaler:%s", build.Version())
)

func (c *HTTPInterceptorSepc) GetProxyPort() int32 {
func (c *HTTPInterceptorSpec) GetProxyPort() int32 {
if c.Config == nil || c.Config.ProxyPort == nil {
return 8080
}
return *c.Config.ProxyPort
}

func (c *HTTPInterceptorSepc) GetAdminPort() int32 {
func (c *HTTPInterceptorSpec) GetAdminPort() int32 {
if c.Config == nil || c.Config.AdminPort == nil {
return 9090
}
return *c.Config.AdminPort
}
func (c *HTTPInterceptorSepc) GetConnectTimeout() string {
func (c *HTTPInterceptorSpec) GetConnectTimeout() string {
if c.Config == nil || c.Config.ConnectTimeout == nil {
return "500ms"
}
return *c.Config.ConnectTimeout
}
func (c *HTTPInterceptorSepc) GetHeaderTimeout() string {
func (c *HTTPInterceptorSpec) GetHeaderTimeout() string {
if c.Config == nil || c.Config.HeaderTimeout == nil {
return "500ms"
}
return *c.Config.HeaderTimeout
}
func (c *HTTPInterceptorSepc) GetWaitTimeout() string {
func (c *HTTPInterceptorSpec) GetWaitTimeout() string {
if c.Config == nil || c.Config.WaitTimeout == nil {
return "1500ms"
}
return *c.Config.WaitTimeout
}
func (c *HTTPInterceptorSepc) GetIdleConnTimeout() string {
func (c *HTTPInterceptorSpec) GetIdleConnTimeout() string {
if c.Config == nil || c.Config.IdleConnTimeout == nil {
return "90s"
}
return *c.Config.IdleConnTimeout
}
func (c *HTTPInterceptorSepc) GetTLSHandshakeTimeout() string {
func (c *HTTPInterceptorSpec) GetTLSHandshakeTimeout() string {
if c.Config == nil || c.Config.TLSHandshakeTimeout == nil {
return "10s"
}
return *c.Config.TLSHandshakeTimeout
}
func (c *HTTPInterceptorSepc) GetExpectContinueTimeout() string {
func (c *HTTPInterceptorSpec) GetExpectContinueTimeout() string {
if c.Config == nil || c.Config.ExpectContinueTimeout == nil {
return "1s"
}
return *c.Config.ExpectContinueTimeout
}
func (c *HTTPInterceptorSepc) GetForceHTTP2() bool {
func (c *HTTPInterceptorSpec) GetForceHTTP2() bool {
if c.Config == nil || c.Config.ForceHTTP2 == nil {
return false
}
return *c.Config.ForceHTTP2
}
func (c *HTTPInterceptorSepc) GetKeepAlive() string {
func (c *HTTPInterceptorSpec) GetKeepAlive() string {
if c.Config == nil || c.Config.KeepAlive == nil {
return "1s"
}
return *c.Config.KeepAlive
}
func (c *HTTPInterceptorSepc) GetMaxIdleConns() int {
func (c *HTTPInterceptorSpec) GetMaxIdleConns() int {
if c.Config == nil || c.Config.MaxIdleConns == nil {
return 100
}
return *c.Config.MaxIdleConns
}
func (c *HTTPInterceptorSepc) GetPollingInterval() int {
func (c *HTTPInterceptorSpec) GetPollingInterval() int {
if c.Config == nil || c.Config.PollingInterval == nil {
return 1000
}
return *c.Config.PollingInterval
}

func (c *HTTPInterceptorSepc) GetImage() string {
func (c *HTTPInterceptorSpec) GetImage() string {
if c.Image == nil {
return interceptorImage
}
return *c.Image
}

func (c *HTTPInterceptorSepc) GetLabels() map[string]string {
func (c *HTTPInterceptorSpec) GetLabels() map[string]string {
if c.Labels == nil {
return map[string]string{}
}
return c.Labels
}

func (c *HTTPInterceptorSepc) GetAnnotations() map[string]string {
func (c *HTTPInterceptorSpec) GetAnnotations() map[string]string {
if c.Annotations == nil {
return map[string]string{}
}
return c.Annotations
}

func (c *HTTPScalerSepc) GetPort() int32 {
func (c *HTTPScalerSpec) GetPort() int32 {
if c.Config.Port == nil {
return 9090
}
return *c.Config.Port
}

func (c *HTTPScalerSepc) GetImage() string {
func (c *HTTPScalerSpec) GetImage() string {
if c.Image == nil {
return scalerImage
}
return *c.Image
}

func (c *HTTPScalerSepc) GetLabels() map[string]string {
func (c *HTTPScalerSpec) GetLabels() map[string]string {
if c.Labels == nil {
return map[string]string{}
}
return c.Labels
}

func (c *HTTPScalerSepc) GetAnnotations() map[string]string {
func (c *HTTPScalerSpec) GetAnnotations() map[string]string {
if c.Annotations == nil {
return map[string]string{}
}
Expand Down
26 changes: 13 additions & 13 deletions operator/apis/http/v1alpha1/httpscalingset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ type HTTPInterceptorScalingSpec struct {
Target int `json:"target"`
}

// HTTPInterceptorConfigurationSepc defines the desired state of Interceptor configuration
type HTTPInterceptorConfigurationSepc struct {
// HTTPInterceptorConfigurationSpec defines the desired state of Interceptor configuration
type HTTPInterceptorConfigurationSpec struct {
// +optional
// Port to be used for proxy operations
ProxyPort *int32 `json:"proxyPort,omitempty"`
// +optional
// Port to be used for admin operations
AdminPort *int32 `json:"adminPort,omitempty"`
// +optional
// Timeout for stablishing the connection
// Timeout for establishing the connection
ConnectTimeout *string `json:"connectTimeout,omitempty"`
// +optional
// How long to wait between when the HTTP request
Expand Down Expand Up @@ -86,11 +86,11 @@ type HTTPInterceptorConfigurationSepc struct {
PollingInterval *int `json:"pollingInterval,omitempty"`
}

// HTTPInterceptorSepc defines the desired state of Interceptor component
type HTTPInterceptorSepc struct {
// HTTPInterceptorSpec defines the desired state of Interceptor component
type HTTPInterceptorSpec struct {
// +optional
// Traffic configuration
Config *HTTPInterceptorConfigurationSepc `json:"config,omitempty"`
Config *HTTPInterceptorConfigurationSpec `json:"config,omitempty"`
// Number of replicas for the interceptor
Replicas *int32 `json:"replicas,omitempty"`
// Container image name.
Expand Down Expand Up @@ -126,20 +126,20 @@ type HTTPInterceptorSepc struct {
ServiceAccountName string `json:"serviceAccountName"`
}

// HTTPScalerConfigurationSepc defines the desired state of scaler configuration
type HTTPScalerConfigurationSepc struct {
// HTTPScalerConfigurationSpec defines the desired state of scaler configuration
type HTTPScalerConfigurationSpec struct {
// +kubebuilder:default=9090
// +optional
// Port to be used for proxy operations
Port *int32 `json:"port,omitempty"`
}

// HTTPScalerSepc defines the desired state of Scaler component
type HTTPScalerSepc struct {
// HTTPScalerSpec defines the desired state of Scaler component
type HTTPScalerSpec struct {
// +kubebuilder:default={}
// +optional
// Traffic configuration
Config HTTPScalerConfigurationSepc `json:"config,omitempty"`
Config HTTPScalerConfigurationSpec `json:"config,omitempty"`
// Number of replicas for the interceptor
Replicas *int32 `json:"replicas,omitempty"`
// Container image name.
Expand Down Expand Up @@ -175,8 +175,8 @@ type HTTPScalerSepc struct {

// HTTPScalingSetSpec defines the desired state of HTTPScalingSet
type HTTPScalingSetSpec struct {
Interceptor HTTPInterceptorSepc `json:"interceptor"`
Scaler HTTPScalerSepc `json:"scaler"`
Interceptor HTTPInterceptorSpec `json:"interceptor"`
Scaler HTTPScalerSpec `json:"scaler"`
}

// HTTPScalingSetStatus defines the observed state of HTTPScalingSet
Expand Down
34 changes: 17 additions & 17 deletions operator/apis/http/v1alpha1/zz_generated.deepcopy.go

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

10 changes: 1 addition & 9 deletions operator/controllers/http/clusterhttpscalingset_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Licensed 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
Expand Down Expand Up @@ -85,13 +83,7 @@ func (r *ClusterHTTPScalingSetReconciler) Reconcile(ctx context.Context, req ctr
httpss.Namespace = r.KEDANamespace

// Create required app objects for the application defined by the CRD
err := createOrUpdateInterceptorResources(
ctx,
logger,
r.Client,
httpss,
r.Scheme,
)
err := createOrUpdateInterceptorResources(ctx, logger, r.Client, httpss, r.Scheme)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var _ = Describe("ClusterHTTPScalingSetController", func() {
Name: name,
},
Spec: v1alpha1.HTTPScalingSetSpec{
Interceptor: v1alpha1.HTTPInterceptorSepc{},
Scaler: v1alpha1.HTTPScalerSepc{},
Interceptor: v1alpha1.HTTPInterceptorSpec{},
Scaler: v1alpha1.HTTPScalerSpec{},
},
}
err := k8sClient.Create(context.Background(), css)
Expand Down Expand Up @@ -145,10 +145,10 @@ var _ = Describe("ClusterHTTPScalingSetController", func() {
Name: name,
},
Spec: v1alpha1.HTTPScalingSetSpec{
Interceptor: v1alpha1.HTTPInterceptorSepc{
Interceptor: v1alpha1.HTTPInterceptorSpec{
Replicas: ptr.To(interceptorReplicas),
Resources: interceptorResouces,
Config: &v1alpha1.HTTPInterceptorConfigurationSepc{
Config: &v1alpha1.HTTPInterceptorConfigurationSpec{
ProxyPort: ptr.To(interceptorProxyPort),
AdminPort: ptr.To(interceptorAdminPort),
},
Expand All @@ -159,10 +159,10 @@ var _ = Describe("ClusterHTTPScalingSetController", func() {
"interceptor-annotation-1": "value-2",
},
},
Scaler: v1alpha1.HTTPScalerSepc{
Scaler: v1alpha1.HTTPScalerSpec{
Replicas: ptr.To(scalerReplicas),
Resources: scalerResouces,
Config: v1alpha1.HTTPScalerConfigurationSepc{
Config: v1alpha1.HTTPScalerConfigurationSpec{
Port: ptr.To(scalerPort),
},
Labels: map[string]string{
Expand Down
10 changes: 1 addition & 9 deletions operator/controllers/http/httpscalingset_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Licensed 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
Expand Down Expand Up @@ -81,13 +79,7 @@ func (r *HTTPScalingSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

// Create required app objects for the application defined by the CRD
err := createOrUpdateInterceptorResources(
ctx,
logger,
r.Client,
httpss,
r.Scheme,
)
err := createOrUpdateInterceptorResources(ctx, logger, r.Client, httpss, r.Scheme)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
Loading

0 comments on commit 6286ab0

Please sign in to comment.