LoadInfo loads basic environment metadata without requiring dagger operations. This is useful for operations that only need access to configuration and state information without the overhead of initializing container operations.
(ctx context.Context, id string, state []byte, worktree string)
| 88 | // This is useful for operations that only need access to configuration and state |
| 89 | // information without the overhead of initializing container operations. |
| 90 | func LoadInfo(ctx context.Context, id string, state []byte, worktree string) (*EnvironmentInfo, error) { |
| 91 | envInfo := &EnvironmentInfo{ |
| 92 | ID: id, |
| 93 | State: &State{}, |
| 94 | } |
| 95 | |
| 96 | if err := envInfo.State.Unmarshal(state); err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | |
| 100 | // Backward compatibility: if there's no config in the state, load it from the worktree |
| 101 | if envInfo.State.Config == nil { |
| 102 | config := DefaultConfig() |
| 103 | if err := config.Load(worktree); err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | envInfo.State.Config = config |
| 107 | } |
| 108 | |
| 109 | return envInfo, nil |
| 110 | } |
| 111 | |
| 112 | func (env *Environment) apply(ctx context.Context, newState *dagger.Container) error { |
| 113 | // TODO(braa): is this sync redundant with newState.ID? |
no test coverage detected