Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Remove unnecessary methods from Store2, and moves handling of protobuf to store #1120

Merged
merged 22 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions doc/dev/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,3 @@ You can also run a simple client to interact with the server:
--string_attributes source.uid=kubernetes://xyz.default
Check RPC returned OK
```

## Testing

Similar to Pilot, some tests for Mixer requires access to Kubernetes cluster
(version 1.7.0 or higher). Please configure your `kubectl` to point to a development
cluster (e.g. minikube) before building or invoking the tests and add a symbolic link
to your repository pointing to Kubernetes cluster credentials:

ln -s ~/.kube/config testdata/kubernetes/

_Note1_: If you are running Bazel in a VM (e.g. in Vagrant environment), copy
the kube config file on the host to testdata/kubernetes instead of symlinking it,
and change the paths to minikube certs.

cp ~/.kube/config testdata/kubernetes/
sed -i 's!/Users/<username>!/home/ubuntu!' testdata/kubernetes/config

Also, copy the same file to `/home/ubuntu/.kube/config` in the VM, and make
sure that the file is readable to user `ubuntu`.

See also [Pilot's guide of setting up test environment](https://github.com/istio/pilot/blob/master/doc/testing.md).
21 changes: 6 additions & 15 deletions pkg/config/crd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"queue.go",
"resource.go",
"store.go",
],
visibility = ["//visibility:public"],
deps = [
"//pkg/config/store:go_default_library",
"@com_github_gogo_protobuf//jsonpb:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_apimachinery//pkg/runtime:go_default_library",
Expand All @@ -31,24 +28,18 @@ go_test(
name = "go_default_test",
size = "medium",
srcs = [
"queue_test.go",
"resource_test.go",
"store_test.go",
],
library = ":go_default_library",
deps = [
"//pkg/config/proto:go_default_library",
"//pkg/config/store:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@io_k8s_api//core/v1:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1/unstructured:go_default_library",
"@io_k8s_apimachinery//pkg/runtime/schema:go_default_library",
"@io_k8s_client_go//kubernetes:go_default_library",
"@io_k8s_client_go//plugin/pkg/client/auth/gcp:go_default_library",
"@io_k8s_client_go//plugin/pkg/client/auth/oidc:go_default_library",
"@io_k8s_apimachinery//pkg/runtime:go_default_library",
"@io_k8s_apimachinery//pkg/watch:go_default_library",
"@io_k8s_client_go//discovery:go_default_library",
"@io_k8s_client_go//discovery/fake:go_default_library",
"@io_k8s_client_go//rest:go_default_library",
"@io_k8s_client_go//tools/clientcmd:go_default_library",
"@io_k8s_client_go//testing:go_default_library",
"@io_k8s_client_go//tools/cache:go_default_library",
],
)
26 changes: 0 additions & 26 deletions pkg/config/crd/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
package crd

import (
"bytes"
"encoding/json"

"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -101,24 +96,3 @@ func (r *resourceList) DeepCopyObject() runtime.Object {
}
return r2
}

func convert(spec map[string]interface{}, pbSpec proto.Message) error {
// This is inefficient; convert to a protobuf message through JSON.
// TODO: use reflect.
jsonData, err := json.Marshal(spec)
if err != nil {
return err
}
return jsonpb.Unmarshal(bytes.NewReader(jsonData), pbSpec)
}

func convertBack(pbSpec proto.Message, spec *map[string]interface{}) error {
buf := bytes.NewBuffer(nil)
if err := (&jsonpb.Marshaler{}).Marshal(buf, pbSpec); err != nil {
return err
}
if err := json.Unmarshal(buf.Bytes(), spec); err != nil {
return err
}
return nil
}
Loading