chore: use slog instead of klog

This commit is contained in:
Mariell Hoversholm
2024-11-19 08:31:59 +01:00
parent d50afe3020
commit 1811e81900
+10 -8
View File
@@ -3,12 +3,12 @@ package provisioning
import (
"context"
"fmt"
"log/slog"
"net/http"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/klog/v2"
"github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
)
@@ -73,7 +73,7 @@ func (s *helloWorldSubresource) Connect(ctx context.Context, name string, opts r
name, // resource name
rest.DefaultUpdatedObjectInfo(obj, func(ctx context.Context, newObj, oldObj runtime.Object) (transformedNewObj runtime.Object, err error) {
newObj.(*v0alpha1.Repository).Status.CurrentGitCommit = newCommit
klog.InfoS("updated the commit", "newObj", newObj, "newCommit", newCommit)
slog.InfoContext(ctx, "updated the commit", "newObj", newObj, "newCommit", newCommit)
return newObj, nil
}),
func(ctx context.Context, obj runtime.Object) error { return nil }, // createValidation
@@ -86,14 +86,16 @@ func (s *helloWorldSubresource) Connect(ctx context.Context, name string, opts r
return
}
repo = obj.(*v0alpha1.Repository)
klog.InfoS("the conspicuous boolean", "bool", b)
slog.InfoContext(ctx, "the conspicuous boolean", "bool", b)
}
fmt.Printf("GOT: %s/%s\n", repo.Name, repo.Spec.Type)
fmt.Printf(" status: %+v\n", repo.Status)
fmt.Printf(" local: %+v\n", repo.Spec.Local)
fmt.Printf(" github: %+v\n", repo.Spec.GitHub)
fmt.Printf(" s3: %+v\n", repo.Spec.S3)
slog.InfoContext(ctx, "Got a repository",
"name", repo.Name,
"type", repo.Spec.Type,
"status", repo.Status,
"local", repo.Spec.Local,
"github", repo.Spec.GitHub,
"s3", repo.Spec.S3)
responder.Object(http.StatusOK, &v0alpha1.HelloWorld{Whom: whom})
}), nil