Skip to content

Commit

Permalink
make specific adapter var to global
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Kumar Sahu <[email protected]>
  • Loading branch information
viveksahu26 committed Feb 19, 2025
1 parent 16c1ec3 commit 57bc2db
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
15 changes: 4 additions & 11 deletions pkg/source/github/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ type GitHubAdapter struct {
ExcludeRepos []string
}

type ProcessingMode string

const (
FetchParallel ProcessingMode = "parallel"
FetchSequential ProcessingMode = "sequential"
)

type GitHubMethod string

const (
Expand Down Expand Up @@ -240,13 +233,13 @@ func (g *GitHubAdapter) FetchSBOMs(ctx *tcontext.TransferMetadata) (iterator.SBO

logger.LogDebug(ctx.Context, "Listing repos of organization after filtering", "values", repos)

processingMode := FetchSequential
processingMode := types.FetchSequential
var sbomIterator iterator.SBOMIterator

switch ProcessingMode(processingMode) {
case FetchParallel:
switch processingMode {
case types.FetchParallel:
sbomIterator, err = g.fetchSBOMsConcurrently(ctx, repos)
case FetchSequential:
case types.FetchSequential:
sbomIterator, err = g.fetchSBOMsSequentially(ctx, repos)
default:
return nil, fmt.Errorf("Unsupported Processing Mode !!")
Expand Down
23 changes: 5 additions & 18 deletions pkg/target/interlynk/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,7 @@ type InterlynkAdapter struct {

// HTTP client for API requests
client *http.Client
settings UploadSettings
}

type UploadMode string

const (
UploadParallel UploadMode = "parallel"
UploadBatching UploadMode = "batch"
UploadSequential UploadMode = "sequential"
)

// UploadSettings contains configuration for SBOM uploads
type UploadSettings struct {
ProcessingMode UploadMode // "sequential", "parallel", or "batch"
settings types.UploadSettings
}

// AddCommandParams adds GitHub-specific CLI flags
Expand Down Expand Up @@ -130,7 +117,7 @@ func (i *InterlynkAdapter) ParseAndValidateParams(cmd *cobra.Command) error {
i.ProjectName = projectName
i.ProjectEnv = projectEnv
i.ApiKey = token
i.settings = UploadSettings{ProcessingMode: UploadSequential}
i.settings = types.UploadSettings{ProcessingMode: types.UploadSequential}

logger.LogDebug(cmd.Context(), "Interlynk parameters validated and assigned",
"url", i.BaseURL,
Expand All @@ -154,17 +141,17 @@ func (i *InterlynkAdapter) UploadSBOMs(ctx *tcontext.TransferMetadata, iterator

switch i.settings.ProcessingMode {

case UploadParallel:
case types.UploadParallel:
// TODO: cuncurrent upload: As soon as we get the SBOM, upload it
// i.uploadParallel()
return fmt.Errorf("processing mode %q not yet implemented", i.settings.ProcessingMode)

case UploadBatching:
case types.UploadBatching:
// TODO: hybrid of sequential + parallel
// i.uploadBatch()
return fmt.Errorf("processing mode %q not yet implemented", i.settings.ProcessingMode)

case UploadSequential:
case types.UploadSequential:
// Sequential Processing: Fetch SBOM → Upload → Repeat
i.uploadSequential(ctx, iterator)

Expand Down
20 changes: 20 additions & 0 deletions pkg/types/adapter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,23 @@ const (
GithubAdapterType AdapterType = "github"
InterlynkAdapterType AdapterType = "interlynk"
)

type ProcessingMode string

const (
FetchParallel ProcessingMode = "parallel"
FetchSequential ProcessingMode = "sequential"
)

type UploadMode string

const (
UploadParallel UploadMode = "parallel"
UploadBatching UploadMode = "batch"
UploadSequential UploadMode = "sequential"
)

// UploadSettings contains configuration for SBOM uploads
type UploadSettings struct {
ProcessingMode UploadMode // "sequential", "parallel", or "batch"
}

0 comments on commit 57bc2db

Please sign in to comment.