From fc47759ca014d30bb949f26fe943fa91234f31c3 Mon Sep 17 00:00:00 2001 From: Victor Buciuc Date: Tue, 12 Jan 2021 14:41:39 -0700 Subject: [PATCH 1/2] APIGOV-15667 - Add MeshDiscovery and MeshService resources --- .../management/v1alpha1/MeshDiscovery.go | 201 ++++++++++++++++++ .../management/v1alpha1/MeshService.go | 201 ++++++++++++++++++ pkg/apic/apiserver/clients/set.go | 40 ++-- .../management/v1alpha1/MeshDiscovery.go | 84 ++++++++ .../models/management/v1alpha1/MeshService.go | 84 ++++++++ .../v1alpha1/model_mesh_discovery_spec.go | 16 ++ .../v1alpha1/model_mesh_service_spec.go | 22 ++ .../model_mesh_service_spec_endpoints.go | 19 ++ .../v1alpha1/model_mesh_service_spec_ports.go | 17 ++ .../model_mesh_workload_spec_specs.go | 2 +- 10 files changed, 670 insertions(+), 16 deletions(-) create mode 100644 pkg/apic/apiserver/clients/management/v1alpha1/MeshDiscovery.go create mode 100644 pkg/apic/apiserver/clients/management/v1alpha1/MeshService.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/MeshDiscovery.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/MeshService.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/model_mesh_discovery_spec.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_endpoints.go create mode 100644 pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_ports.go diff --git a/pkg/apic/apiserver/clients/management/v1alpha1/MeshDiscovery.go b/pkg/apic/apiserver/clients/management/v1alpha1/MeshDiscovery.go new file mode 100644 index 000000000..e8a7edae4 --- /dev/null +++ b/pkg/apic/apiserver/clients/management/v1alpha1/MeshDiscovery.go @@ -0,0 +1,201 @@ +/* + * This file is automatically generated + */ + +package v1alpha1 + +import ( + "fmt" + + v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/api/v1" + apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" + "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/management/v1alpha1" +) + +type MeshDiscoveryMergeFunc func(*v1alpha1.MeshDiscovery, *v1alpha1.MeshDiscovery) (*v1alpha1.MeshDiscovery, error) + +// Merge builds a merge option for an update operation +func MeshDiscoveryMerge(f MeshDiscoveryMergeFunc) v1.UpdateOption { + return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) { + p, n := &v1alpha1.MeshDiscovery{}, &v1alpha1.MeshDiscovery{} + + switch t := prev.(type) { + case *v1alpha1.MeshDiscovery: + p = t + case *apiv1.ResourceInstance: + err := p.FromInstance(t) + if err != nil { + return nil, fmt.Errorf("merge: failed to unserialise prev resource: %w", err) + } + default: + return nil, fmt.Errorf("merge: failed to unserialise prev resource, unxexpected resource type: %T", t) + } + + switch t := new.(type) { + case *v1alpha1.MeshDiscovery: + n = t + case *apiv1.ResourceInstance: + err := n.FromInstance(t) + if err != nil { + return nil, fmt.Errorf("merge: failed to unserialize new resource: %w", err) + } + default: + return nil, fmt.Errorf("merge: failed to unserialise new resource, unxexpected resource type: %T", t) + } + + return f(p, n) + }) +} + +// MeshDiscoveryClient - +type MeshDiscoveryClient struct { + client v1.Scoped +} + +// UnscopedMeshDiscoveryClient - +type UnscopedMeshDiscoveryClient struct { + client v1.Unscoped +} + +// NewMeshDiscoveryClient - +func NewMeshDiscoveryClient(c v1.Base) (*UnscopedMeshDiscoveryClient, error) { + + client, err := c.ForKind(v1alpha1.MeshDiscoveryGVK()) + if err != nil { + return nil, err + } + + return &UnscopedMeshDiscoveryClient{client}, nil + +} + +// WithScope - +func (c *UnscopedMeshDiscoveryClient) WithScope(scope string) *MeshDiscoveryClient { + return &MeshDiscoveryClient{ + c.client.WithScope(scope), + } +} + +// Get - +func (c *UnscopedMeshDiscoveryClient) Get(name string) (*v1alpha1.MeshDiscovery, error) { + ri, err := c.client.Get(name) + if err != nil { + return nil, err + } + + service := &v1alpha1.MeshDiscovery{} + service.FromInstance(ri) + + return service, nil +} + +// Update - +func (c *UnscopedMeshDiscoveryClient) Update(res *v1alpha1.MeshDiscovery, opts ...v1.UpdateOption) (*v1alpha1.MeshDiscovery, error) { + ri, err := res.AsInstance() + if err != nil { + return nil, err + } + resource, err := c.client.Update(ri, opts...) + if err != nil { + return nil, err + } + + updated := &v1alpha1.MeshDiscovery{} + + // Updates the resource in place + err = updated.FromInstance(resource) + if err != nil { + return nil, err + } + + return updated, nil +} + +// List - +func (c *MeshDiscoveryClient) List(options ...v1.ListOptions) ([]*v1alpha1.MeshDiscovery, error) { + riList, err := c.client.List(options...) + if err != nil { + return nil, err + } + + result := make([]*v1alpha1.MeshDiscovery, len(riList)) + + for i := range riList { + result[i] = &v1alpha1.MeshDiscovery{} + err := result[i].FromInstance(riList[i]) + if err != nil { + return nil, err + } + } + + return result, nil +} + +// Get - +func (c *MeshDiscoveryClient) Get(name string) (*v1alpha1.MeshDiscovery, error) { + ri, err := c.client.Get(name) + if err != nil { + return nil, err + } + + service := &v1alpha1.MeshDiscovery{} + service.FromInstance(ri) + + return service, nil +} + +// Delete - +func (c *MeshDiscoveryClient) Delete(res *v1alpha1.MeshDiscovery) error { + ri, err := res.AsInstance() + + if err != nil { + return err + } + + return c.client.Delete(ri) +} + +// Create - +func (c *MeshDiscoveryClient) Create(res *v1alpha1.MeshDiscovery, opts ...v1.CreateOption) (*v1alpha1.MeshDiscovery, error) { + ri, err := res.AsInstance() + + if err != nil { + return nil, err + } + + cri, err := c.client.Create(ri, opts...) + if err != nil { + return nil, err + } + + created := &v1alpha1.MeshDiscovery{} + + err = created.FromInstance(cri) + if err != nil { + return nil, err + } + + return created, err +} + +// Update - +func (c *MeshDiscoveryClient) Update(res *v1alpha1.MeshDiscovery, opts ...v1.UpdateOption) (*v1alpha1.MeshDiscovery, error) { + ri, err := res.AsInstance() + if err != nil { + return nil, err + } + resource, err := c.client.Update(ri, opts...) + if err != nil { + return nil, err + } + + updated := &v1alpha1.MeshDiscovery{} + + // Updates the resource in place + err = updated.FromInstance(resource) + if err != nil { + return nil, err + } + + return updated, nil +} diff --git a/pkg/apic/apiserver/clients/management/v1alpha1/MeshService.go b/pkg/apic/apiserver/clients/management/v1alpha1/MeshService.go new file mode 100644 index 000000000..4ced49985 --- /dev/null +++ b/pkg/apic/apiserver/clients/management/v1alpha1/MeshService.go @@ -0,0 +1,201 @@ +/* + * This file is automatically generated + */ + +package v1alpha1 + +import ( + "fmt" + + v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/api/v1" + apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" + "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/management/v1alpha1" +) + +type MeshServiceMergeFunc func(*v1alpha1.MeshService, *v1alpha1.MeshService) (*v1alpha1.MeshService, error) + +// Merge builds a merge option for an update operation +func MeshServiceMerge(f MeshServiceMergeFunc) v1.UpdateOption { + return v1.Merge(func(prev, new apiv1.Interface) (apiv1.Interface, error) { + p, n := &v1alpha1.MeshService{}, &v1alpha1.MeshService{} + + switch t := prev.(type) { + case *v1alpha1.MeshService: + p = t + case *apiv1.ResourceInstance: + err := p.FromInstance(t) + if err != nil { + return nil, fmt.Errorf("merge: failed to unserialise prev resource: %w", err) + } + default: + return nil, fmt.Errorf("merge: failed to unserialise prev resource, unxexpected resource type: %T", t) + } + + switch t := new.(type) { + case *v1alpha1.MeshService: + n = t + case *apiv1.ResourceInstance: + err := n.FromInstance(t) + if err != nil { + return nil, fmt.Errorf("merge: failed to unserialize new resource: %w", err) + } + default: + return nil, fmt.Errorf("merge: failed to unserialise new resource, unxexpected resource type: %T", t) + } + + return f(p, n) + }) +} + +// MeshServiceClient - +type MeshServiceClient struct { + client v1.Scoped +} + +// UnscopedMeshServiceClient - +type UnscopedMeshServiceClient struct { + client v1.Unscoped +} + +// NewMeshServiceClient - +func NewMeshServiceClient(c v1.Base) (*UnscopedMeshServiceClient, error) { + + client, err := c.ForKind(v1alpha1.MeshServiceGVK()) + if err != nil { + return nil, err + } + + return &UnscopedMeshServiceClient{client}, nil + +} + +// WithScope - +func (c *UnscopedMeshServiceClient) WithScope(scope string) *MeshServiceClient { + return &MeshServiceClient{ + c.client.WithScope(scope), + } +} + +// Get - +func (c *UnscopedMeshServiceClient) Get(name string) (*v1alpha1.MeshService, error) { + ri, err := c.client.Get(name) + if err != nil { + return nil, err + } + + service := &v1alpha1.MeshService{} + service.FromInstance(ri) + + return service, nil +} + +// Update - +func (c *UnscopedMeshServiceClient) Update(res *v1alpha1.MeshService, opts ...v1.UpdateOption) (*v1alpha1.MeshService, error) { + ri, err := res.AsInstance() + if err != nil { + return nil, err + } + resource, err := c.client.Update(ri, opts...) + if err != nil { + return nil, err + } + + updated := &v1alpha1.MeshService{} + + // Updates the resource in place + err = updated.FromInstance(resource) + if err != nil { + return nil, err + } + + return updated, nil +} + +// List - +func (c *MeshServiceClient) List(options ...v1.ListOptions) ([]*v1alpha1.MeshService, error) { + riList, err := c.client.List(options...) + if err != nil { + return nil, err + } + + result := make([]*v1alpha1.MeshService, len(riList)) + + for i := range riList { + result[i] = &v1alpha1.MeshService{} + err := result[i].FromInstance(riList[i]) + if err != nil { + return nil, err + } + } + + return result, nil +} + +// Get - +func (c *MeshServiceClient) Get(name string) (*v1alpha1.MeshService, error) { + ri, err := c.client.Get(name) + if err != nil { + return nil, err + } + + service := &v1alpha1.MeshService{} + service.FromInstance(ri) + + return service, nil +} + +// Delete - +func (c *MeshServiceClient) Delete(res *v1alpha1.MeshService) error { + ri, err := res.AsInstance() + + if err != nil { + return err + } + + return c.client.Delete(ri) +} + +// Create - +func (c *MeshServiceClient) Create(res *v1alpha1.MeshService, opts ...v1.CreateOption) (*v1alpha1.MeshService, error) { + ri, err := res.AsInstance() + + if err != nil { + return nil, err + } + + cri, err := c.client.Create(ri, opts...) + if err != nil { + return nil, err + } + + created := &v1alpha1.MeshService{} + + err = created.FromInstance(cri) + if err != nil { + return nil, err + } + + return created, err +} + +// Update - +func (c *MeshServiceClient) Update(res *v1alpha1.MeshService, opts ...v1.UpdateOption) (*v1alpha1.MeshService, error) { + ri, err := res.AsInstance() + if err != nil { + return nil, err + } + resource, err := c.client.Update(ri, opts...) + if err != nil { + return nil, err + } + + updated := &v1alpha1.MeshService{} + + // Updates the resource in place + err = updated.FromInstance(resource) + if err != nil { + return nil, err + } + + return updated, nil +} diff --git a/pkg/apic/apiserver/clients/set.go b/pkg/apic/apiserver/clients/set.go index 7be0ad9cc..7f0f8a268 100644 --- a/pkg/apic/apiserver/clients/set.go +++ b/pkg/apic/apiserver/clients/set.go @@ -13,9 +13,6 @@ import ( ) type Set struct { - EdgeDataplaneManagementV1alpha1 *management_v1alpha1.UnscopedEdgeDataplaneClient - EdgeDiscoveryAgentManagementV1alpha1 *management_v1alpha1.UnscopedEdgeDiscoveryAgentClient - EdgeTraceabilityAgentManagementV1alpha1 *management_v1alpha1.UnscopedEdgeTraceabilityAgentClient EnvironmentManagementV1alpha1 *management_v1alpha1.EnvironmentClient APIServiceManagementV1alpha1 *management_v1alpha1.UnscopedAPIServiceClient APIServiceRevisionManagementV1alpha1 *management_v1alpha1.UnscopedAPIServiceRevisionClient @@ -31,6 +28,11 @@ type Set struct { SpecDiscoveryManagementV1alpha1 *management_v1alpha1.UnscopedSpecDiscoveryClient APISpecManagementV1alpha1 *management_v1alpha1.UnscopedAPISpecClient MeshWorkloadManagementV1alpha1 *management_v1alpha1.UnscopedMeshWorkloadClient + MeshServiceManagementV1alpha1 *management_v1alpha1.UnscopedMeshServiceClient + MeshDiscoveryManagementV1alpha1 *management_v1alpha1.UnscopedMeshDiscoveryClient + EdgeDataplaneManagementV1alpha1 *management_v1alpha1.UnscopedEdgeDataplaneClient + EdgeDiscoveryAgentManagementV1alpha1 *management_v1alpha1.UnscopedEdgeDiscoveryAgentClient + EdgeTraceabilityAgentManagementV1alpha1 *management_v1alpha1.UnscopedEdgeTraceabilityAgentClient AWSDataplaneManagementV1alpha1 *management_v1alpha1.UnscopedAWSDataplaneClient AWSDiscoveryAgentManagementV1alpha1 *management_v1alpha1.UnscopedAWSDiscoveryAgentClient AWSTraceabilityAgentManagementV1alpha1 *management_v1alpha1.UnscopedAWSTraceabilityAgentClient @@ -47,18 +49,6 @@ func New(b cAPIV1.Base) *Set { var err error - s.EdgeDataplaneManagementV1alpha1, err = management_v1alpha1.NewEdgeDataplaneClient(b) - if err != nil { - panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeDataplane: %s", err)) - } - s.EdgeDiscoveryAgentManagementV1alpha1, err = management_v1alpha1.NewEdgeDiscoveryAgentClient(b) - if err != nil { - panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeDiscoveryAgent: %s", err)) - } - s.EdgeTraceabilityAgentManagementV1alpha1, err = management_v1alpha1.NewEdgeTraceabilityAgentClient(b) - if err != nil { - panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeTraceabilityAgent: %s", err)) - } s.EnvironmentManagementV1alpha1, err = management_v1alpha1.NewEnvironmentClient(b) if err != nil { panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.Environment: %s", err)) @@ -119,6 +109,26 @@ func New(b cAPIV1.Base) *Set { if err != nil { panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.MeshWorkload: %s", err)) } + s.MeshServiceManagementV1alpha1, err = management_v1alpha1.NewMeshServiceClient(b) + if err != nil { + panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.MeshService: %s", err)) + } + s.MeshDiscoveryManagementV1alpha1, err = management_v1alpha1.NewMeshDiscoveryClient(b) + if err != nil { + panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.MeshDiscovery: %s", err)) + } + s.EdgeDataplaneManagementV1alpha1, err = management_v1alpha1.NewEdgeDataplaneClient(b) + if err != nil { + panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeDataplane: %s", err)) + } + s.EdgeDiscoveryAgentManagementV1alpha1, err = management_v1alpha1.NewEdgeDiscoveryAgentClient(b) + if err != nil { + panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeDiscoveryAgent: %s", err)) + } + s.EdgeTraceabilityAgentManagementV1alpha1, err = management_v1alpha1.NewEdgeTraceabilityAgentClient(b) + if err != nil { + panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.EdgeTraceabilityAgent: %s", err)) + } s.AWSDataplaneManagementV1alpha1, err = management_v1alpha1.NewAWSDataplaneClient(b) if err != nil { panic(fmt.Sprintf("Failed to create client for github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1.AWSDataplane: %s", err)) diff --git a/pkg/apic/apiserver/models/management/v1alpha1/MeshDiscovery.go b/pkg/apic/apiserver/models/management/v1alpha1/MeshDiscovery.go new file mode 100644 index 000000000..c3fc6e4f9 --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/MeshDiscovery.go @@ -0,0 +1,84 @@ +/* + * This file is automatically generated + */ + +package v1alpha1 + +import ( + "encoding/json" + + apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" +) + +var ( + _MeshDiscoveryGVK = apiv1.GroupVersionKind{ + GroupKind: apiv1.GroupKind{ + Group: "management", + Kind: "MeshDiscovery", + }, + APIVersion: "v1alpha1", + } +) + +const ( + MeshDiscoveryScope = "Mesh" + + MeshDiscoveryResource = "meshdiscoveries" +) + +func MeshDiscoveryGVK() apiv1.GroupVersionKind { + return _MeshDiscoveryGVK +} + +func init() { + apiv1.RegisterGVK(_MeshDiscoveryGVK, MeshDiscoveryScope, MeshDiscoveryResource) +} + +// MeshDiscovery Resource +type MeshDiscovery struct { + apiv1.ResourceMeta + + Spec MeshDiscoverySpec `json:"spec"` +} + +// FromInstance converts a ResourceInstance to a MeshDiscovery +func (res *MeshDiscovery) FromInstance(ri *apiv1.ResourceInstance) error { + if ri == nil { + res = nil + return nil + } + + m, err := json.Marshal(ri.Spec) + if err != nil { + return err + } + + spec := &MeshDiscoverySpec{} + err = json.Unmarshal(m, spec) + if err != nil { + return err + } + + *res = MeshDiscovery{ResourceMeta: ri.ResourceMeta, Spec: *spec} + + return err +} + +// AsInstance converts a MeshDiscovery to a ResourceInstance +func (res *MeshDiscovery) AsInstance() (*apiv1.ResourceInstance, error) { + m, err := json.Marshal(res.Spec) + if err != nil { + return nil, err + } + + spec := map[string]interface{}{} + err = json.Unmarshal(m, &spec) + if err != nil { + return nil, err + } + + meta := res.ResourceMeta + meta.GroupVersionKind = MeshDiscoveryGVK() + + return &apiv1.ResourceInstance{ResourceMeta: meta, Spec: spec}, nil +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/MeshService.go b/pkg/apic/apiserver/models/management/v1alpha1/MeshService.go new file mode 100644 index 000000000..cda081a51 --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/MeshService.go @@ -0,0 +1,84 @@ +/* + * This file is automatically generated + */ + +package v1alpha1 + +import ( + "encoding/json" + + apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" +) + +var ( + _MeshServiceGVK = apiv1.GroupVersionKind{ + GroupKind: apiv1.GroupKind{ + Group: "management", + Kind: "MeshService", + }, + APIVersion: "v1alpha1", + } +) + +const ( + MeshServiceScope = "Mesh" + + MeshServiceResource = "meshservices" +) + +func MeshServiceGVK() apiv1.GroupVersionKind { + return _MeshServiceGVK +} + +func init() { + apiv1.RegisterGVK(_MeshServiceGVK, MeshServiceScope, MeshServiceResource) +} + +// MeshService Resource +type MeshService struct { + apiv1.ResourceMeta + + Spec MeshServiceSpec `json:"spec"` +} + +// FromInstance converts a ResourceInstance to a MeshService +func (res *MeshService) FromInstance(ri *apiv1.ResourceInstance) error { + if ri == nil { + res = nil + return nil + } + + m, err := json.Marshal(ri.Spec) + if err != nil { + return err + } + + spec := &MeshServiceSpec{} + err = json.Unmarshal(m, spec) + if err != nil { + return err + } + + *res = MeshService{ResourceMeta: ri.ResourceMeta, Spec: *spec} + + return err +} + +// AsInstance converts a MeshService to a ResourceInstance +func (res *MeshService) AsInstance() (*apiv1.ResourceInstance, error) { + m, err := json.Marshal(res.Spec) + if err != nil { + return nil, err + } + + spec := map[string]interface{}{} + err = json.Unmarshal(m, &spec) + if err != nil { + return nil, err + } + + meta := res.ResourceMeta + meta.GroupVersionKind = MeshServiceGVK() + + return &apiv1.ResourceInstance{ResourceMeta: meta, Spec: spec}, nil +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_discovery_spec.go b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_discovery_spec.go new file mode 100644 index 000000000..5fb9d4ace --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_discovery_spec.go @@ -0,0 +1,16 @@ +/* + * API Server specification. + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: SNAPSHOT + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package v1alpha1 + +// MeshDiscoverySpec struct for MeshDiscoverySpec +type MeshDiscoverySpec struct { + // Target environment. + EnvironmentRef string `json:"environmentRef,omitempty"` +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec.go b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec.go new file mode 100644 index 000000000..a42fdd528 --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec.go @@ -0,0 +1,22 @@ +/* + * API Server specification. + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: SNAPSHOT + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package v1alpha1 + +// MeshServiceSpec struct for MeshServiceSpec +type MeshServiceSpec struct { + // The labels used by the service to match workloads it exposes. + Selector map[string]string `json:"selector,omitempty"` + // Reference to the K8SResource derived from the Kubernetes Service. + Resource string `json:"resource,omitempty"` + // References to workloads exposed by the service. + Workloads []string `json:"workloads,omitempty"` + // Details per port. + Ports []MeshServiceSpecPorts `json:"ports,omitempty"` +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_endpoints.go b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_endpoints.go new file mode 100644 index 000000000..91c4a6e80 --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_endpoints.go @@ -0,0 +1,19 @@ +/* + * API Server specification. + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: SNAPSHOT + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package v1alpha1 + +// MeshServiceSpecEndpoints struct for MeshServiceSpecEndpoints +type MeshServiceSpecEndpoints struct { + Workloads []string `json:"workloads,omitempty"` + // A subset is the set of labels one or more workloads has outside the labels in the service selector. + Subset map[string]string `json:"subset,omitempty"` + // Array of references to apispecs discovered by the discovery agent. + Specs []string `json:"specs,omitempty"` +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_ports.go b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_ports.go new file mode 100644 index 000000000..ad4cc338f --- /dev/null +++ b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_service_spec_ports.go @@ -0,0 +1,17 @@ +/* + * API Server specification. + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: SNAPSHOT + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package v1alpha1 + +// MeshServiceSpecPorts struct for MeshServiceSpecPorts +type MeshServiceSpecPorts struct { + Name string `json:"name,omitempty"` + Port int32 `json:"port,omitempty"` + Endpoints []MeshServiceSpecEndpoints `json:"endpoints,omitempty"` +} diff --git a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_workload_spec_specs.go b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_workload_spec_specs.go index 27f5624b0..a7b952800 100644 --- a/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_workload_spec_specs.go +++ b/pkg/apic/apiserver/models/management/v1alpha1/model_mesh_workload_spec_specs.go @@ -9,7 +9,7 @@ package v1alpha1 -// MeshWorkloadSpecSpecs API specs exposed by this workload on this pod. +// MeshWorkloadSpecSpecs API specs exposed by this workload on this port. type MeshWorkloadSpecSpecs struct { // Array of references to apispecs discovered by the discovery agent. DiscoveredSpecs []string `json:"discoveredSpecs,omitempty"` From cfa6a485a2942e1b8efe11bd0c87cad19862813b Mon Sep 17 00:00:00 2001 From: Victor Buciuc Date: Tue, 12 Jan 2021 14:56:16 -0700 Subject: [PATCH 2/2] APIGOV-15667 - Fix broken import --- .../clients/management/v1alpha1/fake_example_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/apic/apiserver/clients/management/v1alpha1/fake_example_test.go b/pkg/apic/apiserver/clients/management/v1alpha1/fake_example_test.go index 9780b9580..57fc99d47 100644 --- a/pkg/apic/apiserver/clients/management/v1alpha1/fake_example_test.go +++ b/pkg/apic/apiserver/clients/management/v1alpha1/fake_example_test.go @@ -3,10 +3,10 @@ package v1alpha1_test import ( "testing" - cv1 "github.com/Axway/agents-sdk/pkg/apic/apiserver/clients/api/v1" - cMgmgt "github.com/Axway/agents-sdk/pkg/apic/apiserver/clients/management/v1alpha1" - apiv1 "github.com/Axway/agents-sdk/pkg/apic/apiserver/models/api/v1" - aMgmgt "github.com/Axway/agents-sdk/pkg/apic/apiserver/models/management/v1alpha1" + cv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/api/v1" + cMgmgt "github.com/Axway/agent-sdk/pkg/apic/apiserver/clients/management/v1alpha1" + apiv1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" + aMgmgt "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/management/v1alpha1" ) func TestExampleFake(t *testing.T) {