<commit_before>package buildpacks

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"github.com/buildpacks/pack"
	"github.com/buildpacks/pack/logging"
	"io"
	"os"
)

type Builder struct {
	Verbose   bool
	registry  string
	namespace string
}

func NewBuilder(registry, namespace string) *Builder {
	return &Builder{registry: registry, namespace: namespace}
}

var lang2pack = map[string]string{
	"java": "quay.io/mvasek/faas-quarkus-builder",
	"js":   "quay.io/mvasek/faas-nodejs-builder",
}

func (builder *Builder) Build(name, language, path string) (image string, err error) {

	registry := fmt.Sprintf("%s/%s", builder.registry, builder.namespace)
	image = fmt.Sprintf("%s/%s", registry, name)
	packBuilder, ok := lang2pack[language]
	if !ok {
		err = errors.New(fmt.Sprint("unsupported language: ", language))
		return
	}

	var logWriter io.Writer
	if builder.Verbose {
		logWriter = os.Stdout
	} else {
		logWriter = &bytes.Buffer{}
	}

	logger := logging.New(logWriter)
	packClient, err := pack.NewClient(pack.WithLogger(logger))
	if err != nil {
		return
	}

	packOpts := pack.BuildOptions{
		AppPath:  path,
		Image:    image,
		Builder:  packBuilder,
		Registry: registry,
	}

	err = packClient.Build(context.Background(), packOpts)
	if err != nil {
		if !builder.Verbose {
			err = fmt.Errorf("%v\noutput: %s\n", err, logWriter.(*bytes.Buffer).String())
		}
	}

	return
}
<commit_msg>fix: buildpack image reference<commit_after>package buildpacks

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"github.com/buildpacks/pack"
	"github.com/buildpacks/pack/logging"
	"io"
	"os"
)

type Builder struct {
	Verbose   bool
	registry  string
	namespace string
}

func NewBuilder(registry, namespace string) *Builder {
	return &Builder{registry: registry, namespace: namespace}
}

var lang2pack = map[string]string{
	"java": "quay.io/boson/faas-quarkus-builder",
	"js":   "quay.io/boson/faas-nodejs-builder",
}

func (builder *Builder) Build(name, language, path string) (image string, err error) {

	registry := fmt.Sprintf("%s/%s", builder.registry, builder.namespace)
	image = fmt.Sprintf("%s/%s", registry, name)
	packBuilder, ok := lang2pack[language]
	if !ok {
		err = errors.New(fmt.Sprint("unsupported language: ", language))
		return
	}

	var logWriter io.Writer
	if builder.Verbose {
		logWriter = os.Stdout
	} else {
		logWriter = &bytes.Buffer{}
	}

	logger := logging.New(logWriter)
	packClient, err := pack.NewClient(pack.WithLogger(logger))
	if err != nil {
		return
	}

	packOpts := pack.BuildOptions{
		AppPath:  path,
		Image:    image,
		Builder:  packBuilder,
		Registry: registry,
	}

	err = packClient.Build(context.Background(), packOpts)
	if err != nil {
		if !builder.Verbose {
			err = fmt.Errorf("%v\noutput: %s\n", err, logWriter.(*bytes.Buffer).String())
		}
	}

	return
}

{'fraction_non_alphanumeric': 0.14744734023563014, 'fraction_numerical': 0.0014280614066404856, 'mean_word_length': 4.20817843866171, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1031794', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1009, 'n_words': 221}