Skip to content

Commit

Permalink
Refactor main package
Browse files Browse the repository at this point in the history
create internal package and move implementation into this package
  • Loading branch information
janboll committed Jul 16, 2024
1 parent 0102e6b commit 59deeb0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package internal

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package internal

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package internal

import (
"context"
Expand All @@ -12,8 +12,13 @@ import (
"github.com/containers/image/signature"
"github.com/containers/image/types"
"github.com/spf13/viper"
"go.uber.org/zap"
)

func Log() *zap.SugaredLogger {
return zap.L().Sugar()
}

// SyncConfig is the configuration for the image sync
type SyncConfig struct {
Repositories []string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package internal

import (
"testing"
Expand Down
11 changes: 4 additions & 7 deletions tooling/image-sync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"time"

"github.com/Azure/ARO-HCP/tooling/image-sync/internal"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
Expand All @@ -17,17 +18,13 @@ var (
Short: "image-sync",
Long: "image-sync",
RunE: func(cmd *cobra.Command, args []string) error {
return DoSync()
return internal.DoSync()
},
}
cfgFile string
logLevel string
)

func Log() *zap.SugaredLogger {
return zap.L().Sugar()
}

func main() {
syncCmd.Flags().StringVarP(&cfgFile, "cfgFile", "c", "", "Configuration File")
syncCmd.Flags().StringVarP(&logLevel, "logLevel", "l", "", "Loglevel (info, debug, error, warn, fatal, panic)")
Expand All @@ -45,8 +42,8 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
Log().Debugw("Using configuration", "config", cfgFile)
if err := viper.ReadInConfig(); err != nil {
defaultlog.Fatal(err)
}
}

Expand Down

0 comments on commit 59deeb0

Please sign in to comment.