Adding an option to (de)activate Pilot integration into the Traefik dashboard
Co-authored-by: Jean-Baptiste Doumenjou <925513+jbdoumenjou@users.noreply.github.com>
This commit is contained in:
parent
06fc2c505f
commit
1e716a93ff
8 changed files with 50 additions and 12 deletions
|
@ -222,6 +222,10 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if staticConfiguration.Pilot != nil {
|
||||||
|
version.PilotEnabled = staticConfiguration.Pilot.Dashboard
|
||||||
|
}
|
||||||
|
|
||||||
// Plugins
|
// Plugins
|
||||||
|
|
||||||
pluginBuilder, err := createPluginBuilder(staticConfiguration)
|
pluginBuilder, err := createPluginBuilder(staticConfiguration)
|
||||||
|
|
|
@ -294,6 +294,9 @@ Prefix to use for metrics collection. (Default: ```traefik```)
|
||||||
`--metrics.statsd.pushinterval`:
|
`--metrics.statsd.pushinterval`:
|
||||||
StatsD push interval. (Default: ```10```)
|
StatsD push interval. (Default: ```10```)
|
||||||
|
|
||||||
|
`--pilot.dashboard`:
|
||||||
|
Enable Traefik Pilot in the dashboard. (Default: ```true```)
|
||||||
|
|
||||||
`--pilot.token`:
|
`--pilot.token`:
|
||||||
Traefik Pilot token.
|
Traefik Pilot token.
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,9 @@ Prefix to use for metrics collection. (Default: ```traefik```)
|
||||||
`TRAEFIK_METRICS_STATSD_PUSHINTERVAL`:
|
`TRAEFIK_METRICS_STATSD_PUSHINTERVAL`:
|
||||||
StatsD push interval. (Default: ```10```)
|
StatsD push interval. (Default: ```10```)
|
||||||
|
|
||||||
|
`TRAEFIK_PILOT_DASHBOARD`:
|
||||||
|
Enable Traefik Pilot in the dashboard. (Default: ```true```)
|
||||||
|
|
||||||
`TRAEFIK_PILOT_TOKEN`:
|
`TRAEFIK_PILOT_TOKEN`:
|
||||||
Traefik Pilot token.
|
Traefik Pilot token.
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,11 @@ package static
|
||||||
|
|
||||||
// Pilot Configuration related to Traefik Pilot.
|
// Pilot Configuration related to Traefik Pilot.
|
||||||
type Pilot struct {
|
type Pilot struct {
|
||||||
Token string `description:"Traefik Pilot token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty"`
|
Token string `description:"Traefik Pilot token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty"`
|
||||||
|
Dashboard bool `description:"Enable Traefik Pilot in the dashboard." json:"dashboard,omitempty" toml:"dashboard,omitempty" yaml:"dashboard,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDefaults sets the default values.
|
||||||
|
func (p *Pilot) SetDefaults() {
|
||||||
|
p.Dashboard = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,12 @@ func (c *Configuration) SetEffectiveConfiguration() {
|
||||||
c.Global.SendAnonymousUsage = true
|
c.Global.SendAnonymousUsage = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create Pilot struct to apply default value on undefined configuration.
|
||||||
|
if c.Pilot == nil {
|
||||||
|
c.Pilot = &Pilot{}
|
||||||
|
c.Pilot.SetDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
// Disable Gateway API provider if not enabled in experimental
|
// Disable Gateway API provider if not enabled in experimental
|
||||||
if c.Experimental == nil || !c.Experimental.KubernetesGateway {
|
if c.Experimental == nil || !c.Experimental.KubernetesGateway {
|
||||||
c.Providers.KubernetesGateway = nil
|
c.Providers.KubernetesGateway = nil
|
||||||
|
|
|
@ -24,6 +24,8 @@ var (
|
||||||
StartDate = time.Now()
|
StartDate = time.Now()
|
||||||
// UUID instance uuid.
|
// UUID instance uuid.
|
||||||
UUID string
|
UUID string
|
||||||
|
// PilotEnabled activate integration of pilot into the dashboard.
|
||||||
|
PilotEnabled bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// Handler expose version routes.
|
// Handler expose version routes.
|
||||||
|
@ -38,15 +40,17 @@ func (v Handler) Append(router *mux.Router) {
|
||||||
router.Methods(http.MethodGet).Path("/api/version").
|
router.Methods(http.MethodGet).Path("/api/version").
|
||||||
HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
||||||
v := struct {
|
v := struct {
|
||||||
Version string
|
Version string
|
||||||
Codename string
|
Codename string
|
||||||
StartDate time.Time `json:"startDate"`
|
StartDate time.Time `json:"startDate"`
|
||||||
UUID string `json:"uuid,omitempty"`
|
UUID string `json:"uuid,omitempty"`
|
||||||
|
PilotEnabled bool `json:"pilotEnabled"`
|
||||||
}{
|
}{
|
||||||
Version: Version,
|
Version: Version,
|
||||||
Codename: Codename,
|
Codename: Codename,
|
||||||
StartDate: StartDate,
|
StartDate: StartDate,
|
||||||
UUID: UUID,
|
UUID: UUID,
|
||||||
|
PilotEnabled: PilotEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := templatesRenderer.JSON(response, http.StatusOK, v); err != nil {
|
if err := templatesRenderer.JSON(response, http.StatusOK, v); err != nil {
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="q-app">
|
<div id="q-app">
|
||||||
<router-view />
|
<router-view />
|
||||||
<platform-panel />
|
<platform-panel
|
||||||
|
v-if="pilotEnabled" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { APP } from './_helpers/APP'
|
import { APP } from './_helpers/APP'
|
||||||
import PlatformPanel from './components/platform/PlatformPanel'
|
import PlatformPanel from './components/platform/PlatformPanel'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
PlatformPanel
|
PlatformPanel
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters('core', { coreVersion: 'version' }),
|
||||||
|
pilotEnabled () {
|
||||||
|
return this.coreVersion.pilotEnabled
|
||||||
|
}
|
||||||
|
},
|
||||||
beforeCreate () {
|
beforeCreate () {
|
||||||
// Set vue instance
|
// Set vue instance
|
||||||
APP.vue = () => this.$root
|
APP.vue = () => this.$root
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
</q-menu>
|
</q-menu>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-tabs>
|
</q-tabs>
|
||||||
<platform-auth-state />
|
<platform-auth-state
|
||||||
|
v-if="pilotEnabled" />
|
||||||
</div>
|
</div>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,8 +59,11 @@ export default {
|
||||||
? this.coreVersion.Version
|
? this.coreVersion.Version
|
||||||
: this.coreVersion.Version.substring(0, 7)
|
: this.coreVersion.Version.substring(0, 7)
|
||||||
},
|
},
|
||||||
|
pilotEnabled () {
|
||||||
|
return this.coreVersion.pilotEnabled
|
||||||
|
},
|
||||||
parsedVersion () {
|
parsedVersion () {
|
||||||
if (this.version === undefined) {
|
if (!this.version) {
|
||||||
return 'master'
|
return 'master'
|
||||||
}
|
}
|
||||||
if (this.version === 'dev') {
|
if (this.version === 'dev') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue