-
Notifications
You must be signed in to change notification settings - Fork 88
/
appfile.go
37 lines (33 loc) · 1.34 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
package helper
import (
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/app/types"
"github.com/replicatedhq/kots/pkg/kotsutil"
registrytypes "github.com/replicatedhq/kots/pkg/registry/types"
"github.com/replicatedhq/kots/pkg/render"
"github.com/replicatedhq/kots/pkg/store"
"github.com/replicatedhq/kots/pkg/util"
)
// 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.AppType, 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
}
var registrySettings registrytypes.RegistrySettings
if !util.IsHelmManaged() {
s, err := store.GetStore().GetRegistryDetailsForApp(a.GetID())
if err != nil {
return nil, errors.Wrap(err, "failed to load registry settings")
}
registrySettings = s
}
return render.RenderFile(kotsKinds, registrySettings, a.GetSlug(), sequence, a.GetIsAirgap(), namespace, inputContent)
}