Skip to content

coder template pull <name> does not pull as a folder #2651

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

Closed
phorcys420 opened this issue Jun 25, 2022 · 12 comments
Closed

coder template pull <name> does not pull as a folder #2651

phorcys420 opened this issue Jun 25, 2022 · 12 comments
Labels
stale This issue is like stale bread.

Comments

@phorcys420
Copy link
Member

phorcys420 commented Jun 25, 2022

  • Version: v0.7.4+3f97767
  • Host: Windows

coder templates pull <name> <path> pulls the template and writes it as a tar instead of extracting it's contents.
C:\Users\fr20100048\Documents\basic-env>coder templates pull basic-env basic-env

image


coder templates pull <name> without any path prints out the tar's contents to stdout.
C:\Users\fr20100048\Documents\basic-env>coder templates pull basic-env

README.md0000666000000000000000000000052414255567654010553 0ustar0000000000000000---
name: Basic dev environment
description: Basic environment with code-server.
tags: [local, docker]
---

[...]
main.tf0000666000000000000000000000340314255560711010535 0ustar0000000000000000terraform {
  required_providers {
    coder = {
      source  = "coder/coder"
      version = "0.4.2"
    }
    docker = {
      source  = "kreuzwerker/docker"
      version = "~> 2.16.0"
    }
  }
}

[...]

Maybe getting a tar should still be possible with a --tar argument or --format tar argument? (or if <path> ends with .tar?).
Also, coder template pull <name> . currently isn't possible, but that would be a nice feature to have so i'm suggesting it here since it's related.

@sreya
Copy link
Collaborator

sreya commented Jun 29, 2022

Hi! So the behavior of this command is intentional. It's intended to emulate the behavior of a Linux utility where you can take the output of this command (a tar archive) and redirect it to an arbitrary file. Since tar is a fairly ubiquitous tool and untarring an archive is trivial it's left to the user to decide how they wish to unpack the bundle. You can check out something like docker export <container> which has similar behavior.

coder templates pull <name> . will not work because it assumes that the destination you are providing is going to be a file that it writes to. So if you want it to work you should be able to do coder templates pull <name> ./foo.tar.

I have noticed that you're on Windows, is it difficult to use this command in its current state for you? I have little experience on Windows but my understanding is that it's common to drop into WSL when doing command line work.

@ketang
Copy link
Contributor

ketang commented Jun 29, 2022

WSL isn't available on all versions of Windows.

I understand wanting to align to a standard, but also tar is a command that is notorious for being hard to work with.

I think a decent compromise would be to have two commands. I'm thinking pull does an unpacking and export gives you the tarball.

@kylecarbs what do you think?

@kylecarbs
Copy link
Member

I'd rather have the tar be default behavior, but I think export is a better name.

What do you think about a --extract flag? We could default to cURL behavior, where if the output is a TTY we require explicit - as the argument.

@sreya
Copy link
Collaborator

sreya commented Jun 29, 2022

I think an --extract flag is reasonable, we can also certainly support the case where if you specify a directory we will pick a name and write it to the directory as opposed to returning an error.

@ketang
Copy link
Contributor

ketang commented Jun 29, 2022

Well yeah, that's why you implemented it! But pull sounds more like git than a strict downloader. I'm trying to imagine use cases, and I think it's far more likely that someone wants the expanded form. What is their intention when they pull? It's almost always going to reading or editing. Sometimes it's going to be about transporting it somewhere else, but ow we're talking about situations where it's also not in revision control or they can't just do a recursive copy. As the default behavior it just doesn't match how people are typically going to use it.

@ketang
Copy link
Contributor

ketang commented Jul 4, 2022

I spent a few hours fiddling with templates yesterday, and I'm absolutely 100% convinced that pull should extract a directory tree. The intermediate archive file was only ever an impediment.

@phorcys420
Copy link
Member Author

I definitely think the wording was confusing, I thought it would be like git pull indeed.
Maybe make pull extract and download download a tar or something like that ?

@ammario
Copy link
Member

ammario commented Aug 1, 2022

We could export as a directory if stdout is detected as a TTY.

@phorcys420
Copy link
Member Author

phorcys420 commented Aug 10, 2022

We could export as a directory if stdout is detected as a TTY.

sounds good to me, but then in coder pull <name> <path>, should path be a dir or a tarfile ?

@ammario
Copy link
Member

ammario commented Aug 10, 2022

We could export as a directory if stdout is detected as a TTY.

sounds good to me, but then in coder pull <name> <path>, should path be a dir or a tarfile ?

This gets me thinking. We could copy the UX of tar for something intuitive:

Always require a <path>, so the full invocation becomes coder templates pull <template> <path>

  • If $path is -, send as tar (current behavior)
  • If $path is ., use current working directory
  • Else, use $path literally

@phorcys420
Copy link
Member Author

This looks good to me, except you can't pipe tars in windows (it doesn't work), so maybe add a case where if $path ends with .tar write it as a tar file.

@github-actions
Copy link

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label Oct 30, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue is like stale bread.
Projects
None yet
5 participants