Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesh: adding the protobuf types and resources backing mesh config v2 #18351

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions internal/catalog/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
HealthStatusKind = types.HealthStatusKind
HealthChecksKind = types.HealthChecksKind
DNSPolicyKind = types.DNSPolicyKind
FailoverPolicyKind = types.FailoverPolicyKind

// Resource Types for the v1alpha1 version.

Expand All @@ -43,6 +44,19 @@ var (
HealthStatusV1Alpha1Type = types.HealthStatusV1Alpha1Type
HealthChecksV1Alpha1Type = types.HealthChecksV1Alpha1Type
DNSPolicyV1Alpha1Type = types.DNSPolicyV1Alpha1Type
FailoverPolicyV1Alpha1Type = types.FailoverPolicyV1Alpha1Type
rboyer marked this conversation as resolved.
Show resolved Hide resolved

// Resource Types for the latest version.

WorkloadType = types.WorkloadType
ServiceType = types.ServiceType
ServiceEndpointsType = types.ServiceEndpointsType
VirtualIPsType = types.VirtualIPsType
NodeType = types.NodeType
HealthStatusType = types.HealthStatusType
HealthChecksType = types.HealthChecksType
DNSPolicyType = types.DNSPolicyType
FailoverPolicyType = types.FailoverPolicyType

// Controller Statuses
NodeHealthStatusKey = nodehealth.StatusKey
Expand Down
33 changes: 33 additions & 0 deletions internal/catalog/internal/types/failover_policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbcatalog "github.com/hashicorp/consul/proto-public/pbcatalog/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
FailoverPolicyKind = "FailoverPolicy"
)

var (
FailoverPolicyV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: FailoverPolicyKind,
}

FailoverPolicyType = FailoverPolicyV1Alpha1Type
)

func RegisterFailoverPolicy(r resource.Registry) {
r.Register(resource.Registration{
Type: FailoverPolicyV1Alpha1Type,
Proto: &pbcatalog.FailoverPolicy{},
Validate: nil,
Mutate: nil,
Comment on lines +30 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACLs, validation etc will come in a later PR right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This was done to make the PR a mostly boring plumbing PR.

})
}
1 change: 1 addition & 0 deletions internal/catalog/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ func Register(r resource.Registry) {
RegisterHealthChecks(r)
RegisterDNSPolicy(r)
RegisterVirtualIPs(r)
RegisterFailoverPolicy(r)
}
29 changes: 26 additions & 3 deletions internal/mesh/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,39 @@ var (

// Resource Kind Names.

ProxyConfigurationKind = types.ProxyConfigurationKind
UpstreamsKind = types.UpstreamsKind
ProxyStateKind = types.ProxyStateTemplateKind
ProxyConfigurationKind = types.ProxyConfigurationKind
UpstreamsKind = types.UpstreamsKind
UpstreamsConfigurationKind = types.UpstreamsConfigurationKind
ProxyStateKind = types.ProxyStateTemplateKind
HTTPRouteKind = types.HTTPRouteKind
GRPCRouteKind = types.GRPCRouteKind
TCPRouteKind = types.TCPRouteKind
DestinationPolicyKind = types.DestinationPolicyKind
ComputedRoutesKind = types.ComputedRoutesKind

// Resource Types for the v1alpha1 version.

ProxyConfigurationV1Alpha1Type = types.ProxyConfigurationV1Alpha1Type
UpstreamsV1Alpha1Type = types.UpstreamsV1Alpha1Type
UpstreamsConfigurationV1Alpha1Type = types.UpstreamsConfigurationV1Alpha1Type
ProxyStateTemplateConfigurationV1Alpha1Type = types.ProxyStateTemplateV1Alpha1Type
HTTPRouteV1Alpha1Type = types.HTTPRouteV1Alpha1Type
GRPCRouteV1Alpha1Type = types.GRPCRouteV1Alpha1Type
TCPRouteV1Alpha1Type = types.TCPRouteV1Alpha1Type
DestinationPolicyV1Alpha1Type = types.DestinationPolicyV1Alpha1Type
ComputedRoutesV1Alpha1Type = types.ComputedRoutesV1Alpha1Type

// Resource Types for the latest version.

ProxyConfigurationType = types.ProxyConfigurationType
UpstreamsType = types.UpstreamsType
UpstreamsConfigurationType = types.UpstreamsConfigurationType
ProxyStateTemplateConfigurationType = types.ProxyStateTemplateType
HTTPRouteType = types.HTTPRouteType
GRPCRouteType = types.GRPCRouteType
TCPRouteType = types.TCPRouteType
DestinationPolicyType = types.DestinationPolicyType
ComputedRoutesType = types.ComputedRoutesType
)

