Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 600c7e5

Browse files
authored
✨ Implement cosign verification (#54)
* ✨ Implement cosign verification Also add --bootstrap flag for bindl get to bootstrap cosign * 🌱 Refactor Makefile to separate functional test Functional test (program/cosign_test.go) requires cosign binary to exist as it would not be able to bootstrap cosign through test binary. This can be eliminated if we don't shell out to run cosign bootstrap, but it requires solving dependency tree which would otherwise cause a dependency loop between command/ and program/, _sigh_. * 🌱 Don't assume direnv PATH is active in GitHub Actions
1 parent b9f85ce commit 600c7e5

File tree

21 files changed

+716
-128
lines changed

21 files changed

+716
-128
lines changed

.bindl-lock.yaml

Lines changed: 79 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
programs:
2-
- checksum: https://github.com/google/addlicense/releases/download/v{{ .Version }}/checksums.txt
3-
checksums:
2+
- checksums:
43
addlicense_1.0.0_Linux_arm64.tar.gz:
54
archive: dd42bca32cfcf37c53ae172b5c2f2db8a3f5a09574a55db6aca1eb1186de3330
65
binary: 959d66bebdea6c2fa232cd0b0ee00417008278e023082238fcb81db2263e0b64
@@ -20,10 +19,33 @@ programs:
2019
OS:
2120
darwin: macOS
2221
linux: Linux
23-
url: https://github.com/google/addlicense/releases/download/v{{ .Version }}/{{ .Name }}_{{ .Version }}_{{ .OS }}_{{ .Arch }}.tar.gz
22+
paths:
23+
base: https://github.com/google/addlicense/releases/download/v{{ .Version }}/
24+
checksums:
25+
artifact: https://github.com/google/addlicense/releases/download/v{{ .Version }}/checksums.txt
26+
target: '{{ .Name }}_{{ .Version }}_{{ .OS }}_{{ .Arch }}.tar.gz'
2427
version: 1.0.0
25-
- checksum: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/{{ .Name }}-{{ .Version }}-checksums.txt
26-
checksums:
28+
- checksums:
29+
cosign-darwin-amd64:
30+
archive: f9b598a5c7f571f1ccfd168aea90c1022dc53f4ee9997f6d58aa9f3b0db04a7f
31+
binary: f9b598a5c7f571f1ccfd168aea90c1022dc53f4ee9997f6d58aa9f3b0db04a7f
32+
cosign-darwin-arm64:
33+
archive: b2427998b43c3db3dd773b127f4fc17e3c55353d0c6ac4a4c3fdff9309ce912f
34+
binary: b2427998b43c3db3dd773b127f4fc17e3c55353d0c6ac4a4c3fdff9309ce912f
35+
cosign-linux-amd64:
36+
archive: 2ed460ccc1ba44f10ef98c19cafddad5b5199659c8a35e4b9b2040012ae1b235
37+
binary: 2ed460ccc1ba44f10ef98c19cafddad5b5199659c8a35e4b9b2040012ae1b235
38+
cosign-linux-arm64:
39+
archive: 1caf266cf27825ea10081363746e034b6f24da0e38475d4ddad7162ecbd2069d
40+
binary: 1caf266cf27825ea10081363746e034b6f24da0e38475d4ddad7162ecbd2069d
41+
name: cosign
42+
paths:
43+
base: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/
44+
checksums:
45+
artifact: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/{{ .Name }}_checksums.txt
46+
target: '{{ .Name }}-{{ .OS }}-{{ .Arch }}'
47+
version: 1.7.1
48+
- checksums:
2749
golangci-lint-1.45.2-darwin-amd64.tar.gz:
2850
archive: 995e509e895ca6a64ffc7395ac884d5961bdec98423cb896b17f345a9b4a19cf
2951
binary: 32f233a3213bf48025bae4af1a41482535454dc9a906daf6df66d4c3c366ca19
@@ -37,10 +59,13 @@ programs:
3759
archive: 1463049b744871168095e3e8f687247d6040eeb895955b869889ea151e0603ab
3860
binary: f6ea84deab5752583497b77e22e7e0a93c674edf043b341228ba6c030c17585d
3961
name: golangci-lint
40-
url: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/{{ .Name }}-{{ .Version }}-{{ .OS }}-{{ .Arch }}.tar.gz
62+
paths:
63+
base: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/
64+
checksums:
65+
artifact: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/{{ .Name }}-{{ .Version }}-checksums.txt
66+
target: '{{ .Name }}-{{ .Version }}-{{ .OS }}-{{ .Arch }}.tar.gz'
4167
version: 1.45.2
42-
- checksum: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/checksums.txt
43-
checksums:
68+
- checksums:
4469
goreleaser_Darwin_arm64.tar.gz:
4570
archive: 3349254563781493938c15ea94351e542b32932bfddaff587c5a0bae65e40c94
4671
binary: 148af83bc1d992bfdf5a0607ed1337f239fef24ac7fd22ec97083026a25d3dce
@@ -53,30 +78,57 @@ programs:
5378
goreleaser_Linux_x86_64.tar.gz:
5479
archive: e74934e7571991522324642ac7b032310f04baf192ce2a54db1dc323b97bcd7d
5580
binary: 6675d65b87ed168f6c7a981623b3b80a8c1c734197d6e4467cc764f23e843583
81+
cosign:
82+
- artifact: |
83+
1ab042180aa37bd0946871a08827d0826d12d96730639e8119e3e8dd6c156b4f goreleaser_Windows_armv7.zip.sbom
84+
1cc80fc5552f3220ada72eadd251a3e0435c7f837931bd411b1e40a8508511b2 goreleaser_Windows_i386.zip.sbom
85+
22cd8584bb58e63ab81f5172687aeda4d38f7caaf8b0fec5cb64176e4d104bd0 goreleaser-1.7.0.aarch64.rpm
86+
2bc4bb642db870cc492227c5c740ae68eed442434b05f7f529d795c599226620 goreleaser_Linux_i386.tar.gz
87+
3349254563781493938c15ea94351e542b32932bfddaff587c5a0bae65e40c94 goreleaser_Darwin_arm64.tar.gz
88+
41b3c5c26a53c2141fdc197053286a1b0797de793d37af8b82b207c5b2eca69d goreleaser_Linux_x86_64.tar.gz.sbom
89+
41d9dd50223cedc9bc551834ebd96b38f7e22b3d5c59b5a7fbbbc2d89fe439b3 goreleaser_Darwin_all.tar.gz
90+
4a174977fd538609d2771236328997ca32b53435c8768f622d449c1eba0194cd goreleaser_Darwin_all.tar.gz.sbom
91+
4ec0506fbbc4236422949b6adc55257c408025a49229b4e9854a762d879b48b4 goreleaser_Windows_armv7.zip
92+
5589cbdb77708a4327934cd3ed069c65cd97f3e11d5435c2ec385c0e4e8c520a goreleaser-1.7.0.armv7hl.rpm
93+
6a8627d0ce0046c05f78bda3361122c9804596a3a5b7c329fe21ab14ac9e5928 goreleaser_Windows_i386.zip
94+
6b97640714cb7a5ed8790cc6b0b8b0a3a69fe9ef5b47492c6a0736e72ef02ca5 goreleaser_Linux_arm64.tar.gz.sbom
95+
7463890cc6e14bf06201353480b25d97b51b029686af123d4f39d6288fe4e030 goreleaser_1.7.0_x86.apk
96+
80419d5f5ac6a281c8328084030dd2dc8158106cc4d697d408a700464bc1f1db goreleaser_Linux_armv7.tar.gz
97+
8618a9497706fa694876c0899182769d5960b75171fa7fb500721f12768b8d33 goreleaser_Linux_armv7.tar.gz.sbom
98+
8a438f7d6b41da2f5f8b85096108ec7895667861664861d27c05a5eccf875557 goreleaser_Darwin_x86_64.tar.gz.sbom
99+
8a61178e6d1b086bd52f7113cb563cdacf63ff370c7a1ce22b25e9c8f6efdf89 goreleaser_Windows_arm64.zip.sbom
100+
8a97bdcd530ae193b61d831d810424428f9e32ccb94d2880ed63e7540af25bcb goreleaser_Darwin_arm64.tar.gz.sbom
101+
8be69f369d8cd80aedbcfb39ba0af8fbb71fa86ee5879e0fcd94075cf17f73a2 goreleaser_Linux_arm64.tar.gz
102+
90799f88fc03d5dcd3d4d451a0b5f720bea2805f68c7b0a989510afa9afa33db goreleaser_1.7.0_i386.deb
103+
9ca9e977ea18c2a2b7083a73eb8e53355796496b10f2b709f6a12cec467b10ef goreleaser_Windows_arm64.zip
104+
ace1cc3b9b36f74c629adda635f149fcfda7f64599944522279972db150c9431 goreleaser_1.7.0_armhf.deb
105+
aebb22ab32ddc36002caf3362e2410f1a1487ab098c1f1ac6f5aae59f13f498b goreleaser_Darwin_x86_64.tar.gz
106+
b8bde58f99efa920a908d30100dd1832f8710114bb92d0985a26eae4c7454a32 goreleaser_1.7.0_x86_64.apk
107+
be17f26131a58c8a12c6320e325a964096cbb7464923ae961f17b20ca053b621 goreleaser-1.7.0.x86_64.rpm
108+
c7f3946d8ae6afa2238a0fb359d96ad6bbc3e062fbf5eee7baa9e11de361909d goreleaser_Windows_x86_64.zip.sbom
109+
c8c05b0221c569f7e5a5307d9fc8dfc7b1cb59f311f5869daacf950a679a3ec9 goreleaser_1.7.0_aarch64.apk
110+
cde27bf11fecf5ecc4a0388d62af261529c13772f6e910e5ad6ee082b5c2e013 goreleaser_1.7.0_arm64.deb
111+
d71a6d2a8b62384a20ebcec7ef7454010a49f8cbd525434696e15deec9b0f075 goreleaser_1.7.0_armv7.apk
112+
e74934e7571991522324642ac7b032310f04baf192ce2a54db1dc323b97bcd7d goreleaser_Linux_x86_64.tar.gz
113+
e958990644c0aa06cfdb27aa6f0373497dd87e1cc189f4824db73e20ef2c8482 goreleaser-1.7.0.i386.rpm
114+
faba167e6d3eed6d7cc45b58fefc711b7eef2da7bd21e0ad66eb4f4bccc1ba1f goreleaser_Linux_i386.tar.gz.sbom
115+
fdd5ca7cb052b86aff738ff89f5338ab16b7049c8fd02a74a56b01713e3e786b goreleaser_Windows_x86_64.zip
116+
fe581c9442b4d430195aa7da958572ee4f6493b6c4c7b0b241933a3a13f751ed goreleaser_1.7.0_amd64.deb
117+
certificate: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURDekNDQXBHZ0F3SUJBZ0lVQU8yWjh0VmxWSkxTRHo0TGM4S0VibDd6NnVBd0NnWUlLb1pJemowRUF3TXcKS2pFVk1CTUdBMVVFQ2hNTWMybG5jM1J2Y21VdVpHVjJNUkV3RHdZRFZRUURFd2h6YVdkemRHOXlaVEFlRncweQpNakF6TWpFd01ERXpNRFZhRncweU1qQXpNakV3TURJek1EUmFNQUF3V1RBVEJnY3Foa2pPUFFJQkJnZ3Foa2pPClBRTUJCd05DQUFSL3dXVXI2eXY1emtCcGJYSm9KT1NVZXQ3Wmhlb0l0U2ZNYSsxZWZmMnhydGhUWndjeFhEWlkKaVFqclp6azhUMVA2RERpVDN6UjRHSy8zMWdNNDNVV1lvNElCdlRDQ0Fia3dEZ1lEVlIwUEFRSC9CQVFEQWdlQQpNQk1HQTFVZEpRUU1NQW9HQ0NzR0FRVUZCd01ETUF3R0ExVWRFd0VCL3dRQ01BQXdIUVlEVlIwT0JCWUVGQ1QvClAwTk5PRm14OFpWMG9HdUMyd0tDMGFnK01COEdBMVVkSXdRWU1CYUFGRmpBSGwrUlJhVm1xWHJNa0tHVEl0QXEKeGNYNk1HTUdBMVVkRVFFQi93UlpNRmVHVldoMGRIQnpPaTh2WjJsMGFIVmlMbU52YlM5bmIzSmxiR1ZoYzJWeQpMMmR2Y21Wc1pXRnpaWEl2TG1kcGRHaDFZaTkzYjNKclpteHZkM012WW5WcGJHUXVlVzFzUUhKbFpuTXZkR0ZuCmN5OTJNUzQzTGpBd0l3WUtLd1lCQkFHRHZ6QUJCUVFWWjI5eVpXeGxZWE5sY2k5bmIzSmxiR1ZoYzJWeU1CSUcKQ2lzR0FRUUJnNzh3QVFJRUJIQjFjMmd3T1FZS0t3WUJCQUdEdnpBQkFRUXJhSFIwY0hNNkx5OTBiMnRsYmk1aApZM1JwYjI1ekxtZHBkR2gxWW5WelpYSmpiMjUwWlc1MExtTnZiVEFUQmdvckJnRUVBWU8vTUFFRUJBVmlkV2xzClpEQTJCZ29yQmdFRUFZTy9NQUVEQkNnM05qY3haR0ZpTWpreE5EZ3pZakkzTXpObE9EY3hZV0ptWmpNM09XUXcKTjJVM05HUm1ZelpqTUI0R0Npc0dBUVFCZzc4d0FRWUVFSEpsWm5NdmRHRm5jeTkyTVM0M0xqQXdDZ1lJS29aSQp6ajBFQXdNRGFBQXdaUUl4QUtDelNDVzZQclNuZjVsZmtHdkV2Zi9NLy8xY3QwWWZwZHRFOVV0SDZMTkdmVlhHCkMrNFd0LzBLMTNTMHZ4OHF4d0l3US9Zd0N4dmMrSWptQnl1WTdiQk9mZXc3NE9ZcTZjVzVEU3J1WmpqSG5MeXQKRzJRSDh4emE2SUY3LzI0eW1mQ08KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
118+
signature: MEYCIQCeX4Qsyh6Z290kSAIPdNISZzj5G2BBlt4W0ODD+o9RDQIhAKBNAT+6FubSywqhiTh0yY405BM9hO+gbZMephJVFSwp
56119
name: goreleaser
57120
overlay:
58121
Arch:
59122
amd64: x86_64
60123
OS:
61124
darwin: Darwin
62125
linux: Linux
63-
url: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/{{ .Name }}_{{ .OS }}_{{ .Arch }}.tar.gz
126+
paths:
127+
base: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/
128+
checksums:
129+
artifact: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/checksums.txt
130+
certificate: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/checksums.txt.pem
131+
signature: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/checksums.txt.sig
132+
target: '{{ .Name }}_{{ .OS }}_{{ .Arch }}.tar.gz'
64133
version: 1.7.0
65-
- checksum: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/{{ .Name }}_checksums.txt
66-
checksums:
67-
cosign-darwin-amd64:
68-
archive: fcff17a94fb8a5098c9b9b623e2e190cc4d3c47c4f5e8dbf75b72a56a874b219
69-
binary: fcff17a94fb8a5098c9b9b623e2e190cc4d3c47c4f5e8dbf75b72a56a874b219
70-
cosign-darwin-arm64:
71-
archive: e59fb49a3cc03adbb81dbd2f5cd6206fe09479cdbb7426cdd1b22aaf9145bbbc
72-
binary: e59fb49a3cc03adbb81dbd2f5cd6206fe09479cdbb7426cdd1b22aaf9145bbbc
73-
cosign-linux-amd64:
74-
archive: b62ac8c1ab1cdb072d442d2f3db7d7ffe977566a6170cd03dd48e4583dad3203
75-
binary: b62ac8c1ab1cdb072d442d2f3db7d7ffe977566a6170cd03dd48e4583dad3203
76-
cosign-linux-arm64:
77-
archive: 5f1c8bb2b30c75fb1c72c266b08d9cfc517ddb8b632e35627fd63aaf09e8f1bd
78-
binary: 5f1c8bb2b30c75fb1c72c266b08d9cfc517ddb8b632e35627fd63aaf09e8f1bd
79-
name: cosign
80-
url: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/{{ .Name }}-{{ .OS }}-{{ .Arch }}
81-
version: 1.6.0
82-
updated: "2022-04-10T17:39:53.602314607Z"
134+
updated: "2022-04-12T02:00:56.898866398Z"

.github/workflows/go.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
tests:
1515
- unit
1616
- integration
17+
- functional
1718
steps:
1819
- uses: actions/checkout@v2
1920

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ bin/*
2020
tmp/*
2121
!tmp/.keep
2222
.direnv
23+
tmp/*
24+
!tmp/.keep
2325
dist/

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su
77
# Defaults to first found in PATH
88
GO?=go
99

10+
11+
#########
12+
# BUILD #
13+
#########
14+
1015
# TODO: download from latest release
1116
bin/bindl:
1217
${GO} build -o bin/bindl -trimpath ./cmd/bindl
@@ -21,6 +26,48 @@ bin/bindl-dev: bin/goreleaser
2126

2227
include Makefile.*
2328

29+
.PHONY: program/bootstrap/cosign-lock.yaml
30+
program/bootstrap/cosign-lock.yaml: bin/bindl
31+
bin/bindl sync \
32+
--config program/bootstrap/cosign.yaml \
33+
--lock program/bootstrap/cosign-lock.yaml
34+
35+
36+
#########
37+
# TESTS #
38+
#########
39+
40+
program/testdata/myprogram.tar.gz:
41+
@./program/testdata/generate.sh
42+
43+
.PHONY: testdata
44+
testdata: program/testdata/myprogram.tar.gz
45+
46+
.PHONY: test/unit
47+
test/unit: testdata
48+
${GO} test -race -short -v ./...
49+
50+
.PHONY: test/integration
51+
test/integration:
52+
${GO} test -race -run ".*[Ii]ntegration.*" -v ./...
53+
54+
# Manually build bindl and then download cosign because Makefile
55+
# would not understand the dependency without bin/bindl existing.
56+
.PHONY: test/functional
57+
test/functional:
58+
${MAKE} bin/bindl
59+
${MAKE} bin/cosign
60+
PATH=${PWD}/bin:${PATH} ${GO} test -race -run ".*[Ff]unctional.*" -v ./...
61+
62+
.PHONY: test/all
63+
test/all:
64+
${GO} test -race -v ./...
65+
66+
67+
###########
68+
# LINTERS #
69+
###########
70+
2471
.PHONY: license
2572
license: bin/addlicense
2673
bin/addlicense \

Makefile.tests

Lines changed: 0 additions & 17 deletions
This file was deleted.

bindl.yaml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,50 @@ platforms:
88

99
_uname: &uname
1010
OS: &uname_OS
11-
linux: "Linux"
12-
darwin: "Darwin"
11+
linux: Linux
12+
darwin: Darwin
1313
Arch: &uname_Arch
14-
amd64: "x86_64"
14+
amd64: x86_64
1515

1616
programs:
1717
- name: cosign
18-
version: 1.6.0
18+
version: 1.7.1
1919
provider: url
20-
path: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/{{ .Name }}-{{ .OS }}-{{ .Arch }}
21-
checksums:
22-
_src: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/{{ .Name }}_checksums.txt
20+
paths:
21+
base: https://github.com/sigstore/cosign/releases/download/v{{ .Version }}/
22+
target: "{{ .Name }}-{{ .OS }}-{{ .Arch }}"
23+
checksums:
24+
artifact: "{{ .Name }}_checksums.txt"
2325
- name: addlicense
2426
version: 1.0.0
2527
provider: url
26-
path: https://github.com/google/addlicense/releases/download/v{{ .Version }}/{{ .Name }}_{{ .Version }}_{{ .OS }}_{{ .Arch }}.tar.gz
2728
overlay:
2829
OS:
2930
<<: *uname_OS
30-
darwin: "macOS"
31+
darwin: macOS
3132
Arch: *uname_Arch
32-
checksums:
33-
_src: https://github.com/google/addlicense/releases/download/v{{ .Version }}/checksums.txt
33+
paths:
34+
base: https://github.com/google/addlicense/releases/download/v{{ .Version }}
35+
target: "{{ .Name }}_{{ .Version }}_{{ .OS }}_{{ .Arch }}.tar.gz"
36+
checksums:
37+
artifact: checksums.txt
3438
- name: goreleaser
3539
version: 1.7.0
3640
provider: url
37-
path: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/{{ .Name }}_{{ .OS }}_{{ .Arch }}.tar.gz
3841
overlay: *uname
39-
checksums:
40-
_src: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}/checksums.txt
42+
paths:
43+
base: https://github.com/goreleaser/goreleaser/releases/download/v{{ .Version }}
44+
target: "{{ .Name }}_{{ .OS }}_{{ .Arch }}.tar.gz"
45+
checksums:
46+
artifact: checksums.txt
47+
certificate: checksums.txt.pem
48+
signature: checksums.txt.sig
4149
- name: golangci-lint
4250
# LINT: Match with version in .golangci.yaml and .github/workflows/go.yaml
4351
version: 1.45.2
4452
provider: url
45-
path: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/{{ .Name }}-{{ .Version }}-{{ .OS }}-{{ .Arch }}.tar.gz
46-
checksums:
47-
_src: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}/{{ .Name }}-{{ .Version }}-checksums.txt
53+
paths:
54+
base: https://github.com/golangci/golangci-lint/releases/download/v{{ .Version }}
55+
target: "{{ .Name }}-{{ .Version }}-{{ .OS }}-{{ .Arch }}.tar.gz"
56+
checksums:
57+
artifact: "{{ .Name }}-{{ .Version }}-checksums.txt"

command/cli/get.go

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,37 @@
1515
package cli
1616

1717
import (
18+
"context"
19+
"fmt"
20+
1821
"github.com/spf13/cobra"
1922

2023
"github.com/bindl-dev/bindl/command"
24+
"github.com/bindl-dev/bindl/config"
2125
"github.com/bindl-dev/bindl/internal"
26+
"github.com/bindl-dev/bindl/program/bootstrap"
2227
)
2328

29+
var bindlGetBootstrap = false
30+
31+
func init() {
32+
BindlGet.Flags().BoolVar(&bindlGetBootstrap, "bootstrap", bindlGetBootstrap, "get bootstrapped program")
33+
}
34+
2435
var BindlGet = &cobra.Command{
2536
Use: "get [name, ...]",
2637
Short: "Get local copy of program",
2738
Long: `Get downloads the names program, which must already exist in bindl.yaml,
28-
and ensures the program is ready to be used by setting executable flag.
39+
and ensures the program is ready to be used by setting executable flag. If no
40+
program name is specified through args, then all programs in lockfile will be selected.
2941
30-
If no program name is specified through args, then all programs in lockfile
31-
will be selected.`,
42+
While it is unlikely for end-user to need it, the flag --bootstrap is provided to download
43+
internally trusted program. Bootstrap mode uses pre-defined values of program validations
44+
at compile time. In bootstrap mode, program name must be specified in args.`,
3245
RunE: func(cmd *cobra.Command, names []string) error {
46+
if bindlGetBootstrap {
47+
return getBootstrap(cmd.Context(), names)
48+
}
3349
err := command.IterateLockfilePrograms(
3450
cmd.Context(),
3551
conf,
@@ -41,3 +57,31 @@ will be selected.`,
4157
return err
4258
},
4359
}
60+
61+
func getBootstrap(ctx context.Context, names []string) error {
62+
if len(names) < 1 {
63+
return fmt.Errorf("bootstrap mode requires program name to be specified")
64+
}
65+
66+
for _, name := range names {
67+
manifest, err := bootstrap.Lock(name)
68+
if err != nil {
69+
return err
70+
}
71+
lock, err := config.ParseLockBytes(manifest)
72+
if err != nil {
73+
return err
74+
}
75+
if len(lock.Programs) == 0 {
76+
return fmt.Errorf("no programs were found in the bootstrap manifest for %v, please report this bug", name)
77+
}
78+
if len(lock.Programs) > 1 {
79+
return fmt.Errorf("multiple programs were found in the bootstrap manifest for %v, please report this bug", name)
80+
}
81+
if err := command.Get(ctx, conf, lock.Programs[0]); err != nil {
82+
return err
83+
}
84+
internal.Log().Info().Str("program", name).Msg("bootstrap successful")
85+
}
86+
return nil
87+
}

command/make.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ BINDL_PROGRAMS_PATH?=$(addprefix bin/,$(BINDL_PROGRAMS))
3838
{{ .BinDir }}/bindl sync
3939
4040
# On the other hand, lockfile is a regular pre-requisite where we would like for
41-
# programs to be re-validated if lockfile was modified, in case the versions have changed
41+
# programs to be re-validated if lockfile was modified, in case the versions have changed.
4242
$(BINDL_PROGRAMS_PATH): {{ .Lockfile }} | {{ .BinDir }}/bindl
4343
{{ .BinDir }}/bindl get $(@F)
4444
`

0 commit comments

Comments
 (0)