Skip to content

Commit

Permalink
update to return ingested IDs but not needed for ingestion cmd
Browse files Browse the repository at this point in the history
Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 committed Aug 4, 2024
1 parent 0c8d54c commit f7cf477
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/guacingest/cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func ingest(cmd *cobra.Command, args []string) {
defer csubClient.Close()

emit := func(d *processor.Document) error {
if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
if _, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
var urlErr *url.Error
if errors.As(err, &urlErr) {
return fmt.Errorf("unable to ingest document due to connection error with graphQL %q : %w", d.SourceInformation.Source, urlErr)
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/annotate_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var annotateMetadata = &cobra.Command{
preds.HasMetadata = append(preds.HasMetadata, metadata)
assemblerInputs := []assembler.IngestPredicates{*preds}

err = assemblerFunc(assemblerInputs)
_, err = assemblerFunc(assemblerInputs)
if err != nil {
logger.Fatalf("unable to assemble graphs: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/certify.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ var certifyCmd = &cobra.Command{

assemblerInputs := []assembler.IngestPredicates{*preds}

err = assemblerFunc(assemblerInputs)
_, err = assemblerFunc(assemblerInputs)
if err != nil {
logger.Fatalf("unable to assemble graphs: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/deps_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var depsDevCmd = &cobra.Command{
emit := func(d *processor.Document) error {
totalNum += 1

if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csc, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
if _, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csc, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
gotErr = true
return fmt.Errorf("unable to ingest document: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var filesCmd = &cobra.Command{

emit := func(d *processor.Document) error {
totalNum += 1
if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
if _, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion); err != nil {
gotErr = true
filesWithErrors = append(filesWithErrors, d.SourceInformation.Source)
return fmt.Errorf("unable to ingest document: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var gcsCmd = &cobra.Command{

emit := func(d *processor.Document) error {
totalNum += 1
err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)
_, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)

if err != nil {
gotErr = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var githubCmd = &cobra.Command{
var errFound bool

emit := func(d *processor.Document) error {
err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)
_, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)

if err != nil {
errFound = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var ociCmd = &cobra.Command{
// Set emit function to go through the entire pipeline
emit := func(d *processor.Document) error {
totalNum += 1
err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)
_, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)

if err != nil {
gotErr = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll
errFound := false

emit := func(d *processor.Document) error {
err := ingestor.Ingest(ctx, d, s3Opts.graphqlEndpoint, transport, csubClient, s3Opts.queryVulnOnIngestion, s3Opts.queryLicenseOnIngestion)
_, err := ingestor.Ingest(ctx, d, s3Opts.graphqlEndpoint, transport, csubClient, s3Opts.queryVulnOnIngestion, s3Opts.queryLicenseOnIngestion)

if err != nil {
errFound = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/guacone/cmd/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var scorecardCmd = &cobra.Command{
// Set emit function to go through the entire pipeline
emit := func(d *processor.Document) error {
totalNum += 1
err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)
_, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient, opts.queryVulnOnIngestion, opts.queryLicenseOnIngestion)

if err != nil {
return fmt.Errorf("unable to ingest document: %v", err)
Expand Down
7 changes: 4 additions & 3 deletions pkg/ingestor/ingestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func Ingest(
logger.Infof("unable to create entries in collectsub server, but continuing: %v", err)
}

if ingestedIDs, err := assemblerFunc(predicates); err != nil {
ingestedIDs, err := assemblerFunc(predicates)
if err != nil {
return nil, fmt.Errorf("error assembling graphs for %q : %w", d.SourceInformation.Source, err)
}

Expand Down Expand Up @@ -130,7 +131,7 @@ func MergedIngest(
totalPredicates += 1
// enough predicates have been collected, worth sending them to GraphQL server
if totalPredicates == 5000 {
err = assemblerFunc(predicates)
_, err = assemblerFunc(predicates)
if err != nil {
return fmt.Errorf("unable to assemble graphs: %v", err)
}
Expand All @@ -147,7 +148,7 @@ func MergedIngest(
logger.Infof("unable to create entries in collectsub server, but continuing: %v", err)
}

err = assemblerFunc(predicates)
_, err = assemblerFunc(predicates)
if err != nil {
return fmt.Errorf("unable to assemble graphs: %v", err)
}
Expand Down

0 comments on commit f7cf477

Please sign in to comment.