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

Added "source" annotation to the Task metadata. #5

Closed
wants to merge 4 commits into from

Conversation

Senjuti256
Copy link
Contributor

if !ok {
annotations = make(map[string]interface{})
}
annotations["source"] = fmt.Sprintf("%s/releases/download/%s", strings.TrimPrefix(url, "https://www.github.com/"), version)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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/" .

Comment on lines 66 to 84
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)
}
Copy link
Member

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 ?

@vdemeester
Copy link
Member

$ 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

Copy link
Member

@vdemeester vdemeester left a 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 be source: 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.

@Senjuti256 Senjuti256 closed this Feb 27, 2024
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