Skip to content

Commit

Permalink
(feat): Suggestions from Pull Request
Browse files Browse the repository at this point in the history
  • Loading branch information
lasith-kg committed May 20, 2024
1 parent 382cecc commit bd57ab2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configs/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ devices:
mountPoint: /mnt/bar
user: ubuntu
group: ubuntu
permissions: 755
permissions: 755
5 changes: 2 additions & 3 deletions internal/config/modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ func NewLvmModifier() *LvmModifier {
}

func (lm *LvmModifier) Modify(c *Config) error {
// Fetch a copy of the original keys as we are updating
// the config in-place and it is unsafe to iterate over it
// directly
// Fetch a copy of the original keys as we are updating the
// config in-place and it is unsafe to iterate over it directly
keys := make([]string, len(c.Devices))
for name := range c.Devices {
keys = append(keys, name)
Expand Down
2 changes: 2 additions & 0 deletions internal/datastructures/lvm_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (lg *LvmGraph) GetLogicalVolume(name string, vg string) (*LvmNode, error) {
func (lg *LvmGraph) GetParents(node *LvmNode, state LvmNodeCategory) []*LvmNode {
parents := []*LvmNode{}
for _, p := range node.parents {
// Bitmasking to check if the parent nodes is of the desired category
if int32(p.State)&int32(state) > 0 {
parents = append(parents, p)
}
Expand All @@ -207,6 +208,7 @@ func (lg *LvmGraph) GetParents(node *LvmNode, state LvmNodeCategory) []*LvmNode
func (lg *LvmGraph) GetChildren(node *LvmNode, state LvmNodeCategory) []*LvmNode {
children := []*LvmNode{}
for _, c := range node.children {
// Bitmasking to check if children nodes is of the desired category
if int32(c.State)&int32(state) > 0 {
children = append(children, c)
}
Expand Down
8 changes: 5 additions & 3 deletions internal/model/lvm.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package model

import "github.com/reecetech/ebs-bootstrap/internal/datastructures"

type PhysicalVolume struct {
Name string
}
Expand All @@ -12,9 +14,9 @@ type VolumeGroup struct {
type LogicalVolumeState int32

const (
Inactive LogicalVolumeState = 0b0010000
Active LogicalVolumeState = 0b0110000
Unsupported LogicalVolumeState = 0b1110000
Inactive LogicalVolumeState = LogicalVolumeState(datastructures.LogicalVolumeInactive)
Active LogicalVolumeState = LogicalVolumeState(datastructures.LogicalVolumeActive)
Unsupported LogicalVolumeState = LogicalVolumeState(datastructures.LogicalVolumeUnsupported)
)

type LogicalVolume struct {
Expand Down

0 comments on commit bd57ab2

Please sign in to comment.