Skip to content

Commit

Permalink
Merge pull request #123 from layer5io/kumarabd/featuer/rework
Browse files Browse the repository at this point in the history
updated version for istio
  • Loading branch information
kumarabd authored Oct 3, 2020
2 parents 63b562e + a35e773 commit 0cd76c1
Show file tree
Hide file tree
Showing 8 changed files with 938 additions and 192 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /github.com/layer5io/meshery-istio
ADD . .
RUN GOPROXY=direct GOSUMDB=off go build -ldflags="-w -s" -a -o /meshery-istio .
RUN find . -name "*.go" -type f -delete; mv istio /
RUN wget -O /istio.tar.gz https://github.com/istio/istio/releases/download/1.5.1/istio-1.5.1-linux.tar.gz
RUN wget -O /istio.tar.gz https://github.com/istio/istio/releases/download/1.7.3/istio-1.7.3-linux-amd64.tar.gz

FROM alpine
RUN apk --update add ca-certificates
Expand All @@ -13,7 +13,7 @@ COPY --from=bd /meshery-istio /app/
COPY --from=bd /istio /app/istio
COPY --from=bd /istio.tar.gz /app/
COPY --from=bd /etc/passwd /etc/passwd
ENV ISTIO_VERSION=istio-1.5.1
ENV ISTIO_VERSION=istio-1.7.3
USER appuser
WORKDIR /app
CMD ./meshery-istio
27 changes: 18 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@ go 1.13
replace github.com/kudobuilder/kuttl => github.com/layer5io/kuttl v0.4.1-0.20200723152044-916f10574334

require (
github.com/Azure/go-autorest/autorest/adal v0.9.0
github.com/aspenmesh/istio-client-go v0.0.0-20200122202704-9695ccefca79
github.com/aspenmesh/istio-vet v0.0.0-20190708155745-fac74e54e2e6
github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224 // indirect
cloud.google.com/go v0.46.3 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.0 // indirect
github.com/aspenmesh/istio-vet v0.0.0-20200806222806-9c8e9a962b9f
github.com/ghodss/yaml v1.0.0
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.2
github.com/gophercloud/gophercloud v0.4.0 // indirect
github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20200806140644-44993b65fd37
github.com/layer5io/gokit v0.1.12
github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20200916172547-79cf11334bd7
github.com/onsi/ginkgo v1.13.0 // indirect
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.6.0
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
google.golang.org/grpc v1.30.0
k8s.io/apimachinery v0.17.3
k8s.io/client-go v0.17.3
go.opencensus.io v0.22.3 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
google.golang.org/genproto v0.0.0-20200731012542-8145dea6a485 // indirect
google.golang.org/grpc v1.31.0
google.golang.org/protobuf v1.25.0 // indirect
helm.sh/helm/v3 v3.3.1
istio.io/client-go v0.0.0-20200708142230-d7730fd90478
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/client-go v0.18.8
rsc.io/letsencrypt v0.0.3 // indirect
)
631 changes: 561 additions & 70 deletions go.sum

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"io/ioutil"
"net/http"
"os"
"path"
"strings"
"text/template"
Expand Down Expand Up @@ -66,7 +67,7 @@ func (iClient *Client) CreateMeshInstance(_ context.Context, k8sReq *meshes.Crea
}

