submitter

package
v0.64.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package submitter is L8 of the SigComply CLI: optional cloud submission. Acquires an OIDC token from the CI provider (GitHub Actions, GitLab CI) and POSTs the SubmissionPayload — and only the SubmissionPayload — to {cloud_base_url}/api/v1/runs. Submission failures are logged, never fatal.

See docs/architecture/02-layers.md for the full layer contract.

Package submitter is L8 of the SigComply CLI: optional cloud submission. Acquires an OIDC token from the CI provider (GitHub Actions or GitLab CI) and POSTs the core.SubmissionPayload — and only the SubmissionPayload — to {cloud_base_url}/api/v1/runs. Submission failures are logged, never fatal.

See docs/architecture/02-layers.md §L8 and 06-aggregation.md.

Index

Constants

View Source
const DefaultAudience = "https://api.sigcomply.com"

DefaultAudience is the OIDC token audience the CLI requests when running in CI. Self-hosted deployments override via the OIDC.Audience field.

View Source
const Path = "/api/v1/runs"

Path is the cloud endpoint relative to base_url.

Variables

View Source
var ErrNoToken = fmt.Errorf("submitter: no OIDC token source detected")

ErrNoToken is returned by providers when no token source is available in the environment.

Functions

func HasOIDC

func HasOIDC() bool

HasOIDC reports whether any provider in the default chain can produce a token. The orchestrator uses this before calling Submit so the decision matrix can be evaluated upfront.

func InCI

func InCI() bool

InCI reports whether the current process is running in any recognized CI environment.

Types

type Decision

type Decision int

Decision is the result of evaluating whether to submit.

const (
	DecisionSubmit       Decision = iota
	DecisionSkip                  // no cloud URL, no CI, or user passed --no-cloud
	DecisionMissingToken          // explicit --cloud but OIDC unavailable
)

Decision values.

func Decide

func Decide(opts Options, hasOIDC, inCI bool) Decision

Decide encapsulates the policy described in 06-aggregation.md §Decision matrix. The orchestrator calls Decide first to choose whether to call Submit and to surface the right diagnostic.

type Options

type Options struct {
	BaseURL string // e.g. "https://api.sigcomply.com" — empty disables submission.
	Force   bool   // true if --cloud was passed; require submission.
	Disable bool   // true if --no-cloud was passed; never submit.
	// HTTPClient is injected by tests; nil defaults to a 30s-timeout
	// http.Client.
	HTTPClient *http.Client
	// TokenProvider is injected by tests; nil uses the auto-detected
	// CI providers (GitHub Actions, GitLab CI).
	TokenProvider TokenProvider
	// CLIVersion is stamped in the X-Sigcomply-CLI-Version header.
	CLIVersion string
}

Options control whether and where to submit.

type Response

type Response struct {
	StatusCode int
	Body       []byte
}

Response is the parsed cloud response.

func Submit

func Submit(ctx context.Context, opts Options, payload *core.SubmissionPayload) (Response, error)

Submit POSTs the payload to {BaseURL}{Path}. Failures are returned as errors so the caller can log them; the caller is responsible for the "submission failures are non-fatal" policy.

type TokenProvider

type TokenProvider interface {
	Token(ctx context.Context, audience string) (token, providerName string, err error)
}

TokenProvider returns an OIDC token suitable for cloud authentication. The returned providerName drives the X-OIDC-Provider header.

func DefaultTokenProvider

func DefaultTokenProvider() TokenProvider

DefaultTokenProvider returns a TokenProvider that tries GitHub Actions then GitLab CI, returning ErrNoToken if neither is available.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL