Skip to content

Commit

Permalink
gadget/install/encrypt.go: rename newEncrypt... to createEncrypt...
Browse files Browse the repository at this point in the history
Thanks to Alberto for the suggestion.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
  • Loading branch information
anonymouse64 committed Mar 25, 2022
1 parent 5ea5784 commit f06e06f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions gadget/install/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ type encryptedDeviceWithSetupHook struct {
// sanity
var _ = encryptedDevice(&encryptedDeviceWithSetupHook{})

// newEncryptedDeviceWithSetupHook creates an encrypted device in the
// createEncryptedDeviceWithSetupHook creates an encrypted device in the
// existing partition using the specified key using the fde-setup hook
func newEncryptedDeviceWithSetupHook(part *gadget.OnDiskStructure, key secboot.EncryptionKey, name string) (encryptedDevice, error) {
func createEncryptedDeviceWithSetupHook(part *gadget.OnDiskStructure, key secboot.EncryptionKey, name string) (encryptedDevice, error) {
// for roles requiring encryption, the filesystem label is always set to
// either the implicit value or a value that has been validated
if part.Name != name || part.Label != name {
Expand Down
12 changes: 6 additions & 6 deletions gadget/install/encrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ var mockDeviceStructureForDeviceSetupHook = gadget.OnDiskStructure{
Node: "/dev/node1",
}

func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHook(c *C) {
func (s *encryptSuite) TestCreateEncryptedDeviceWithSetupHook(c *C) {

for _, tc := range []struct {
mockedOpenErr string
Expand Down Expand Up @@ -234,7 +234,7 @@ func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHook(c *C) {
mockDmsetup := testutil.MockCommand(c, "dmsetup", script)
s.AddCleanup(mockDmsetup.Restore)

dev, err := install.NewEncryptedDeviceWithSetupHook(&mockDeviceStructureForDeviceSetupHook,
dev, err := install.CreateEncryptedDeviceWithSetupHook(&mockDeviceStructureForDeviceSetupHook,
s.mockedEncryptionKey, "ubuntu-data")
if tc.expectedErr == "" {
c.Assert(err, IsNil)
Expand All @@ -258,7 +258,7 @@ func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHook(c *C) {
}
}

func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHookPartitionNameCheck(c *C) {
func (s *encryptSuite) TestCreateEncryptedDeviceWithSetupHookPartitionNameCheck(c *C) {
mockDeviceStructureBadName := gadget.OnDiskStructure{
LaidOutStructure: gadget.LaidOutStructure{
VolumeStructure: &gadget.VolumeStructure{
Expand All @@ -282,7 +282,7 @@ func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHookPartitionNameCheck(c *
s.AddCleanup(mockDmsetup.Restore)

// pass a name that does not match partition name
dev, err := install.NewEncryptedDeviceWithSetupHook(&mockDeviceStructureBadName,
dev, err := install.CreateEncryptedDeviceWithSetupHook(&mockDeviceStructureBadName,
s.mockedEncryptionKey, "some-name")
c.Assert(err, ErrorMatches, `cannot use partition name "some-name" for an encrypted structure with system-data role and filesystem with label "ubuntu-data"`)
c.Check(dev, IsNil)
Expand All @@ -291,7 +291,7 @@ func (s *encryptSuite) TestNewEncryptedDeviceWithSetupHookPartitionNameCheck(c *
// the implicit value or has already been validated and matches what is
// expected for the particular role
mockDeviceStructureBadName.Name = "bad-name"
dev, err = install.NewEncryptedDeviceWithSetupHook(&mockDeviceStructureBadName,
dev, err = install.CreateEncryptedDeviceWithSetupHook(&mockDeviceStructureBadName,
s.mockedEncryptionKey, "bad-name")
c.Assert(err, ErrorMatches, `cannot use partition name "bad-name" for an encrypted structure with system-data role and filesystem with label "ubuntu-data"`)
c.Check(dev, IsNil)
Expand All @@ -309,7 +309,7 @@ func (s *encryptSuite) TestAddRecoveryKeyDeviceWithSetupHook(c *C) {
mockDmsetup := testutil.MockCommand(c, "dmsetup", "")
s.AddCleanup(mockDmsetup.Restore)

dev, err := install.NewEncryptedDeviceWithSetupHook(&mockDeviceStructureForDeviceSetupHook,
dev, err := install.CreateEncryptedDeviceWithSetupHook(&mockDeviceStructureForDeviceSetupHook,
s.mockedEncryptionKey, "ubuntu-data")
c.Assert(err, IsNil)
c.Check(setupReq.Device, Equals, "/dev/mapper/ubuntu-data")
Expand Down
6 changes: 3 additions & 3 deletions gadget/install/export_secboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
)

var (
DiskWithSystemSeed = diskWithSystemSeed
NewEncryptedDeviceLUKS = newEncryptedDeviceLUKS
NewEncryptedDeviceWithSetupHook = newEncryptedDeviceWithSetupHook
DiskWithSystemSeed = diskWithSystemSeed
NewEncryptedDeviceLUKS = newEncryptedDeviceLUKS
CreateEncryptedDeviceWithSetupHook = createEncryptedDeviceWithSetupHook
)

func MockSecbootFormatEncryptedDevice(f func(key secboot.EncryptionKey, label, node string) error) (restore func()) {
Expand Down
2 changes: 1 addition & 1 deletion gadget/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func Run(model gadget.Model, gadgetRoot, kernelRoot, bootDevice string, options
}
case secboot.EncryptionTypeDeviceSetupHook:
timings.Run(perfTimings, fmt.Sprintf("new-encrypted-device-setup-hook[%s]", roleOrLabelOrName(part)), fmt.Sprintf("Create encryption device for %s using device-setup-hook", roleOrLabelOrName(part)), func(timings.Measurer) {
dataPart, err = newEncryptedDeviceWithSetupHook(&part, keys.Key, part.Name)
dataPart, err = createEncryptedDeviceWithSetupHook(&part, keys.Key, part.Name)
})
if err != nil {
return nil, err
Expand Down

0 comments on commit f06e06f

Please sign in to comment.