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

[WIP] v4alpha1 CRDs #5790

Draft
wants to merge 10 commits into
base: dev/v4
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ issues:
text: "^tests: .* should return nothing$"
run:
timeout: 9m # CircleCI is slow?
skip-dirs:
- pkg/json
- pkg/yaml

# I don't know of a linter that lets you blacklist specific functions
# and variables within a package, but if one exists, I would like to
Expand Down
1 change: 1 addition & 0 deletions build-aux/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ generate-fast/files += $(OSS_HOME)/pkg/api/getambassador.io/v1/zz_generated.conv
generate-fast/files += $(OSS_HOME)/pkg/api/getambassador.io/v2/zz_generated.conversion.go
generate-fast/files += $(OSS_HOME)/pkg/api/getambassador.io/v2/zz_generated.conversion-spoke.go
generate-fast/files += $(OSS_HOME)/pkg/api/getambassador.io/v3alpha1/zz_generated.conversion-hub.go
generate-fast/files += $(OSS_HOME)/pkg/api/emissary-ingress.dev/v4alpha1/zz_generated.conversion-hub.go
# Individual files: YAML
generate-fast/files += $(OSS_HOME)/manifests/emissary/emissary-crds.yaml.in
generate-fast/files += $(OSS_HOME)/manifests/emissary/emissary-emissaryns.yaml.in
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/ambassador_metainfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/emissary-ingress/emissary/v3/cmd/entrypoint"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
"github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

consulapi "github.com/hashicorp/consul/api"

amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/consulwatch"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
)
Expand Down Expand Up @@ -41,7 +41,7 @@
var resolvers []*amb.ConsulResolver
for _, cr := range s.ConsulResolvers {
if cr.Spec.AmbassadorID.Matches(envAmbID) {
resolvers = append(resolvers, cr)

Check failure on line 44 in cmd/entrypoint/consul.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use cr (variable of type *v3alpha1.ConsulResolver) as *v4alpha1.ConsulResolver value in argument to append

Check failure on line 44 in cmd/entrypoint/consul.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use cr (variable of type *v3alpha1.ConsulResolver) as *v4alpha1.ConsulResolver value in argument to append
}
}

Expand All @@ -57,7 +57,7 @@
}
}

return consulWatcher.reconcile(ctx, s.ConsulResolvers, mappings)

Check failure on line 60 in cmd/entrypoint/consul.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use s.ConsulResolvers (variable of type []*v3alpha1.ConsulResolver) as []*v4alpha1.ConsulResolver value in argument to consulWatcher.reconcile
}

type consulWatcher struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/datawire/dlib/dgroup"
"github.com/datawire/dlib/dlog"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/consulwatch"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/endpoint_routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/emissary-ingress/emissary/v3/cmd/entrypoint"
"github.com/emissary-ingress/emissary/v3/pkg/ambex"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
"github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
v3bootstrap "github.com/envoyproxy/go-control-plane/envoy/config/bootstrap/v3"
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"strings"

"github.com/datawire/dlib/dlog"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
)
Expand Down Expand Up @@ -92,7 +92,7 @@
// interested in.
for _, m := range s.Modules {
if m.Spec.AmbassadorID.Matches(envAmbID) {
eri.checkModule(ctx, m, "CRD")

Check failure on line 95 in cmd/entrypoint/endpoints.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use m (variable of type *v3alpha1.Module) as *v4alpha1.Module value in argument to eri.checkModule
}
}

Expand Down Expand Up @@ -138,13 +138,13 @@

for _, m := range s.Mappings {
if m.Spec.AmbassadorID.Matches(envAmbID) {
eri.checkMapping(ctx, m, "CRD")

Check failure on line 141 in cmd/entrypoint/endpoints.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use m (variable of type *v3alpha1.Mapping) as *v4alpha1.Mapping value in argument to eri.checkMapping
}
}

