Skip to content

Commit 353766e

Browse files
authored
Add stubs for compiling without wasmtime / without cgo (#3664)
This allows us to compile kpt without cgo support; wasm support is in alpha and we have to opt in to wasm support and the wasmtime runner anyway. We can likely add an exec-based runner here instead in future (though we already have the nodejs one).
1 parent 4fe5d7f commit 353766e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

internal/fnruntime/wasmtime.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build cgo
2+
// +build cgo
3+
14
// Copyright 2022 Google LLC
25
//
36
// Licensed under the Apache License, Version 2.0 (the "License");
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//go:build !cgo
2+
// +build !cgo
3+
4+
// Copyright 2022 Google LLC
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
package fnruntime
19+
20+
// Stub functions for running without wasmtime support compiled in.
21+
// wasmtime requires cgo, which is not always a viable option.
22+
23+
import (
24+
"fmt"
25+
"io"
26+
)
27+
28+
type WasmtimeFn struct {
29+
}
30+
31+
func NewWasmtimeFn(loader WasmLoader) (*WasmtimeFn, error) {
32+
return nil, fmt.Errorf("wasmtime support is not compiled into binary (check cgo settings)")
33+
}
34+
35+
func (f *WasmtimeFn) Run(r io.Reader, w io.Writer) error {
36+
return fmt.Errorf("wasmtime support is not compiled into binary (check cgo settings)")
37+
}

0 commit comments

Comments
 (0)