Skip to content

Commit 21405f2

Browse files
committed
move vault ui page into extension
1 parent e9dee91 commit 21405f2

File tree

8 files changed

+1803
-1922
lines changed

8 files changed

+1803
-1922
lines changed

cmd/mock.go

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,94 +17,94 @@ limitations under the License.
1717
package cmd
1818

1919
import (
20-
"fmt"
21-
"net"
22-
"os"
23-
"os/signal"
24-
"syscall"
25-
26-
"github.com/linuxsuren/api-testing/pkg/mock"
27-
"github.com/spf13/cobra"
20+
"fmt"
21+
"net"
22+
"os"
23+
"os/signal"
24+
"syscall"
25+
26+
"github.com/linuxsuren/api-testing/pkg/mock"
27+
"github.com/spf13/cobra"
2828
)
2929

3030
type mockOption struct {
31-
port int
32-
prefix string
33-
metrics bool
34-
tls bool
35-
tlsCert string
36-
tlsKey string
31+
port int
32+
prefix string
33+
metrics bool
34+
tls bool
35+
tlsCert string
36+
tlsKey string
3737
}
3838

3939
func createMockCmd() (c *cobra.Command) {
40-
opt := &mockOption{}
41-
42-
c = &cobra.Command{
43-
Use: "mock",
44-
Short: "Start a mock server",
45-
Args: cobra.ExactArgs(1),
46-
RunE: opt.runE,
47-
}
48-
49-
flags := c.Flags()
50-
flags.IntVarP(&opt.port, "port", "", 6060, "The mock server port")
51-
flags.StringVarP(&opt.prefix, "prefix", "", "/mock", "The mock server API prefix")
52-
flags.BoolVarP(&opt.metrics, "metrics", "m", true, "Enable request metrics collection")
53-
flags.BoolVarP(&opt.tls, "tls", "", false, "Enable TLS mode. Set to true to enable TLS. Alow SAN certificates")
54-
flags.StringVarP(&opt.tlsCert, "cert-file", "", "", "The path to the certificate file, Alow SAN certificates")
55-
flags.StringVarP(&opt.tlsKey, "key-file", "", "", "The path to the key file, Alow SAN certificates")
56-
return
40+
opt := &mockOption{}
41+
42+
c = &cobra.Command{
43+
Use: "mock",
44+
Short: "Start a mock server",
45+
Args: cobra.ExactArgs(1),
46+
RunE: opt.runE,
47+
}
48+
49+
flags := c.Flags()
50+
flags.IntVarP(&opt.port, "port", "", 6060, "The mock server port")
51+
flags.StringVarP(&opt.prefix, "prefix", "", "/mock", "The mock server API prefix")
52+
flags.BoolVarP(&opt.metrics, "metrics", "m", true, "Enable request metrics collection")
53+
flags.BoolVarP(&opt.tls, "tls", "", false, "Enable TLS mode. Set to true to enable TLS. Alow SAN certificates")
54+
flags.StringVarP(&opt.tlsCert, "cert-file", "", "", "The path to the certificate file, Alow SAN certificates")
55+
flags.StringVarP(&opt.tlsKey, "key-file", "", "", "The path to the key file, Alow SAN certificates")
56+
return
5757
}
5858

