-
Notifications
You must be signed in to change notification settings - Fork 8
/
charts.go
34 lines (29 loc) · 1.01 KB
/
charts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package helm
import (
"context"
"fmt"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"namespacelabs.dev/foundation/internal/artifacts"
"namespacelabs.dev/foundation/internal/artifacts/download"
"namespacelabs.dev/foundation/internal/bytestream"
"namespacelabs.dev/foundation/internal/compute"
"namespacelabs.dev/foundation/schema"
)
func Chart(repo, name, version string, digest schema.Digest) compute.Computable[*chart.Chart] {
d := download.URL(artifacts.Reference{
URL: fmt.Sprintf("%s/charts/%s-%s.tgz", repo, name, version),
Digest: digest,
})
return compute.Transform("load chart", d, func(ctx context.Context, b bytestream.ByteStream) (*chart.Chart, error) {
reader, err := b.Reader()
if err != nil {
return nil, err
}
defer reader.Close()
return loader.LoadArchive(reader)
})
}