Get rid of statik and fix failing tests

This commit is contained in:
Katrina Verey
2022-11-23 20:34:38 -05:00
parent e5ab220821
commit 7f9f6140ff
8 changed files with 34 additions and 58 deletions

View File

@@ -6,17 +6,18 @@ package krmfunction
import (
"bufio"
"bytes"
"embed"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"github.com/rakyll/statik/fs"
// load embedded func wrapper
_ "sigs.k8s.io/kustomize/cmd/pluginator/v2/internal/krmfunction/funcwrapper"
)
//go:embed funcwrappersrc/go.mod.src
//go:embed funcwrappersrc/main.go
var fs embed.FS
// Converter is a converter to convert the
// plugin file to KRM function
type Converter struct {
@@ -122,11 +123,7 @@ func (c *Converter) prepareWrapper(content string) string {
// readEmbeddedFile read the file from embedded files with filename
// name. Return the file content if it's successful.
func (c *Converter) readEmbeddedFile(name string) (string, error) {
statikFS, err := fs.New()
if err != nil {
return "", err
}
r, err := statikFS.Open("/" + name)
r, err := fs.Open("funcwrappersrc/" + name)
if err != nil {
return "", err
}