Пример #1
0
// Manager returns a new ConfigManager.
func Manager(s *state.State, hookManager *hookstate.HookManager) (*ConfigManager, error) {
	manager := &ConfigManager{
		state: s,
	}

	hookManager.Register(regexp.MustCompile("^apply-config$"), newApplyConfigHandler)

	return manager, nil
}
Пример #2
0
// Manager returns a new device manager.
func Manager(s *state.State, hookManager *hookstate.HookManager) (*DeviceManager, error) {
	runner := state.NewTaskRunner(s)

	keypairMgr, err := asserts.OpenFSKeypairManager(dirs.SnapDeviceDir)
	if err != nil {
		return nil, err

	}

	m := &DeviceManager{state: s, keypairMgr: keypairMgr, runner: runner}

	hookManager.Register(regexp.MustCompile("^prepare-device$"), newPrepareDeviceHandler)

	runner.AddHandler("generate-device-key", m.doGenerateDeviceKey, nil)
	runner.AddHandler("request-serial", m.doRequestSerial, nil)
	runner.AddHandler("mark-seeded", m.doMarkSeeded, nil)

	return m, nil
}