@@ -6,6 +6,11 @@ import (
66 "bytes"
77 "encoding/csv"
88 "fmt"
9+ "os"
10+ "sort"
11+ "strings"
12+ "time"
13+
914 _ "github.com/APIParkLab/APIPark/resources/access"
1015 _ "github.com/APIParkLab/APIPark/resources/permit"
1116 _ "github.com/APIParkLab/APIPark/resources/plugin"
@@ -14,19 +19,15 @@ import (
1419 "github.com/eolinker/go-common/permit"
1520 "github.com/eolinker/go-common/pm3"
1621 "github.com/eolinker/go-common/utils"
17- "os"
18- "sort"
19- "strings"
20- "time"
2122)
2223
2324const unsetValue = "-"
2425
2526func doCheck () {
2627 accessConf , unset := loadAccess ()
27-
28+
2829 drivers := pm3 .List ()
29-
30+
3031 newAccess := 0
3132 for _ , p := range drivers {
3233 if ac , ok := p .(pm3.AccessConfig ); ok {
@@ -39,9 +40,9 @@ func doCheck() {
3940 }
4041 }
4142 }
42-
43+
4344 }
44-
45+
4546 }
4647 for asKey := range permit .All () {
4748 key := strings .ToLower (asKey )
@@ -53,12 +54,11 @@ func doCheck() {
5354 if newAccess > 0 || unset > 0 {
5455 f := accessFile ()
5556 fmt .Printf ("%d access need set, see : %s and %s" , newAccess + unset , saveTemplate (accessConf , f ), saveCsv (accessConf , f ))
56-
5757 }
5858 os .Exit (0 )
5959}
6060func accessFile () string {
61-
61+
6262 if version == "" {
6363 return time .Now ().Format ("20060102-150405" )
6464 }
@@ -84,7 +84,7 @@ func saveCsv(as map[string]*Access, key string) string {
8484 err = os .WriteFile (filePath , buf .Bytes (), 0666 )
8585 if err != nil {
8686 log .Fatal (err )
87-
87+
8888 }
8989 return filePath
9090}
@@ -111,9 +111,9 @@ func (ls AccessListSort) Swap(i, j int) {
111111
112112func saveTemplate (as map [string ]* Access , key string ) string {
113113 out := make (map [string ][]access.Access )
114-
114+
115115 for _ , a := range as {
116-
116+
117117 out [a .Group ] = append (out [a .Group ], access.Access {
118118 Name : a .Name ,
119119 CName : a .Cname ,
@@ -130,7 +130,7 @@ func saveTemplate(as map[string]*Access, key string) string {
130130 err = os .WriteFile (filePath , buf .Bytes (), 0666 )
131131 if err != nil {
132132 log .Fatal (err )
133-
133+
134134 }
135135 return filePath
136136}
0 commit comments