@@ -139,15 +139,14 @@ func ResolveConventions() reconcilers.SubReconciler {
139
139
convention .ClientConfig = * clientConfig
140
140
} else if source .Spec .Ytt != nil {
141
141
log .Info ("handling a ytt based convention" )
142
-
143
- // read template spec and convert to string
144
-
145
142
log .Info ("retrieved pod template spec from the workload" , parent )
146
- stampedObj , err := ApplyYtt (ctx , * parent )
147
- if err != nil {
148
- return nil
149
- }
150
- log .Info ("stamped out object" , stampedObj )
143
+
144
+ // stampedObj, err := ApplyYtt(ctx, *parent)
145
+ // if err != nil {
146
+ // return nil
147
+ // }
148
+ // log.Info("stamped out object", stampedObj)
149
+ ExecCall ()
151
150
}
152
151
conventions = append (conventions , convention )
153
152
}
@@ -165,23 +164,56 @@ func ResolveConventions() reconcilers.SubReconciler {
165
164
}
166
165
}
167
166
167
+ func ExecCall () {
168
+ app := "echo"
169
+
170
+ arg0 := "-e"
171
+ arg1 := "Hello world"
172
+ arg2 := "\n \t from"
173
+ arg3 := "golang"
174
+
175
+ cmd := exec .Command (app , arg0 , arg1 , arg2 , arg3 )
176
+ stdout , err := cmd .Output ()
177
+
178
+ if err != nil {
179
+ fmt .Println (err .Error ())
180
+ return
181
+ }
182
+ fmt .Println (string (stdout ))
183
+
184
+ }
185
+
168
186
func ApplyYtt (ctx context.Context , workload conventionsv1alpha1.PodIntent ) (interface {}, error ) {
187
+ // read template spec from the workload
169
188
template := workload .Spec .Template .AsPodTemplateSpec ()
170
189
log := logr .FromContextOrDiscard (ctx )
171
190
191
+ // set timeout to about 4 secs to process the ytt template
172
192
ctx , cancel := context .WithTimeout (ctx , 4 * time .Second )
173
193
defer cancel ()
174
194
195
+ // setup ytt path
175
196
ytt := "ytt"
176
197
if kodata , ok := os .LookupEnv ("KO_DATA_PATH" ); ok {
177
198
ytt = path .Join (kodata , fmt .Sprintf ("ytt-%s-%s" , runtime .GOOS , runtime .GOARCH ))
178
199
}
179
200
201
+ // toolsBinDir := filepath.Join(projectRootDir, constants.ToolsBinDirPath)
202
+ // ytt_command := exec.Command(
203
+ // filepath.Join(toolsBinDir, "ytt"),
204
+ // "-f-",
205
+ // "-f", packageHelpersLibFile,
206
+ // "-f", packageValuesFile,
207
+ // "-v", "packageRepository="+packageRepository,
208
+ // "-v", "registry="+registry,
209
+ // ) //
210
+
180
211
args := []string {"--version" }
181
212
stdin := bytes .NewReader ([]byte (template .Spec .String ()))
182
213
stdout := bytes .NewBuffer ([]byte {})
183
214
stderr := bytes .NewBuffer ([]byte {})
184
215
216
+ // setup exec call
185
217
cmd := exec .CommandContext (ctx , ytt , args ... )
186
218
cmd .Stdin = stdin
187
219
cmd .Stdout = stdout
@@ -190,6 +222,7 @@ func ApplyYtt(ctx context.Context, workload conventionsv1alpha1.PodIntent) (inte
190
222
log .Info ("ytt call args" , args )
191
223
log .Info ("ytt call input" , template )
192
224
225
+ // invoke run call
193
226
if err := cmd .Run (); err != nil {
194
227
msg := stderr .String ()
195
228
if msg == "" {
0 commit comments