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

Support self-hosted GitHub Enterprise #3724

Open
joshuaspence opened this issue Apr 28, 2024 · 0 comments · May be fixed by #3748
Open

Support self-hosted GitHub Enterprise #3724

joshuaspence opened this issue Apr 28, 2024 · 0 comments · May be fixed by #3748
Labels
enhancement New feature or request

Comments

@joshuaspence
Copy link

joshuaspence commented Apr 28, 2024

Is your feature request related to a problem? Please describe.

I want to use Chezmoi to install various binaries from a self-hosted GitHub Enterprise installation. I am already using chezmoiexternals and the githubLatestRelease function to install binaries from github.com, for example:

---
.local/bin/chezmoi:
  type: 'file'
  executable: true
  url: '{{ (gitHubLatestRelease "twpayne/chezmoi").HTMLURL | replace "/releases/tag/" "/releases/download/" }}/chezmoi-{{ .chezmoi.os }}-{{ .chezmoi.arch }}'

But this doesn't work for self-hosted GitHub Enterprise as I don't believe there is a way to pass in a custom hostname. Similarly there isn't a way to pass in an auth token (there is $CHEZMOI_GITHUB_ACCESS_TOKEN but I would need a way to provide a token that is scoped to a single domain).

Describe the solution you'd like

Either a new family of functions (e.g. githubEnterpriseLatestRelease) or extending the existing GitHub functions to accept a hostname (e.g. githubLatestRelease "https://git.example.com/owner/repo"). Additionally, a way to provide the auth token for git.example.com in chezmoi.yaml.

Describe alternatives you've considered

Previously I was just using a script to do this:

#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

{{ $version := output "gh" "release" "--repo=git.example.com/owner/repo" "view" "--json=name" "--template={{.name}}" -}}
gh release --repo git.example.com/owner/repo download --output=- --pattern=example_{{ .chezmoi.os }}_{{ .chezmoi.arch }}.tar.gz {{ $version }} | tar --extract --file=- --gunzip --directory ~/.local/bin example

I have since changed to using a template since I want Chezmoi to purge unmanaged files from ~/.local/bin.

# dot_local/bin/executable_example.tmpl
{{- $version := output "gh" "--repo=git.example.com/owner/repo" "release" "view" "--json=name" "--jq=.name" | trim -}}
{{ output "sh" "-c" (printf "gh --repo=git.example.com/owner/repo release download --output=- --pattern=example_%s_%s.tar.gz %s | tar --extract --to-stdout --gunzip example" .chezmoi.os .chezmoi.arch $version) }}

This works okay, but seems a bit hacky and is definitely less readable.

I realize I could also do this using the git-repo external, but I would then need to add some sort is post-install script to do the actual compilation.

@joshuaspence joshuaspence added the enhancement New feature or request label Apr 28, 2024
@twpayne twpayne linked a pull request May 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant