@@ -23,12 +23,12 @@ var _ service.Service = &hvaultRemoteService{}
2323type hvaultRemoteService struct {
2424 * api.Client
2525
26- keyID string
27- debug bool
28- Address string `json:"Address "`
29- Transitkey string `json:"Transitkey "`
30- Vaultrole string `json:"Vaultrole "`
31- Namespace string `json:"Namespace "`
26+ // keyID string
27+ Debug bool
28+ Namespace string `json:"namespace "`
29+ Transitkey string `json:"transitkey "`
30+ Vaultrole string `json:"vaultrole "`
31+ Address string `json:"address "`
3232}
3333
3434func NewVaultClientRemoteService (configFilePath string , debug bool ) (service.Service , error ) {
@@ -45,20 +45,29 @@ func NewVaultClientRemoteService(configFilePath string, debug bool) (service.Ser
4545 log .Println ("DEBUG: verifying keyID:" , keyID )
4646 }
4747
48- vaultService := & hvaultRemoteService {
49- keyID : keyID ,
50- debug : debug ,
51- }
48+ // vaultService := &hvaultRemoteService{
49+ // // keyID: keyID,
50+ // Debug : debug,
51+ // }
5252
53+ vaultService := & hvaultRemoteService {}
54+ vaultService .Debug = debug
5355 json .Unmarshal (([]byte (ctx )), & vaultService )
56+
5457 vaultconfig := api .DefaultConfig ()
5558 vaultconfig .Address = vaultService .Address
5659
5760 keypath := fmt .Sprintf ("transit/keys/%s" , vaultService .Transitkey )
5861
5962 if debug {
6063 log .Println ("DEBUG:--------------------------------------------------" )
61- log .Println ("DEBUG: unmarshal JSON values:" , "\n -> vaultService.Address:" , vaultService .Address , "\n -> vaultService.Trasitkey:" , vaultService .Transitkey , "\n -> vaultService.Vaultrole:" , vaultService .Vaultrole , "\n -> vaultService.Namespace:" , vaultService .Namespace , "\n -> keypath:" , keypath )
64+ log .Println ("DEBUG: unmarshal JSON values:" ,
65+ "\n -> vaultService.debug" , vaultService .Debug ,
66+ "\n -> vaultService.Address:" , vaultService .Address ,
67+ "\n -> vaultService.Transitkey:" , vaultService .Transitkey ,
68+ "\n -> vaultService.Vaultrole:" , vaultService .Vaultrole ,
69+ "\n -> vaultService.Namespace:" , vaultService .Namespace ,
70+ "\n -> keypath:" , keypath )
6271 }
6372
6473 client , err := api .NewClient (vaultconfig )
@@ -92,9 +101,10 @@ func NewVaultClientRemoteService(configFilePath string, debug bool) (service.Ser
92101 log .Fatalln ("EXIT:authInfo: no kubernetes auth info was returned after login" )
93102 }
94103
95- vaultService = & hvaultRemoteService {
96- Client : client ,
97- }
104+ // vaultService = &hvaultRemoteService{
105+ // Client: client,
106+ // }
107+ vaultService .Client = client
98108
99109 client .SetNamespace (vaultService .Namespace )
100110
@@ -115,12 +125,20 @@ func NewVaultClientRemoteService(configFilePath string, debug bool) (service.Ser
115125
116126func (s * hvaultRemoteService ) Encrypt (ctx context.Context , uid string , plaintext []byte ) (* service.EncryptResponse , error ) {
117127
118- if s .debug {
128+ if s .Debug {
119129 log .Println ("DEBUG:--------------------------------------------------" )
120130 log .Println ("DEBUG: unencrypted payload:" , string ([]byte (plaintext )))
121131 log .Println ("DEBUG:--------------------------------------------------" )
122132 }
123133
134+ log .Println ("DEBUG:--------------------------------------------------" )
135+ log .Println ("DEBUG: unmarshal JSON values:" ,
136+ "\n -> vaultService.debug" , s .Debug ,
137+ "\n -> vaultService.Address:" , s .Address ,
138+ "\n -> vaultService.Transitkey:" , s .Transitkey ,
139+ "\n -> vaultService.Vaultrole:" , s .Vaultrole ,
140+ "\n -> vaultService.Namespace:" , s .Namespace )
141+
124142 enckeypath := fmt .Sprintf ("transit/encrypt/%s" , s .Transitkey )
125143 // keypath := "transit/encrypt/kleidi"
126144 encodepayload := map [string ]interface {}{
@@ -130,7 +148,11 @@ func (s *hvaultRemoteService) Encrypt(ctx context.Context, uid string, plaintext
130148 encrypt , err := s .Logical ().WriteWithContext (ctx , enckeypath , encodepayload )
131149 if err != nil {
132150 log .Println ("--------------------------------------------------------" )
133- log .Println ("DEBUG:encrypt:" , "\n plaintext:" , string ([]byte (plaintext )), "\n keypath:" , enckeypath , "\n encodepayload:" , encodepayload )
151+ log .Println ("DEBUG:encrypt:" ,
152+ "\n debug:" , s .Debug ,
153+ "\n plaintext:" , string ([]byte (plaintext )),
154+ "\n keypath:" , enckeypath ,
155+ "\n encodepayload:" , encodepayload )
134156 log .Println ("--------------------------------------------------------" )
135157 log .Fatalln ("EXIT:encrypt: with error:\n " , err .Error ())
136158 }
0 commit comments