5959
func (o *mockOption) runE(c *cobra.Command, args []string) (err error) {
60-
reader := mock.NewLocalFileReader(args[0])
61-
server := mock.NewInMemoryServer(c.Context(), o.port)
62-
if o.tls {
63-
server.WithTLS(o.tlsCert, o.tlsKey)
64-
}
65-
if o.metrics {
66-
server.EnableMetrics()
67-
}
68-
if err = server.Start(reader, o.prefix); err != nil {
69-
return
70-
}
71-
72-
clean := make(chan os.Signal, 1)
73-
signal.Notify(clean, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
74-
printLocalIPs(c, o.port)
75-
if o.metrics {
76-
c.Printf("Metrics available at http://localhost:%d%s/metrics\n", o.port, o.prefix)
77-
}
78-
79-
select {
80-
case <-c.Context().Done():
81-
case <-clean:
82-
}
83-
err = server.Stop()
84-
return
60+
reader := mock.NewLocalFileReader(args[0])
61+
server := mock.NewInMemoryServer(c.Context(), o.port)
62+
if o.tls {
63+
server.WithTLS(o.tlsCert, o.tlsKey)
64+
}
65+
if o.metrics {
66+
server.EnableMetrics()
67+
}
68+
if err = server.Start(reader, o.prefix); err != nil {
69+
return
70+
}
71+
72+
clean := make(chan os.Signal, 1)
73+
signal.Notify(clean, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
74+
printLocalIPs(c, o.port)
75+
if o.metrics {
76+
c.Printf("Metrics available at http://localhost:%d%s/metrics\n", o.port, o.prefix)
77+
}
78+
79+
select {
80+
case <-c.Context().Done():
81+
case <-clean:
82+
}
83+
err = server.Stop()
84+
return
8585
}
8686

8787
func printLocalIPs(c *cobra.Command, port int) {
88-
if ips, err := getLocalIPs(); err == nil {
89-
for _, ip := range ips {
90-
c.Printf("server is available at http://%s:%d\n", ip, port)
91-
}
92-
}
88+
if ips, err := getLocalIPs(); err == nil {
89+
for _, ip := range ips {
90+
c.Printf("server is available at http://%s:%d\n", ip, port)
91+
}
92+
}
9393
}
9494

9595
func getLocalIPs() ([]string, error) {
96-
var ips []string
97-
addrs, err := net.InterfaceAddrs()
98-
if err != nil {
99-
return nil, fmt.Errorf("failed to get interface addresses: %v", err)
100-
}
101-
102-
for _, addr := range addrs {
103-
if ipNet, ok := addr.(*net.IPNet); ok {
104-
if ipNet.IP.To4() != nil && !ipNet.IP.IsLoopback() {
105-
ips = append(ips, ipNet.IP.String())
106-
}
107-
}
108-
}
109-
return ips, nil
96+
var ips []string
97+
addrs, err := net.InterfaceAddrs()
98+
if err != nil {
99+
return nil, fmt.Errorf("failed to get interface addresses: %v", err)
100+
}
101+
102+
for _, addr := range addrs {
103+
if ipNet, ok := addr.(*net.IPNet); ok {
104+
if ipNet.IP.To4() != nil && !ipNet.IP.IsLoopback() {
105+
ips = append(ips, ipNet.IP.String())
106+
}
107+
}
108+
}
109+
return ips, nil
110110
}

console/atest-ui/src/App.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
import {
3-
Document,
43
Menu as IconMenu,
54
Histogram,
65
Location,
@@ -16,7 +15,6 @@ import TestingPanel from './views/TestingPanel.vue'
1615
import TestingHistoryPanel from './views/TestingHistoryPanel.vue'
1716
import MockManager from './views/MockManager.vue'
1817
import StoreManager from './views/StoreManager.vue'
19-
import SecretManager from './views/SecretManager.vue'
2018
import WelcomePage from './views/WelcomePage.vue'
2119
import DataManager from './views/DataManager.vue'
2220
import MagicKey from './components/MagicKey.vue'
@@ -158,10 +156,6 @@ API.GetMenus((menus) => {
158156
<el-icon><DataAnalysis /></el-icon>
159157
<template #title>{{ t('title.data' )}}</template>
160158
</el-menu-item>
161-
<el-menu-item index="secret">
162-
<el-icon><document /></el-icon>
163-
<template #title>{{ t('title.secrets') }}</template>
164-
</el-menu-item>
165159
<el-menu-item index="store">
166160
<el-icon><location /></el-icon>
167161
<template #title>{{ t('title.stores') }}</template>
@@ -186,11 +180,10 @@ API.GetMenus((menus) => {
186180
<DataManager v-else-if="panelName === 'data'" />
187181
<MockManager v-else-if="panelName === 'mock'" />
188182
<StoreManager v-else-if="panelName === 'store'" />
189-
<SecretManager v-else-if="panelName === 'secret'" />
190183
<WelcomePage v-else-if="panelName === 'welcome' || panelName === ''" />
191184

192185
<span v-for="menu in extensionMenus" :key="menu.index" :index="menu.index">
193-
<Extension v-if="panelName === 'demo'" :name="menu.name" />
186+
<Extension v-if="panelName === menu.index" :name="menu.name" />
194187
</span>
195188
</el-main>
196189

console/atest-ui/src/views/SecretManager.vue

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)