|
| 1 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +package storage |
| 6 | + |
| 7 | +import ( |
| 8 | + "context" |
| 9 | + |
| 10 | + "github.com/cosi-project/runtime/pkg/controller" |
| 11 | + "go.uber.org/zap" |
| 12 | + |
| 13 | + "github.com/siderolabs/talos/pkg/machinery/resources/block" |
| 14 | + "github.com/siderolabs/talos/pkg/machinery/resources/storage" |
| 15 | +) |
| 16 | + |
| 17 | +// LVMLogicalVolumeStatusController manages LVMLogicalVolumeStatus resources. |
| 18 | +type LVMLogicalVolumeStatusController struct{} |
| 19 | + |
| 20 | +// Name implements controller.Controller interface. |
| 21 | +func (ctrl *LVMLogicalVolumeStatusController) Name() string { |
| 22 | + return "storage.LVMLogicalVolumeStatusController" |
| 23 | +} |
| 24 | + |
| 25 | +// Inputs implements controller.Controller interface. |
| 26 | +func (ctrl *LVMLogicalVolumeStatusController) Inputs() []controller.Input { |
| 27 | + return []controller.Input{ |
| 28 | + { |
| 29 | + Namespace: block.NamespaceName, |
| 30 | + Type: block.DiscoveredVolumeType, |
| 31 | + Kind: controller.InputWeak, |
| 32 | + }, |
| 33 | + { |
| 34 | + Namespace: storage.NamespaceName, |
| 35 | + Type: storage.LVMPhysicalVolumeStatusType, |
| 36 | + Kind: controller.InputWeak, |
| 37 | + }, |
| 38 | + { |
| 39 | + Namespace: storage.NamespaceName, |
| 40 | + Type: storage.LVMLogicalVolumeStatusType, |
| 41 | + Kind: controller.InputWeak, |
| 42 | + }, |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +// Outputs implements controller.Controller interface. |
| 47 | +func (ctrl *LVMLogicalVolumeStatusController) Outputs() []controller.Output { |
| 48 | + return []controller.Output{ |
| 49 | + { |
| 50 | + Type: storage.LVMLogicalVolumeStatusType, |
| 51 | + Kind: controller.OutputExclusive, |
| 52 | + }, |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +// Run implements controller.Controller interface. |
| 57 | +func (ctrl *LVMLogicalVolumeStatusController) Run(ctx context.Context, r controller.Runtime, _ *zap.Logger) error { |
| 58 | + for { |
| 59 | + select { |
| 60 | + case <-ctx.Done(): |
| 61 | + return nil |
| 62 | + case <-r.EventCh(): |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments