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

Add Jpaths for jsonnet #2679 #2678

Closed
wants to merge 8 commits into from
Closed

Conversation

anarcher
Copy link

@anarcher anarcher commented Nov 9, 2019

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Optional. My organization is added to the README.
  • I've signed the CLA and my build is green (troubleshooting builds).

Closes #2679

@CLAassistant
Copy link

CLAassistant commented Nov 9, 2019

CLA assistant check
All committers have signed the CLA.

pkg/apis/application/v1alpha1/types.go Outdated Show resolved Hide resolved
cmd/argocd/commands/app.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 9, 2019

Codecov Report

Merging #2678 into master will decrease coverage by 0.01%.
The diff coverage is 48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2678      +/-   ##
==========================================
- Coverage   38.13%   38.11%   -0.02%     
==========================================
  Files         156      156              
  Lines       17297    17311      +14     
  Branches      229      203      -26     
==========================================
+ Hits         6596     6598       +2     
- Misses       9882     9898      +16     
+ Partials      819      815       -4
Impacted Files Coverage Δ
pkg/apis/application/v1alpha1/types.go 63.51% <ø> (ø) ⬆️
cmd/argocd/commands/app.go 1.01% <0%> (-0.01%) ⬇️
reposerver/repository/repository.go 59.16% <70.58%> (-0.42%) ⬇️
ui/src/app/applications/components/utils.tsx 46.68% <0%> (ø) ⬆️
ui/src/app/shared/services/projects-service.ts 19.71% <0%> (ø) ⬆️

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 84f24cd...a0a80cf. Read the comment docs.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution, @anarcher ! Overall, it looks good and useful to me, and I can see the use-case.

Please have a look at my code comments regarding jumping out of appPath (needs to be addressed) and the documentation (minor).

@@ -486,8 +486,12 @@ func findManifests(appPath string, env *v1alpha1.Env, directory v1alpha1.Applica
objs = append(objs, &obj)
} else if strings.HasSuffix(f.Name(), ".jsonnet") {
vm := makeJsonnetVm(directory.Jsonnet, env)
jpaths := []string{appPath}
for _, p := range directory.Jsonnet.JPaths {
jpaths = append(jpaths, filepath.Join(appPath, p))
Copy link
Member

Choose a reason for hiding this comment

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

We should really make sure that we don't jump out of appPath here, i.e. when p is ../../foo/bar or similar. Paths should only be added if they are within appPath after calling filepath.Join()

Copy link
Author

@anarcher anarcher Nov 11, 2019

Choose a reason for hiding this comment

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

my usecase like below:

├── environments
│   └── default
│       ├── app.yaml
│       ├── main.jsonnet
│       └── spec.json
├── jsonnetfile.json
├── jsonnetfile.lock.json
├── lib
└── vendor
    ├── k.libsonnet
    ├── k8s.libsonnet
    └── ksonnet-util
        ├── jaeger.libsonnet
        └── kausal.libsonnet

If appPath is environments/default or something else like environments/XXX, jpaths can be that ../../vendor and ../../lib . So I need to access appRoot (e.g.: gitRoot or local file path of spec.source.repoURL).
IMHO, Paths shoule be there inside appRoot. Is it right? Do you have a good idea about it? :->

vm.Importer(&jsonnet.FileImporter{
JPaths: []string{appPath},
JPaths: jpaths,
Copy link
Member

Choose a reason for hiding this comment

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

It should be documented somewhere that appPath will be an implicit member of jpath, even if not explicitly specified by --jsonnet-jpath

@anarcher
Copy link
Author

Failed
time="2019-11-11T07:34:55Z" level=info msg="Start syncing cluster" cluster=test
time="2019-11-11T07:34:55Z" level=info msg="Cluster successfully synced" cluster=test
cluster_test.go:469: 
Error Trace:	cluster_test.go:469
Error:      	Should be true
Test:       	TestWatchCacheUpdated

But, This failure is not reproduced with my desktop ㅠ

$go test ./controller/cache/ -v -run TestWatch
=== RUN   TestWatchCacheUpdated
time="2019-11-11T19:24:08+09:00" level=info msg="Start syncing cluster" cluster=test
time="2019-11-11T19:24:08+09:00" level=info msg="Cluster successfully synced" cluster=test
--- PASS: TestWatchCacheUpdated (0.00s)
PASS
ok  	github.com/argoproj/argo-cd/controller/cache	0.732s

@anarcher anarcher changed the title Add Jpaths for jsonnet Add Jpaths for jsonnet #2679 Nov 11, 2019
@alexec alexec self-assigned this Nov 11, 2019
@anarcher anarcher closed this Nov 13, 2019
@anarcher anarcher deleted the pr/jsonnet-1 branch November 21, 2019 07:36
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.

Support Jsonnet Jpaths
5 participants