diff --git a/pkg/db/db.go b/pkg/db/db.go index 70998c437f..577744ddb9 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -35,11 +35,11 @@ type Client struct { githubClient GitHubOperation } -func NewClient(ctx context.Context) Client { +func NewClient() Client { return Client{ dbc: db.Config{}, clock: clock.RealClock{}, - githubClient: github.NewClient(ctx), + githubClient: github.NewClient(), } } diff --git a/pkg/github/github.go b/pkg/github/github.go index 55c60b8676..e5e8ce42bf 100644 --- a/pkg/github/github.go +++ b/pkg/github/github.go @@ -5,14 +5,12 @@ import ( "fmt" "io" "net/http" - "os" "sort" "strings" "github.com/aquasecurity/trivy-db/pkg/db" "github.com/aquasecurity/trivy/pkg/log" "github.com/google/go-github/v28/github" - "golang.org/x/oauth2" "golang.org/x/xerrors" ) @@ -45,12 +43,8 @@ type Client struct { Repository RepositoryInterface } -func NewClient(ctx context.Context) Client { - ts := oauth2.StaticTokenSource( - &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, - ) - tc := oauth2.NewClient(ctx, ts) - gc := github.NewClient(tc) +func NewClient() Client { + gc := github.NewClient(nil) repo := Repository{ repository: gc.Repositories, diff --git a/pkg/run.go b/pkg/run.go index bdcb82ee7e..50fe6b39b5 100644 --- a/pkg/run.go +++ b/pkg/run.go @@ -46,8 +46,8 @@ func Run(c *cli.Context) (err error) { light := c.Bool("light") if !skipUpdate { + client := dbFile.NewClient() ctx := context.Background() - client := dbFile.NewClient(ctx) if err = client.Download(ctx, c.App.Version, cacheDir, light); err != nil { return xerrors.Errorf("failed to download vulnerability DB: %w", err) }