@@ -89,9 +89,10 @@ func loadSnapshot(dir, fpath string, ctx *cue.Context) (*Snapshot, error) {
89
89
90
90
// we probably want this to be closer to `cue def`
91
91
// with imports, schemas, and such... indep eval'able
92
- func writeSnapshot (dir , fname , message , pkgId string , V cue.Value ) error {
93
- ver := fmt .Sprintf ("ver_%s" , fname )
94
- msg := fmt .Sprintf ("msg_%s" , fname )
92
+ func writeSnapshot (dir , fname , suffix , message , pkgId string , V cue.Value ) error {
93
+ sname := fmt .Sprintf ("%s_%s" , fname , suffix )
94
+ ver := fmt .Sprintf ("ver_%s" , sname )
95
+ msg := fmt .Sprintf ("msg_%s" , sname )
95
96
96
97
err := V .Validate (cue .Concrete (true ))
97
98
if err != nil {
@@ -142,7 +143,7 @@ func writeSnapshot(dir, fname, message, pkgId string, V cue.Value) error {
142
143
143
144
// write file
144
145
str := string (bytes )
145
- fn := filepath .Join (dir , fmt .Sprintf ("%s.cue" , fname ))
146
+ fn := filepath .Join (dir , fmt .Sprintf ("%s.cue" , sname ))
146
147
err = os .WriteFile (fn , []byte (str ), 0666 )
147
148
if err != nil {
148
149
return err
@@ -153,27 +154,27 @@ func writeSnapshot(dir, fname, message, pkgId string, V cue.Value) error {
153
154
154
155
// MakeSnapshot creates a new snapshot for each history annotation in the Datamodel tree
155
156
func (dm * Datamodel ) MakeSnapshot (timestamp string , dflags flags.DatamodelPflagpole , cflags flags.Datamodel__CheckpointFlagpole ) error {
156
- err := dm .T .makeSnapshotR (timestamp , cflags .Message )
157
+ err := dm .T .makeSnapshotR (timestamp , cflags .Suffix , cflags . Message )
157
158
if err != nil {
158
159
return err
159
160
}
160
161
161
162
return nil
162
163
}
163
164
164
- func (V * Value ) makeSnapshotR (timestamp , message string ) error {
165
+ func (V * Value ) makeSnapshotR (timestamp , suffix , message string ) error {
165
166
166
167
// load own history
167
168
if V .Hof .Datamodel .History {
168
- err := V .makeSnapshot (timestamp , message )
169
+ err := V .makeSnapshot (timestamp , suffix , message )
169
170
if err != nil {
170
171
return err
171
172
}
172
173
}
173
174
174
175
// recurse if children to load any nested histories
175
176
for _ , c := range V .Children {
176
- err := c .T .makeSnapshotR (timestamp , message )
177
+ err := c .T .makeSnapshotR (timestamp , suffix , message )
177
178
if err != nil {
178
179
return err
179
180
}
@@ -182,7 +183,7 @@ func (V *Value) makeSnapshotR(timestamp, message string) error {
182
183
return nil
183
184
}
184
185
185
- func (V * Value ) makeSnapshot (timestamp , message string ) error {
186
+ func (V * Value ) makeSnapshot (timestamp , suffix , message string ) error {
186
187
187
188
// if no diff, no snapshot
188
189
if len (V .history ) > 0 && ! V .hasDiff () {
@@ -205,7 +206,7 @@ func (V *Value) makeSnapshot(timestamp, message string) error {
205
206
pkg = V .Hof .Metadata .Name
206
207
}
207
208
pkg = strings .Replace (pkg , "-" , "_" , - 1 )
208
- err = writeSnapshot (dir , timestamp , message , pkg , val )
209
+ err = writeSnapshot (dir , timestamp , suffix , message , pkg , val )
209
210
if err != nil {
210
211
return err
211
212
}
0 commit comments