8
8
"github.com/hashicorp/hcl/v2/hclsyntax"
9
9
"github.com/hashicorp/hcl/v2/hclwrite"
10
10
"github.com/postmanlabs/postman-insights-agent/cfg"
11
+ "github.com/postmanlabs/postman-insights-agent/cmd/internal/apidump"
11
12
"github.com/postmanlabs/postman-insights-agent/cmd/internal/cmderr"
12
13
"github.com/postmanlabs/postman-insights-agent/rest"
13
14
"github.com/spf13/cobra"
@@ -16,6 +17,11 @@ import (
16
17
"sigs.k8s.io/yaml"
17
18
)
18
19
20
+ var (
21
+ printHelmApidumpFlags * apidump.CommonApidumpFlags
22
+ printTFApidumpFlags * apidump.CommonApidumpFlags
23
+ )
24
+
19
25
var printHelmChartFragmentCmd = & cobra.Command {
20
26
Use : "helm-fragment" ,
21
27
Short : "Print a Helm chart container definition for adding the Postman Insights Agent to existing kubernetes deployment." ,
@@ -38,8 +44,9 @@ func printHelmChartFragment(_ *cobra.Command, _ []string) error {
38
44
return err
39
45
}
40
46
47
+ apidumpArgs := apidump .ConvertCommonApiDumpFlagsToArgs (printHelmApidumpFlags )
41
48
// Create the Postman Insights Agent sidecar container
42
- container := createPostmanSidecar (insightsProjectID , false )
49
+ container := createPostmanSidecar (insightsProjectID , false , apidumpArgs )
43
50
// Store it in an array since the fragment will be added to a list of containers
44
51
containerArray := []v1.Container {container }
45
52
@@ -91,17 +98,21 @@ func createTerraformContainer(insightsProjectID string) *hclwrite.File {
91
98
cty .StringVal ("NET_RAW" ),
92
99
}))
93
100
94
- // Add the args to the container
95
- args := cty .ListVal ([]cty.Value {
101
+ argList := []cty.Value {
96
102
cty .StringVal ("apidump" ),
97
103
cty .StringVal ("--project" ),
98
104
cty .StringVal (insightsProjectID ),
99
- })
105
+ }
100
106
// If a non default --domain flag was used, specify it for the container as well.
101
107
if rest .Domain != rest .DefaultDomain () {
102
- args .Add (cty .StringVal ("--domain" ))
103
- args .Add (cty .StringVal (rest .Domain ))
108
+ argList = append (argList , cty .StringVal ("--domain" ), cty .StringVal (rest .Domain ))
109
+ }
110
+ apidumpArgs := apidump .ConvertCommonApiDumpFlagsToArgs (printTFApidumpFlags )
111
+ for _ , arg := range apidumpArgs {
112
+ argList = append (argList , cty .StringVal (arg ))
104
113
}
114
+ // Add the args to the container
115
+ args := cty .ListVal (argList )
105
116
containerBody .SetAttributeValue ("args" , args )
106
117
107
118
// Add the environment variables to the container
@@ -133,6 +144,9 @@ func indentCodeFragment(codeFragmentInBytes []byte, indentLevel int) string {
133
144
}
134
145
135
146
func init () {
147
+ printHelmApidumpFlags = apidump .AddCommonApiDumpFlags (printHelmChartFragmentCmd )
136
148
Cmd .AddCommand (printHelmChartFragmentCmd )
149
+
150
+ printTFApidumpFlags = apidump .AddCommonApiDumpFlags (printTerraformFragmentCmd )
137
151
Cmd .AddCommand (printTerraformFragmentCmd )
138
152
}
0 commit comments