(ctx context.Context, customResource interface{}, infoCatalog InfoCatalog)
| 75 | } |
| 76 | |
| 77 | func (m *stateManager) SyncState(ctx context.Context, customResource interface{}, infoCatalog InfoCatalog) Results { |
| 78 | logger := log.FromContext(ctx) |
| 79 | logger.V(consts.LogLevelInfo).Info("Syncing system state") |
| 80 | |
| 81 | managerResult := Results{ |
| 82 | Status: SyncStateNotReady, |
| 83 | } |
| 84 | statesReady := true |
| 85 | |
| 86 | for _, state := range m.states { |
| 87 | logger.V(consts.LogLevelInfo).Info("Sync State", "Name", state.Name(), "Description", state.Description()) |
| 88 | stateCtx := log.IntoContext(ctx, logger.WithName("state").WithName(state.Name())) |
| 89 | ss, err := state.Sync(stateCtx, customResource, infoCatalog) |
| 90 | result := Result{StateName: state.Name(), Status: ss, ErrInfo: err} |
| 91 | managerResult.StatesStatus = append(managerResult.StatesStatus, result) |
| 92 | |
| 93 | if result.Status == SyncStateNotReady || result.Status == SyncStateError { |
| 94 | statesReady = false |
| 95 | } |
| 96 | |
| 97 | if result.ErrInfo != nil { |
| 98 | logger.V(consts.LogLevelWarning).Error(result.ErrInfo, "Error while syncing state") |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | if statesReady { |
| 103 | // Done Syncing CR |
| 104 | managerResult.Status = SyncStateReady |
| 105 | logger.V(consts.LogLevelInfo).Info("Sync Done for custom resource") |
| 106 | } else { |
| 107 | logger.V(consts.LogLevelInfo).Info("Sync not Done for custom resource") |
| 108 | } |
| 109 | |
| 110 | return managerResult |
| 111 | } |
| 112 | |
| 113 | func newStates(crdKind string, namespace string, k8sClient client.Client, scheme *runtime.Scheme) ([]State, error) { |
| 114 | switch crdKind { |
nothing calls this directly
no test coverage detected