@@ -83,9 +83,7 @@ func (c Config) ToIgn3_5Unvalidated(options common.TranslateOptions) (types.Conf
83
83
84
84
tr := translate .NewTranslator ("yaml" , "json" , options )
85
85
tr .AddCustomTranslator (translateIgnition )
86
- tr .AddCustomTranslator (translateFile )
87
- tr .AddCustomTranslator (translateDirectory )
88
- tr .AddCustomTranslator (translateLink )
86
+ tr .AddCustomTranslator (translateStorage )
89
87
tr .AddCustomTranslator (translateResource )
90
88
tr .AddCustomTranslator (translatePasswdUser )
91
89
tr .AddCustomTranslator (translateUnit )
@@ -99,7 +97,6 @@ func (c Config) ToIgn3_5Unvalidated(options common.TranslateOptions) (types.Conf
99
97
translate .MergeP (tr , tm , & r , "systemd" , & c .Systemd , & ret .Systemd )
100
98
101
99
c .addMountUnits (& ret , & tm )
102
-
103
100
tm2 , r2 := c .processTrees (& ret , options )
104
101
tm .Merge (tm2 )
105
102
r .Merge (r2 )
@@ -121,6 +118,64 @@ func translateIgnition(from Ignition, options common.TranslateOptions) (to types
121
118
return
122
119
}
123
120
121
+ func translateStorage (from Storage , options common.TranslateOptions ) (to types.Storage , tm translate.TranslationSet , r report.Report ) {
122
+ tr := translate .NewTranslator ("yaml" , "json" , options )
123
+ tr .AddCustomTranslator (translateFile )
124
+ tr .AddCustomTranslator (translateDirectory )
125
+ tr .AddCustomTranslator (translateLink )
126
+ tr .AddCustomTranslator (translateLuks )
127
+ tm , r = translate .Prefixed (tr , "directories" , & from .Directories , & to .Directories )
128
+ translate .MergeP (tr , tm , & r , "disks" , & from .Disks , & to .Disks )
129
+ translate .MergeP (tr , tm , & r , "files" , & from .Files , & to .Files )
130
+ translate .MergeP (tr , tm , & r , "filesystems" , & from .Filesystems , & to .Filesystems )
131
+ translate .MergeP (tr , tm , & r , "links" , & from .Links , & to .Links )
132
+ translate .MergeP (tr , tm , & r , "luks" , & from .Luks , & to .Luks )
133
+ translate .MergeP (tr , tm , & r , "raid" , & from .Raid , & to .Raid )
134
+ for _ , file := range from .Files {
135
+ if util .NotEmpty (file .Parent .Path ) {
136
+ c := path .New ("yaml" , "parent" )
137
+ parentDirectory := types.Directory {
138
+ Node : types.Node {
139
+ Path : * file .Parent .Path ,
140
+ Group : types.NodeGroup {ID : file .Group .ID , Name : file .Group .Name },
141
+ User : types.NodeUser {ID : file .User .ID , Name : file .User .Name },
142
+ },
143
+ DirectoryEmbedded1 : types.DirectoryEmbedded1 {
144
+ Mode : file .Parent .Mode ,
145
+ },
146
+ }
147
+ to .Directories = append (to .Directories , parentDirectory )
148
+ // find what is between parent and file path
149
+ theInBetween := strings .Replace (file .Path , * file .Parent .Path , "" , 1 )
150
+
151
+ workingDirectory := * file .Parent .Path
152
+ // render all directories between the filepath and the parent with the parent's mode
153
+ arrayDirectory := strings .Split (theInBetween , "/" )
154
+ for i := 0 ; i < len (arrayDirectory )- 1 ; i ++ {
155
+ dirTobeCreated := arrayDirectory [i ]
156
+ if dirTobeCreated == "" {
157
+ continue
158
+ }
159
+ workingDirectory += "/" + dirTobeCreated
160
+ directoryToBeRendered := types.Directory {
161
+ Node : types.Node {
162
+ Path : workingDirectory ,
163
+ Group : types.NodeGroup {ID : file .Group .ID , Name : file .Group .Name },
164
+ User : types.NodeUser {ID : file .User .ID , Name : file .User .Name },
165
+ },
166
+ DirectoryEmbedded1 : types.DirectoryEmbedded1 {
167
+ Mode : file .Parent .Mode ,
168
+ },
169
+ }
170
+ to .Directories = append (to .Directories , directoryToBeRendered )
171
+ }
172
+ tm .AddFromCommonSource (c , path .New ("json" , "directories" ), to .Directories )
173
+ }
174
+
175
+ }
176
+ return
177
+ }
178
+
124
179
func translateFile (from File , options common.TranslateOptions ) (to types.File , tm translate.TranslationSet , r report.Report ) {
125
180
tr := translate .NewTranslator ("yaml" , "json" , options )
126
181
tr .AddCustomTranslator (translateResource )
@@ -134,6 +189,15 @@ func translateFile(from File, options common.TranslateOptions) (to types.File, t
134
189
return
135
190
}
136
191
192
+ func translateLuks (from Luks , options common.TranslateOptions ) (to types.Luks , tm translate.TranslationSet , r report.Report ) {
193
+ tr := translate .NewTranslator ("yaml" , "json" , options )
194
+ tm , r = translate .Prefixed (tr , "clevis" , & from .Clevis , & to .Clevis )
195
+ translate .MergeP (tr , tm , & r , "device" , & from .Device , & to .Device )
196
+ translate .MergeP (tr , tm , & r , "name" , & from .Name , & to .Name )
197
+ translate .MergeP (tr , tm , & r , "wipe_volume" , & from .WipeVolume , & to .WipeVolume )
198
+ return
199
+ }
200
+
137
201
func translateResource (from Resource , options common.TranslateOptions ) (to types.Resource , tm translate.TranslationSet , r report.Report ) {
138
202
tr := translate .NewTranslator ("yaml" , "json" , options )
139
203
tm , r = translate .Prefixed (tr , "verification" , & from .Verification , & to .Verification )
0 commit comments