Skip to content

Commit 3cce61e

Browse files
#816 added Encryption status to file volume-detail
1 parent 5f172f7 commit 3cce61e

6 files changed

Lines changed: 35 additions & 79 deletions

File tree

plugin/commands/block/volume_detail.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ func (cmd *VolumeDetailCommand) Run(args []string) error {
135135
return slErr.NewAPIError(T("Failed to decoded the note.\n"), err.Error(), 2)
136136
}
137137
table.Add(T("Notes"), decodedValue)
138-
hasEncryption := T("false")
139-
if (blockVolume.HasEncryptionAtRest != nil) {
140-
hasEncryption = T(fmt.Sprintf("%v", *blockVolume.HasEncryptionAtRest))
138+
hasEncryption := T("False")
139+
if (blockVolume.HasEncryptionAtRest != nil && *blockVolume.HasEncryptionAtRest == true) {
140+
hasEncryption := T("True")
141141
}
142142
table.Add(T("Encrypted"), hasEncryption)
143143
table.Print()

plugin/commands/block/volume_detail_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var _ = Describe("Block Volume-Detail Tests", func() {
6666
Expect(fakeUI.Outputs()).To(ContainSubstring("User name IBM01SEL278444-16"))
6767
Expect(fakeUI.Outputs()).To(ContainSubstring("Endurance Tier WRITEHEAVY_TIER"))
6868
Expect(fakeUI.Outputs()).To(ContainSubstring("Notes -"))
69-
Expect(fakeUI.Outputs()).To(ContainSubstring("Encrypted false"))
69+
Expect(fakeUI.Outputs()).To(ContainSubstring("Encrypted False"))
7070
})
7171
})
7272
})

plugin/commands/file/volume_detail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ func (cmd *VolumeDetailCommand) Run(args []string) error {
136136
return slErr.NewAPIError(T("Failed to decoded the note.\n"), err.Error(), 2)
137137
}
138138
table.Add(T("Notes"), decodedValue)
139+
hasEncryption := T("False")
140+
if (blockVolume.HasEncryptionAtRest != nil && *blockVolume.HasEncryptionAtRest == true) {
141+
hasEncryption := T("True")
142+
}
143+
table.Add(T("Encrypted"), hasEncryption)
139144
table.Print()
140145
return nil
141146
}

plugin/commands/file/volume_detail_test.go

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package file_test
22

