Skip to content

Commit

Permalink
Merge pull request #184 from networkservicemesh/update/networkservice…
Browse files Browse the repository at this point in the history
…mesh/sdk-k8s

Update from update/networkservicemesh/sdk-k8s
  • Loading branch information
denis-tingaikin authored May 12, 2022
2 parents feac0e5 + 6c2e65e commit 97f4a84
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 33 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.3.2-0.20220509143420-a1414febd727
github.com/networkservicemesh/sdk v0.5.1-0.20220509144219-1d4d4cca3172
github.com/networkservicemesh/sdk-k8s v0.0.0-20220509144811-65a8747c9e8e
github.com/networkservicemesh/sdk-k8s v0.0.0-20220511231607-f455879f4571
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/spiffe/go-spiffe/v2 v2.0.0
google.golang.org/grpc v1.42.0
k8s.io/api v0.22.1
k8s.io/apimachinery v0.22.1
k8s.io/client-go v0.22.1
)
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ github.com/networkservicemesh/api v1.3.2-0.20220509143420-a1414febd727 h1:IonbJe
github.com/networkservicemesh/api v1.3.2-0.20220509143420-a1414febd727/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/sdk v0.5.1-0.20220509144219-1d4d4cca3172 h1:TGXcwiTg8QA1tBZOr4eyaxEDNLFey+HKMu9K+9qd+7c=
github.com/networkservicemesh/sdk v0.5.1-0.20220509144219-1d4d4cca3172/go.mod h1:DNe9LVK43qshgBNVexcylOwDS6Xup1t3wKbWS2HrZys=
github.com/networkservicemesh/sdk-k8s v0.0.0-20220509144811-65a8747c9e8e h1:4wsbrXWmQh4TUJEAMt4grhAIEYHs21IYtD8ByPjxsz0=
github.com/networkservicemesh/sdk-k8s v0.0.0-20220509144811-65a8747c9e8e/go.mod h1:QzlkftMz0wD96AI+BlU6FVUa4OnTjP7Bgj2gAZ1S1ME=
github.com/networkservicemesh/sdk-k8s v0.0.0-20220511231607-f455879f4571 h1:4g4N984x2futFjZhmqfLSI+vGaJVVY6CpSoZ4JU7UI0=
github.com/networkservicemesh/sdk-k8s v0.0.0-20220511231607-f455879f4571/go.mod h1:azTqhn4z5lo98dedo/CI/mK34nZ8RPPVkH930MJCfBM=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down Expand Up @@ -531,7 +531,6 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/imports/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2021 Cisco and/or its affiliates.
// Copyright (c) 2020-2022 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -18,5 +18,5 @@
package imports

//go:generate bash -c "rm -rf imports*.go"
//go:generate bash -c "cd $(mktemp -d) && GO111MODULE=on go get github.com/edwarnicke/imports-gen@v1.1.0"
//go:generate bash -c "cd $(mktemp -d) && GO111MODULE=on go install github.com/edwarnicke/imports-gen@v1.1.0"
//go:generate bash -c "GOOS=linux ${GOPATH}/bin/imports-gen"
4 changes: 0 additions & 4 deletions internal/pkg/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package imports

import (
_ "context"
_ "encoding/json"
_ "github.com/antonfisher/nested-logrus-formatter"
_ "github.com/edwarnicke/grpcfd"
_ "github.com/kelseyhightower/envconfig"
Expand All @@ -27,9 +26,6 @@ import (
_ "google.golang.org/grpc"
_ "google.golang.org/grpc/credentials"
_ "io/ioutil"
_ "k8s.io/api/core/v1"
_ "k8s.io/apimachinery/pkg/runtime"
_ "k8s.io/apimachinery/pkg/runtime/serializer"
_ "k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/rest"
_ "net/url"
Expand Down
22 changes: 1 addition & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package main

import (
"context"
"encoding/json"
"io/ioutil"
"net/url"
"os"
Expand All @@ -39,9 +38,6 @@ import (
"github.com/spiffe/go-spiffe/v2/workloadapi"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

Expand Down Expand Up @@ -181,27 +177,11 @@ func main() {
}
logger.Infof("successfully obtained kubernetes client")

scheme := runtime.NewScheme()
codecFactory := serializer.NewCodecFactory(scheme)
deserializer := codecFactory.UniversalDeserializer()
podYamlBytes, err := ioutil.ReadFile(config.PodDescriptionFile)
if err != nil {
logger.Fatalf("can't read pod file: %+v", err)
}

var podDesc corev1.Pod
_, _, err = deserializer.Decode(podYamlBytes, nil, &podDesc)
if err != nil {
logger.Fatalf("can't parse pod file: %+v", err)
}
logger.Infof("successfully parsed pod description")

podPrettyPrint, err := json.MarshalIndent(podDesc, "", " ")
if err != nil {
logger.Fatalf("can't pretty-print pod file: %+v", err)
}
logger.Infof(string(podPrettyPrint))

// ********************************************************************************
logger.Infof("executing phase 4: create supplier endpoint")
// ********************************************************************************
Expand All @@ -210,7 +190,7 @@ func main() {
endpoint.WithName(config.Name),
endpoint.WithAuthorizeServer(authorize.NewServer()),
endpoint.WithAdditionalFunctionality(
createpod.NewServer(ctx, client, &podDesc, createpod.WithNamespace(config.Namespace)),
createpod.NewServer(ctx, client, string(podYamlBytes), createpod.WithNamespace(config.Namespace)),
),
)

Expand Down

0 comments on commit 97f4a84

Please sign in to comment.