enaml-ops / enaml

because (en)ough with the y(aml) already
Apache License 2.0
16 stars 4 forks source link

enaml generate fails on pivnet releases #14

Open warroyo opened 7 years ago

warroyo commented 7 years ago

when trying to generate go structs for a locally downloaded pivnet release (ex.cf-1.8.8-build.1.pivotal) an error occurs (see below). this error does not occur when running enaml show and the command succeeds with the proper output. What seems to be happening is the show command expects the zip format that pivnet releases are bundled in and knows to unpackage and go into the releases folder to go through all of the releases. however the generate command is expecting a gzip archive like a bosh.io release.

I tried repackaging the .pivotal release as a gzipped archive, still named cf-1.8.8-build.1.pivotal since it looks like the .pivotal is important to detemrinig a pivnet release. The generate command ran without any errors but did not generate any structs. This seems like the generate command is never executing the pivnet specific functions https://github.com/enaml-ops/enaml/blob/b232608251205ea0fc1e039631214a64954f7cb1/release/pivnetrelease.go#L42

also when running the show command on the repackaged release I revieve an error zip: not a valid zip file which means the show command is properly executing the pivotal release specific code.

gzip: invalid header
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x280 pc=0x155f27]

goroutine 1 [running]:
panic(0x32d5a0, 0xc42000e0c0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
compress/gzip.(*Reader).Read(0x0, 0xc42009adb8, 0x200, 0x200, 0x4f8220, 0xc420074178, 0x4f6d60)
        /usr/local/go/src/compress/gzip/gunzip.go:242 +0x37
io.ReadAtLeast(0x4f6960, 0x0, 0xc42009adb8, 0x200, 0x200, 0x200, 0x4f6d60, 0xc4200f8e60, 0x0)
        /usr/local/go/src/io/io.go:307 +0xa4
io.ReadFull(0x4f6960, 0x0, 0xc42009adb8, 0x200, 0x200, 0x4f6960, 0x0, 0x0)
        /usr/local/go/src/io/io.go:325 +0x58
archive/tar.(*Reader).readHeader(0xc42009ad80, 0x0)
        /usr/local/go/src/archive/tar/reader.go:542 +0x7c
archive/tar.(*Reader).Next(0xc42009ad80, 0x4f75e0, 0xc4200840a0, 0xc42009ad80)
        /usr/local/go/src/archive/tar/reader.go:127 +0x9a
github.com/enaml-ops/enaml/generators.(*ReleaseJobsGenerator).ProcessFile(0xc42003fbf8, 0x7fff5fbff97f, 0x18)
        /go/src/github.com/enaml-ops/enaml/generators/releasejobs.go:40 +0xd6
github.com/enaml-ops/enaml/generators.GenerateReleaseJobsPackage(0x7fff5fbff97f, 0x18, 0x387b4c, 0x6, 0x389519, 0xb, 0x82b41, 0xc4200f8dc0)
        /go/src/github.com/enaml-ops/enaml/generators/releasejobs.go:27 +0x235
main.main.func1(0xc4200f8dc0, 0x388832, 0x8)
        /go/src/github.com/enaml-ops/enaml/cmd/enaml/main.go:65 +0xd2
github.com/enaml-ops/enaml/vendor/gopkg.in/urfave/cli%2ev2.(*Command).Run(0xc4200b2700, 0xc4200f8b80, 0x0, 0x0)
        /go/src/github.com/enaml-ops/enaml/vendor/gopkg.in/urfave/cli.v2/command.go:143 +0x787
github.com/enaml-ops/enaml/vendor/gopkg.in/urfave/cli%2ev2.(*App).Run(0xc420096840, 0xc4200780c0, 0x3, 0x3, 0x0, 0x0)
        /go/src/github.com/enaml-ops/enaml/vendor/gopkg.in/urfave/cli.v2/app.go:228 +0x5de
main.main()
        /go/src/github.com/enaml-ops/enaml/cmd/enaml/main.go:103 +0x549
zmb3 commented 7 years ago

You're correct to point out that enaml show operates on pivnet tiles and enaml generate operates on gzipped releases.

To generate structs for a pivnet release, you need to rename the .pivotal to .zip, extract it, and run enaml generate on each .tgz in the releases directory.