Skip to content

Commit

Permalink
fix: Initialize fluentd as nil (#2)
Browse files Browse the repository at this point in the history
* initialize fluentd as nil

* fix: unit tests

* debug logs

* no explicit nil initialization
  • Loading branch information
niklastreml authored Feb 22, 2024
1 parent 042a302 commit df57463
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
4 changes: 2 additions & 2 deletions fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"

"github.com/crossplane/crossplane-runtime/pkg/errors"
"github.com/crossplane/crossplane-runtime/pkg/logging"
Expand Down Expand Up @@ -60,15 +61,14 @@ func (f *Function) RunFunction(ctx context.Context, req *fnv1beta1.RunFunctionRe

projectid, ok := targetns.GetLabels()[in.NamespaceLabel]
if !ok {
response.Fatal(rsp, errors.New("cannot get project id"))
response.Fatal(rsp, fmt.Errorf("cannot get project id %s for namespace %s", projectid, targetns.GetName()))
return rsp, nil
}

l := &v1beta1.Logging{}
l.Spec.ControlNamespace = ns
l.Spec.WatchNamespaceSelector = &metav1.LabelSelector{}
l.Spec.WatchNamespaceSelector.MatchLabels = map[string]string{in.NamespaceLabel: projectid}
l.Spec.FluentdSpec = &v1beta1.FluentdSpec{}

cd, err := composed.From(l)
if err != nil {
Expand Down
23 changes: 0 additions & 23 deletions fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,6 @@ func TestRunFunction(t *testing.T) {
},
"enableRecreateWorkloadOnImmutableFieldChange": false,
"flowConfigCheckDisabled": false,
"fluentd": {
"compressConfigFile": false,
"disablePvc": false,
"enableMsgpackTimeSupport": false,
"livenessDefaultCheck": false,
"port": 0,
"readinessDefaultCheck": {
"bufferFileNumber": false,
"bufferFileNumberMax": 0,
"bufferFreeSpace": false,
"bufferFreeSpaceThreshold": 0,
"failureThreshold": 0,
"initialDelaySeconds": 0,
"periodSeconds": 0,
"successThreshold": 0,
"timeoutSeconds": 0
},
"tls": {
"enabled": false
},
"volumeMountChmod": false,
"workers": 0
},
"skipInvalidResources": false
},
"status": {
Expand Down

0 comments on commit df57463

Please sign in to comment.