Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-adds source and docs for review #4

Merged
merged 3 commits into from
Apr 3, 2018
Merged

Conversation

mhrivnak
Copy link
Member

I contrived these two branches to provide a review opportunity. Whatever revisions come out of it, I'll squash and cherry-pick onto master.

@mhrivnak mhrivnak added the enhancement New feature or request label Mar 26, 2018
```
$ helm2bundle redis-1.1.12.tgz
$ ls
apb.yml Dockerfile redis-1.1.12.tgz

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about following the same format as apb init and creating a directory named redis-1.1.12-apb? Or even dropping the version and redis-apb. I also know it might be dumb to create a directory of 2 files...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea. I think the main reason we wouldn't do that is that the image needs the chart file itself. All three of the files you see here have to be used while building the image. apb init is a bit different since it is starting from 0 assets.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, doesn't really make sense the more I think about it.

helm2bundle.go Outdated
Async: "optional",
Metadata: map[string]string{
"displayName": fmt.Sprintf("%s (helm bundle)", v.Name),
"console.openshift.io/iconClass": fmt.Sprintf("icon-%s", v.Name), // no guarantee it exists, but worth a shot

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the worst that happens if it doesn't exist is some javascript errors?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/djzager/bundle-lib/blob/4634b97c2d8aed4ccc1a8573f97aa56b98fcd24e/registries/adapters/helm_adapter.go#L212

Not sure why imageUrl wouldn't work here. You would need to add the Chart's Icon as a field in TarValues and grab it from the Chart.yaml to use it. But that seems to work better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. I need to give imageUrl another try here and will likely just switch to that. Not sure why it wasn't working for me previously, but I also didn't try very hard to troubleshoot it.

Copy link

@dymurray dymurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no issues with stable/mariadb using the tool. oc not working is messing with my ability to test the full development cycle but the bundle image works properly as expected using docker run.

helm2bundle.go Outdated
Plans []Plan `yaml:"plans"`
}

type Plan struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could vendor in broker-client-go to get these types. Might not be a bad idea so you don't have to maintain them.

https://github.com/automationbroker/broker-client-go/blob/master/pkg/apis/automationbroker.io/v1/types.go#L73

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

Copy link

@djzager djzager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot. The only thing I think you should do is grab the Chart's Icon URL and use that in imageUrl in the apb.yml's metadata section.

helm2bundle.go Outdated
Async: "optional",
Metadata: map[string]string{
"displayName": fmt.Sprintf("%s (helm bundle)", v.Name),
"console.openshift.io/iconClass": fmt.Sprintf("icon-%s", v.Name), // no guarantee it exists, but worth a shot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/djzager/bundle-lib/blob/4634b97c2d8aed4ccc1a8573f97aa56b98fcd24e/registries/adapters/helm_adapter.go#L212

Not sure why imageUrl wouldn't work here. You would need to add the Chart's Icon as a field in TarValues and grab it from the Chart.yaml to use it. But that seems to work better.

Copy link

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, I'll leave it up to you if you want to fix them. The missing comments for Plan and Parameter come from running golint.

apb.yml Dockerfile redis-1.1.12.tgz
```

On OpenShift you can ``apb push`` to build and push the service bundle into your
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically you only need one back tick to format code inline. like this, no need to change in this document but could save you 2 extra characters in future documents. Imagine the time you could save in a lifetime :)

helm2bundle.go Outdated
Plans []Plan `yaml:"plans"`
}

type Plan struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a comment

helm2bundle.go Outdated
Parameters []Parameter `yaml:"parameters"`
}

type Parameter struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a comment

"io/ioutil"
"os"
"path"
"text/template"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goimport tool will reorder the imports to be ordered as stdlib first and alphabetized. Then third party, alphabetized. I use vim-go with goimports which handles this for me.

import (
    "archive/tar"
    "compress/gzip"
    "errors"
    "fmt"
    "io"
    "io/ioutil"
    "os"
    "path"
    "text/template"
    
    "github.com/spf13/cobra"
    "gopkg.in/yaml.v2"
)

Use: "helm2bundle CHARTFILE",
Short: "Packages a helm chart as a Service Bundle",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the func here is clever but makes the code harder to read since it is longer than a few lines. Not a blocker but I would've had a separate function for it. If we add new parameters I can see this main function becoming quite large.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I started just from the cobra examples, and it grew from there. I'll factor most of it out.

helm2bundle.go Outdated
}
}

// fileExists returns true if either apb.yml or Dockerfile exist in the working
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should read:

either apb.yml or Dockerfile exists in the working directory


// getTarValues opens the helm chart tarball to 1) retrieve Chart.yaml so it can
// be parsed, and 2) retrieve the entire contents of values.yaml.
func getTarValues(filename string) (TarValues, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice looks good.

@mhrivnak
Copy link
Member Author

I think I've addressed everything except @rthallisey 's suggestion to vendor in the APB structs. I'm looking into that and may want to ask a couple of questions about it next week.

@mhrivnak
Copy link
Member Author

mhrivnak commented Apr 3, 2018

@rthallisey I looked into vendoring in bundle-lib for the types, and I filed a bundle-lib issue about why that's not viable at the moment: automationbroker/bundle-lib#47

I also filed an issue to track it in this repo: #5

Copy link

@rthallisey rthallisey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhrivnak thanks for checking

@rthallisey rthallisey merged commit 5ceffa9 into review Apr 3, 2018
@jmrodri
Copy link

jmrodri commented Apr 3, 2018

@mhrivnak I know it already got merged, but yes the refactor looks good. Thanks.

@mhrivnak
Copy link
Member Author

mhrivnak commented Apr 3, 2018

Thanks @jmrodri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants