Skip to content

Commit

Permalink
- Correction due to integration tests.
Browse files Browse the repository at this point in the history
Signed-off-by: HeyeOpenSource <[email protected]>
  • Loading branch information
HeyeOpenSource committed Oct 30, 2024
1 parent 464e11e commit 438d94f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
13 changes: 7 additions & 6 deletions cmd/syft/internal/options/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import (
"strings"

"github.com/anchore/clio"
"github.com/anchore/syft/syft/credential"
"github.com/anchore/syft/syft/pkg/cataloger/dotnet"
)

type dotNetProviderCredentials []dotNetProviderCredential

func (dnpc dotNetProviderCredentials) ToProviderCredentials() []dotnet.ProviderCredential {
result := []dotnet.ProviderCredential{}
for _, credential := range dnpc {
result = append(result, dotnet.ProviderCredential{
Username: credential.Username.String(),
Password: credential.Password.String(),
func (dnpc dotNetProviderCredentials) ToProviderCredentials() []credential.SimpleCredential {
result := []credential.SimpleCredential{}
for _, _credential := range dnpc {
result = append(result, credential.SimpleCredential{
Username: _credential.Username.String(),
Password: _credential.Password.String(),
})
}

Expand Down
31 changes: 13 additions & 18 deletions syft/pkg/cataloger/dotnet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"strings"
"sync"
"time"

"github.com/anchore/syft/syft/credential"
)

const (
Expand All @@ -26,21 +28,12 @@ var (
defaultProviders = ""
)

type ProviderCredential struct {
Username string `yaml:"username" json:"username" mapstructure:"username"`
Password string `yaml:"password" json:"password" mapstructure:"password"`
}

func (pc ProviderCredential) Valid() bool {
return pc.Username != "" && pc.Password != ""
}

type CatalogerConfig struct {
SearchLocalLicenses bool `yaml:"search-local-licenses" json:"search-local-licenses" mapstructure:"search-local-licenses"`
LocalCachePaths []string `yaml:"local-cache-paths" json:"local-cache-paths" mapstructure:"local-cache-paths"`
SearchRemoteLicenses bool `yaml:"search-remote-licenses" json:"search-remote-licenses" mapstructure:"search-remote-licenses"`
Providers []string `yaml:"package-providers,omitempty" json:"package-providers,omitempty" mapstructure:"package-providers"`
ProviderCredentials []ProviderCredential `yaml:"package-provider-credentials,omitempty" json:"package-provider-credentials,omitempty" mapstructure:"package-provider-credentials"`
SearchLocalLicenses bool `yaml:"search-local-licenses" json:"search-local-licenses" mapstructure:"search-local-licenses"`
LocalCachePaths []string `yaml:"local-cache-paths" json:"local-cache-paths" mapstructure:"local-cache-paths"`
SearchRemoteLicenses bool `yaml:"search-remote-licenses" json:"search-remote-licenses" mapstructure:"search-remote-licenses"`
Providers []string `yaml:"package-providers,omitempty" json:"package-providers,omitempty" mapstructure:"package-providers"`
ProviderCredentials []credential.SimpleCredential `yaml:"package-provider-credentials,omitempty" json:"package-provider-credentials,omitempty" mapstructure:"package-provider-credentials"`
}

// DefaultCatalogerConfig create a CatalogerConfig with default options, which includes:
Expand Down Expand Up @@ -78,14 +71,16 @@ func (g CatalogerConfig) WithProviders(input string) CatalogerConfig {
return g
}

func (g CatalogerConfig) WithCredentials(input []ProviderCredential) CatalogerConfig {
func (g CatalogerConfig) WithCredentials(input []credential.SimpleCredential) CatalogerConfig {
if len(input) == 0 {
return g
}

for _, credential := range input {
if credential.Valid() {
g.ProviderCredentials = append([]ProviderCredential{}, credential)
g.ProviderCredentials = []credential.SimpleCredential{}

for _, _credential := range input {
if _credential.Valid() {
g.ProviderCredentials = append(g.ProviderCredentials, _credential)
}
}

Expand Down

0 comments on commit 438d94f

Please sign in to comment.