Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
release: configure go logger to log using our go-kit logger
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansedich committed Feb 17, 2020
1 parent bf3524c commit 52f4f52
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
22 changes: 14 additions & 8 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
golog "log"
"os"
"os/signal"
"strings"
Expand All @@ -23,12 +24,13 @@ import (
clientset "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned"
ifinformers "github.com/fluxcd/helm-operator/pkg/client/informers/externalversions"
"github.com/fluxcd/helm-operator/pkg/helm"
"github.com/fluxcd/helm-operator/pkg/helm/v2"
"github.com/fluxcd/helm-operator/pkg/helm/v3"
helmv2 "github.com/fluxcd/helm-operator/pkg/helm/v2"
helmv3 "github.com/fluxcd/helm-operator/pkg/helm/v3"
daemonhttp "github.com/fluxcd/helm-operator/pkg/http/daemon"
"github.com/fluxcd/helm-operator/pkg/operator"
"github.com/fluxcd/helm-operator/pkg/release"
"github.com/fluxcd/helm-operator/pkg/status"
"github.com/fluxcd/helm-operator/pkg/utils"
)

var (
Expand Down Expand Up @@ -124,7 +126,7 @@ func init() {

versionedHelmRepositoryIndexes = fs.StringSlice("helm-repository-import", nil, "Targeted version and the path of the Helm repository index to import, i.e. v3:/tmp/v3/index.yaml,v2:/tmp/v2/index.yaml")

enabledHelmVersions = fs.StringSlice("enabled-helm-versions", []string{v2.VERSION, v3.VERSION}, "Helm versions supported by this operator instance")
enabledHelmVersions = fs.StringSlice("enabled-helm-versions", []string{helmv2.VERSION, helmv3.VERSION}, "Helm versions supported by this operator instance")
}

func main() {
Expand Down Expand Up @@ -159,6 +161,10 @@ func main() {
logger = log.With(logger, "caller", log.DefaultCaller)
}

// configure go logger to output using go-kit log
logWriter := utils.NewLogWriter(logger)
golog.SetOutput(logWriter)

// error channel
errc := make(chan error)

Expand Down Expand Up @@ -200,8 +206,8 @@ func main() {
versionedLogger := log.With(logger, "component", "helm", "version", v)

switch v {
case v2.VERSION:
helmClients.Add(v2.VERSION, v2.New(versionedLogger, kubeClient, v2.TillerOptions{
case helmv2.VERSION:
helmClients.Add(helmv2.VERSION, helmv2.New(versionedLogger, kubeClient, helmv2.TillerOptions{
Host: *tillerIP,
Port: *tillerPort,
Namespace: *tillerNamespace,
Expand All @@ -212,9 +218,9 @@ func main() {
TLSCACert: *tillerTLSCACert,
TLSHostname: *tillerTLSHostname,
}))
case v3.VERSION:
client := v3.New(versionedLogger, cfg)
helmClients.Add(v3.VERSION, client)
case helmv3.VERSION:
client := helmv3.New(versionedLogger, cfg)
helmClients.Add(helmv3.VERSION, client)
default:
mainLogger.Log("error", fmt.Sprintf("unsupported Helm version: %s", v))
continue
Expand Down
4 changes: 2 additions & 2 deletions pkg/helm/v2/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package v2
import (
"k8s.io/helm/pkg/downloader"

"github.com/fluxcd/helm-operator/pkg/helm"
"github.com/fluxcd/helm-operator/pkg/utils"
)

func (h *HelmV2) DependencyUpdate(chartPath string) error {
out := helm.NewLogWriter(h.logger)
out := utils.NewLogWriter(h.logger)
man := downloader.Manager{
Out: out,
ChartPath: chartPath,
Expand Down
4 changes: 2 additions & 2 deletions pkg/helm/v2/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/urlutil"

"github.com/fluxcd/helm-operator/pkg/helm"
"github.com/fluxcd/helm-operator/pkg/utils"
)

func (h *HelmV2) Pull(ref, version, dest string) (string, error) {
repositoryConfigLock.RLock()
defer repositoryConfigLock.RUnlock()

out := helm.NewLogWriter(h.logger)
out := utils.NewLogWriter(h.logger)
c := downloader.ChartDownloader{
Out: out,
HelmHome: helmHome(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/helm/v3/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package v3
import (
"helm.sh/helm/v3/pkg/downloader"

"github.com/fluxcd/helm-operator/pkg/helm"
"github.com/fluxcd/helm-operator/pkg/utils"
)

func (h *HelmV3) DependencyUpdate(chartPath string) error {
out := helm.NewLogWriter(h.logger)
out := utils.NewLogWriter(h.logger)
man := &downloader.Manager{
Out: out,
ChartPath: chartPath,
Expand Down
4 changes: 2 additions & 2 deletions pkg/helm/v3/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/repo"

"github.com/fluxcd/helm-operator/pkg/helm"
"github.com/fluxcd/helm-operator/pkg/utils"
)

func (h *HelmV3) Pull(ref, version, dest string) (string, error) {
repositoryConfigLock.RLock()
defer repositoryConfigLock.RUnlock()

out := helm.NewLogWriter(h.logger)
out := utils.NewLogWriter(h.logger)
c := downloader.ChartDownloader{
Out: out,
Verify: downloader.VerifyNever,
Expand Down
2 changes: 1 addition & 1 deletion pkg/helm/logwriter.go → pkg/utils/logwriter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package helm
package utils

import (
"fmt"
Expand Down

0 comments on commit 52f4f52

Please sign in to comment.