Skip to content

Commit 0adb7c1

Browse files
committed
Add JSON encoding to server package
Add JSON encoding of cri runtime configuration options to the server package. Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
1 parent 98a3338 commit 0adb7c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/cri/server/helpers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package server
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"fmt"
2223
"path"
2324
"path/filepath"
@@ -348,6 +349,16 @@ func generateRuntimeOptions(r criconfig.Runtime) (interface{}, error) {
348349
// For generic configuration, if no config path specified (preserving old behavior), pass
349350
// the whole TOML configuration section to the runtime.
350351
if runtimeOpts, ok := options.(*runtimeoptions.Options); ok && runtimeOpts.ConfigPath == "" {
352+
353+
if runtimeOpts.TypeUrl != "" {
354+
body, err := json.Marshal(r.Options)
355+
if err != nil {
356+
return nil, fmt.Errorf("failed to marshal config body as JSON for runtime %q: %v", r.Type, err)
357+
}
358+
runtimeOpts.ConfigBody = body
359+
return options, nil
360+
}
361+
351362
runtimeOpts.ConfigBody, err = optionsTree.Marshal()
352363
if err != nil {
353364
return nil, fmt.Errorf("failed to marshal TOML blob for runtime %q: %v", r.Type, err)

0 commit comments

Comments
 (0)