Skip to content

Commit f776561

Browse files
committed
runtime: base64 code
1 parent 76bc53e commit f776561

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/task/kubernetes.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ package task
77
import (
88
"bytes"
99
"context"
10+
"fmt"
1011
"net/http"
1112
"os"
12-
"path/filepath"
1313
"time"
1414

1515
"github.com/pkg/errors"
1616
uuid "github.com/satori/go.uuid"
17+
"github.com/wuhan005/gadget"
1718
v1 "k8s.io/api/core/v1"
1819
"k8s.io/apimachinery/pkg/api/resource"
1920
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -137,8 +138,9 @@ func (t *KubernetesTask) Run(ctx context.Context) ([]*CommandOutput, error) {
137138
}
138139

139140
// Write the code to the container.
140-
filePath := filepath.Join("/code/" + "code" + t.runner.Ext)
141-
cmd := []string{"sh", "-c", "echo '" + string(t.code) + "' > " + filePath}
141+
filePath := "code" + t.runner.Ext
142+
base64Code := gadget.Base64Encode(string(t.code))
143+
cmd := []string{"sh", "-c", fmt.Sprintf("echo '%s' | base64 -d > %s", base64Code, filePath)}
142144
_, err = t.exec(ctx, name, namespace, cmd)
143145
if err != nil {
144146
return nil, errors.Wrap(err, "exec: write code file")

0 commit comments

Comments
 (0)