Skip to content

Commit

Permalink
Add new files to BUILD, AEAD => k8s-aes-gcm
Browse files Browse the repository at this point in the history
  • Loading branch information
Saksham Sharma committed May 25, 2017
1 parent 9c8f798 commit a8ba07c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
10 changes: 9 additions & 1 deletion staging/src/k8s.io/apiserver/pkg/server/options/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ load(

go_test(
name = "go_default_test",
srcs = ["serving_test.go"],
srcs = [
"encryption_provider_config_test.go",
"serving_test.go",
],
library = ":go_default_library",
tags = ["automanaged"],
deps = [
Expand All @@ -20,6 +23,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/value:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
Expand All @@ -35,6 +39,7 @@ go_library(
"authentication.go",
"authorization.go",
"doc.go",
"encryption_provider_config.go",
"etcd.go",
"feature.go",
"recommended.go",
Expand All @@ -43,6 +48,7 @@ go_library(
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
Expand All @@ -62,6 +68,8 @@ go_library(
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/storagebackend:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/value:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/value/encrypt/aes:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
"//vendor/k8s.io/apiserver/plugin/pkg/audit/log:go_default_library",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (e EncryptionProviderConfig) Set(filepath string) error {
if err != nil {
return err
}
if providerConfig.Kind == "AEAD" {
if providerConfig.Kind == "k8s-aes-gcm" {
aead, err := aestransformer.NewGCMTransformerFromConfig(provider)
if err != nil {
return err
Expand Down Expand Up @@ -80,6 +80,7 @@ func (e EncryptionProviderConfig) Type() string {
// Stores information common to all encryption providers
type providerInfo struct {
Kind string
Version string
Resource string
}

Expand All @@ -100,5 +101,10 @@ func parseProviderInfo(config map[string]interface{}) (providerInfo, error) {
return result, fmt.Errorf("ignoring encryption provider \"%s\" without a valid \"resource\" key specified in configuration", result.Kind)
}

// Version can be skipped
if version, ok := config["version"]; ok {
result.Version = "-" + fmt.Sprintf("%v", version)
}

return result, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import (
)

var correctConfig string = `
- kind: AEAD
- kind: k8s-aes-gcm
version: v1
keys:
- name: key1
secret: c2VjcmV0IGlzIHNlY3VyZQ==
- name: key2
secret: dGhpcyBpcyBwYXNzd29yZA==
resource: /registry/namespaces
- kind: AEAD
- kind: k8s-aes-gcm
version: v1
keys:
- name: key2
Expand All @@ -45,7 +45,7 @@ var correctConfig string = `
`

var incorrectConfig1 string = `
- kind: AEAD
- kind: k8s-aes-gcm
version: v1
keys:
- name: key1
Expand All @@ -55,15 +55,15 @@ var incorrectConfig1 string = `
`

var incorrectConfig2 string = `
- kind: AEAD
- kind: k8s-aes-gcm
version: v1
keys:
- name: key2
secret: dGhpcyBpcyBwYXNzd29yZA==
`

var incorrectConfig3 string = `
- kind: AEAD
- kind: k8s-aes-gcm
version: v1
keys:
- name: key1
Expand Down
6 changes: 5 additions & 1 deletion staging/src/k8s.io/apiserver/pkg/storage/value/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ go_test(

go_library(
name = "go_default_library",
srcs = ["transformer.go"],
srcs = [
"location_transformer.go",
"transformer.go",
"helpers.go",
],
tags = ["automanaged"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func NewGCMTransformerFromConfig(config map[string]interface{}) (value.Transform
Prefix: []byte("k8s-aes-gcm-v1:"),
}), nil

} else {
return nil, fmt.Errorf("no valid keys found in configuration for AEAD transformer")
}

return nil, fmt.Errorf("no valid keys found in configuration for k8s-aes-gcm-v1 transformer")
}

func (t *gcm) TransformFromStorage(data []byte, context value.Context) ([]byte, bool, error) {
Expand Down

0 comments on commit a8ba07c

Please sign in to comment.