33
import (
4-
"errors"
5-
64
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
75
. "github.com/onsi/ginkgo"
86
. "github.com/onsi/gomega"
97

10-
"github.com/softlayer/softlayer-go/datatypes"
118
"github.com/softlayer/softlayer-go/session"
12-
"github.com/softlayer/softlayer-go/sl"
139
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/file"
1410
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
1511
"github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers"
@@ -19,18 +15,18 @@ var _ = Describe("Volume detail", func() {
1915
var (
2016
fakeUI *terminal.FakeUI
2117
cliCommand *file.VolumeDetailCommand
22-
fakeSession *session.Session
18+
fakeSession *session.Session
19+
fakeHandler *testhelpers.FakeTransportHandler
2320
slCommand *metadata.SoftlayerStorageCommand
24-
FakeStorageManager *testhelpers.FakeStorageManager
21+
2522
)
2623
BeforeEach(func() {
2724
fakeUI = terminal.NewFakeUI()
28-
fakeSession = testhelpers.NewFakeSoftlayerSession([]string{})
29-
FakeStorageManager = new(testhelpers.FakeStorageManager)
25+
fakeSession = testhelpers.NewFakeSoftlayerSession(nil)
26+
fakeHandler = testhelpers.GetSessionHandler(fakeSession)
3027
slCommand = metadata.NewSoftlayerStorageCommand(fakeUI, fakeSession, "file")
3128
cliCommand = file.NewVolumeDetailCommand(slCommand)
3229
cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.")
33-
cliCommand.StorageManager = FakeStorageManager
3430
})
3531

3632
Describe("Volume detail", func() {
@@ -51,7 +47,7 @@ var _ = Describe("Volume detail", func() {
5147

5248
Context("Volume detail with correct volume id but server API call fails", func() {
5349
BeforeEach(func() {
54-
FakeStorageManager.GetVolumeDetailsReturns(datatypes.Network_Storage{}, errors.New("Internal Server Error"))
50+
fakeHandler.AddApiError("SoftLayer_Network_Storage", "getObject", 500, "Internal Server Error")
5551
})
5652
It("return error", func() {
5753
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234")
@@ -62,63 +58,14 @@ var _ = Describe("Volume detail", func() {
6258
})
6359

6460
Context("Volume detail with correct volume id", func() {
65-
BeforeEach(func() {
66-
FakeStorageManager.GetVolumeDetailsReturns(datatypes.Network_Storage{
67-
Id: sl.Int(1234),
68-
Username: sl.String("myvolume"),
69-
CapacityGb: sl.Int(1000),
70-
Iops: sl.String("400"),
71-
StorageTierLevel: sl.String("HEAVY_WRITE"),
72-
StorageType: &datatypes.Network_Storage_Type{
73-
KeyName: sl.String("performance"),
74-
},
75-
ServiceResource: &datatypes.Network_Service_Resource{
76-
Datacenter: &datatypes.Location{
77-
Name: sl.String("tok02"),
78-
},
79-
},
80-
ServiceResourceBackendIpAddress: sl.String("9.9.9.9"),
81-
SnapshotCapacityGb: sl.String("500"),
82-
ParentVolume: &datatypes.Network_Storage{
83-
SnapshotSizeBytes: sl.String("10000"),
84-
},
85-
ActiveTransactionCount: sl.Uint(uint(1)),
86-
ActiveTransactions: []datatypes.Provisioning_Version1_Transaction{
87-
datatypes.Provisioning_Version1_Transaction{
88-
TransactionStatus: &datatypes.Provisioning_Version1_Transaction_Status{
89-
FriendlyName: sl.String("Restarting"),
90-
},
91-
},
92-
},
93-
ReplicationPartnerCount: sl.Uint(uint(1)),
94-
ReplicationStatus: sl.String("replication finished"),
95-
ReplicationPartners: []datatypes.Network_Storage{
96-
datatypes.Network_Storage{
97-
Id: sl.Int(5678),
98-
Username: sl.String("myreplicant"),
99-
ServiceResourceBackendIpAddress: sl.String("9.9.9.8"),
100-
ServiceResource: &datatypes.Network_Service_Resource{
101-
Datacenter: &datatypes.Location{
102-
Name: sl.String("dal10"),
103-
},
104-
},
105-
ReplicationSchedule: &datatypes.Network_Storage_Schedule{
106-
Type: &datatypes.Network_Storage_Schedule_Type{
107-
Keyname: sl.String("DAILY"),
108-
},
109-
},
110-
},
111-
},
112-
}, nil)
113-
})
11461
It("return no error", func() {
11562
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234")
11663
Expect(err).NotTo(HaveOccurred())
117-
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
118-
Expect(fakeUI.Outputs()).To(ContainSubstring("myvolume"))
119-
Expect(fakeUI.Outputs()).To(ContainSubstring("tok02"))
120-
Expect(fakeUI.Outputs()).To(ContainSubstring("9.9.9.9"))
121-
Expect(fakeUI.Outputs()).To(ContainSubstring("Restarting"))
64+
Expect(fakeUI.Outputs()).To(ContainSubstring("ID 17336531"))
65+
Expect(fakeUI.Outputs()).To(ContainSubstring("User name IBM01SEL278444-16"))
66+
Expect(fakeUI.Outputs()).To(ContainSubstring("Endurance Tier WRITEHEAVY_TIER"))
67+
Expect(fakeUI.Outputs()).To(ContainSubstring("Notes -"))
68+
Expect(fakeUI.Outputs()).To(ContainSubstring("Encrypted False"))
12269
})
12370
})
12471
})

plugin/i18n/resources/en_US.all.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,10 @@
27152715
"id": "Enables/Disables snapshot space usage threshold warning for a given volume.",
27162716
"translation": "Enables/Disables snapshot space usage threshold warning for a given volume."
27172717
},
2718+
{
2719+
"id": "Encrypted",
2720+
"translation": "Encrypted"
2721+
},
27182722
{
27192723
"id": "End",
27202724
"translation": "End"

plugin/resources/i18n_resources.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)