MCPcopy Index your code
hub / github.com/coder/coder / GetAllDependencies

Method GetAllDependencies

agent/unit/manager.go:242–271  ·  view source on GitHub ↗

GetAllDependencies returns all dependencies for a unit, both satisfied and unsatisfied.

(unit ID)

Source from the content-addressed store, hash-verified

240
241// GetAllDependencies returns all dependencies for a unit, both satisfied and unsatisfied.
242func (m *Manager) GetAllDependencies(unit ID) ([]Dependency, error) {
243 m.mu.RLock()
244 defer m.mu.RUnlock()
245
246 if unit == "" {
247 return nil, xerrors.Errorf("unit ID cannot be empty: %w", ErrUnitIDRequired)
248 }
249
250 if !m.registered(unit) {
251 return nil, xerrors.Errorf("checking registration for unit %q: %w", unit, ErrUnitNotFound)
252 }
253
254 dependencies := m.graph.GetForwardAdjacentVertices(unit)
255
256 var allDependencies []Dependency
257
258 for _, dependency := range dependencies {
259 dependsOnUnit := m.units[dependency.To]
260 requiredStatus := dependency.Edge
261 allDependencies = append(allDependencies, Dependency{
262 Unit: unit,
263 DependsOn: dependency.To,
264 RequiredStatus: requiredStatus,
265 CurrentStatus: dependsOnUnit.status,
266 IsSatisfied: dependsOnUnit.status == requiredStatus,
267 })
268 }
269
270 return allDependencies, nil
271}
272
273// GetUnmetDependencies returns a list of unsatisfied dependencies for a unit.
274func (m *Manager) GetUnmetDependencies(unit ID) ([]Dependency, error) {

Callers 4

GetUnmetDependenciesMethod · 0.95
SyncStatusMethod · 0.80

Calls 3

registeredMethod · 0.95
ErrorfMethod · 0.45

Tested by 2