@@ -4,15 +4,16 @@ import (
4
4
"bytes"
5
5
"encoding/json"
6
6
"fmt"
7
- "github.com/openware/pkg/vault"
8
- sonic "github.com/openware/pkg/sonic/config"
9
7
"io/ioutil"
10
8
"log"
11
9
"net/http"
12
10
"net/url"
13
11
"path"
14
12
"time"
15
13
14
+ sonic "github.com/openware/pkg/sonic/config"
15
+ "github.com/openware/pkg/vault"
16
+
16
17
"github.com/gin-gonic/gin"
17
18
"github.com/openware/pkg/jwt"
18
19
"github.com/openware/pkg/mngapi/peatio"
@@ -62,22 +63,22 @@ func SetSecret(ctx *gin.Context) {
62
63
63
64
appName := ctx .Param ("component" )
64
65
65
- if err := vaultService .LoadSecrets (appName , params .Scope ); err != nil {
66
- log .Printf ("ERR: LoadSecrets : %s" , err )
66
+ if err := vaultService .Read (appName , params .Scope ); err != nil {
67
+ log .Printf ("ERR: Read : %s" , err )
67
68
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
68
69
return
69
70
}
70
71
71
- err = vaultService .SetSecret (appName , params .Key , params .Value , params .Scope )
72
+ err = vaultService .SetEntry (appName , params .Scope , params .Key , params .Value )
72
73
if err != nil {
73
- log .Printf ("ERR: SetSecret : %s" , err )
74
+ log .Printf ("ERR: SetEntry : %s" , err )
74
75
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
75
76
return
76
77
}
77
78
78
- err = vaultService .SaveSecrets (appName , params .Scope )
79
+ err = vaultService .Write (appName , params .Scope )
79
80
if err != nil {
80
- log .Printf ("ERR: SaveSecrets : %s" , err )
81
+ log .Printf ("ERR: Write : %s" , err )
81
82
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
82
83
return
83
84
}
@@ -108,15 +109,15 @@ func GetSecrets(ctx *gin.Context) {
108
109
result [app ] = make (map [string ]interface {})
109
110
110
111
for _ , scope := range scopes {
111
- if err := vaultService .LoadSecrets (app , scope ); err != nil {
112
+ if err := vaultService .Read (app , scope ); err != nil {
112
113
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
113
114
return
114
115
}
115
116
116
117
result [app ][scope ] = make (map [string ]interface {})
117
118
118
119
if scope == "secret" {
119
- secretsKeys , err := vaultService .ListSecrets (app , scope )
120
+ secretsKeys , err := vaultService .ListEntries (app , scope )
120
121
if err != nil {
121
122
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
122
123
return
@@ -126,7 +127,7 @@ func GetSecrets(ctx *gin.Context) {
126
127
result [app ][scope ].(map [string ]interface {})[key ] = "******"
127
128
}
128
129
} else {
129
- secrets , err := vaultService .GetSecrets (app , scope )
130
+ secrets , err := vaultService .GetEntries (app , scope )
130
131
if err != nil {
131
132
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
132
133
return
@@ -272,7 +273,6 @@ func updateMarkets(sc *SonicContext, engineID string) error {
272
273
return nil
273
274
}
274
275
275
-
276
276
// CreatePlatform to handler '/api/v2/admin/platforms/new'
277
277
func CreatePlatform (ctx * gin.Context , licenseCreator LicenseCreator , fetchConfig FetchConfigFunction ) gin.HandlerFunc {
278
278
return func (context * gin.Context ) {
@@ -374,18 +374,18 @@ func createPlatform(ctx *gin.Context, creator LicenseCreator, fetchConfig FetchC
374
374
scope := "private"
375
375
key := "platform_id"
376
376
// Load secret
377
- vaultService .LoadSecrets (app , scope )
377
+ vaultService .Read (app , scope )
378
378
379
379
// Set Platform ID to secret
380
- err = vaultService .SetSecret (app , key , platform .PID , scope )
380
+ err = vaultService .SetEntry (app , scope , key , platform .PID )
381
381
if err != nil {
382
382
log .Printf ("ERROR: Failed to store Platform ID in vault: %s" , err .Error ())
383
383
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
384
384
return
385
385
}
386
386
387
387
// Save secret to vault
388
- err = vaultService .SaveSecrets (app , scope )
388
+ err = vaultService .Write (app , scope )
389
389
if err != nil {
390
390
log .Printf ("ERROR: Failed to store secrets: %s" , err .Error ())
391
391
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : err .Error ()})
0 commit comments