Addressed nits

Signed-off-by: Brandon Lum <lumjjb@gmail.com>
This commit is contained in:
Brandon Lum
2020-01-24 15:46:30 +00:00
parent 8df431fc31
commit ffcef9dc32
3 changed files with 8 additions and 7 deletions

View File

@@ -414,7 +414,8 @@ func newTransport() *http.Transport {
// addEncryptedImagesPullOpts adds the necessary pull options to a list of
// pull options if enabled.
func (c *criService) encryptedImagesPullOpts() []containerd.RemoteOpt {
if c.config.EncryptedImagesConfig.KeyModel == criconfig.EncryptionKeyModelNode {
if c.config.ImageEncryption.KeyModel == criconfig.EncryptionKeyModelNode ||
c.config.ImageEncryption.KeyModel == "" {
ltdd := imgcrypt.Payload{}
decUnpackOpt := encryption.WithUnpackConfigApplyOpts(encryption.WithDecryptedUnpack(&ltdd))
opt := containerd.WithUnpackOpts([]containerd.UnpackOpt{decUnpackOpt})

View File

@@ -298,14 +298,14 @@ func TestEncryptedImagePullOpts(t *testing.T) {
keyModel: criconfig.EncryptionKeyModelNode,
expectedOpts: 1,
},
"no key model selected should not add any opts": {
"no key model selected should default to node key model": {
keyModel: "",
expectedOpts: 0,
expectedOpts: 1,
},
} {
t.Logf("TestCase %q", desc)
c := newTestCRIService()
c.config.EncryptedImagesConfig.KeyModel = test.keyModel
c.config.ImageEncryption.KeyModel = test.keyModel
got := len(c.encryptedImagesPullOpts())
assert.Equal(t, test.expectedOpts, got)
}