(enforcedRunnerType schemaapi.CraftingSchema_Runner_RunnerType, dryRun bool, authToken string, logger zerolog.Logger)
| 132 | } |
| 133 | |
| 134 | func 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 | } |
no test coverage detected