Skip to content

feat: add template export functionality to UI #17890

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Keerthi421
Copy link

@Keerthi421 Keerthi421 commented May 16, 2025

This PR adds the ability to export templates directly from the Coder UI, making it easier for users to backup, share, and version control their template configurations.

Changes

  • Added "Export template" button to the template menu dropdown
  • Implemented /api/v2/templates/{template}/export endpoint that:
    • Gets the latest version of the template
    • Creates a gzipped tar archive containing:
      • main.tf with the template's Terraform configuration
      • README.md with the template's description
    • Sets appropriate headers for file download
    • Streams the archive to the client

Related Issues

Closes #17859

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label May 16, 2025
Copy link

github-actions bot commented May 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Keerthi421 Keerthi421 changed the title feat: Add template export functionality to UI feat: add template export functionality to UI May 16, 2025
@Keerthi421
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request May 16, 2025
@matifali matifali requested a review from BrunoQuaresma May 16, 2025 19:21
// @Param template path string true "Template ID" format(uuid)
// @Success 200 {file} binary "Template archive"
// @Router /templates/{template}/export [get]
func (api *API) exportTemplate(rw http.ResponseWriter, r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this new endpoint necessary? coder templates pull just calls api/v2/files/{fileID}.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we could use the files endpoint for this feature.

Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

@Keerthi421 thanks for the contribution. During the review I have identified a few required changes:

  • There is no need to implement a new endpoint. You can use the one pointed by @ethanndickson in the previous comment.
  • It is always nice to include a screenshot or short video showing up the feature.
  • There are a few failed checks that need to be solved before approval.

Please, let me know if you need any help with these. Happy to help.

@github-actions github-actions bot added the stale This issue is like stale bread. label May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Pull Requests and issues created by the community. stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow exporting templates from UI
3 participants