-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/envoy: switch to Cluster.TransportSocket for upstream TLS
Updates #1351 Envoy 1.12 has deprecated the Cluster.TLSContext field, instead the UpstreamTLSContext must be provided via a typed config attached to a TransportSocket. ref: https://www.envoyproxy.io/docs/envoy/v1.12.0/api-v2/api/v2/cds.proto#envoy-api-field-cluster-tls-context Signed-off-by: Dave Cheney <dave@cheney.net>
- Loading branch information
1 parent
6f5c618
commit 147edfa
Showing
8 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright © 2019 VMware | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package envoy | ||
|
||
import ( | ||
envoy_api_v2_auth "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth" | ||
envoy_api_v2_core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" | ||
) | ||
|
||
// UpstreamTLSTransportSocket returns a custom transport socket using the UpstreamTlsContext provided. | ||
func UpstreamTLSTransportSocket(tls *envoy_api_v2_auth.UpstreamTlsContext) *envoy_api_v2_core.TransportSocket { | ||
return &envoy_api_v2_core.TransportSocket{ | ||
Name: "tls", | ||
ConfigType: &envoy_api_v2_core.TransportSocket_TypedConfig{ | ||
TypedConfig: toAny(tls), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright © 2019 VMware | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package envoy | ||
|
||
import ( | ||
"testing" | ||
|
||
envoy_api_v2_auth "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth" | ||
envoy_api_v2_core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" | ||
"github.com/projectcontour/contour/internal/assert" | ||
) | ||
|
||
func TestUpstreamTLSTransportSocket(t *testing.T) { | ||
tests := map[string]struct { | ||
ctxt *envoy_api_v2_auth.UpstreamTlsContext | ||
want *envoy_api_v2_core.TransportSocket | ||
}{ | ||
"h2": { | ||
ctxt: UpstreamTLSContext(nil, "", "h2"), | ||
want: &envoy_api_v2_core.TransportSocket{ | ||
Name: "tls", | ||
ConfigType: &envoy_api_v2_core.TransportSocket_TypedConfig{ | ||
TypedConfig: toAny(UpstreamTLSContext(nil, "", "h2")), | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for name, tc := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
got := UpstreamTLSTransportSocket(tc.ctxt) | ||
assert.Equal(t, tc.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters