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

Allow retrieval of files for Custom Tasks #234

Open
tnelson-doghouse opened this issue Jul 27, 2022 · 10 comments
Open

Allow retrieval of files for Custom Tasks #234

tnelson-doghouse opened this issue Jul 27, 2022 · 10 comments

Comments

@tnelson-doghouse
Copy link

tnelson-doghouse commented Jul 27, 2022

Is your feature request related to a problem? Please describe.
When I do a database dump on a non-drush site (via a Custom Task), there's no straightforward way to retrieve the file from the task.

Describe the solution you'd like
Ben Jackson's suggestion for solving this problem (not an approval from him, just a thought) was something along the lines of:

  • Make the file appear in the task view page
  • Allow retrieval of the file via lagoon get task-file --task-id <id>

Describe alternatives you've considered
Dumping the files directly into the backups list.

EDIT: Changed some wording and references to better reflect that tasks are different to backups.

@rocketeerbkw
Copy link
Member

rocketeerbkw commented Sep 27, 2024

Make the file appear in the task view page

Not sure what this means? Task files have been shown and downloadable from the UI since we add them to the UI.

@tnelson-doghouse
Copy link
Author

@rocketeerbkw has this changed since July of 2022? If so, can you point me at documentation on how to take a file created by a custom task and add it to the UI? Thanks!

@shreddedbacon
Copy link
Member

What you originally asked is how to retrieve a file from a task, not add a file to a task

@shreddedbacon
Copy link
Member

It is possible to upload a file to a task via the API. The CLI offers a way to upload files to a task.

You just need to know some information about the task. All task pods have a variable named TASK_DATA_ID which contains the ID that the CLI command needs.

@tnelson-doghouse
Copy link
Author

@shreddedbacon , yes, you're right. For context, I think this was for a database dump task; we wanted the devs to be able to dump the database, then download it from the UI. Discussion should be visible on AIOSD-7263.

The discussion there says that it's not currently possible to retrieve task files from the CLI. Does that mean it'd be possible via GraphQL?

Thanks!

@shreddedbacon
Copy link
Member

shreddedbacon commented Sep 30, 2024

Does that mean it'd be possible via GraphQL?

Yes, well retrieving the download link for the file(s) would be possible.

@tnelson-doghouse
Copy link
Author

Oh, that makes sense. If the CLI could do it, that'd be even better, but that's better than nothing :) .

@shreddedbacon
Copy link
Member

If the CLI could do it, that'd be even better

It can probably do this yes, when time permits to add the functionality I guess.

@rocketeerbkw
Copy link
Member

has this changed since July of 2022?

No, tasks have always been able to have files attached and downloadable from the UI.

can you point me at documentation on how to take a file created by a custom task and add it to the UI?

We don't have documentation for this. The easiest option, as Ben suggested, is to use the lagoon cli lagoon upload task-files --help (this is a new option in the cli since 2022). The other option is to use a graphql query, as we do in our native tasks using curl. Both methods will upload the task to Lagoon and show a link when viewing the task.

image

The discussion there says that it's not currently possible to retrieve task files from the CLI. Does that mean it'd be possible via GraphQL?

This is one valid query, there are other ways of course:

query ($taskId: Int!) {
  taskById(
    id: $taskId
  ) {
    id
    name
    files {
      id
      filename
      download
    }
  }
}

If you wanted to use the lagoon-cli to get the download link you could do something like the following:

lagoon raw --raw "query {taskById(id:50476){files{download}}}" | jq -r '.taskById.files.[] | .download' | xargs curl -O

@tnelson-doghouse
Copy link
Author

Oh, nice! Didn't know about lagoon raw. Thanks!

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

No branches or pull requests

3 participants