Skip to content

Commit

Permalink
added smi conformance model
Browse files Browse the repository at this point in the history
Signed-off-by: kumarabd <[email protected]>
  • Loading branch information
kumarabd committed Nov 20, 2020
1 parent 74438f1 commit 436a088
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
25 changes: 25 additions & 0 deletions models/smi_conformance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package models

import (
"github.com/google/uuid"
)

type Specification struct {
Name string `json:"name,omitempty" db:"name"`
Version string `json:"version,omitempty" db:"version"`
Assertions string `json:"assertions,omitempty" db:"assertion"`
Duration string `json:"duration,omitempty" db:"duration"`
Result string `json:"result,omitempty" db:"result"`
Reason string `json:"reason,omitempty" db:"reason"`
}

// SmiResult - represents the results from Meshery smi conformance test run
type SmiResult struct {
ID uuid.UUID `json:"meshery_id,omitempty" db:"id"`
Date string `json:"datetime,omitempty" dc:"datetime"`
ServiceMesh string `json:"servicemesh,omitempty" db:"servicemesh"`
ServiceMeshVersion string `json:"servicemeshversion,omitempty" db:"servicemeshversion"`
Capability string `json:"capability,omitempty" db:"capability"`
Status string `json:"status,omitempty" db:"status"`
Specifications []Specification `json:"specifications,omitempty" db:"specifications"`
}
4 changes: 2 additions & 2 deletions utils/kubernetes/apply-manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ApplyOptions struct {
Delete bool
}

func (cfg *Config) ApplyManifest(contents []byte, options ApplyOptions) error {
func (client *Client) ApplyManifest(contents []byte, options ApplyOptions) error {

if options == (ApplyOptions{}) {
options = ApplyOptions{
Expand All @@ -40,7 +40,7 @@ func (cfg *Config) ApplyManifest(contents []byte, options ApplyOptions) error {
return ErrApplyManifest(err)
}

helper, err := constructObject(cfg.Clientset, cfg.RestConfig, object)
helper, err := constructObject(client.Clientset, client.RestConfig, object)
if err != nil {
return ErrApplyManifest(err)
}
Expand Down
6 changes: 3 additions & 3 deletions utils/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"k8s.io/client-go/rest"
)

type Config struct {
type Client struct {
RestConfig rest.Config `json:"restconfig,omitempty"`
Clientset kubernetes.Interface `json:"clientset,omitempty"`
}

func New(clientset kubernetes.Interface, cfg rest.Config) (*Config, error) {
return &Config{
func New(clientset kubernetes.Interface, cfg rest.Config) (*Client, error) {
return &Client{
Clientset: clientset,
RestConfig: cfg,
}, nil
Expand Down
6 changes: 3 additions & 3 deletions utils/kubernetes/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

// GetServiceEndpoint returns the endpoint for the given service
func (cfg *Config) GetServiceEndpoint(ctx context.Context, svcName, namespace string) (*utils.Endpoint, error) {
svc, err := cfg.Clientset.CoreV1().Services(namespace).Get(ctx, svcName, v1.GetOptions{})
func (client *Client) GetServiceEndpoint(ctx context.Context, svcName, namespace string) (*utils.Endpoint, error) {
svc, err := client.Clientset.CoreV1().Services(namespace).Get(ctx, svcName, v1.GetOptions{})
if err != nil {
return nil, ErrServiceDiscovery(err)
}
Expand All @@ -21,7 +21,7 @@ func (cfg *Config) GetServiceEndpoint(ctx context.Context, svcName, namespace st
}

// Try nodeport endpoint
nodes, err := cfg.Clientset.CoreV1().Nodes().List(ctx, v1.ListOptions{})
nodes, err := client.Clientset.CoreV1().Nodes().List(ctx, v1.ListOptions{})
if err != nil {
return nil, ErrServiceDiscovery(err)
}
Expand Down

0 comments on commit 436a088

Please sign in to comment.