-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port OS Environment varialbes to viper config #127
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
asrr: | ||
s3: | ||
region: | ||
endpoint: | ||
bucket: | ||
access_key: | ||
secret_key: | ||
s3: | ||
access_key: | ||
secret_key: | ||
serverservice: | ||
client_secret: | ||
client_id: | ||
oidc_provider_endpoint: | ||
audience_endpoint: | ||
github: | ||
openbmc_token: |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ import ( | |
"os" | ||
|
||
"github.com/bmc-toolbox/common" | ||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/metal-toolbox/firmware-syncer/internal/config" | ||
"github.com/metal-toolbox/firmware-syncer/internal/vendors" | ||
"github.com/metal-toolbox/firmware-syncer/internal/vendors/asrockrack" | ||
|
@@ -15,6 +13,8 @@ import ( | |
"github.com/metal-toolbox/firmware-syncer/internal/vendors/intel" | ||
"github.com/metal-toolbox/firmware-syncer/internal/vendors/mellanox" | ||
"github.com/metal-toolbox/firmware-syncer/internal/vendors/supermicro" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
|
@@ -46,6 +46,16 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
logger.SetLevel(logrus.InfoLevel) | ||
} | ||
|
||
// Load up configs | ||
v := viper.New() | ||
v.SetConfigFile("config.yaml") | ||
v.AddConfigPath(".") | ||
err := v.ReadInConfig() | ||
|
||
if err != nil { | ||
logger.Error("Failed to find viper config file") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be a |
||
} | ||
|
||
// Load configuration | ||
cfgSyncer, err := config.LoadSyncerConfig(configFile) | ||
if err != nil { | ||
|
@@ -67,7 +77,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case common.VendorDell: | ||
var dup vendors.Vendor | ||
|
||
dup, err = dell.NewDUP(context.TODO(), firmwares, cfgSyncer, logger) | ||
dup, err = dell.NewDUP(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of passing the viper pointer, it would be nicer (IMO) to parse this into one (or several?) structs that were specific to the vendors? |
||
if err != nil { | ||
logger.Error("Failed to initialize Dell vendor: " + err.Error()) | ||
return nil, err | ||
|
@@ -77,7 +87,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case common.VendorAsrockrack: | ||
var asrr vendors.Vendor | ||
|
||
asrr, err = asrockrack.New(context.TODO(), firmwares, cfgSyncer, logger) | ||
asrr, err = asrockrack.New(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
if err != nil { | ||
logger.Error("Failed to initialize ASRockRack vendor:" + err.Error()) | ||
return nil, err | ||
|
@@ -87,7 +97,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case common.VendorSupermicro: | ||
var sm vendors.Vendor | ||
|
||
sm, err = supermicro.New(context.TODO(), firmwares, cfgSyncer, logger) | ||
sm, err = supermicro.New(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
if err != nil { | ||
logger.Error("Failed to initialize Supermicro vendor: " + err.Error()) | ||
return nil, err | ||
|
@@ -97,7 +107,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case common.VendorMellanox: | ||
var mlx vendors.Vendor | ||
|
||
mlx, err = mellanox.New(context.TODO(), firmwares, cfgSyncer, logger) | ||
mlx, err = mellanox.New(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
if err != nil { | ||
logger.Error("Failed to initialize Mellanox vendor: " + err.Error()) | ||
return nil, err | ||
|
@@ -107,7 +117,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case common.VendorIntel: | ||
var i vendors.Vendor | ||
|
||
i, err = intel.New(context.TODO(), firmwares, cfgSyncer, logger) | ||
i, err = intel.New(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
if err != nil { | ||
logger.Error("Failed to initialize Intel vendor: " + err.Error()) | ||
return nil, err | ||
|
@@ -117,7 +127,7 @@ func New(configFile string, logLevel int) (*Syncer, error) { | |
case "equinix": | ||
var e vendors.Vendor | ||
|
||
e, err = equinix.New(context.TODO(), firmwares, cfgSyncer, logger) | ||
e, err = equinix.New(context.TODO(), firmwares, cfgSyncer, logger, v) | ||
if err != nil { | ||
logger.Error("Failed to initialize Equinix vendor: " + err.Error()) | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between the
s3
andasrr.s3
stanzas?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DoctorVin s3 is the destination bucket. asrr s3 is the source bucket for AsRockrack firmware images. It's a hack because our firmware images for ASRR come from a ftp site that's not available publicly so at the time this was added we agreed to keep the fw images in that s3 bucket and sync from there instead of using the private ftp they provide.