@@ -67,7 +67,7 @@ func doServerSideApply(ctx context.Context, cfg *rest.Config, obj *unstructured.
67
67
return err
68
68
}
69
69
70
- func applyYaml (yamlFile []byte , config * rest.Config , disableTelemetry bool ) error {
70
+ func applyYaml (yamlFile []byte , config * rest.Config , disableTelemetry bool , disableStreaming bool ) error {
71
71
multidocReader := utilyaml .NewYAMLReader (bufio .NewReader (bytes .NewReader (yamlFile )))
72
72
73
73
for {
@@ -85,6 +85,7 @@ func applyYaml(yamlFile []byte, config *rest.Config, disableTelemetry bool) erro
85
85
return err
86
86
}
87
87
88
+ // Disable telemetry
88
89
if disableTelemetry && obj .GetKind () == "Deployment" && obj .GetName () == "cyclops-ctrl" {
89
90
containers , _ , _ := unstructured .NestedSlice (obj .Object , "spec" , "template" , "spec" , "containers" )
90
91
if len (containers ) > 0 {
@@ -108,6 +109,34 @@ func applyYaml(yamlFile []byte, config *rest.Config, disableTelemetry bool) erro
108
109
}
109
110
}
110
111
112
+ // Disable streaming resources
113
+ if disableStreaming && obj .GetKind () == "Deployment" && obj .GetName () == "cyclops-ui" {
114
+ containers , _ , _ := unstructured .NestedSlice (obj .Object , "spec" , "template" , "spec" , "containers" )
115
+ if len (containers ) > 0 {
116
+ container := containers [0 ].(map [string ]interface {})
117
+ env , _ , _ := unstructured .NestedSlice (container , "env" )
118
+
119
+ for i , e := range env {
120
+ soloEnvMap := e .(map [string ]interface {})
121
+ if soloEnvMap ["name" ] == "REACT_APP_ENABLE_STREAMING" {
122
+ soloEnvMap ["value" ] = "false"
123
+ env [i ] = soloEnvMap
124
+ break // update the value and break the loop
125
+ }
126
+ }
127
+ err := unstructured .SetNestedSlice (container , env , "env" )
128
+ if err != nil {
129
+ log .Fatal (err )
130
+ }
131
+ containers [0 ] = container
132
+ err = unstructured .SetNestedSlice (obj .Object , containers , "spec" , "template" , "spec" , "containers" )
133
+ if err != nil {
134
+ log .Fatal (err )
135
+ }
136
+ fmt .Println ("streaming resources are disabled" )
137
+ }
138
+ }
139
+
111
140
err = doServerSideApply (context .TODO (), config , obj )
112
141
if err != nil {
113
142
return err
@@ -131,6 +160,11 @@ var applyCmd = &cobra.Command{
131
160
log .Fatal (err )
132
161
}
133
162
163
+ disableStreaming , err := cmd .Flags ().GetBool ("disable-streaming" )
164
+ if err != nil {
165
+ log .Fatal (err )
166
+ }
167
+
134
168
var deployUrl string
135
169
var demoUrl string
136
170
@@ -159,7 +193,8 @@ var applyCmd = &cobra.Command{
159
193
160
194
fmt .Println ("initializing cyclops resources" )
161
195
162
- err = applyYaml (deployYamlFile , kubeconfig .Config , disableTelemetry )
196
+ // Apply cyclops resources with appropriate flags
197
+ err = applyYaml (deployYamlFile , kubeconfig .Config , disableTelemetry , disableStreaming )
163
198
if err != nil {
164
199
log .Fatal (err )
165
200
}
@@ -180,7 +215,7 @@ var applyCmd = &cobra.Command{
180
215
}
181
216
182
217
fmt .Println ("creating demo templates" )
183
- err = applyYaml (demoYamlFile , kubeconfig .Config , disableTelemetry )
218
+ err = applyYaml (demoYamlFile , kubeconfig .Config , disableTelemetry , disableStreaming )
184
219
if err != nil {
185
220
log .Fatal (err )
186
221
}
@@ -190,5 +225,7 @@ var applyCmd = &cobra.Command{
190
225
func init () {
191
226
applyCmd .Flags ().StringP ("version" , "v" , "main" , "specify cyclops version" )
192
227
applyCmd .Flags ().BoolP ("disable-telemetry" , "t" , false , "disable emitting telemetry metrics from cyclops controller" )
228
+ applyCmd .Flags ().BoolP ("disable-streaming" , "s" , false , "disable streaming resources from cyclops controller" )
229
+
193
230
RootCmd .AddCommand (applyCmd )
194
231
}
0 commit comments