MCPcopy Create free account
hub / github.com/cloudbase/garm / GetJITConfigFile

Method GetJITConfigFile

runner/metadata.go:522–545  ·  view source on GitHub ↗
(ctx context.Context, file string)

Source from the content-addressed store, hash-verified

520}
521
522func (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
547func (r *Runner) GetInstanceGithubRegistrationToken(ctx context.Context) (string, error) {
548 // Check if this instance already fetched a registration token or if it was configured using

Calls 2

InstanceHasJITConfigFunction · 0.92
validateInstanceStateFunction · 0.85