@@ -40,7 +40,10 @@ func RunWarp(ctx context.Context, l *slog.Logger, opts WarpOptions) error {
40
40
}
41
41
42
42
// create necessary file structures
43
- if err := makeDirs (); err != nil {
43
+ if err := os .MkdirAll (filepath .Join ("stuff" , "primary" ), os .ModePerm ); err != nil {
44
+ return err
45
+ }
46
+ if err := os .MkdirAll (filepath .Join ("stuff" , "secondary" ), os .ModePerm ); err != nil {
44
47
return err
45
48
}
46
49
l .Debug ("'primary' and 'secondary' directories are ready" )
@@ -208,43 +211,17 @@ func runWarpInWarp(ctx context.Context, l *slog.Logger, bind netip.AddrPort, end
208
211
209
212
func createPrimaryAndSecondaryIdentities (l * slog.Logger , license string ) error {
210
213
// make primary identity
211
- warp .UpdatePath ("./primary" )
212
- if ! warp .CheckProfileExists (license ) {
213
- err := warp .LoadOrCreateIdentity (l , license )
214
- if err != nil {
215
- return err
216
- }
217
- }
218
- // make secondary
219
- warp .UpdatePath ("./secondary" )
220
- if ! warp .CheckProfileExists (license ) {
221
- err := warp .LoadOrCreateIdentity (l , license )
222
- if err != nil {
223
- return err
224
- }
225
- }
226
- return nil
227
- }
228
-
229
- func makeDirs () error {
230
- stuffDir := "stuff"
231
- primaryDir := "primary"
232
- secondaryDir := "secondary"
233
-
234
- // Check if 'stuff' directory exists, if not create it
235
- if _ , err := os .Stat (stuffDir ); os .IsNotExist (err ) {
236
- if err := os .Mkdir (stuffDir , 0o755 ); err != nil {
237
- return fmt .Errorf ("error creating 'stuff' directory: %w" , err )
238
- }
214
+ err := warp .LoadOrCreateIdentity (l , "./primary" , license )
215
+ if err != nil {
216
+ l .Error ("couldn't load primary warp identity" )
217
+ return err
239
218
}
240
219
241
- // Create 'primary' and 'secondary' directories if they don't exist
242
- for _ , dir := range []string {primaryDir , secondaryDir } {
243
- if _ , err := os .Stat (filepath .Join (stuffDir , dir )); os .IsNotExist (err ) {
244
- if err := os .Mkdir (filepath .Join (stuffDir , dir ), 0o755 ); err != nil {
245
- return fmt .Errorf ("error creating '%s' directory: %w" , dir , err )
246
- }
247
- }
220
+ // make secondary
221
+ err = warp .LoadOrCreateIdentity (l , "./secondary" , license )
222
+ if err != nil {
223
+ l .Error ("couldn't load secondary warp identity" )
224
+ return err
248
225
}
249
226
250
227
return nil
0 commit comments