Skip to content

Commit

Permalink
cmd: precalculate-measurements -> measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
msanft committed Jun 6, 2024
1 parent 432825c commit d888a9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newRootCmd() *cobra.Command {
cmd.SetOut(os.Stdout)
cmd.InitDefaultVersionFlag()
cmd.AddCommand(newUploadCmd())
cmd.AddCommand(newPrecalculateMeasurementsCmd())
cmd.AddCommand(newMeasurementsCmd())

return cmd
}
16 changes: 8 additions & 8 deletions precalculate-measurements.go → measurements.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import (
"github.com/spf13/cobra"
)

func newPrecalculateMeasurementsCmd() *cobra.Command {
func newMeasurementsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "precalculate-measurements <image>",
Use: "measurements <image>",
Short: "Precalculate TPM PCR measurements for an image",
Args: cobra.ExactArgs(1),
RunE: runPrecalculateMeasurements,
RunE: runMeasurements,
}
cmd.Flags().StringP("output-file", "o", "", "Output file for the precalculated measurements")
cmd.Flags().StringP("uki-path", "u", measuredboot.UkiPath, "Path to the UKI file in the image")

return cmd
}

func runPrecalculateMeasurements(cmd *cobra.Command, args []string) error {
flags, err := parsePrecalculateMeasurementsFlags(cmd)
func runMeasurements(cmd *cobra.Command, args []string) error {
flags, err := parseMeasurementsFlags(cmd)
if err != nil {
return fmt.Errorf("parsing flags: %w", err)
}
Expand All @@ -56,12 +56,12 @@ func runPrecalculateMeasurements(cmd *cobra.Command, args []string) error {
return nil
}

type precalculateMeasurementsFlags struct {
type measurementsFlags struct {
outputFile string
ukiPath string
}

func parsePrecalculateMeasurementsFlags(cmd *cobra.Command) (*precalculateMeasurementsFlags, error) {
func parseMeasurementsFlags(cmd *cobra.Command) (*measurementsFlags, error) {
outputFile, err := cmd.Flags().GetString("output-file")
if err != nil {
return nil, fmt.Errorf("getting output-file flag: %w", err)
Expand All @@ -70,7 +70,7 @@ func parsePrecalculateMeasurementsFlags(cmd *cobra.Command) (*precalculateMeasur
if err != nil {
return nil, fmt.Errorf("getting uki-path flag: %w", err)
}
return &precalculateMeasurementsFlags{
return &measurementsFlags{
outputFile: outputFile,
ukiPath: ukiPath,
}, nil
Expand Down

0 comments on commit d888a9d

Please sign in to comment.