Skip to content

Commit

Permalink
Backfill unit tests for peering dialler (#1265)
Browse files Browse the repository at this point in the history
- Clean up some of the logic in peering dialler and acceptor
- Rename handler -> connectWebhook
  • Loading branch information
Ashwin Venkatesh authored and ndhanushkodi committed Jun 15, 2022
1 parent dae0fd3 commit f32764b
Show file tree
Hide file tree
Showing 25 changed files with 1,223 additions and 515 deletions.
6 changes: 3 additions & 3 deletions charts/consul/templates/crd-peeringacceptors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ spec:
key:
description: Key is the key of the secret generated.
type: string
latestHash:
description: ResourceVersion is the resource version for the secret.
type: string
name:
description: Name is the name of the secret generated.
type: string
resourceVersion:
description: ResourceVersion is the resource version for the secret.
type: string
type: object
type: object
type: object
Expand Down
6 changes: 3 additions & 3 deletions charts/consul/templates/crd-peeringdialers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ spec:
key:
description: Key is the key of the secret generated.
type: string
latestHash:
description: ResourceVersion is the resource version for the secret.
type: string
name:
description: Name is the name of the secret generated.
type: string
resourceVersion:
description: ResourceVersion is the resource version for the secret.
type: string
type: object
type: object
type: object
Expand Down
17 changes: 10 additions & 7 deletions control-plane/api/v1alpha1/peeringacceptor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ type ReconcileErrorStatus struct {
}

type SecretRefStatus struct {
// Name is the name of the secret generated.
Name string `json:"name,omitempty"`
// Key is the key of the secret generated.
Key string `json:"key,omitempty"`
// Backend is where the generated secret is stored. Currently supports the value: "kubernetes".
Backend string `json:"backend,omitempty"`
Secret `json:",inline"`
// ResourceVersion is the resource version for the secret.
ResourceVersion string `json:"latestHash,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
}

func (pa *PeeringAcceptor) Secret() *Secret {
return pa.Spec.Peer.Secret
}

func (pa *PeeringAcceptor) SecretRef() *SecretRefStatus {
return pa.Status.SecretRef
}
11 changes: 11 additions & 0 deletions control-plane/api/v1alpha1/peeringdialer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ type PeeringDialerStatus struct {
// +optional
SecretRef *SecretRefStatus `json:"secret,omitempty"`
}

func (pd *PeeringDialer) Secret() *Secret {
if pd.Spec.Peer == nil {
return nil
}
return pd.Spec.Peer.Secret
}

func (pd *PeeringDialer) SecretRef() *SecretRefStatus {
return pd.Status.SecretRef
}
1 change: 1 addition & 0 deletions control-plane/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ spec:
key:
description: Key is the key of the secret generated.
type: string
latestHash:
description: ResourceVersion is the resource version for the secret.
type: string
name:
description: Name is the name of the secret generated.
type: string
resourceVersion:
description: ResourceVersion is the resource version for the secret.
type: string
type: object
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ spec:
key:
description: Key is the key of the secret generated.
type: string
latestHash:
description: ResourceVersion is the resource version for the secret.
type: string
name:
description: Name is the name of the secret generated.
type: string
resourceVersion:
description: ResourceVersion is the resource version for the secret.
type: string
type: object
type: object
type: object
Expand Down
Loading

0 comments on commit f32764b

Please sign in to comment.