| 520 | } |
| 521 | |
| 522 | func (r *Runner) GetJITConfigFile(ctx context.Context, file string) ([]byte, error) { |
| 523 | if !auth.InstanceHasJITConfig(ctx) { |
| 524 | return nil, runnerErrors.NewNotFoundError("instance not configured for JIT") |
| 525 | } |
| 526 | |
| 527 | instance, err := validateInstanceState(ctx) |
| 528 | if err != nil { |
| 529 | slog.With(slog.Any("error", err)).ErrorContext( |
| 530 | ctx, "failed to get instance params") |
| 531 | return nil, runnerErrors.ErrUnauthorized |
| 532 | } |
| 533 | jitConfig := instance.JitConfiguration |
| 534 | contents, ok := jitConfig[file] |
| 535 | if !ok { |
| 536 | return nil, runnerErrors.NewNotFoundError("could not find file %q", file) |
| 537 | } |
| 538 | |
| 539 | decoded, err := base64.StdEncoding.DecodeString(contents) |
| 540 | if err != nil { |
| 541 | return nil, fmt.Errorf("error decoding file contents: %w", err) |
| 542 | } |
| 543 | |
| 544 | return decoded, nil |
| 545 | } |
| 546 | |
| 547 | func (r *Runner) GetInstanceGithubRegistrationToken(ctx context.Context) (string, error) { |
| 548 | // Check if this instance already fetched a registration token or if it was configured using |