Skip to content

Commit

Permalink
Merge pull request #156 from Cray-HPE/settled-dark-phoenix
Browse files Browse the repository at this point in the history
remove empty tests and continuity to error on commands that are not implemented
  • Loading branch information
jacobsalmela committed Oct 30, 2023
2 parents 73d114f + e3837e3 commit 5c8bd7b
Show file tree
Hide file tree
Showing 38 changed files with 33 additions and 1,207 deletions.
26 changes: 0 additions & 26 deletions cmd/add_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/blade/add_blade_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/blade/list_blade_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/blade/remove_blade_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/cabinet/add_cabinet_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/cabinet/cabinet_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/cabinet/list_cabinet_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/cabinet/remove_cabinet_test.go

This file was deleted.

25 changes: 5 additions & 20 deletions cmd/cdu/add_cdu.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,21 @@
package cdu

import (
root "github.com/Cray-HPE/cani/cmd"
"github.com/Cray-HPE/cani/internal/domain"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)

// AddCduCmd represents the cdu add command
var AddCduCmd = &cobra.Command{
Use: "cdu",
Short: "Add cdus to the inventory.",
Long: `Add cdus to the inventory.`,
PersistentPreRunE: root.DatastoreExists, // A session must be active to write to a datastore
Args: validHardware, // Hardware can only be valid if defined in the hardware library
RunE: addCdu, // Add a cdu when this sub-command is called
Use: "cdu",
Short: "Add cdus to the inventory.",
Long: `Add cdus to the inventory.`,
PreRunE: validHardware, // Hardware can only be valid if defined in the hardware library
RunE: addCdu, // Add a cdu when this sub-command is called
}

// addCdu adds a cdu to the inventory
func addCdu(cmd *cobra.Command, args []string) error {
// Create a domain object to interact with the datastore
_, err := domain.New(root.Conf.Session.DomainOptions)
if err != nil {
return err
}
log.Info().Msgf("Not yet implemented")
// Remove the cdu from the inventory using domain methods
// TODO:
// err = d.AddCdu()
// if err != nil {
// return err
// }
// log.Info().Msgf("Added cdu %s", args[0])
return nil
}
26 changes: 0 additions & 26 deletions cmd/cdu/add_cdu_test.go

This file was deleted.

37 changes: 2 additions & 35 deletions cmd/cdu/list_cdu.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@
package cdu

import (
"encoding/json"
"errors"
"fmt"

root "github.com/Cray-HPE/cani/cmd"
"github.com/Cray-HPE/cani/internal/domain"
"github.com/Cray-HPE/cani/internal/inventory"
"github.com/Cray-HPE/cani/pkg/hardwaretypes"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)

Expand All @@ -49,31 +41,6 @@ var ListCduCmd = &cobra.Command{

// listCdu lists cdus in the inventory
func listCdu(cmd *cobra.Command, args []string) error {
// Create a domain object to interact with the datastore
d, err := domain.New(root.Conf.Session.DomainOptions)
if err != nil {
return err
}

// Get the entire inventory
inv, err := d.List()
if err != nil {
return err
}
// Filter the inventory to only cdus
filtered := make(map[uuid.UUID]inventory.Hardware, 0)
for key, hw := range inv.Hardware {
if hw.Type == hardwaretypes.CoolingDistributionUnit {
filtered[key] = hw
}
}
// Convert the filtered inventory into a formatted JSON string
inventoryJSON, err := json.MarshalIndent(filtered, "", " ")
if err != nil {
return errors.New(fmt.Sprintf("Error marshaling inventory to JSON: %v", err))
}

// Print the inventory
fmt.Println(string(inventoryJSON))
log.Info().Msgf("Not yet implemented")
return nil
}
26 changes: 0 additions & 26 deletions cmd/cdu/list_cdu_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions cmd/cdu/remove_cdu_test.go

This file was deleted.

Loading

0 comments on commit 5c8bd7b

Please sign in to comment.