Skip to content

bloblang: hostname() errors without Benthos #1291

Open
@billgraziano

Description

@billgraziano

I'm looking at using bloblang in another app. The only issue I've found so far is that hostname doesn't seem to work.

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/benthosdev/benthos/v4/public/bloblang"
)

func main() {
	mapping := `
		root.host = hostname()
		root.ksuid = ksuid()
	`
	exe, err := bloblang.Parse(mapping)
	if err != nil {
		log.Fatal(err)
	}
	src := "{}"
	var object interface{}
	err = json.Unmarshal([]byte(src), &object)
	if err != nil {
		log.Fatal(err)
	}
	res, err := exe.Query(object)
	if err != nil {
		log.Fatal(err)
	}
	jsonBytes, err := json.MarshalIndent(res, "", "  ")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(jsonBytes))
}

The output is below. If you comment out hostname, then ksuid works just fine.

2022/06/14 08:56:46 unrecognised function 'hostname': hostn
exit status 1

Bloblang is fantastic! This is a great little scripting tool and works really well for what you're doing -- and hopefully what I'm doing. My only other concern is that it pulls A LOT of dependencies into my application when I include it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions