feat: import prepared Catalog bindings through authenticated services
This commit is contained in:
@@ -40,7 +40,7 @@ func fixture(t *testing.T) (string, preflight.Plan) {
|
||||
b, _ := os.ReadFile(p)
|
||||
write(p, strings.ReplaceAll(string(b), "https://CHANGE_ME/workspaces.git", "https://example.com/workspaces.git"))
|
||||
}
|
||||
for name, value := range map[string]string{"secrets.env": "OPENAI_API_KEY=PRIVATE_SENTINEL\n", "git-credentials": "", "git-ca.pem": "", "database-password": "PRIVATE_SENTINEL"} {
|
||||
for name, value := range map[string]string{"secrets.env": "OPENAI_API_KEY=PRIVATE_SENTINEL\n", "git-credentials": "", "git-ca.pem": "", "database-password": "PRIVATE_SENTINEL\n"} {
|
||||
write(filepath.Join(dir, "secrets", name), value)
|
||||
}
|
||||
installation, err := config.LoadPrepared(filepath.Join(dir, "thothii-installation.yaml"))
|
||||
@@ -66,7 +66,11 @@ func fixture(t *testing.T) (string, preflight.Plan) {
|
||||
b, _ := json.Marshal(m)
|
||||
write(manifest, string(b))
|
||||
inputs = append(inputs, manifest)
|
||||
p := preflight.Plan{SchemaVersion: 1, ValidatorProtocol: 1, Installation: installation, Release: m, ManifestPath: manifest, BootstrapPath: filepath.Join(dir, "database-bootstrap.yaml"), Platform: "linux/amd64", Inputs: inputs, AbsentInputs: preflight.AbsentOverrides(installation), Report: preflight.NewReport()}
|
||||
workspace := filepath.Join(root, "workspaces")
|
||||
_ = os.Mkdir(workspace, 0o700)
|
||||
write(filepath.Join(workspace, "thoth-workspaces.yaml"), "schema_version: 1\nworkspaces: []\n")
|
||||
inputs = append(inputs, filepath.Join(workspace, "thoth-workspaces.yaml"), filepath.Join(dir, "secrets/admin-password"), filepath.Join(dir, "secrets/database-password"), filepath.Join(dir, "database-bootstrap.yaml"))
|
||||
p := preflight.Plan{SchemaVersion: 1, ValidatorProtocol: 1, Installation: installation, Release: m, ManifestPath: manifest, BootstrapPath: filepath.Join(dir, "database-bootstrap.yaml"), WorkspaceDirectory: workspace, WorkspaceRevision: "content-snapshot", Platform: "linux/amd64", Inputs: inputs, AbsentInputs: preflight.AbsentOverrides(installation), Report: preflight.NewReport()}
|
||||
path := filepath.Join(dir, "plan.json")
|
||||
if err := preflight.WritePlan(path, &p); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -82,7 +86,22 @@ type dockerFixture struct {
|
||||
|
||||
func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (compose.Result, error) {
|
||||
if input != nil {
|
||||
return compose.Result{}, fmt.Errorf("unexpected interactive input")
|
||||
if args[len(args)-1] != bindingClient {
|
||||
return compose.Result{}, fmt.Errorf("unexpected interactive input")
|
||||
}
|
||||
command := strings.Join(args, " ")
|
||||
if !strings.Contains(command, " run --rm -T --no-deps --pull never --name ") || !strings.Contains(command, " --entrypoint node core ") {
|
||||
return compose.Result{}, fmt.Errorf("import must use a named one-shot for cancellation cleanup")
|
||||
}
|
||||
data, err := io.ReadAll(input)
|
||||
if err != nil || !strings.Contains(string(data), "PRIVATE_SENTINEL") || strings.Contains(strings.Join(args, " "), "PRIVATE_SENTINEL") {
|
||||
return compose.Result{}, fmt.Errorf("invalid protected pipe")
|
||||
}
|
||||
if strings.Contains(string(data), `PRIVATE_SENTINEL\n`) {
|
||||
return compose.Result{}, fmt.Errorf("file newline leaked into scalar credential")
|
||||
}
|
||||
r.calls = append(r.calls, append([]string{}, args...))
|
||||
return compose.Result{Stdout: `{"ok":true,"code":"bindings_ready","completed":1}`}, nil
|
||||
}
|
||||
r.calls = append(r.calls, append([]string{}, args...))
|
||||
line := strings.Join(args, " ")
|
||||
|
||||
Reference in New Issue
Block a user