Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

add cfg.LoadAndValidate back #90

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion converters/google/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ type AssetResource struct {
}

// NewConverter is a factory function for Converter.
func NewConverter(ancestryManager ancestrymanager.AncestryManager, project, credentials string) (*Converter, error) {
func NewConverter(ancestryManager ancestrymanager.AncestryManager, project, credentials string, offline bool) (*Converter, error) {
cfg := &converter.Config{
Project: project,
Credentials: credentials,
}
if !offline {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just check for a nil config/client instead of needing to pass this boolean around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client is cfg so it was not pass into this function. I am also very tempted to extract cfg construction out of this function but @morgante may know better if it is the right way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it as-is.

converter.ConfigureBasePaths(cfg)
if err := cfg.LoadAndValidate(); err != nil {
return nil, errors.Wrap(err, "load and validate config")
}
}
p := provider.Provider().(*schema.Provider)
return &Converter{
schema: p,
Expand Down
2 changes: 1 addition & 1 deletion tfgcv/planned_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ReadPlannedAssets(path, project, ancestry string, offline bool) ([]google.A
if err != nil {
return nil, errors.Wrap(err, "constructing resource manager client")
}
converter, err := google.NewConverter(ancestryManager, project, "")
converter, err := google.NewConverter(ancestryManager, project, "", offline)
if err != nil {
return nil, errors.Wrap(err, "building google converter")
}
Expand Down