// RegisterTypes adds all resource types within the "catalog" API group
Expand Down
32 changes: 32 additions & 0 deletions internal/mesh/internal/types/computed_routes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
ComputedRoutesKind = "ComputedRoutes"
)

var (
ComputedRoutesV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: ComputedRoutesKind,
}

ComputedRoutesType = ComputedRoutesV1Alpha1Type
)

func RegisterComputedRoutes(r resource.Registry) {
r.Register(resource.Registration{
Type: ComputedRoutesV1Alpha1Type,
Proto: &pbmesh.ComputedRoutes{},
Validate: nil,
})
}
32 changes: 32 additions & 0 deletions internal/mesh/internal/types/destination_policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
DestinationPolicyKind = "DestinationPolicy"
)

var (
DestinationPolicyV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: DestinationPolicyKind,
}

DestinationPolicyType = DestinationPolicyV1Alpha1Type
)

func RegisterDestinationPolicy(r resource.Registry) {
r.Register(resource.Registration{
Type: DestinationPolicyV1Alpha1Type,
Proto: &pbmesh.DestinationPolicy{},
Validate: nil,
})
}
32 changes: 32 additions & 0 deletions internal/mesh/internal/types/grpc_route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
GRPCRouteKind = "GRPCRoute"
)

var (
GRPCRouteV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: GRPCRouteKind,
}

GRPCRouteType = GRPCRouteV1Alpha1Type
)

func RegisterGRPCRoute(r resource.Registry) {
r.Register(resource.Registration{
Type: GRPCRouteV1Alpha1Type,
Proto: &pbmesh.GRPCRoute{},
Validate: nil,
})
}
32 changes: 32 additions & 0 deletions internal/mesh/internal/types/http_route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
HTTPRouteKind = "HTTPRoute"
)

var (
HTTPRouteV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: HTTPRouteKind,
}

HTTPRouteType = HTTPRouteV1Alpha1Type
)

func RegisterHTTPRoute(r resource.Registry) {
r.Register(resource.Registration{
Type: HTTPRouteV1Alpha1Type,
Proto: &pbmesh.HTTPRoute{},
Validate: nil,
})
}
32 changes: 32 additions & 0 deletions internal/mesh/internal/types/tcp_route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"github.com/hashicorp/consul/internal/resource"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

const (
TCPRouteKind = "TCPRoute"
)

var (
TCPRouteV1Alpha1Type = &pbresource.Type{
Group: GroupName,
GroupVersion: VersionV1Alpha1,
Kind: TCPRouteKind,
}

TCPRouteType = TCPRouteV1Alpha1Type
)

func RegisterTCPRoute(r resource.Registry) {
r.Register(resource.Registration{
Type: TCPRouteV1Alpha1Type,
Proto: &pbmesh.TCPRoute{},
Validate: nil,
})
}
5 changes: 5 additions & 0 deletions internal/mesh/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ func Register(r resource.Registry) {
RegisterUpstreams(r)
RegisterUpstreamsConfiguration(r)
RegisterProxyStateTemplate(r)
RegisterHTTPRoute(r)
RegisterTCPRoute(r)
RegisterGRPCRoute(r)
RegisterDestinationPolicy(r)
RegisterComputedRoutes(r)
}
38 changes: 38 additions & 0 deletions proto-public/pbcatalog/v1alpha1/failover_policy.pb.binary.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading