diff --git a/pkg/source/github/adapter.go b/pkg/source/github/adapter.go index 4af4279..0a4efe0 100644 --- a/pkg/source/github/adapter.go +++ b/pkg/source/github/adapter.go @@ -49,13 +49,6 @@ type GitHubAdapter struct { ExcludeRepos []string } -type ProcessingMode string - -const ( - FetchParallel ProcessingMode = "parallel" - FetchSequential ProcessingMode = "sequential" -) - type GitHubMethod string const ( @@ -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 !!") diff --git a/pkg/target/interlynk/adapter.go b/pkg/target/interlynk/adapter.go index c961c90..58409c9 100644 --- a/pkg/target/interlynk/adapter.go +++ b/pkg/target/interlynk/adapter.go @@ -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 @@ -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, @@ -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) diff --git a/pkg/types/adapter_types.go b/pkg/types/adapter_types.go index 99fda84..a70ea8a 100644 --- a/pkg/types/adapter_types.go +++ b/pkg/types/adapter_types.go @@ -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" +}