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

Issue #2261 - Refactor Helm first class support #2364

Merged
merged 3 commits into from
Sep 26, 2019

Conversation

alexmt
Copy link
Collaborator

@alexmt alexmt commented Sep 25, 2019

PR refactors Helm first-class support.

Following major changes are implemented:

  • added chart field to the application source definition. If chart field is specified the argo cd assumes the application uses Helm repo. This improves user experience and replaces repo type autodetection.
  • repo server method ListApps support only git repo. ListApps is used only in UI and UI is different in case of Helm.
  • repo server method GetRevisionMetadata support only git repo. Git commit metadata is different from helm chart metadata. There is no author, tags, message message in helm chart metadata.
  • introduced helm specific method GetHelmCharts which is used to power app creation UI
  • implements proper application creation UI with both chart and version auto-completion:

Screen Shot 2019-09-25 at 12 55 41 PM

Following issues are solved:

@codecov
Copy link

codecov bot commented Sep 25, 2019

Codecov Report

Merging #2364 into master will decrease coverage by 1.54%.
The diff coverage is 8.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2364      +/-   ##
==========================================
- Coverage    38.8%   37.25%   -1.55%     
==========================================
  Files         109      103       -6     
  Lines       14197    14146      -51     
==========================================
- Hits         5509     5270     -239     
- Misses       7970     8203     +233     
+ Partials      718      673      -45
Impacted Files Coverage Δ
pkg/apis/application/v1alpha1/types.go 53.18% <0%> (-0.22%) ⬇️
server/server.go 51.48% <0%> (+0.43%) ⬆️
reposerver/repository/helm.go 0% <0%> (ø)
util/git/git.go 78.37% <0%> (-15.18%) ⬇️
cmd/argocd/commands/app.go 1.82% <0%> (-0.01%) ⬇️
util/argo/argo.go 25% <0%> (-3.51%) ⬇️
util/helm/cmd.go 26.54% <0%> (-10.96%) ⬇️
reposerver/repository/repository.go 25.89% <0.54%> (-21.43%) ⬇️
util/git/client.go 51.88% <100%> (-0.6%) ⬇️
util/cache/cache.go 20.53% <31.57%> (-0.19%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32f825e...a9872aa. Read the comment docs.

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

I've only some minor comments really. A couple of areas to watch out for:

  • I found that there was not much in the way of tests around caching, so be wary of changes in those areas.
  • I feel more confident about performance with these changes as we can optimize where we need to.

@@ -110,6 +110,12 @@ type ApplicationSource struct {
Directory *ApplicationSourceDirectory `json:"directory,omitempty" protobuf:"bytes,10,opt,name=directory"`
// ConfigManagementPlugin holds config management plugin specific options
Plugin *ApplicationSourcePlugin `json:"plugin,omitempty" protobuf:"bytes,11,opt,name=plugin"`
// Chart is a Helm chart name
Chart string `json:"chart,omitempty" protobuf:"bytes,12,opt,name=chart"`
Copy link
Contributor

Choose a reason for hiding this comment

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

one thought, what about

spec:
  source:
     helm:
       chart: my-chart

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like it in general, but spec still looks unclean if we introduce helm and keep path and targetRevision.

I would deprecate and migration chart, targetRevision and path, targetRevision to

  # one of
  source:
     helm:
       chart: my-chart
       version: my-version
    git:
       path: my-path
       revision: my-revision

Is it ok to create ticket and migrate both when we are ready?

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, I still think we need more user feedback on this feature as a priority over perfection

s.repoLock.Lock(repoPath)
defer s.repoLock.Unlock(repoPath)

err := os.Mkdir(repoPath, 0700)
Copy link
Contributor

Choose a reason for hiding this comment

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

I seem to recall someone concerned about permissions, is 0700 correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that was this comment: #1865 (comment) . The suggestion was to change 0777 to 0700

reposerver/repository/helm.go Show resolved Hide resolved

message HelmChart {
string name = 1;
repeated string versions = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@@ -158,26 +156,38 @@ func (s *Server) GetAppDetails(ctx context.Context, q *repositorypkg.RepoAppDeta
return nil, err
}
return repoClient.GetAppDetails(ctx, &apiclient.RepoServerAppDetailsQuery{
Repo: repo,
Copy link
Contributor

Choose a reason for hiding this comment

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

I've found a few places in the code where you have to pass values around for it to work correctly, and where unit tests won't go red. This could be one of the places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing to this method. Noticed that we don't set Plugins field here and discovered at field is not required at all. Removed it.

util/helm/cmd.go Show resolved Hide resolved
util/helm/index.go Show resolved Hide resolved
@@ -593,7 +596,8 @@ type appOptions struct {

func addAppFlags(command *cobra.Command, opts *appOptions) {
command.Flags().StringVar(&opts.repoURL, "repo", "", "Repository URL, ignored if a file is set")
command.Flags().StringVar(&opts.appPath, "path", "", "Path in repository to the ksonnet app directory, ignored if a file is set")
command.Flags().StringVar(&opts.appPath, "path", "", "Path in repository to the app directory, ignored if a file is set")
command.Flags().StringVar(&opts.chart, "chart", "", "Chart is a Helm Chart name")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe --helm-chart?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree. This is more in line with other helm related flags. Changed

message KsonnetAppDetailsQuery {
string environment = 1;
github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSource source = 2;
repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Repository repos = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@@ -1,24 +0,0 @@
package repo
Copy link
Contributor

Choose a reason for hiding this comment

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

don't you want these tests, but move them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, nice catch. thank you!

@alexmt
Copy link
Collaborator Author

alexmt commented Sep 26, 2019

@alexec , do you want to make any other changes in this PR? Can I get approval please?

@@ -1 +1 @@
1.1.2
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is used to override the value of a version constant in https://github.com/argoproj/argo-cd/blob/master/common/version.go#L11

@alexmt alexmt merged commit 0f7e9a1 into argoproj:master Sep 26, 2019
@alexmt alexmt deleted the 2261-helm-improvements branch September 26, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants