@@ -11,10 +11,12 @@ router.post('/secrets/*', (req, resp) => {
11
11
url = url . split ( '/secrets' ) [ 1 ]
12
12
13
13
let environment = url . split ( '/' ) [ 1 ] ;
14
- let applicationName = url . split ( '/' ) [ 2 ] ;
14
+ let applicationName = ( url . split ( '/' ) [ 2 ] ) . split ( "?" ) [ 0 ] ;
15
15
console . debug ( "Environment : " + environment ) ;
16
16
console . debug ( "Application : " + applicationName ) ;
17
17
18
+ let option = req . query . option ;
19
+
18
20
let settings = readConfiguration ( ) ;
19
21
20
22
settings . filter ( setting => setting . environment === environment ) . map (
@@ -37,9 +39,40 @@ router.post('/secrets/*', (req, resp) => {
37
39
application => {
38
40
console . debug ( "Application name : " + application . name ) ;
39
41
console . debug ( "Application description : " + application . description ) ;
42
+
43
+ console . debug ( "Option: " + option ) ;
44
+
40
45
resp . statusCode = 200 ;
41
- resp . json ( application . secrets ) ;
42
- return ;
46
+ if ( option && option !== null ) {
47
+ if ( option === 'properties' ) {
48
+ console . debug ( "Generate Properties" ) ;
49
+ let result = "" ;
50
+ application . secrets . map ( secret => {
51
+ result += "#" + secret . description + "\n" ;
52
+ result += secret . key + "=" + secret . value + "\n\n" ;
53
+ } ) ;
54
+ resp . send ( result ) ;
55
+ } else if ( option === 'yaml' || option === 'yml' ) {
56
+ console . debug ( "Generate Yaml" ) ;
57
+ let result = "" ;
58
+ application . secrets . map ( secret => {
59
+ result += "#" + secret . description + "\n" ;
60
+ result += secret . key + ": " + secret . value + "\n\n" ;
61
+ } ) ;
62
+ resp . send ( result ) ;
63
+ return ;
64
+ } else {
65
+ console . debug ( "Generate Json" ) ;
66
+ resp . json ( application . secrets ) ;
67
+ return ;
68
+ }
69
+ } else {
70
+ console . debug ( "Generate Json" ) ;
71
+ resp . json ( application . secrets ) ;
72
+ return ;
73
+ }
74
+
75
+ return ;
43
76
}
44
77
) ;
45
78
}
0 commit comments