Skip to content

Commit e635106

Browse files
committed
remove verbosity constants in favor of integers
1 parent 351d124 commit e635106

File tree

8 files changed

+15
-57
lines changed

8 files changed

+15
-57
lines changed

pkg/ansible/controller/reconcile.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/kubeconfig"
3030
"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
3131
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
32-
"github.com/operator-framework/operator-sdk/pkg/logutil"
3332

3433
"k8s.io/api/core/v1"
3534
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -90,7 +89,7 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
9089
pendingFinalizers := u.GetFinalizers()
9190
// If the resource is being deleted we don't want to add the finalizer again
9291
if finalizerExists && !deleted && !contains(pendingFinalizers, finalizer) {
93-
logger.V(logutil.VDebug).Info("Adding finalizer to resource", "Finalizer", finalizer)
92+
logger.V(1).Info("Adding finalizer to resource", "Finalizer", finalizer)
9493
finalizers := append(pendingFinalizers, finalizer)
9594
u.SetFinalizers(finalizers)
9695
err := r.Client.Update(context.TODO(), u)
@@ -106,7 +105,7 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
106105
spec := u.Object["spec"]
107106
_, ok := spec.(map[string]interface{})
108107
if !ok {
109-
logger.V(logutil.VDebug).Info("spec was not found")
108+
logger.V(1).Info("spec was not found")
110109
u.Object["spec"] = map[string]interface{}{}
111110
err = r.Client.Update(context.TODO(), u)
112111
if err != nil {

pkg/ansible/controller/status/types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"time"
1919

2020
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
21-
"github.com/operator-framework/operator-sdk/pkg/logutil"
2221

2322
"k8s.io/api/core/v1"
2423
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -132,7 +131,7 @@ func createConditionFromMap(cm map[string]interface{}) Condition {
132131
if ok {
133132
t, err := time.Parse("2006-01-02T15:04:05Z", ltts)
134133
if err != nil {
135-
log.V(logutil.VWarn).Info("unable to parse time for status condition", "Time", ltts)
134+
log.Info("unable to parse time for status condition", "Time", ltts)
136135
} else {
137136
ltt = metav1.NewTime(t)
138137
}
@@ -162,7 +161,7 @@ func CreateFromMap(statusMap map[string]interface{}) Status {
162161
for _, ci := range conditionsInterface {
163162
cm, ok := ci.(map[string]interface{})
164163
if !ok {
165-
log.V(logutil.VWarn).Info("unknown condition, removing condition", "ConditionInterface", ci)
164+
log.Info("unknown condition, removing condition", "ConditionInterface", ci)
166165
continue
167166
}
168167
conditions = append(conditions, createConditionFromMap(cm))

pkg/ansible/events/log_events.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"errors"
1919

2020
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
21-
"github.com/operator-framework/operator-sdk/pkg/logutil"
2221

2322
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2423
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
@@ -71,7 +70,7 @@ func (l loggingEventHandler) Handle(ident string, u *unstructured.Unstructured,
7170
return
7271
}
7372
if e.Event == eventapi.EventRunnerOnOk && debugAction {
74-
logger.V(logutil.VDebug).Info("[playbook debug]", "EventData.TaskArgs", e.EventData["task_args"])
73+
logger.V(1).Info("[playbook debug]", "EventData.TaskArgs", e.EventData["task_args"])
7574
return
7675
}
7776
if e.Event == eventapi.EventRunnerOnFailed {

pkg/ansible/proxy/proxy.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"net/http"
2828
"net/http/httputil"
2929

30-
"github.com/operator-framework/operator-sdk/pkg/logutil"
31-
3230
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3331
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3432
"k8s.io/client-go/rest"
@@ -42,7 +40,7 @@ func InjectOwnerReferenceHandler(h http.Handler) http.Handler {
4240
if req.Method == http.MethodPost {
4341
log.Info("injecting owner reference")
4442
dump, _ := httputil.DumpRequest(req, false)
45-
log.V(logutil.VDebug).Info("dumping request", "RequestDump", string(dump))
43+
log.V(1).Info("dumping request", "RequestDump", string(dump))
4644

4745
user, _, ok := req.BasicAuth()
4846
if !ok {
@@ -61,7 +59,7 @@ func InjectOwnerReferenceHandler(h http.Handler) http.Handler {
6159
owner := metav1.OwnerReference{}
6260
json.Unmarshal(authString, &owner)
6361

64-
log.V(logutil.VDebug).Info(fmt.Sprintf("%#+v", owner))
62+
log.V(1).Info(fmt.Sprintf("%#+v", owner))
6563

6664
body, err := ioutil.ReadAll(req.Body)
6765
if err != nil {
@@ -86,7 +84,7 @@ func InjectOwnerReferenceHandler(h http.Handler) http.Handler {
8684
http.Error(w, m, http.StatusInternalServerError)
8785
return
8886
}
89-
log.V(logutil.VDebug).Info("serialized body", "Body", string(newBody))
87+
log.V(1).Info("serialized body", "Body", string(newBody))
9088
req.Body = ioutil.NopCloser(bytes.NewBuffer(newBody))
9189
req.ContentLength = int64(len(newBody))
9290
}

pkg/ansible/runner/eventapi/eventapi.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
"sync"
2626
"time"
2727

28-
"github.com/operator-framework/operator-sdk/pkg/logutil"
29-
3028
"github.com/go-logr/logr"
3129
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
3230
)
@@ -96,7 +94,7 @@ func (e *EventReceiver) Close() {
9694
e.mutex.Lock()
9795
e.stopped = true
9896
e.mutex.Unlock()
99-
e.logger.V(logutil.VDebug).Info("event API stopped")
97+
e.logger.V(1).Info("event API stopped")
10098
e.server.Close()
10199
close(e.Events)
102100
}
@@ -153,7 +151,7 @@ func (e *EventReceiver) handleEvents(w http.ResponseWriter, r *http.Request) {
153151
// we're not currently interested in.
154152
// https://ansible-runner.readthedocs.io/en/latest/external_interface.html#event-structure
155153
if event.UUID == "" {
156-
e.logger.V(logutil.VDebug).Info("dropping event that is not a JobEvent")
154+
e.logger.V(1).Info("dropping event that is not a JobEvent")
157155
} else {
158156
// timeout if the channel blocks for too long
159157
timeout := time.NewTimer(10 * time.Second)

pkg/ansible/runner/runner.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/operator-framework/operator-sdk/pkg/ansible/paramconv"
2929
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
3030
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/internal/inputdir"
31-
"github.com/operator-framework/operator-sdk/pkg/logutil"
3231

3332
yaml "gopkg.in/yaml.v2"
3433
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -223,7 +222,7 @@ func (r *runner) Run(ident string, u *unstructured.Unstructured, kubeconfig stri
223222
go func() {
224223
var dc *exec.Cmd
225224
if r.isFinalizerRun(u) {
226-
logger.V(logutil.VDebug).Info("Resource is marked for deletion, running finalizer", "Finalizer", r.Finalizer.Name)
225+
logger.V(1).Info("Resource is marked for deletion, running finalizer", "Finalizer", r.Finalizer.Name)
227226
dc = r.finalizerCmdFunc(ident, inputDir.Path)
228227
} else {
229228
dc = r.cmdFunc(ident, inputDir.Path)
@@ -321,7 +320,7 @@ func (r *runner) makeParameters(u *unstructured.Unstructured) map[string]interfa
321320
s := u.Object["spec"]
322321
spec, ok := s.(map[string]interface{})
323322
if !ok {
324-
log.V(logutil.VWarn).Info("spec was not found for CR", "GroupVersionKind", u.GroupVersionKind(), "Namespace", u.GetNamespace(), "Name", u.GetName())
323+
log.Info("spec was not found for CR", "GroupVersionKind", u.GroupVersionKind(), "Namespace", u.GetNamespace(), "Name", u.GetName())
325324
spec = map[string]interface{}{}
326325
}
327326
parameters := paramconv.MapToSnake(spec)

pkg/leader/leader.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
"strings"
2424
"time"
2525

26-
"github.com/operator-framework/operator-sdk/pkg/logutil"
27-
2826
corev1 "k8s.io/api/core/v1"
2927
apierrors "k8s.io/apimachinery/pkg/api/errors"
3028
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -151,13 +149,13 @@ func myNS() (string, error) {
151149
nsBytes, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
152150
if err != nil {
153151
if os.IsNotExist(err) {
154-
log.V(logutil.VDebug).Info("current namespace not found")
152+
log.V(1).Info("current namespace not found")
155153
return "", errNoNS
156154
}
157155
return "", err
158156
}
159157
ns := strings.TrimSpace(string(nsBytes))
160-
log.V(logutil.VDebug).Info("found namespace", "Namespace", ns)
158+
log.V(1).Info("found namespace", "Namespace", ns)
161159
return ns, nil
162160
}
163161

@@ -170,7 +168,7 @@ func myOwnerRef(ctx context.Context, client crclient.Client, ns string) (*metav1
170168
return nil, fmt.Errorf("required env %s not set, please configure downward API", PodNameEnv)
171169
}
172170

173-
log.V(logutil.VDebug).Info("found podname", "Pod.Name", podName)
171+
log.V(1).Info("found podname", "Pod.Name", podName)
174172

175173
myPod := &corev1.Pod{
176174
TypeMeta: metav1.TypeMeta{

pkg/logutil/log_util.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)