Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
Signed-off-by: houdini91 <mdstrauss91@gmail.com>
  • Loading branch information
houdini91 committed Apr 17, 2022
1 parent 1e5dde2 commit c277661
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/wagoodman/go-partybus"
)

func LibInitBase(cfg *config.Application, l logger.Logger, enable_ui bool) ([]ui.UI, error) {
func libInitBase(cfg *config.Application, l logger.Logger, enable_ui bool) ([]ui.UI, error) {
if err := cfg.LibParseConfigValues(); err != nil {
return nil, fmt.Errorf("invalid application config: %w", err)
}
Expand Down Expand Up @@ -49,13 +49,19 @@ func libInitEventBus() {
}
}

// LibPackagesExec run packages command as a library
// userInput: target
// cfg: syft configuration structure
// l: logger to attach to, nil for default syft logger
// enable_ui: enable disable ui output
// Function return sbom or errors.
func LibPackagesExec(userInput string, cfg *config.Application, l logger.Logger, enable_ui bool) (*sbom.SBOM, error) {
writer, err := makeWriter(cfg.Outputs, cfg.File)
if err != nil {
return nil, err
}

uis, err := LibInitBase(cfg, l, enable_ui)
uis, err := libInitBase(cfg, l, enable_ui)
if err != nil {
return nil, err
}
Expand All @@ -74,7 +80,7 @@ func LibPackagesExec(userInput string, cfg *config.Application, l logger.Logger,

libInitEventBus()
outSbom, errs := packagesExecWorker(*si, cfg, writer)
return SbomEventLoop(
return sbomEventLoop(
outSbom, errs,
setupSignals(),
eventSubscription,
Expand All @@ -83,7 +89,7 @@ func LibPackagesExec(userInput string, cfg *config.Application, l logger.Logger,
)
}

func SbomEventLoop(outSbom <-chan *sbom.SBOM, workerErrs <-chan error, signals <-chan os.Signal, subscription *partybus.Subscription, cleanupFn func(), uxs ...ui.UI) (*sbom.SBOM, error) {
func sbomEventLoop(outSbom <-chan *sbom.SBOM, workerErrs <-chan error, signals <-chan os.Signal, subscription *partybus.Subscription, cleanupFn func(), uxs ...ui.UI) (*sbom.SBOM, error) {
err := eventLoop(workerErrs,
signals,
subscription,
Expand Down

0 comments on commit c277661

Please sign in to comment.