-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
193 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dvcore | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cayleygraph/cayley" | ||
"github.com/cayleygraph/cayley/schema" | ||
"go.uber.org/zap" | ||
"moul.io/depviz/v3/internal/dvparser" | ||
"moul.io/multipmuri" | ||
) | ||
|
||
type FetchOpts struct { | ||
Logger *zap.Logger | ||
Schema *schema.Config | ||
|
||
GitHubToken string | ||
Resync bool | ||
} | ||
|
||
func Fetch(h *cayley.Handle, args []string, opts FetchOpts) error { | ||
targets, err := dvparser.ParseTargets(args) | ||
if err != nil { | ||
return fmt.Errorf("parse targets: %w", err) | ||
} | ||
|
||
_, err = PullAndSave(targets, h, opts.Schema, opts.GitHubToken, opts.Resync, opts.Logger) | ||
return err | ||
} | ||
|
||
func PullAndSave(targets []multipmuri.Entity, h *cayley.Handle, schema *schema.Config, githubToken string, resync bool, logger *zap.Logger) (bool, error) { | ||
batches := pullBatches(targets, h, githubToken, resync, logger) | ||
if len(batches) > 0 { | ||
err := saveBatches(h, schema, batches) | ||
if err != nil { | ||
return false, fmt.Errorf("save batches: %w", err) | ||
} | ||
return true, nil | ||
} | ||
return false, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters