cli verify: remove ownerid

This commit is contained in:
Thomas Tendyck 2022-09-11 15:58:31 +02:00 committed by Thomas Tendyck
parent 53560ca6c5
commit d83a5f8693
2 changed files with 21 additions and 25 deletions

View File

@ -41,8 +41,7 @@ If arguments aren't specified, values are read from ` + "`" + constants.ClusterI
), ),
RunE: runVerify, RunE: runVerify,
} }
cmd.Flags().String("owner-id", "", "verify using the owner identity derived from the master secret") cmd.Flags().String("cluster-id", "", "expected cluster identifier")
cmd.Flags().String("cluster-id", "", "verify using Constellation's cluster identifier")
cmd.Flags().StringP("node-endpoint", "e", "", "endpoint of the node to verify, passed as HOST[:PORT]") cmd.Flags().StringP("node-endpoint", "e", "", "endpoint of the node to verify, passed as HOST[:PORT]")
return cmd return cmd
} }
@ -104,10 +103,7 @@ func parseVerifyFlags(cmd *cobra.Command, fileHandler file.Handler) (verifyFlags
if err != nil { if err != nil {
return verifyFlags{}, fmt.Errorf("parsing config path argument: %w", err) return verifyFlags{}, fmt.Errorf("parsing config path argument: %w", err)
} }
ownerID, err := cmd.Flags().GetString("owner-id") ownerID := ""
if err != nil {
return verifyFlags{}, fmt.Errorf("parsing owner-id argument: %w", err)
}
clusterID, err := cmd.Flags().GetString("cluster-id") clusterID, err := cmd.Flags().GetString("cluster-id")
if err != nil { if err != nil {
return verifyFlags{}, fmt.Errorf("parsing cluster-id argument: %w", err) return verifyFlags{}, fmt.Errorf("parsing cluster-id argument: %w", err)
@ -128,7 +124,7 @@ func parseVerifyFlags(cmd *cobra.Command, fileHandler file.Handler) (verifyFlags
endpoint = idFile.IP endpoint = idFile.IP
} }
if emptyIDs { if emptyIDs {
cmd.Printf("Using IDs from %q. Specify --owner-id and/or --cluster-id to override this.\n", constants.ClusterIDsFileName) cmd.Printf("Using ID from %q. Specify --cluster-id to override this.\n", constants.ClusterIDsFileName)
ownerID = idFile.OwnerID ownerID = idFile.OwnerID
clusterID = idFile.ClusterID clusterID = idFile.ClusterID
} }
@ -139,7 +135,7 @@ func parseVerifyFlags(cmd *cobra.Command, fileHandler file.Handler) (verifyFlags
// Validate // Validate
if ownerID == "" && clusterID == "" { if ownerID == "" && clusterID == "" {
return verifyFlags{}, errors.New("neither owner-id nor cluster-id provided to verify the cluster") return verifyFlags{}, errors.New("cluster-id not provided to verify the cluster")
} }
endpoint, err = addPortIfMissing(endpoint, constants.VerifyServiceNodePortGRPC) endpoint, err = addPortIfMissing(endpoint, constants.VerifyServiceNodePortGRPC)
if err != nil { if err != nil {

View File

@ -51,33 +51,33 @@ func TestVerify(t *testing.T) {
"gcp": { "gcp": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
nodeEndpointFlag: "192.0.2.1:1234", nodeEndpointFlag: "192.0.2.1:1234",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
wantEndpoint: "192.0.2.1:1234", wantEndpoint: "192.0.2.1:1234",
}, },
"azure": { "azure": {
provider: cloudprovider.Azure, provider: cloudprovider.Azure,
nodeEndpointFlag: "192.0.2.1:1234", nodeEndpointFlag: "192.0.2.1:1234",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
wantEndpoint: "192.0.2.1:1234", wantEndpoint: "192.0.2.1:1234",
}, },
"default port": { "default port": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
nodeEndpointFlag: "192.0.2.1", nodeEndpointFlag: "192.0.2.1",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
wantEndpoint: "192.0.2.1:" + strconv.Itoa(constants.VerifyServiceNodePortGRPC), wantEndpoint: "192.0.2.1:" + strconv.Itoa(constants.VerifyServiceNodePortGRPC),
}, },
"endpoint not set": { "endpoint not set": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
wantErr: true, wantErr: true,
}, },
"endpoint from id file": { "endpoint from id file": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
idFile: &clusterIDsFile{IP: "192.0.2.1"}, idFile: &clusterIDsFile{IP: "192.0.2.1"},
wantEndpoint: "192.0.2.1:" + strconv.Itoa(constants.VerifyServiceNodePortGRPC), wantEndpoint: "192.0.2.1:" + strconv.Itoa(constants.VerifyServiceNodePortGRPC),
@ -85,7 +85,7 @@ func TestVerify(t *testing.T) {
"override endpoint from details file": { "override endpoint from details file": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
nodeEndpointFlag: "192.0.2.2:1234", nodeEndpointFlag: "192.0.2.2:1234",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
idFile: &clusterIDsFile{IP: "192.0.2.1"}, idFile: &clusterIDsFile{IP: "192.0.2.1"},
wantEndpoint: "192.0.2.2:1234", wantEndpoint: "192.0.2.2:1234",
@ -93,7 +93,7 @@ func TestVerify(t *testing.T) {
"invalid endpoint": { "invalid endpoint": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
nodeEndpointFlag: ":::::", nodeEndpointFlag: ":::::",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{}, protoClient: &stubVerifyClient{},
wantErr: true, wantErr: true,
}, },
@ -111,7 +111,7 @@ func TestVerify(t *testing.T) {
}, },
"config file not existing": { "config file not existing": {
provider: cloudprovider.GCP, provider: cloudprovider.GCP,
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
nodeEndpointFlag: "192.0.2.1:1234", nodeEndpointFlag: "192.0.2.1:1234",
configFlag: "./file", configFlag: "./file",
wantErr: true, wantErr: true,
@ -119,14 +119,14 @@ func TestVerify(t *testing.T) {
"error protoClient GetState": { "error protoClient GetState": {
provider: cloudprovider.Azure, provider: cloudprovider.Azure,
nodeEndpointFlag: "192.0.2.1:1234", nodeEndpointFlag: "192.0.2.1:1234",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{verifyErr: rpcStatus.Error(codes.Internal, "failed")}, protoClient: &stubVerifyClient{verifyErr: rpcStatus.Error(codes.Internal, "failed")},
wantErr: true, wantErr: true,
}, },
"error protoClient GetState not rpc": { "error protoClient GetState not rpc": {
provider: cloudprovider.Azure, provider: cloudprovider.Azure,
nodeEndpointFlag: "192.0.2.1:1234", nodeEndpointFlag: "192.0.2.1:1234",
ownerIDFlag: zeroBase64, clusterIDFlag: zeroBase64,
protoClient: &stubVerifyClient{verifyErr: someErr}, protoClient: &stubVerifyClient{verifyErr: someErr},
wantErr: true, wantErr: true,
}, },