IDsFilename -> ClusterIDsFilename

This commit is contained in:
Nils Hanke 2022-07-05 13:52:36 +02:00 committed by Nils Hanke
parent 24cba8d91a
commit 259c88fa1a
6 changed files with 19 additions and 19 deletions

View File

@ -1,6 +1,6 @@
package cmd
type clusterIDFile struct {
type clusterIDsFile struct {
ClusterID string
OwnerID string
Endpoint string

View File

@ -267,8 +267,8 @@ func (r activationResult) writeOutput(wr io.Writer, fileHandler file.Handler) er
return fmt.Errorf("write kubeconfig: %w", err)
}
idFile := clusterIDFile{ClusterID: r.clusterID, OwnerID: r.ownerID, Endpoint: r.coordinatorPubIP}
if err := fileHandler.WriteJSON(constants.IDsFileName, idFile, file.OptNone); err != nil {
idFile := clusterIDsFile{ClusterID: r.clusterID, OwnerID: r.ownerID, Endpoint: r.coordinatorPubIP}
if err := fileHandler.WriteJSON(constants.ClusterIDsFileName, idFile, file.OptNone); err != nil {
return fmt.Errorf("writing Constellation id file: %w", err)
}

View File

@ -333,7 +333,7 @@ func TestWriteOutput(t *testing.T) {
kubeconfig: "foo-bar-baz-qq",
}
expectedIdFile := clusterIDFile{
expectedIdFile := clusterIDsFile{
Endpoint: result.coordinatorPubIP,
ClusterID: result.clusterID,
OwnerID: result.ownerID,
@ -356,9 +356,9 @@ func TestWriteOutput(t *testing.T) {
assert.NoError(err)
assert.Equal(result.kubeconfig, string(adminConf))
idsFile, err := afs.ReadFile(constants.IDsFileName)
idsFile, err := afs.ReadFile(constants.ClusterIDsFileName)
assert.NoError(err)
var testIdFile clusterIDFile
var testIdFile clusterIDsFile
err = json.Unmarshal(idsFile, &testIdFile)
assert.NoError(err)
assert.Equal(expectedIdFile, testIdFile)

View File

@ -28,7 +28,7 @@ func NewVerifyCmd() *cobra.Command {
Short: "Verify the confidential properties of a Constellation cluster",
Long: `Verify the confidential properties of a Constellation cluster.
If arguments aren't specified, values are read from ` + "`" + constants.IDsFileName + "`.",
If arguments aren't specified, values are read from ` + "`" + constants.ClusterIDsFileName + "`.",
Args: cobra.MatchAll(
cobra.ExactArgs(1),
isCloudProvider(0),
@ -123,11 +123,11 @@ func parseVerifyFlags(cmd *cobra.Command, fileHandler file.Handler) (verifyFlags
if emptyEndpoint || emptyIDs {
if details, err := readIds(fileHandler); err == nil {
if emptyEndpoint {
cmd.Printf("Using endpoint from %q. Specify --node-endpoint to override this.\n", constants.IDsFileName)
cmd.Printf("Using endpoint from %q. Specify --node-endpoint to override this.\n", constants.ClusterIDsFileName)
endpoint = details.Endpoint
}
if emptyIDs {
cmd.Printf("Using IDs from %q. Specify --owner-id and/or --unique-id to override this.\n", constants.IDsFileName)
cmd.Printf("Using IDs from %q. Specify --owner-id and/or --unique-id to override this.\n", constants.ClusterIDsFileName)
ownerID = details.OwnerID
clusterID = details.ClusterID
}
@ -160,10 +160,10 @@ type verifyFlags struct {
configPath string
}
func readIds(fileHandler file.Handler) (clusterIDFile, error) {
det := clusterIDFile{}
if err := fileHandler.ReadJSON(constants.IDsFileName, &det); err != nil {
return clusterIDFile{}, fmt.Errorf("reading cluster ids: %w", err)
func readIds(fileHandler file.Handler) (clusterIDsFile, error) {
det := clusterIDsFile{}
if err := fileHandler.ReadJSON(constants.ClusterIDsFileName, &det); err != nil {
return clusterIDsFile{}, fmt.Errorf("reading cluster ids: %w", err)
}
return det, nil
}

View File

@ -66,7 +66,7 @@ func TestVerify(t *testing.T) {
configFlag string
ownerIDFlag string
clusterIDFlag string
idFile *clusterIDFile
idFile *clusterIDsFile
wantEndpoint string
wantErr bool
}{
@ -106,7 +106,7 @@ func TestVerify(t *testing.T) {
provider: cloudprovider.GCP,
ownerIDFlag: zeroBase64,
protoClient: &stubVerifyClient{},
idFile: &clusterIDFile{Endpoint: "192.0.2.1:1234"},
idFile: &clusterIDsFile{Endpoint: "192.0.2.1:1234"},
wantEndpoint: "192.0.2.1:1234",
},
"override endpoint from details file": {
@ -115,7 +115,7 @@ func TestVerify(t *testing.T) {
nodeEndpointFlag: "192.0.2.2:1234",
ownerIDFlag: zeroBase64,
protoClient: &stubVerifyClient{},
idFile: &clusterIDFile{Endpoint: "192.0.2.1:1234"},
idFile: &clusterIDsFile{Endpoint: "192.0.2.1:1234"},
wantEndpoint: "192.0.2.2:1234",
},
"invalid endpoint": {
@ -137,7 +137,7 @@ func TestVerify(t *testing.T) {
provider: cloudprovider.GCP,
nodeEndpointFlag: "192.0.2.1:1234",
protoClient: &stubVerifyClient{},
idFile: &clusterIDFile{OwnerID: zeroBase64},
idFile: &clusterIDsFile{OwnerID: zeroBase64},
wantEndpoint: "192.0.2.1:1234",
},
"config file not existing": {
@ -191,7 +191,7 @@ func TestVerify(t *testing.T) {
fileHandler := file.NewHandler(tc.setupFs(require))
if tc.idFile != nil {
require.NoError(fileHandler.WriteJSON(constants.IDsFileName, tc.idFile, file.OptNone))
require.NoError(fileHandler.WriteJSON(constants.ClusterIDsFileName, tc.idFile, file.OptNone))
}
err := verify(cmd, tc.provider, fileHandler, tc.protoClient)

View File

@ -50,7 +50,7 @@ const (
//
StateFilename = "constellation-state.json"
IDsFileName = "constellation-id.json"
ClusterIDsFileName = "constellation-id.json"
ConfigFilename = "constellation-conf.yaml"
DebugdConfigFilename = "cdbg-conf.yaml"
AdminConfFilename = "constellation-admin.conf"