-
Notifications
You must be signed in to change notification settings - Fork 444
/
generate.go
58 lines (49 loc) · 2.53 KB
/
generate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"log"
"path/filepath"
"github.com/solo-io/gloo/projects/gloo/pkg/defaults"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/istio"
"github.com/solo-io/gloo/test/kubernetes/testutils/resources"
"github.com/solo-io/skv2/codegen/util"
)
const (
// exampleNs is the namespace where the resources will be created. Change this to the namespace where you want to create the resources
exampleNs = defaults.GlooSystem
)
// Dev tool to generate the manifest files for the test suite for demo and docs purposes
//
//go:generate go run ./generate.go
func main() {
log.Println("starting generate for istio examples")
// use the Gloo Edge Gateway api resources with automtls enabled
edgeGatewayApiResources := istio.GetGlooGatewayEdgeResources(exampleNs, istio.UpstreamConfigOpts{})
automtlsGeneratedExample := filepath.Join(util.MustGetThisDir(), "generated_example", fmt.Sprintf("automtls-enabled-%s.gen.yaml", istio.EdgeApisRoutingFileName))
err := resources.WriteResourcesToFile(edgeGatewayApiResources, automtlsGeneratedExample)
if err != nil {
panic(err)
}
// automtls disabled
edgeGatewayApiResources = istio.GetGlooGatewayEdgeResources(exampleNs, istio.UpstreamConfigOpts{DisableIstioAutoMtls: true})
disableAutomtlsGeneratedExample := filepath.Join(util.MustGetThisDir(), "generated_example", fmt.Sprintf("automtls-disabled-%s.gen.yaml", istio.EdgeApisRoutingFileName))
err = resources.WriteResourcesToFile(edgeGatewayApiResources, disableAutomtlsGeneratedExample)
if err != nil {
panic(err)
}
// Upstream sslConfig is set
edgeGatewayApiResources = istio.GetGlooGatewayEdgeResources(exampleNs, istio.UpstreamConfigOpts{SetSslConfig: true})
upstreamSslConfigGeneratedExample := filepath.Join(util.MustGetThisDir(), "generated_example", fmt.Sprintf("sslconfig-%s.gen.yaml", istio.EdgeApisRoutingFileName))
err = resources.WriteResourcesToFile(edgeGatewayApiResources, upstreamSslConfigGeneratedExample)
if err != nil {
panic(err)
}
// Upstream sslConfig is set and automtls is disabled
edgeGatewayApiResources = istio.GetGlooGatewayEdgeResources(exampleNs, istio.UpstreamConfigOpts{SetSslConfig: true, DisableIstioAutoMtls: true})
sslConfigAndDisableAutomtlsGeneratedExample := filepath.Join(util.MustGetThisDir(), "generated_example", fmt.Sprintf("sslconfig-and-automtls-disabled-%s.gen.yaml", istio.EdgeApisRoutingFileName))
err = resources.WriteResourcesToFile(edgeGatewayApiResources, sslConfigAndDisableAutomtlsGeneratedExample)
if err != nil {
panic(err)
}
log.Println("finished generate for istio examples")
}