profile
viewpoint
Mitchell Hashimoto mitchellh HashiCorp Los Angeles, CA http://mitchellh.com

hashicorp/vagrant 20652

Vagrant is a tool for building and distributing development environments.

hashicorp/packer 11269

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.

joefitzgerald/packer-windows 1549

Windows Packer Templates

mitchellh/cli 1190

A Go library for implementing command-line interfaces.

armon/bloomd 1165

C network daemon for bloom filters

armon/go-radix 585

Golang implementation of Radix trees

mitchellh/boot2docker-vagrant-box 425

Packer scripts to build a Vagrant-compatible boot2docker box.

hashicorp/hil 345

HIL is a small embedded language for string interpolations.

mitchellh/colorstring 248

Go (golang) library for colorizing strings for terminal output.

mitchellh/copystructure 203

Go (golang) library for deep copying values in Go.

delete branch mitchellh/go-glint

delete branch : f-input

delete time in 18 hours

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 7d256a0f0fd7c4369c4a457c5cd01c46d65ec2fb

word wrap text first before clamping

view details

push time in 18 hours

created tagmitchellh/go-wordwrap

tagv1.0.1

A Go (golang) library for wrapping words in a string.

created time in 18 hours

push eventmitchellh/go-wordwrap

David Tolnay

commit sha 271c4e5dd7f76e4cf97818a9bb970a5ff9a46784

Do not break on non-breaking space

view details

Mitchell Hashimoto

commit sha ecf0936a077a4bd73a1cc2ac5c370f2b55618d62

Merge pull request #3 from dtolnay/nbsp Do not break on non-breaking space

view details

push time in 20 hours

PR merged mitchellh/go-wordwrap

Do not break on non-breaking space
+9 -1

0 comment

2 changed files

dtolnay

pr closed time in 20 hours

issue closedmitchellh/go-wordwrap

no tests for special characters

I noticed that there are no tests for special characters, and that the source does convert the string into a rune slice.

closed time in 20 hours

ghostsquad

issue commentmitchellh/go-wordwrap

no tests for special characters

Tests added and bugs fixed: https://github.com/mitchellh/go-wordwrap/commit/a2d9f5454f274244a5c322543d3fa9827eb1d035

ghostsquad

comment created time in 20 hours

push eventmitchellh/go-wordwrap

Mitchell Hashimoto

commit sha 7256b9c0a84f21c609b5c38205e57f0cf4c3981b

update go.mod

view details

Mitchell Hashimoto

commit sha a2d9f5454f274244a5c322543d3fa9827eb1d035

Wrap multibyte characters properly

view details

push time in 20 hours

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha b2ab0b1e9ceb96da60858ddf61500ffb11d04956

Add panic case and fix off by one error for clamp text

view details

push time in a day

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha b2a6d8fe7459fb6dbcb1a892a7414675af70337b

update gookit/color

view details

push time in 3 days

created tagmitchellh/cli

tagv1.1.2

A Go library for implementing command-line interfaces.

created time in 3 days

push eventmitchellh/cli

Mitchell Hashimoto

commit sha 8c0c01154428e654cfad0336e01de9d24ea306c4

update Go versions

view details

push time in 3 days

push eventmitchellh/cli

Mitchell Hashimoto

commit sha cdadc45e2b8d317297eebc68ba7c4757bd2bc5ea

Make SubcommandName available in HelpTemplate, add Sprig funcs

view details

push time in 3 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha a2e71408be7d431e9f96449eb5f864374ba1a8cc

renderer/term: if everything finalized, need to draw a newline

view details

push time in 4 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 6a615e833dc756a20b826291a8260854a95eadcb

renderers can implement io.Closer, called during Document.Close

view details

push time in 5 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 80ac1ec0e92df504104c2f0032315ee5778005d5

renderer/term: clear previous height, not current

view details

push time in 5 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha b4613b4146bd69fa80561122f634476b390ba2f5

empty string text should take up 1 height

view details

push time in 5 days

push eventmitchellh/protoc-gen-go-json

