Skip to content

Commit

Permalink
follow recommendations
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
  • Loading branch information
frzifus committed Oct 11, 2022
1 parent 5689a0d commit 9d292d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apis/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// functionality is only available if one of the valid modes is set.
// Valid modes are: deployment, daemonset and statefulset.
type Ingress struct {
// Type default value is: none
// Type default value is: ""
// Supported types are: ingress
Type IngressType `json:"type,omitempty"`

Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/opentelemetrycollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error {

}

if r.Spec.Ingress.Type == IngressTypeNginx && (r.Spec.Mode != ModeDeployment || r.Spec.Mode == ModeDaemonSet || r.Spec.Mode == ModeStatefulSet) {
if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar {
return fmt.Errorf("the OptenTelemetry Spec Ingress configuiration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s",
ModeDeployment, ModeDaemonSet, ModeStatefulSet,
)
Expand Down
12 changes: 4 additions & 8 deletions pkg/collector/reconcile/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress {
if params.Instance.Spec.Ingress.Type != v1alpha1.IngressTypeNginx {
return nil
}
svcTarget := naming.Service(params.Instance)
hostname := params.Instance.Spec.Ingress.Hostname
tls := params.Instance.Spec.Ingress.TLS
ns := params.Instance.Namespace

config, err := adapters.ConfigFromString(params.Instance.Spec.Config)
if err != nil {
Expand Down Expand Up @@ -89,7 +85,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress {
PathType: &pathType,
Backend: networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: svcTarget,
Name: naming.Service(params.Instance),
Port: networkingv1.ServiceBackendPort{
// Valid names must be non-empty and no more than 15 characters long.
Name: naming.Truncate(p.Name, 15),
Expand All @@ -102,7 +98,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress {
return &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: naming.Ingress(params.Instance),
Namespace: ns,
Namespace: params.Instance.Namespace,
Annotations: params.Instance.Spec.Ingress.Annotations,
Labels: map[string]string{
"app.kubernetes.io/name": naming.Ingress(params.Instance),
Expand All @@ -111,10 +107,10 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress {
},
},
Spec: networkingv1.IngressSpec{
TLS: tls,
TLS: params.Instance.Spec.Ingress.TLS,
Rules: []networkingv1.IngressRule{
{
Host: hostname,
Host: params.Instance.Spec.Ingress.Hostname,
IngressRuleValue: networkingv1.IngressRuleValue{
HTTP: &networkingv1.HTTPIngressRuleValue{
Paths: paths,
Expand Down

0 comments on commit 9d292d5

Please sign in to comment.