mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
2d8fcd9bf4
Co-authored-by: Malte Poll <mp@edgeless.systems> Co-authored-by: katexochen <katexochen@users.noreply.github.com> Co-authored-by: Daniel Weiße <dw@edgeless.systems> Co-authored-by: Thomas Tendyck <tt@edgeless.systems> Co-authored-by: Benedict Schlueter <bs@edgeless.systems> Co-authored-by: leongross <leon.gross@rub.de> Co-authored-by: Moritz Eckert <m1gh7ym0@gmail.com>
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/edgelesssys/constellation/cli/file"
|
|
"github.com/edgelesssys/constellation/coordinator/atls"
|
|
"github.com/edgelesssys/constellation/coordinator/attestation/gcp"
|
|
"github.com/edgelesssys/constellation/internal/config"
|
|
"github.com/spf13/afero"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newVerifyGCPCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "gcp IP PORT",
|
|
Short: "Verify the confidential properties of your Constellation on Google Cloud Platform.",
|
|
Long: "Verify the confidential properties of your Constellation on Google Cloud Platform.",
|
|
Args: cobra.ExactArgs(2),
|
|
ValidArgsFunction: verifyCompletion,
|
|
RunE: runVerifyGCP,
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func runVerifyGCP(cmd *cobra.Command, args []string) error {
|
|
fileHandler := file.NewHandler(afero.NewOsFs())
|
|
devConfigName, err := cmd.Flags().GetString("dev-config")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
config, err := config.FromFile(fileHandler, devConfigName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
validators, err := getGCPValidator(cmd, *config.Provider.GCP.PCRs)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return runVerify(cmd, args, *config.Provider.GCP.PCRs, validators)
|
|
}
|
|
|
|
// getValidators returns a GCP validator.
|
|
func getGCPValidator(cmd *cobra.Command, pcrs map[uint32][]byte) (atls.Validator, error) {
|
|
if err := prepareValidator(cmd, pcrs); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return gcp.NewValidator(pcrs), nil
|
|
}
|