Mitchell Hashimoto

commit sha 364b693410aec1ada41b9592fe26c48b20dfe3d7

Update nix package

view details

push time in 9 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 4e2f8479bc0ba8dc42ee33028d81e4ca10853eba

add Pause/Resume

view details

push time in 10 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha b7aa44c8b6221899bc186f59cb71565f4898dfc0

Mount/Unmount take a context

view details

Mitchell Hashimoto

commit sha 44c11ce9527cea48790fd082ffb884dcbe9f0140

initial input working

view details

Mitchell Hashimoto

commit sha 9e62463ef7ce26886f98eadab3a1b413dd1ee308

internal/input/terminal: fork this lib so we can set custom flags

view details

Mitchell Hashimoto

commit sha d46e11efb3d1c4d8801ec81f697b77d177322c7c

Close should be called to register all unmount calls

view details

Mitchell Hashimoto

commit sha 8516eaa7262a340a75891649218225c51c8e0107

some docs

view details

Mitchell Hashimoto

commit sha a2a6436c1ba5a16d3b9e5155c7d81ed5597831b0

internal/input: tweak raw mode so we output indentations correctly

view details

Mitchell Hashimoto

commit sha 5e6d5ca6746c63a7f3c729c77bc99f438ffcb14c

ignore children with a zero height

view details

Mitchell Hashimoto

commit sha c74571cec4866f135a09e69305edddc65881e802

undo all the input stuff for now I couldn't get this to work, its pretty complicated. I want to keep this in the Git history though in case I come back to that.

view details

push time in 10 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha c74571cec4866f135a09e69305edddc65881e802

undo all the input stuff for now I couldn't get this to work, its pretty complicated. I want to keep this in the Git history though in case I come back to that.

view details

push time in 10 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 8516eaa7262a340a75891649218225c51c8e0107

some docs

view details

Mitchell Hashimoto

commit sha a2a6436c1ba5a16d3b9e5155c7d81ed5597831b0

internal/input: tweak raw mode so we output indentations correctly

view details

Mitchell Hashimoto

commit sha 5e6d5ca6746c63a7f3c729c77bc99f438ffcb14c

ignore children with a zero height

view details

push time in 10 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 9e62463ef7ce26886f98eadab3a1b413dd1ee308

internal/input/terminal: fork this lib so we can set custom flags

view details

Mitchell Hashimoto

commit sha d46e11efb3d1c4d8801ec81f697b77d177322c7c

Close should be called to register all unmount calls

view details

push time in 10 days

create barnchmitchellh/go-glint

branch : f-input

created branch time in 11 days

delete branch mitchellh/go-glint

delete branch : mount

delete time in 12 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 7170628b202959185764be7e82ab4b7750f85358

Add Mount/Unmount callbacks

view details

Mitchell Hashimoto

commit sha 2fc749c3b0676ae2cf4e01fa39018b338876af1a

update README

view details

push time in 12 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 2fc749c3b0676ae2cf4e01fa39018b338876af1a

update README

view details

push time in 12 days

create barnchmitchellh/go-glint

branch : mount

created branch time in 12 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha a678c1e33096dda352472918d398864d2076bba3

update sparkline example

view details

push time in 17 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha ffd1db8f02261ede9729aa22517ac8b52c0efc19

remove comment about multi-byte chars cause its fixed!

view details

push time in 17 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 0eff0ecd1bc69b6ef969900dd476aad860f7f9f8

text measurement is done by rune, not byte

view details

push time in 17 days

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha 82696d64a187596b0552837228a8930eac8a3730

sparkline component

view details

push time in 17 days

PublicEvent

push eventmitchellh/go-glint

Mitchell Hashimoto

commit sha fccea6fed7fd59e0c4095c5f1ce50155a848beb8

change type signatures to for docs

view details

push time in 18 days

PullRequestReviewEvent

push eventmitchellh/protostructure

Mitchell Hashimoto

commit sha 3cfccdb015ce0b45045430f263a85a018abd7475

