Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature flags #3030

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go/beacon_srv/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var _ config.Config = (*Config)(nil)
// Config is the beacon server configuration.
type Config struct {
General env.General
Features env.Features
Logging env.Logging
Metrics env.Metrics
Tracing env.Tracing
Expand All @@ -67,6 +68,7 @@ type Config struct {
func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand All @@ -81,6 +83,7 @@ func (cfg *Config) InitDefaults() {
func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.TrustDB,
Expand All @@ -94,6 +97,7 @@ func (cfg *Config) Validate() error {
func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand Down
4 changes: 4 additions & 0 deletions go/border/brconf/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var _ config.Config = (*Config)(nil)
// Config is the border router configuration that is loaded from file.
type Config struct {
General env.General
Features env.Features
Logging env.Logging
Metrics env.Metrics
Discovery Discovery
Expand All @@ -37,6 +38,7 @@ type Config struct {
func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Discovery,
Expand All @@ -47,6 +49,7 @@ func (cfg *Config) InitDefaults() {
func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Discovery,
Expand All @@ -57,6 +60,7 @@ func (cfg *Config) Validate() error {
func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Discovery,
Expand Down
4 changes: 4 additions & 0 deletions go/cert_srv/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var _ config.Config = (*Config)(nil)

type Config struct {
General env.General
Features env.Features
Logging env.Logging
Metrics env.Metrics
Tracing env.Tracing
Expand All @@ -60,6 +61,7 @@ type Config struct {
func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand All @@ -73,6 +75,7 @@ func (cfg *Config) InitDefaults() {
func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Sciond,
Expand All @@ -85,6 +88,7 @@ func (cfg *Config) Validate() error {
func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.General,
&cfg.Features,
&cfg.Sciond,
&cfg.Logging,
&cfg.Metrics,
Expand Down
2 changes: 2 additions & 0 deletions go/godispatcher/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
var _ config.Config = (*Config)(nil)

type Config struct {
Features env.Features
Logging env.Logging
Metrics env.Metrics
Dispatcher struct {
Expand Down Expand Up @@ -75,6 +76,7 @@ func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
Name: "dispatcher",
}
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
dispSampler,
Expand Down
1 change: 1 addition & 0 deletions go/lib/env/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go_library(
name = "go_default_library",
srcs = [
"env.go",
"features.go",
"flags.go",
"logging.go",
"sample.go",
Expand Down
44 changes: 44 additions & 0 deletions go/lib/env/features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019 ETH Zurich, Anapaya Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package env

import (
"io"

"github.com/scionproto/scion/go/lib/config"
)

var _ config.Config = (*Features)(nil)

// Add feature flags to this structure as needed.
// Feature flags are always boolean. Don't use any other types here!
type Features struct {
}

func (cfg *Features) InitDefaults() {
// All feature flags are intialized to false.
}

func (cfg *Features) Validate() error {
return nil
}

func (cfg *Features) Sample(dst io.Writer, path config.Path, ctx config.CtxMap) {
config.WriteString(dst, featuresSample)
}

func (cfg *Features) ConfigName() string {
return "features"
}
4 changes: 4 additions & 0 deletions go/lib/env/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Topology = "/etc/scion/topology.json"
ReconnectToDispatcher = false
`

const featuresSample = `
# Feature flags are various boolean properties as defined in go/lib/env/features.go
`

const sciondClientSample = `
# The Sciond path. (default sciond.DefaultSCIONDPath)
Path = "/run/shm/sciond/default.sock"
Expand Down
4 changes: 4 additions & 0 deletions go/path_srv/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var _ config.Config = (*Config)(nil)

type Config struct {
General env.General
Features env.Features
Logging env.Logging
Metrics env.Metrics
Tracing env.Tracing
Expand All @@ -49,6 +50,7 @@ type Config struct {
func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand All @@ -61,6 +63,7 @@ func (cfg *Config) InitDefaults() {
func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.TrustDB,
Expand All @@ -72,6 +75,7 @@ func (cfg *Config) Validate() error {
func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand Down
4 changes: 4 additions & 0 deletions go/sciond/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var _ config.Config = (*Config)(nil)

type Config struct {
General env.General
Features env.Features
Logging env.Logging
Metrics env.Metrics
Tracing env.Tracing
Expand All @@ -50,6 +51,7 @@ type Config struct {
func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand All @@ -62,6 +64,7 @@ func (cfg *Config) InitDefaults() {
func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.TrustDB,
Expand All @@ -73,6 +76,7 @@ func (cfg *Config) Validate() error {
func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.General,
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Tracing,
Expand Down
12 changes: 8 additions & 4 deletions go/sig/internal/sigconfig/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ const (
var _ config.Config = (*Config)(nil)

type Config struct {
Logging env.Logging
Metrics env.Metrics
Sciond env.SciondClient `toml:"sd_client"`
Sig SigConf
Features env.Features
Logging env.Logging
Metrics env.Metrics
Sciond env.SciondClient `toml:"sd_client"`
Sig SigConf
}

func (cfg *Config) InitDefaults() {
config.InitAll(
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Sciond,
Expand All @@ -52,6 +54,7 @@ func (cfg *Config) InitDefaults() {

func (cfg *Config) Validate() error {
return config.ValidateAll(
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Sciond,
Expand All @@ -61,6 +64,7 @@ func (cfg *Config) Validate() error {

func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
config.WriteSample(dst, path, config.CtxMap{config.ID: idSample},
&cfg.Features,
&cfg.Logging,
&cfg.Metrics,
&cfg.Sciond,
Expand Down