hashicorp / nomad-pack

Mozilla Public License 2.0
393 stars 51 forks source link

nomad-pack add registry does not honer default main/master branch #490

Open Thadir opened 6 months ago

Thadir commented 6 months ago

What I tried to do on nomad pack is add our own internal tempaltes. Trough the folwoing command:

nomad-pack registry add arval ssh://gitea@gitea.internal/nomad_pack_templates.git

The target repo I use had main as only branch. However i get the folowing error:

go-getter URL is ssh://gitea@gitea.internal/nomad_pack_templates.git?depth=1
! Could Not Install Registry

    Error:   error downloading 'ssh://gitea@ssh://gitea@gitea.internal/nomad_pack_templates.git?depth=1': /usr/bin/git exited with 128: Cloning into '/home/thadir/.cache/nomad/packs/nomad-pack-tmp'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin
fatal: The remote end hung up unexpectedly
Gitea: Internal error

    Context:
        - Cache Path: /home/thadir/.cache/nomad/packs
        - Registry Source: ssh://gitea@gitea@gitea.internal/nomad_pack_templates.git
        - Registry Name: arval
        - Ref:
        - Pack Name:

Work around is creating a master branch. But our default and only branch was main.

lm2497358068 commented 6 months ago

May I ask how you resolved it

Thadir commented 6 months ago

May I ask how you resolved it

Like i said created a master branch again and have that as well. its not a workaround perse but it makes it work.

angrycub commented 5 months ago

@lm2497358068, @Thadir: You can avoid creating an additional branch by specifying the branch to target using the -ref flag. Could you share some additional information that might help figure out how to reproduce this issue locally?

Thadir commented 5 months ago

I am running them in containers as part of my pipline. But I would expect that pact will honer the main branch flag and not default to master.

This is my containerised version ill update it later this week to test with the new version v0.1.1:

#hadolint ignore=DL3007
FROM alpine:3.19.1 as verify

#hadolint ignore=DL3018
RUN apk --update add --no-cache unzip gnupg git jq

ARG HASHICORP_FINGERPRINT=c874011f0ab405110d02105534365d9472d7468f
ADD https://keybase.io/hashicorp/pgp_keys.asc?fingerprint=${HASHICORP_FINGERPRINT} /gpg/import/hashicorp.asc
RUN gpg --import /gpg/import/hashicorp.asc

WORKDIR /tmp

ARG NOMAD_VERSION=1.7.6
ARG NOMAD_PACK_VERSION=0.1.0

ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS .
ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS.sig .
ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip .

# Knwon bug atm in hasicorp certificate
#RUN wget -qO- https://www.hashicorp.com/.well-known/pgp-key.txt | gpg --import && gpg --verify nomad_${NOMAD_VERSION}_SHA256SUMS.sig nomad_${NOMAD_VERSION}_SHA256SUMS

#hadolint ignore=DL4006
RUN grep linux_amd64.zip nomad_${NOMAD_VERSION}_SHA256SUMS | sha256sum -cs
RUN unzip nomad_${NOMAD_VERSION}_linux_amd64.zip -d /usr/local/bin

#As soon as we get somting stable please top upsing a tech preview
ADD https://releases.hashicorp.com/nomad-pack/${NOMAD_PACK_VERSION}/nomad-pack_${NOMAD_PACK_VERSION}_linux_amd64.zip /tmp/nomad-pack.zip
RUN unzip /tmp/nomad-pack.zip -d /usr/local/bin

#hadolint ignore=DL3007
FROM frolvlad/alpine-glibc:alpine-3.19
#hadolint ignore=DL3018
RUN apk upgrade && \
    apk --update add --no-cache git jq

COPY --from=verify /usr/local/bin/* /usr/local/bin/
ENV PATH="$PATH:/usr/local/bin/"
RUN nomad version && \
    nomad-pack version

# Setup nomad pack registry
ENV HOME /home/jenkins/agent
RUN nomad-pack registry add internalcorppackregestry https://git.internalcorp.intranet/nomad_pack_templates.git