test string slices Trying to chase down a bug somewhere else and thought this might be it but this is fine.

view details

push time in a month

issue commenthashicorp/go-plugin

Use grpc for the handshake protocol

If it goes to stderr then the host system will log it, so that is the recommended place for logs! Otherwise yes a file. Or sometimes what we do is launch our plugins with extra file descriptors to get access to the original TTY too.

entropitor

comment created time in 2 months

issue commenthashicorp/go-plugin

Use grpc for the handshake protocol

These are good things to update the doc with but to answer your questions:

What is unclear to me about that wiki page is, should the handshake line be the first line on the stdout, the only line on stdout or can it be any line on stdout (and go-plugin will pick the first one that matches)?

First line, preferably only but I think any later lines are presently ignored.

The expectation is that the plugin process takes over stdout/stderr immediately on startup. That is what the Go plugin framework does, it expects you to call plugin.Serve (or something like that) immediately on main which overrides os.Stdout so any loggers or whatever don't write to it.

(I was thinking an adapter application could do the translating between V1 and V2 and thus making it quite robust and backwards-compatible, outside of go-plugin, the applications or any of the SDKs)

Yeah its certainly possible no doubt. Its just one of those things that if the old way has to be maintained indefinitely, it feels a bit painful to introduce a second way. You went from one problem to two!

entropitor

comment created time in 2 months

created tagmitchellh/mapstructure

tagv1.3.3

Go library for decoding generic map values into native Go structures and vice versa.

created time in 2 months

push eventmitchellh/mapstructure

Mitchell Hashimoto

commit sha 9e1e4717f8567d7ead72d070d064ad17d444a67e

update CHANGELOG

view details

push time in 2 months

issue closedmitchellh/mapstructure

Panic with a decode hook to convert a `time.Time` in a struct into a `*github.com/golang/protobuf/types.Timestamp` in other struct

I was trying to use mapstructure to convert between a protobuf type and a corresponding internal type. The two times had different forms of timestamp where the protobuf type used the well known Timestamp type and the internal type used a time.Time.

My decode hook looked like the following:

var (
	tsType      = reflect.TypeOf((*types.Timestamp)(nil))
	timePtrType = reflect.TypeOf((*time.Time)(nil))
	timeType    = timePtrType.Elem()
	mapStrInf   = reflect.TypeOf((map[string]interface{})(nil))
)

// HookTimeToPBtimestamp is a mapstructure decode hook to translate a time.Time value to
// a protobuf Timestamp value.
func HookTimeToPBTimestamp(from, to reflect.Type, data interface{}) (interface{}, error) {
	// Note that mapstructure doesn't do direct struct to struct conversion in this case. I
	// still don't completely understand why converting the PB TS to time.Time does but
	// I suspect it has something to do with the struct containing a concrete time.Time
	// as opposed to a pointer to a time.Time. Regardless this path through mapstructure
	// first will decode the concrete time.Time into a map[string]interface{} before
	// eventually decoding that map[string]interface{} into the *types.Timestamp. One
	// other note is that mapstructure ends up creating a new Value and sets it it to
	// the time.Time value and thats what gets passed to us. That is why we end up
	// seeing a *time.Time instead of a time.Time.
	if from == timePtrType && to == mapStrInf {
		ts := data.(*time.Time)
		nanos := ts.UnixNano()

		seconds := nanos / 1000000000
		nanos = nanos % 1000000000

		return &map[string]interface{}{
			"Seconds": seconds,
			"Nanos":   int32(nanos),
		}, nil
	}
	return data, nil
}

I had a test to ensure my decode hook was working but it was panicing like so:

        panic: reflect: reflect.flag.mustBeAssignable using unaddressable value

goroutine 4 [running]:
testing.tRunner.func1.1(0x14b6d00, 0xc000061410)
        /usr/local/go/src/testing/testing.go:941 +0x3d0
testing.tRunner.func1(0xc00012f440)
        /usr/local/go/src/testing/testing.go:944 +0x3f9
panic(0x14b6d00, 0xc000061410)
        /usr/local/go/src/runtime/panic.go:967 +0x166
reflect.flag.mustBeAssignableSlow(0x15)
        /usr/local/go/src/reflect/value.go:247 +0x138
reflect.flag.mustBeAssignable(...)
        /usr/local/go/src/reflect/value.go:234
reflect.Value.Set(0x14d9fe0, 0xc00007bd10, 0x15, 0x14d9fe0, 0xc00007bd70, 0x15)
        /usr/local/go/src/reflect/value.go:1526 +0x3b
github.com/mitchellh/mapstructure.(*Decoder).decodeMapFromMap(0xc000010070, 0x1481f3b, 0x9, 0x14d9fe0, 0xc000010098, 0x195, 0x14d9fe0, 0xc00007bd10, 0x15, 0x14d9fe0, ...)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:843 +0x49c
github.com/mitchellh/mapstructure.(*Decoder).decodeMap(0xc000010070, 0x1481f3b, 0x9, 0x14a7320, 0xc000010098, 0x14d9fe0, 0xc00007bd10, 0x15, 0x14a7320, 0xc000010098)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:763 +0x56a
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc000010070, 0x1481f3b, 0x9, 0x1552700, 0xc00000e600, 0x14d9fe0, 0xc00007bd10, 0x15, 0x0, 0x0)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:439 +0x625
github.com/mitchellh/mapstructure.(*Decoder).decodeMapFromStruct(0xc000010070, 0x0, 0x0, 0x14eddc0, 0xc00000e580, 0x99, 0x14d9fe0, 0xc000010078, 0x195, 0x14d9fe0, ...)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:912 +0x978
github.com/mitchellh/mapstructure.(*Decoder).decodeStruct(0xc000010070, 0x0, 0x0, 0x14eddc0, 0xc00000e580, 0x14edd40, 0xc000010068, 0x199, 0x14eddc0, 0xc00000e580)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:1172 +0x329
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc000010070, 0x0, 0x0, 0x14eddc0, 0xc00000e580, 0x14edd40, 0xc000010068, 0x199, 0xc00000e580, 0xc00005df58)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:437 +0x75f
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc000010070, 0x14eddc0, 0xc00000e580, 0xc00000e580, 0x0)
        /Users/mkeeler/Code/repos/mapstructure/mapstructure.go:370 +0xf0
github.com/hashicorp/consul/agent/agentpb.TestHookTimeToPBTimestamp(0xc00012f440)
        /Users/mkeeler/Code/repos/consul/auto-config/cert-generation/agent/agentpb/translate_test.go:63 +0x16c

I managed to find the cause which exists in a couple places. In both the intermediate map being created for the intermediate steps in a struct -> struct decode are not being created in a way that they are settable:

https://github.com/mitchellh/mapstructure/blob/d16e9488127408e67948eb43b6d3fbb9f222da10/mapstructure.go#L907

https://github.com/mitchellh/mapstructure/blob/d16e9488127408e67948eb43b6d3fbb9f222da10/mapstructure.go#L1157-L1158

I have a PR almost ready that fixes the issues by creating these maps in a way that they are settable. I just wanted to have an issue open to track when adding my test to mapstructure_bug_test.go.

closed time in 2 months

mkeeler

push eventmitchellh/mapstructure

Matt Keeler

commit sha bfe0d3c2f4c47d70d56f279e6c8867b05a3117cb

Ensure that intermediate maps during struct to struct decoding are settable

view details

Mitchell Hashimoto

commit sha fb53316e1ca956dcadc71f32ea502facb5362ddc

Merge pull request #203 from mkeeler/settable-intermediates Ensure that intermediate maps during struct to struct decoding are settable

view details

push time in 2 months

Pull request review commentmitchellh/mapstructure

Ensure that intermediate maps during struct to struct decoding are settable

 func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re 			mType := reflect.MapOf(vKeyType, vElemType) 			vMap := reflect.MakeMap(mType) -			err := d.decode(keyName, x.Interface(), vMap)+			// Creating a pointer to a map so that other methods can completely+			// overwrite the map if need be (looking at you decodeMapFromMap). The+			// indirection allows the underlying map to be settable (CanSet() == true)+			// where as reflect.MakeMap returns an unsettable map.+			addrVal := reflect.New(vMap.Type())+			reflect.Indirect(addrVal).Set(vMap)