func (iClient *Client) createResource(ctx context.Context, res schema.GroupVersionResource, data *unstructured.Unstructured) error {
_, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Create(data, metav1.CreateOptions{})
_, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Create(context.TODO(), data, metav1.CreateOptions{})
if err != nil {
if strings.Contains(err.Error(), "already exists") {
// if err1 := iClient.deleteResource(ctx, res, data); err1 != nil {
Expand All @@ -76,7 +77,7 @@ func (iClient *Client) createResource(ctx context.Context, res schema.GroupVersi
}
err = errors.Wrapf(err, "unable to create the requested resource, attempting operation without namespace")
logrus.Warn(err)
if _, err = iClient.k8sDynamicClient.Resource(res).Create(data, metav1.CreateOptions{}); err != nil {
if _, err = iClient.k8sDynamicClient.Resource(res).Create(context.TODO(), data, metav1.CreateOptions{}); err != nil {
if strings.Contains(err.Error(), "already exists") {
return errors.Wrap(err, "resource already exists")
}
Expand Down Expand Up @@ -113,12 +114,12 @@ func (iClient *Client) deleteResource(ctx context.Context, res schema.GroupVersi
}
}

err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Delete(data.GetName(), &metav1.DeleteOptions{})
err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Delete(context.TODO(), data.GetName(), metav1.DeleteOptions{})
if err != nil {
err = errors.Wrapf(err, "unable to delete the requested resource, attempting operation without namespace")
logrus.Warn(err)

err := iClient.k8sDynamicClient.Resource(res).Delete(data.GetName(), &metav1.DeleteOptions{})
err := iClient.k8sDynamicClient.Resource(res).Delete(context.TODO(), data.GetName(), metav1.DeleteOptions{})
if err != nil {
err = errors.Wrapf(err, "unable to delete the requested resource")
logrus.Error(err)
Expand All @@ -130,12 +131,12 @@ func (iClient *Client) deleteResource(ctx context.Context, res schema.GroupVersi
}

func (iClient *Client) getResource(ctx context.Context, res schema.GroupVersionResource, data *unstructured.Unstructured) (*unstructured.Unstructured, error) {
data1, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Get(data.GetName(), metav1.GetOptions{})
data1, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Get(context.TODO(), data.GetName(), metav1.GetOptions{})
if err != nil {
err = errors.Wrap(err, "unable to retrieve the resource with a matching name, attempting operation without namespace")
logrus.Warn(err)

data1, err = iClient.k8sDynamicClient.Resource(res).Get(data.GetName(), metav1.GetOptions{})
data1, err = iClient.k8sDynamicClient.Resource(res).Get(context.TODO(), data.GetName(), metav1.GetOptions{})
if err != nil {
err = errors.Wrap(err, "unable to retrieve the resource with a matching name, while attempting to apply the config")
logrus.Error(err)
Expand All @@ -147,15 +148,15 @@ func (iClient *Client) getResource(ctx context.Context, res schema.GroupVersionR
}

func (iClient *Client) updateResource(ctx context.Context, res schema.GroupVersionResource, data *unstructured.Unstructured) error {
if _, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Update(data, metav1.UpdateOptions{}); err != nil {
if _, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Update(context.TODO(), data, metav1.UpdateOptions{}); err != nil {
if strings.Contains(err.Error(), "the server does not allow this method on the requested resource") {
logrus.Error(err)
return err
}
err = errors.Wrap(err, "unable to update resource with the given name, attempting operation without namespace")
logrus.Warn(err)

if _, err = iClient.k8sDynamicClient.Resource(res).Update(data, metav1.UpdateOptions{}); err != nil {
if _, err = iClient.k8sDynamicClient.Resource(res).Update(context.TODO(), data, metav1.UpdateOptions{}); err != nil {
if strings.Contains(err.Error(), "the server does not allow this method on the requested resource") {
logrus.Error(err)
return err
Expand Down Expand Up @@ -632,16 +633,16 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu
if err != nil {
return nil, err
}
case runVet:
err = iClient.runVet()
return &meshes.ApplyRuleResponse{
OperationId: arReq.OperationId,
}, err
// case runVet:
// err = iClient.runVet()
// return &meshes.ApplyRuleResponse{
// OperationId: arReq.OperationId,
// }, err
case customOpCommand:
yamlFileContents = arReq.CustomBody
isCustomOp = true
case smiConformanceCommand:
err = iClient.runConformanceTest("istio", arReq)
err = iClient.runConformanceTest(arReq.OperationId, "istio", os.Getenv("ISTIO_VERSION"))
if err != nil {
return nil, err
}
Expand Down
32 changes: 32 additions & 0 deletions istio/smi/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package smi

import (
"fmt"

"github.com/layer5io/gokit/errors"
)

// ErrSmiInit is the error for smi init method
func ErrSmiInit(des string) error {
return errors.New(errors.ErrSmiInit, des)
}

// ErrInstallSmi is the error for installing smi tool
func ErrInstallSmi(err error) error {
return errors.New(errors.ErrInstallSmi, fmt.Sprintf("Error installing smi tool: %s", err.Error()))
}

// ErrConnectSmi is the error for connecting to smi tool
func ErrConnectSmi(err error) error {
return errors.New(errors.ErrConnectSmi, fmt.Sprintf("Error connecting to smi tool: %s", err.Error()))
}

// ErrRunSmi is the error for running conformance test
func ErrRunSmi(err error) error {
return errors.New(errors.ErrRunSmi, fmt.Sprintf("Error running smi tool: %s", err.Error()))
}

// ErrDeleteSmi is the error for deleteing smi tool
func ErrDeleteSmi(err error) error {
return errors.New(errors.ErrDeleteSmi, fmt.Sprintf("Error deleting smi tool: %s", err.Error()))
}
Loading

0 comments on commit 0cd76c1

Please sign in to comment.