Skip to content

Commit 6976236

Browse files
committed
impr(cm/k8s/emp): support printable
1 parent 6d7ce1c commit 6976236

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

chall-manager/k8s.EMP/config/config.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package config
22

33
import (
44
"github.com/ctfer-io/recipes/chall-manager/common"
5+
6+
k8s "github.com/ctfer-io/chall-manager/sdk/kubernetes"
57
)
68

79
type Config struct {
@@ -22,7 +24,7 @@ type Config struct {
2224
type ContainerArgs struct {
2325
Image string `form:"image" json:"image"`
2426
Ports []common.PortArgs `form:"ports" json:"ports"`
25-
Envs map[string]common.Variable `form:"envs" json:"envs"`
27+
Envs map[string]Printable `form:"envs" json:"envs"`
2628
Files map[string]common.Variable `form:"files" json:"files"`
2729
Requests map[string]string `form:"requests" json:"requests"`
2830
Limits map[string]string `form:"limits" json:"limits"`
@@ -34,3 +36,17 @@ type RuleArgs struct {
3436
On int `form:"on" json:"on"`
3537
Protocol string `form:"protocol" json:"protocol"`
3638
}
39+
40+
type Printable struct {
41+
Variable common.Variable `form:"variable" json:"variable"`
42+
43+
Format string `form:"format" json:"format"`
44+
Serivces []string `form:"services" json:"services"`
45+
}
46+
47+
func (pr Printable) ToPrinter(seed string) k8s.PrinterArgs {
48+
if pr.Variable.Content != "" {
49+
return k8s.NewPrinter(pr.Variable.Produce(seed))
50+
}
51+
return k8s.NewPrinter(pr.Format, pr.Serivces...)
52+
}

chall-manager/k8s.EMP/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func main() {
5454
Envs: func() k8s.PrinterMap {
5555
out := map[string]k8s.PrinterInput{}
5656
for k, v := range args.Envs {
57-
out[k] = k8s.NewPrinter(v.Produce(req.Identity))
57+
out[k] = v.ToPrinter(req.Identity)
5858
}
5959
return out
6060
}(),

0 commit comments

Comments
 (0)