Conversation
Pull Request Test Coverage Report for Build 953
💛 - Coveralls |
|
👍 |
|
would you mind to give comment access to the design doc, please? |
underrun
left a comment
There was a problem hiding this comment.
just a couple questions... will dig in more Monday
Makefile
Outdated
| VERSION?=dev-$(shell date +%FT%T%z) | ||
| KS_BIN?=ks | ||
|
|
||
| APIMACHINERY_VER := $(shell dep status | grep k8s.io/apimachinery | awk '{print $$3}') |
There was a problem hiding this comment.
is api machinery back/forward compat as of 1.8? i'm all for getting rid of this line as it requires someone to have run dep ensure before running make - just checking to make sure we can do this safely.
There was a problem hiding this comment.
Another option here if we we want to keep the flexibility without the terrible build time:
APIMACHINERY_VER := $(shell grep -B1 k8s.io/apimachinery Gopkg.lock | head -n1 | cut -d'"' -f2)
| } | ||
|
|
||
| // MakeRegistryRefSpec returns app registry ref spec. | ||
| func (h *Helm) MakeRegistryRefSpec() *app.RegistryRefSpec { |
There was a problem hiding this comment.
why is this called MakeRegistryRefSpec instead of RegistryRefSpec?
pkg/registry/helm.go
Outdated
| spec *app.RegistryRefSpec | ||
| repositoryClient HelmRepositoryClient | ||
| unarchiver archive.Unarchiver | ||
| httpGet httpGet |
There was a problem hiding this comment.
Why is this not encapsulated in the repositoryClient?
There was a problem hiding this comment.
Because I missed it. It should be in there.
pkg/registry/helm.go
Outdated
| spec: registryRef, | ||
| repositoryClient: rc, | ||
| unarchiver: ua, | ||
| httpGet: http.Get, |
There was a problem hiding this comment.
We should support request timeouts - http.DefaultClient does not.
pkg/registry/helm.go
Outdated
| Version string `json:"version,omitempty"` | ||
| } | ||
|
|
||
| type httpGet func(string) (*http.Response, error) |
There was a problem hiding this comment.
Is this style preferred over a getter interface?
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| // Helm is a Helm repository. |
There was a problem hiding this comment.
Is there a good helm repository spec we could link to from somewhere? The most comprehensive I found was this.
There was a problem hiding this comment.
The might be the best there is.
pkg/registry/helm.go
Outdated
| } | ||
|
|
||
| if hg == nil { | ||
| hg = http.Get |
pkg/registry/helm.go
Outdated
| }, nil | ||
| } | ||
|
|
||
| func (hrc *helmRepositoryClient) Repository() (*HelmRepository, error) { |
There was a problem hiding this comment.
Let's document exported methods.
There was a problem hiding this comment.
This method isn't exported, but it should have documentation.
pkg/registry/helm.go
Outdated
| } | ||
| }() | ||
|
|
||
| b, err := ioutil.ReadAll(resp.Body) |
There was a problem hiding this comment.
How do we feel about reading arbitrarily long bodies into memory?
There was a problem hiding this comment.
Not great, but this would required an onFile refactor. I noted this in #522.
pkg/registry/helm.go
Outdated
| defer func() { | ||
| cerr := resp.Body.Close() | ||
| if cerr != nil { | ||
| err = cerr |
There was a problem hiding this comment.
What's the intention here? What is generally done with errors within defer blocks?
There was a problem hiding this comment.
This is an extremely hard error to trigger. If it does happen, return it instead of the initial error since it is most likely the cause of the problem. The reason it's a deferred function is because defer resp.Body.Close() will swallow the error.
There was a problem hiding this comment.
But to pull that off correctly, would error need to be a named return value?
There was a problem hiding this comment.
Also, if that's the plan it might be better to wrap any existing error rather than steam-rolling it.
pkg/registry/helm.go
Outdated
| } | ||
|
|
||
| func (hrc *helmRepositoryClient) Chart(name, version string) (*HelmRepositoryChart, error) { | ||
| repo, err := hrc.Repository() |
There was a problem hiding this comment.
This should probably be cached - do we want to download and parse multiple megabytes for each call?
There was a problem hiding this comment.
I agree, going to add another issue for this.
pkg/registry/helm.go
Outdated
| } | ||
|
|
||
| if version == "" { | ||
| for _, chart := range repo.Latest() { |
There was a problem hiding this comment.
This seems like a lot of extra work - we're sorting all versions of all charts, then doing a linear search for the desired chart name. Why instead not sort just repo.Charts[name]?
| return githubFactory(a, spec) | ||
| case ProtocolFilesystem: | ||
| return NewFs(a, spec) | ||
| case ProtocolHelm: |
There was a problem hiding this comment.
Is registry add support in scope for this PR?
There was a problem hiding this comment.
Nope. Don't want to do that until we have a complete solution.
pkg/registry/manager.go
Outdated
| case ProtocolFilesystem: | ||
| return NewFs(a, spec) | ||
| case ProtocolHelm: | ||
| client, err := newHelmRepositoryClient("https://kubernetes-charts.storage.googleapis.com", nil) |
There was a problem hiding this comment.
Should this be configurable? Or at least const? Or will that be part of the registry add work?
There was a problem hiding this comment.
It should be, but this is dependent on registry add. So for now, it is hard coded.
pkg/registry/helm.go
Outdated
| } | ||
|
|
||
| if resp.StatusCode != http.StatusOK { | ||
| return nil, nil, errors.Errorf("unexpected HTTP status code %q when retrieving helm chart", resp.Status) |
There was a problem hiding this comment.
Some more context in this error (chart? url?) would be useful - I'm not clear on whether those are added up the stack.
| } | ||
| }() | ||
|
|
||
| handler := func(f *archive.File) error { |
There was a problem hiding this comment.
A comment along the lines of "file contents are returned to the caller via onFile handler would be useful to the uninitiated.
|
|
||
| name := path.Join(chart.Name, "helm", chart.Version, f.Name) | ||
|
|
||
| return onFile(name, b) |
There was a problem hiding this comment.
I'd consider a future refactor of the ResolveFile interface to allow streaming with io.Reader all the way to the consumer.
|
|
||
| refSpec := &app.LibraryRefSpec{ | ||
| Name: partAlias, | ||
| Registry: h.Name(), |
There was a problem hiding this comment.
Conspicuously missing is GitVersion - should we discuss how we might better abstract away the version details while allowing them to be persisted in app.yaml?
There was a problem hiding this comment.
There is no GitVersion if there is not GitRepo. This is an implementation detailed that leaked before registries were understood.
e6d54ca to
c205f1e
Compare
|
@ksonnet/reviewers is this ready to go? Any more changes? |
pkg/helm/client.go
Outdated
| Charts map[string][]RepositoryChart `json:"entries,omitempty"` | ||
| } | ||
|
|
||
| // FooLatest returns the latest version of charts in a Helm repository. |
pkg/helm/client.go
Outdated
| Get(string) (*http.Response, error) | ||
| } | ||
|
|
||
| type getter struct { |
There was a problem hiding this comment.
I propose renaming to httpGetter - it will be clearer to read vs. the abstract getter interface.
pkg/helm/client.go
Outdated
|
|
||
| // Repository returns the Helm repository's content. | ||
| func (hrc *HTTPClient) Repository() (*Repository, error) { | ||
| resp, err := hrc.getter.Get(hrc.url.String()) |
There was a problem hiding this comment.
Should we use Fetch() from below here?
| } | ||
|
|
||
| // Fetch fetches URLs from a repository. If uri is a path, it will use the client URL as the base. | ||
| func (hrc *HTTPClient) Fetch(uri string) (io.ReadCloser, error) { |
There was a problem hiding this comment.
Yes, because the Helm registry uses it to resolve files and it is in another package.
|
Added a last round of comments. None need to be hard blockers. |
Creates a helm registry that can treat helm charts as ksonnet parts. [design doc](https://docs.google.com/document/d/1FcK8pDqj_9EFjNVr9e_t9WemouQpS9ix-r0AxNDB_nM/edit?usp=sharing) Signed-off-by: bryanl bryanliles@gmail.com
Creates a helm registry that can treat helm charts as ksonnet parts.
design doc
#522
This change does the following:
If you have a helm registry defined in
app.yaml, It will show up in the registry listing:You can run
ks pkg listand see charts in your helm repositoryYou can run
ks pkg installto install a package:The pkg will then be vendored for you:
Signed-off-by: bryanl bryanliles@gmail.com