-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added "source" annotation to the Task metadata. #5
Conversation
internal/catalog/catalog.go
Outdated
if !ok { | ||
annotations = make(map[string]interface{}) | ||
} | ||
annotations["source"] = fmt.Sprintf("%s/releases/download/%s", strings.TrimPrefix(url, "https://www.github.com/"), version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we could just print out the repository URI (so https://github.com/openshift-pipelines/task-containers for example)
- Why do we trim the github.com part ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was assuming that people will by default understand that the prefix will be "https://www.github.com/" .
internal/catalog/catalog.go
Outdated
taskFile := filepath.Join(path, "tasks", name, version, name+".yaml") | ||
if err := addSourceAnnotationToTask(taskFile, uri, version); err != nil { | ||
fmt.Fprintf(os.Stderr, "Failed to add source annotation to Task YAML file %s: %v\n", taskFile, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be multiple tasks we pull from there. I think an example here is task-containers
. I think this would try to mutate a task-containers.yaml
file that doesn't exists, wouldn't it ?
371c10e
to
0e13ca2
Compare
$ catalog-cd catalog generate --config ./externals.yaml .
Generating a catalog from ./externals.yaml in .
# Fetching resources from golang-tasks
## Fetching version 0.4.0
Error traversing task directory tasks/golang-tasks/0.4.0: lstat tasks/golang-tasks/0.4.0: no such file or directory
## Fetching version 0.5.0
Error traversing task directory tasks/golang-tasks/0.5.0: lstat tasks/golang-tasks/0.5.0: no such file or directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So few things:
- For some reason, the code indentation is wrong (files need to go through
gofmt
.. usually editors automatically do that) - It did skip some Tasks (see output below)
- URL should point to the repository, not the resource.tar.gz imo (
source: https://github.com/openshift-pipelines/task-maven/releases/download/v0.1.0/resources.tar.gz
should probably besource: https://github.com/openshift-pipelines/task-maven/
)
Generating a catalog from ../tektoncd-catalog/externals.yaml in /tmp/foo
# Fetching resources from task-git
## Fetching version 0.2.0
Adding source annotation to Task YAML file: /tmp/foo/tasks/task-git/0.2.0/task-git.yaml
## Fetching version 0.1.0
Adding source annotation to Task YAML file: /tmp/foo/tasks/task-git/0.1.0/task-git.yaml
# Fetching resources from task-maven
## Fetching version 0.1.0
Adding source annotation to Task YAML file: /tmp/foo/tasks/task-maven/0.1.0/task-maven.yaml
# Fetching resources from task-openshift
# Fetching resources from task-containers
## Fetching version 0.2.0
## Fetching version 0.1.1
It didn't do anything for task-containers
tasks.
c213301
to
8de592e
Compare
Signed off :- @Senjuti256 [email protected]