Skip to content

Commit

Permalink
changed namespace to empty in api methods
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Avramenko <avramenkomihail15@gmail.com>
  • Loading branch information
Mixaster995 committed Oct 8, 2021
1 parent adf19e0 commit 4329b82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions pkg/registry/etcd/ns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func (n *etcdNSRegistryServer) Register(ctx context.Context, request *registry.N
)
if apierrors.IsAlreadyExists(err) {
var exist *v1.NetworkService
exist, err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Get(ctx, request.Name, metav1.GetOptions{})
exist, err = n.client.NetworkservicemeshV1().NetworkServices("").Get(ctx, request.Name, metav1.GetOptions{})
if err == nil {
exist.Spec = *(*v1.NetworkServiceSpec)(request)
apiResp, err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Update(ctx, exist, metav1.UpdateOptions{})
apiResp, err = n.client.NetworkservicemeshV1().NetworkServices("").Update(ctx, exist, metav1.UpdateOptions{})
}
}
if err != nil {
Expand All @@ -78,7 +78,7 @@ func (n *etcdNSRegistryServer) watch(query *registry.NetworkServiceQuery, s regi
var watchErr error
for watchErr == nil {
timeoutSeconds := int64(time.Minute / time.Second)
watcher, err := n.client.NetworkservicemeshV1().NetworkServices(n.ns).Watch(s.Context(), metav1.ListOptions{
watcher, err := n.client.NetworkservicemeshV1().NetworkServices("").Watch(s.Context(), metav1.ListOptions{
TimeoutSeconds: &timeoutSeconds,
})
if err != nil {
Expand Down Expand Up @@ -126,7 +126,7 @@ func (n *etcdNSRegistryServer) handleWatcher(
}

func (n *etcdNSRegistryServer) Find(query *registry.NetworkServiceQuery, s registry.NetworkServiceRegistry_FindServer) error {
list, err := n.client.NetworkservicemeshV1().NetworkServices(n.ns).List(s.Context(), metav1.ListOptions{})
list, err := n.client.NetworkservicemeshV1().NetworkServices("").List(s.Context(), metav1.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func (n *etcdNSRegistryServer) Unregister(ctx context.Context, request *registry
if err != nil {
return nil, err
}
err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Delete(
err = n.client.NetworkservicemeshV1().NetworkServices("").Delete(
ctx,
request.Name,
metav1.DeleteOptions{},
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/etcd/ns_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

func Test_NSReRegister(t *testing.T) {
s := etcd.NewNetworkServiceRegistryServer(context.Background(), "default", fake.NewSimpleClientset())
s := etcd.NewNetworkServiceRegistryServer(context.Background(), "", fake.NewSimpleClientset())
_, err := s.Register(context.Background(), &registry.NetworkService{Name: "ns-1"})
require.NoError(t, err)
_, err = s.Register(context.Background(), &registry.NetworkService{Name: "ns-1", Payload: "IP"})
Expand All @@ -46,14 +46,14 @@ func Test_K8sNERegistry_ShouldMatchMetadataToName(t *testing.T) {

var myClientset = fake.NewSimpleClientset()

_, err := myClientset.NetworkservicemeshV1().NetworkServices("default").Create(ctx, &v1.NetworkService{
_, err := myClientset.NetworkservicemeshV1().NetworkServices("").Create(ctx, &v1.NetworkService{
ObjectMeta: metav1.ObjectMeta{
Name: "ns-1",
},
}, metav1.CreateOptions{})
require.NoError(t, err)

s := etcd.NewNetworkServiceRegistryServer(ctx, "default", myClientset)
s := etcd.NewNetworkServiceRegistryServer(ctx, "", myClientset)
c := adapters.NetworkServiceServerToClient(s)

stream, err := c.Find(ctx, &registry.NetworkServiceQuery{
Expand Down
10 changes: 5 additions & 5 deletions pkg/registry/etcd/nse_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func (n *etcdNSERegistryServer) Register(ctx context.Context, request *registry.
)
if apierrors.IsAlreadyExists(err) {
var exist *v1.NetworkServiceEndpoint
exist, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Get(ctx, request.Name, metav1.GetOptions{})
exist, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Get(ctx, request.Name, metav1.GetOptions{})
if err == nil {
exist.Spec = *(*v1.NetworkServiceEndpointSpec)(request)
apiResp, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Update(ctx, exist, metav1.UpdateOptions{})
apiResp, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Update(ctx, exist, metav1.UpdateOptions{})
}
}
if err != nil {
Expand All @@ -77,7 +77,7 @@ func (n *etcdNSERegistryServer) Register(ctx context.Context, request *registry.
}

func (n *etcdNSERegistryServer) Find(query *registry.NetworkServiceEndpointQuery, s registry.NetworkServiceEndpointRegistry_FindServer) error {
list, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).List(s.Context(), metav1.ListOptions{})
list, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").List(s.Context(), metav1.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (n *etcdNSERegistryServer) Unregister(ctx context.Context, request *registr
if err != nil {
return nil, err
}
err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Delete(
err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Delete(
ctx,
request.Name,
metav1.DeleteOptions{})
Expand All @@ -120,7 +120,7 @@ func (n *etcdNSERegistryServer) watch(query *registry.NetworkServiceEndpointQuer
var watchErr error
for watchErr == nil {
timeoutSeconds := int64(time.Minute / time.Second)
watcher, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Watch(s.Context(), metav1.ListOptions{
watcher, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Watch(s.Context(), metav1.ListOptions{
TimeoutSeconds: &timeoutSeconds,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/etcd/nse_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func Test_NSEReRegister(t *testing.T) {
s := etcd.NewNetworkServiceEndpointRegistryServer(context.Background(), "default", fake.NewSimpleClientset())
s := etcd.NewNetworkServiceEndpointRegistryServer(context.Background(), "", fake.NewSimpleClientset())
_, err := s.Register(context.Background(), &registry.NetworkServiceEndpoint{Name: "nse-1"})
require.NoError(t, err)
_, err = s.Register(context.Background(), &registry.NetworkServiceEndpoint{Name: "nse-1", NetworkServiceNames: []string{"ns-1"}})
Expand Down

0 comments on commit 4329b82

Please sign in to comment.