-
Notifications
You must be signed in to change notification settings - Fork 14
/
output.go
51 lines (40 loc) · 1.14 KB
/
output.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
41
42
43
44
45
46
47
48
49
50
51
package engine
import (
"fmt"
"path"
"github.com/Microsoft/oe-engine/pkg/api"
)
// ArtifactWriter represents the object that writes artifacts
type ArtifactWriter struct {
}
// WriteTLSArtifacts saves TLS certificates and keys to the server filesystem
func (w *ArtifactWriter) WriteTLSArtifacts(oe *api.OpenEnclave, template, parameters, artifactsDir string, certsGenerated bool, parametersOnly bool) error {
if len(artifactsDir) == 0 {
artifactsDir = fmt.Sprintf("%s-%s", "oe", "00") //GenerateClusterID(oe.Properties))
artifactsDir = path.Join("_output", artifactsDir)
}
f := &FileSaver{}
// convert back the API object, and write it
var b []byte
var err error
if !parametersOnly {
apiloader := &api.Apiloader{}
b, err = apiloader.SerializeOpenEnclave(oe)
if err != nil {
return err
}
if e := f.SaveFile(artifactsDir, "apimodel.json", b); e != nil {
return e
}
if e := f.SaveFileString(artifactsDir, "azuredeploy.json", template); e != nil {
return e
}
}
if e := f.SaveFileString(artifactsDir, "azuredeploy.parameters.json", parameters); e != nil {
return e
}
if !certsGenerated {
return nil
}
return nil
}