Skip to content

Commit 7cf30ad

Browse files
committed
cleanup: update files, docs
Signed-off-by: K.B.Dharun Krishna <[email protected]>
1 parent 0db9f03 commit 7cf30ad

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
core/plugins.go
2+
downloads/*
23
example/downloads/*
34
example/sources/*
5+
sources/*
46
test/*
57
build
68
docs/website/dist/*
79
docs/website/node_modules/*
10+
Containerfile
811
go.work
12+
recipe.yml
913
*~

api/download.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,27 @@ func checksumValidation(source Source, path string) error {
217217
if len(strings.TrimSpace(source.Checksum)) == 0 {
218218
return nil
219219
}
220+
220221
// Open the file
221222
file, err := os.Open(path)
222223
if err != nil {
223-
return err
224+
return fmt.Errorf("could not open file: %v", err)
224225
}
226+
225227
// Close the file when the function ends
226228
defer file.Close()
229+
227230
// Calculate the checksum
228231
checksum := sha256.New()
229232
_, err = io.Copy(checksum, file)
230233
if err != nil {
231-
return fmt.Errorf("could not calculate tar file checksum")
234+
return fmt.Errorf("could not calculate checksum: %v", err)
232235
}
233236

234-
// Validate the checksum
235-
if fmt.Sprintf("%x", checksum.Sum(nil)) != source.Checksum {
236-
return fmt.Errorf("tar file checksum doesn't match")
237+
// Validate the checksum based on source type
238+
calculatedChecksum := fmt.Sprintf("%x", checksum.Sum(nil))
239+
if (source.Type == "tar" || source.Type == "file") && calculatedChecksum != source.Checksum {
240+
return fmt.Errorf("%s source module checksum doesn't match: expected %s, got %s", source.Type, source.Checksum, calculatedChecksum)
237241
}
238242

239243
return nil

docs/articles/en/use-modules.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ You will find that some modules have a common `source` field, this instructs Vib
5757
- chmod +x /usr/bin/cur-gpu
5858
```
5959
60-
In the above example we define a `shell` module that downloads a tarball from a GitHub release and then copies the binaries to `/usr/bin`. A source can be of two types:
60+
In the above example we define a `shell` module that downloads a tarball from a GitHub release and then copies the binaries to `/usr/bin`. A source can be of three types:
6161

62-
- `tar`: a tarball archive. It can also define a `Checksum` field to verify the integrity of the downloaded file using a `sha256` hash.
62+
- `tar`: a tarball archive. You can also define a `checksum` field to verify the integrity of the downloaded archive using a `sha256` hash.
63+
- `file`: a single file. You can also define a `checksum` field to verify the integrity of the downloaded file using a `sha256` hash.
6364
- `git`: a Git repository.
6465

6566
In the latter case, you can specify the branch, tag or commit to checkout like this:
@@ -85,6 +86,7 @@ modules:
8586

8687
Supported fields for a git source are:
8788

89+
- `url`: the address of the repository to clone
8890
- `tag`: the tag to checkout, collides with `branch` and `commit`.
8991
- `branch`: the branch to checkout, collides with `tag`.
9092
- `commit`: the commit to checkout, collides with `tag` and `branch`. It can be a commit hash or `latest` to checkout the latest commit.

docs/website/src/index.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ stages:
8484
args:
8585
DEBIAN_FRONTEND: noninteractive
8686
runs:
87-
- echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommends
87+
commands:
88+
- echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommends
8889
modules:
8990
- name: update
9091
type: shell

0 commit comments

Comments
 (0)