for _, t := range s.TCPMappings {
if t.Spec.AmbassadorID.Matches(envAmbID) {
eri.checkTCPMapping(ctx, t, "CRD")

Check failure on line 147 in cmd/entrypoint/endpoints.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use t (variable of type *v3alpha1.TCPMapping) as *v4alpha1.TCPMapping value in argument to eri.checkTCPMapping
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/entrypoint/host_semantic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (
"github.com/stretchr/testify/require"

"github.com/emissary-ingress/emissary/v3/cmd/entrypoint"
"github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
"github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
bootstrap "github.com/envoyproxy/go-control-plane/envoy/config/bootstrap/v3"
)

func getExpected(expectedFile string, inputObjects []kates.Object) ([]RenderedListener, []v3alpha1.Mapping, []string, error) {
func getExpected(expectedFile string, inputObjects []kates.Object) ([]RenderedListener, []amb.Mapping, []string, error) {
// Figure out all the mappings and clusters we'll need.
neededClusters := []string{}
neededMappings := []v3alpha1.Mapping{}
neededMappings := []amb.Mapping{}

// Read the expected rendering from a file.
content, err := ioutil.ReadFile(expectedFile)
Expand All @@ -38,7 +38,7 @@ func getExpected(expectedFile string, inputObjects []kates.Object) ([]RenderedLi

for _, obj := range inputObjects {
// Skip things that aren't Mappings.
mapping, ok := obj.(*v3alpha1.Mapping)
mapping, ok := obj.(*amb.Mapping)

if !ok {
continue
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"github.com/datawire/dlib/derror"
"github.com/datawire/dlib/dlog"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
"github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
Expand Down Expand Up @@ -203,7 +203,7 @@
for _, h := range sh.k8sSnapshot.Hosts {
var id amb.AmbassadorID
if len(h.Spec.AmbassadorID) > 0 {
id = h.Spec.AmbassadorID

Check failure on line 206 in cmd/entrypoint/secrets.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use h.Spec.AmbassadorID (variable of type v3alpha1.AmbassadorID) as v4alpha1.AmbassadorID value in assignment
}
if id.Matches(envAmbID) {
resources = append(resources, h)
Expand Down
2 changes: 1 addition & 1 deletion cmd/entrypoint/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/datawire/dlib/dlog"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v3alpha1"
amb "github.com/emissary-ingress/emissary/v3/pkg/api/emissary-ingress.dev/v4alpha1"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
snapshotTypes "github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
)
Expand Down
39 changes: 19 additions & 20 deletions cmd/entrypoint/testdata/Collision1.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# @TEMPLATE@
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: Host
metadata:
name: staging.upchieve.org
namespace: default
spec:
hostname: staging.upchieve.org
acmeProvider:
authority: none
email: [email protected]
hostname: staging.upchieve.org
requestPolicy:
insecure:
action: Route
Expand All @@ -19,66 +18,66 @@ spec:
# metadata:
# name: staging
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: KubernetesEndpointResolver
metadata:
labels:
app.kubernetes.io/managed-by: pulumi
name: endpoint
namespace: ambassador
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: Mapping
metadata:
name: subway-staging-socket-stable-mapping
namespace: staging
spec:
allow_upgrade:
allowUpgrade:
- websocket
host: staging.upchieve.org
load_balancer:
loadBalancer:
policy: ring_hash
source_ip: true
sourceIP: true
prefix: /
query_parameters:
transport: true
queryParameters:
transport: "true"
resolver: endpoint
service: subway-staging-stable.staging:3001
timeout_ms: 500000
timeoutMS: 500000
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: Mapping
metadata:
name: subway-staging-whiteboard-reset-stable-mapping
namespace: staging
spec:
host: staging.upchieve.org
load_balancer:
loadBalancer:
policy: ring_hash
source_ip: true
sourceIP: true
prefix: /whiteboard/reset/
resolver: endpoint
rewrite: /whiteboard/reset/
service: subway-staging-stable.staging:3000
timeout_ms: 500000
timeoutMS: 500000
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: Mapping
metadata:
name: subway-staging-whiteboard-stable-mapping
namespace: staging
spec:
allow_upgrade:
allowUpgrade:
- websocket
host: staging.upchieve.org
load_balancer:
loadBalancer:
policy: ring_hash
source_ip: true
sourceIP: true
prefix: /whiteboard/
resolver: endpoint
rewrite: /whiteboard/
service: subway-staging-stable.staging:3000
timeout_ms: 500000
timeoutMS: 500000
---
apiVersion: v1
kind: Service
Expand Down
120 changes: 120 additions & 0 deletions cmd/entrypoint/testdata/Collision1_v3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# @TEMPLATE@
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
name: staging.upchieve.org
namespace: default
spec:
hostname: staging.upchieve.org
acmeProvider:
authority: none
email: [email protected]
requestPolicy:
insecure:
action: Route
# ---
# apiVersion: v1
# kind: Namespace
# metadata:
# name: staging
---
apiVersion: getambassador.io/v3alpha1
kind: KubernetesEndpointResolver
metadata:
labels:
app.kubernetes.io/managed-by: pulumi
name: endpoint
namespace: ambassador
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: subway-staging-socket-stable-mapping
namespace: staging
spec:
allow_upgrade:
- websocket
host: staging.upchieve.org
load_balancer:
policy: ring_hash
source_ip: true
prefix: /
query_parameters:
transport: "true"
resolver: endpoint
service: subway-staging-stable.staging:3001
timeout_ms: 500000
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: subway-staging-whiteboard-reset-stable-mapping
namespace: staging
spec:
host: staging.upchieve.org
load_balancer:
policy: ring_hash
source_ip: true
prefix: /whiteboard/reset/
resolver: endpoint
rewrite: /whiteboard/reset/
service: subway-staging-stable.staging:3000
timeout_ms: 500000
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: subway-staging-whiteboard-stable-mapping
namespace: staging
spec:
allow_upgrade:
- websocket
host: staging.upchieve.org
load_balancer:
policy: ring_hash
source_ip: true
prefix: /whiteboard/
resolver: endpoint
rewrite: /whiteboard/
service: subway-staging-stable.staging:3000
timeout_ms: 500000
---
apiVersion: v1
kind: Service
metadata:
name: subway-staging-stable
namespace: staging
spec:
selector:
app: echo
ports:
- name: http
port: 3000
protocol: TCP
targetPort: 3000
sessionAffinity: ClientIP
type: ClusterIP
# ---
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: echo
# namespace: staging
# spec:
# replicas: 1
# selector:
# matchLabels:
# app: echo
# template:
# metadata:
# labels:
# app: echo
# spec:
# containers:
# - name: churn
# # image: {{image "echo/Dockerfile"}}
# image: churn:0.0.1
# command: ["echo-server"]
# ports:
# - containerPort: 3000
6 changes: 3 additions & 3 deletions cmd/entrypoint/testdata/Collision2.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
apiVersion: getambassador.io/v3alpha1
apiVersion: emissary-ingress.dev/v4alpha1
kind: Mapping
metadata:
name: subway-staging-stable-mapping
namespace: staging
spec:
host: staging.upchieve.org
load_balancer:
loadBalancer:
policy: least_request
prefix: /
resolver: endpoint
service: subway-staging-stable.staging:3000
timeout_ms: 500000
timeoutMS: 500000
14 changes: 14 additions & 0 deletions cmd/entrypoint/testdata/Collision2_v3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: subway-staging-stable-mapping
namespace: staging
spec:
host: staging.upchieve.org
load_balancer:
policy: least_request
prefix: /
resolver: endpoint
service: subway-staging-stable.staging:3000
timeout_ms: 500000
Loading
Loading