If you know its a pointer I usually prefer addrVal.Elem() over indirect. Indirect just calls that with an additional check but it feels more idiomatic reflect usage. Same with the few other uses.

mkeeler

comment created time in 2 months

issue closedhashicorp/go-plugin

Use grpc for the handshake protocol

Instead of the complicated and undocumented handshake protocol, use a grpc server that is hosted by the application accepting plugins and pass just a single env variable to those applications with the address of that server.

Ideally the address is served over TCP for both windows support and because the go implementation over UDS is not following the spec https://github.com/grpc/grpc-go/issues/2628 at the moment (so plugins in rust / typescript / javascript might not work)

Process:

  1. Application starts plugin with env variable
  2. Plugin calls handshake GRPC service in application via address in env variable
  3. Server responds with the version it supports and the required port range (if any), this is cleaner then passing this over env variables. Potentially, it could also pass an application name (and that value is checked instead of the "MAGIC COOKIE" solution)
  4. The client figures out which version to use and registers itself to the server by calling a second GRPC endpoint, announcing on which endpoint the plugin server is running, ... (instead of putting this information on stdout, and having to block other output to stdout in the mean time and not being able to use newlines in e.g. SSL certificate)

For backwards compatibility reasons, it's probably possible to write a "adapter" binary that starts the real plugin and adapts between v1 and this v2 (this proposal) of the handshake protocol. Given this adapter application can be written once in 1 language, it would be much easier to write SDKs for other languages without necessarily breaking the protocol.

closed time in 2 months

entropitor

issue commenthashicorp/go-plugin

Use grpc for the handshake protocol

The handshake is documented here: https://github.com/hashicorp/go-plugin/blob/master/docs/internals.md#handshake

I think if I were working on go-plugin from scratch today I would go with this route. At the moment, I don’t see a large enough benefit to warrant the change. You note that it would be easier for other languages to write SDKs and I do agree with that, but I also think that outputting the one line isn’t too bad. If the documentation is incorrect, its easier to update that.

This is one of those situations where the end goal is certainly cleaner, but the backwards compatibility in between is very painful as we have to support the two handshake mechanisms for at least many years since we’ve already committed to plugin compatibility across many of the HashiCorp products. Given there would likely be many years of N+1 support (https://xkcd.com/927/) I’m inclined to just stick with the one admittedly weird approach for now.

Your suggestion is reasonable but I hope this helps share my viewpoint. Thanks for the suggestion.

entropitor

comment created time in 2 months

push eventmitchellh/protoc-gen-go-json

Mitchell Hashimoto

commit sha 8fbb6f3d729138a17d5a0019d8da40b39f434628

update dependency to avoid warning on newer versions of protoc

view details

push time in 2 months

push eventmitchellh/protoc-gen-go-json

Mitchell Hashimoto

commit sha 568af7cd1250397c64ac4ea1e60899f78d2eee1b

gen: remove dependency on protoc-gen-go/generator

view details

push time in 2 months

push eventmitchellh/protoc-gen-go-json

Mitchell Hashimoto

commit sha 2ef19f5a7f47cfe0c9f3c8a947ea176573dc7607

add nix shell stuff

view details

Mitchell Hashimoto

commit sha cbea6dfb0ca10529526e39ae433b06d557aa9874

update e2e test for latest version of protoc

view details

push time in 2 months

issue closedmitchellh/hashstructure

Support sorting slice or array

Is there an option for that Hash([1,2,3]) is same as Hash([3,2,1]) ?

closed time in 3 months

koolay

issue commentmitchellh/hashstructure

Support sorting slice or array

If the slice is part of a struct yes, tag the field with “set” (as noted in the docs).

If the slice is not a struct, then wrap it in a struct

koolay

comment created time in 3 months

more