-
Notifications
You must be signed in to change notification settings - Fork 88
/
appfile.go
40 lines (36 loc) · 1.38 KB
/
appfile.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
35
36
37
38
39
40
package helper
import (
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/app/types"
"github.com/replicatedhq/kots/pkg/kotsutil"
"github.com/replicatedhq/kots/pkg/render"
rendertypes "github.com/replicatedhq/kots/pkg/render/types"
"github.com/replicatedhq/kots/pkg/store"
)
// RenderAppFile renders a single file using the current sequence of the provided app, or the overrideSequence (if provided)
// it's here for now to avoid an import cycle between kotsadm/pkg/render and pkg/store
func RenderAppFile(a *types.App, overrideSequence *int64, inputContent []byte, kotsKinds *kotsutil.KotsKinds, namespace string) ([]byte, error) {
var sequence int64
if overrideSequence != nil {
sequence = *overrideSequence
} else {
latestSequence, err := store.GetStore().GetLatestAppSequence(a.GetID(), true)
if err != nil {
return nil, errors.Wrap(err, "failed to get latest app sequence")
}
sequence = latestSequence
}
registrySettings, err := store.GetStore().GetRegistryDetailsForApp(a.GetID())
if err != nil {
return nil, errors.Wrap(err, "failed to load registry settings")
}
return render.RenderFile(rendertypes.RenderFileOptions{
KotsKinds: kotsKinds,
RegistrySettings: registrySettings,
AppSlug: a.GetSlug(),
Sequence: sequence,
IsAirgap: a.GetIsAirgap(),
Namespace: namespace,
InputContent: []byte(inputContent),
})
}