MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / DiscoverAndEnforceRunner

Function DiscoverAndEnforceRunner

pkg/attestation/crafter/runner.go:134–153  ·  view source on GitHub ↗
(enforcedRunnerType schemaapi.CraftingSchema_Runner_RunnerType, dryRun bool, authToken string, logger zerolog.Logger)

Source from the content-addressed store, hash-verified

132}
133
134func DiscoverAndEnforceRunner(enforcedRunnerType schemaapi.CraftingSchema_Runner_RunnerType, dryRun bool, authToken string, logger zerolog.Logger) (SupportedRunner, error) {
135 discoveredRunner := DiscoverRunner(authToken, logger)
136
137 logger.Debug().
138 Str("discovered", discoveredRunner.ID().String()).
139 Str("enforced", enforcedRunnerType.String()).
140 Msg("checking runner context")
141
142 // If the runner type is not specified and it's a dry run, we don't enforce it
143 if enforcedRunnerType == schemaapi.CraftingSchema_Runner_RUNNER_TYPE_UNSPECIFIED || dryRun {
144 return discoveredRunner, nil
145 }
146
147 // Otherwise we enforce the runner type
148 if enforcedRunnerType != discoveredRunner.ID() {
149 return nil, fmt.Errorf("runner not found %s", enforcedRunnerType)
150 }
151
152 return discoveredRunner, nil
153}

Callers 1

RunMethod · 0.92

Calls 4

DiscoverRunnerFunction · 0.85
StringMethod · 0.65
IDMethod · 0.65
DebugMethod · 0.45

Tested by

no test coverage detected