Skip to content

Commit

Permalink
Simplify ParseOrUse.
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavgerchev committed Feb 22, 2024
1 parent 4a73cd9 commit 6f28c2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/cnspec/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func getCobraScanConfig(cmd *cobra.Command, runtime *providers.Runtime, cliRes *
cliRes.Asset.Name = assetName
}

inv, err := inventoryloader.ParseOrUse(func() *inventory.Asset { return cliRes.Asset }, viper.GetBool("insecure"), optAnnotations)
inv, err := inventoryloader.ParseOrUse(cliRes.Asset, viper.GetBool("insecure"), optAnnotations)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse inventory")
}
Expand Down
15 changes: 6 additions & 9 deletions apps/cnspec/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,14 @@ func getServeConfig() (*scanConfig, *cnspec_config.CliConfig, error) {
}
var err error

assetFn := func() *inventory.Asset {
log.Info().Msg("configure inventory to scan local operating system")
return &inventory.Asset{
Connections: []*inventory.Config{{
Type: "local",
}},
Annotations: optAnnotations,
}
asset := &inventory.Asset{
Connections: []*inventory.Config{{
Type: "local",
}},
Annotations: optAnnotations,
}

conf.Inventory, err = inventoryloader.ParseOrUse(assetFn, viper.GetBool("insecure"), optAnnotations)
conf.Inventory, err = inventoryloader.ParseOrUse(asset, viper.GetBool("insecure"), optAnnotations)
if err != nil {
return nil, nil, errors.Wrap(err, "could not load configuration")
}
Expand Down

0 comments on commit 6f28c2b

Please sign in to comment.