-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
jira
configuration section
Signed-off-by: Pablo Aguilar <[email protected]>
- Loading branch information
1 parent
448dc5e
commit 6d14aa6
Showing
10 changed files
with
356 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,57 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
// ExperimentalConfig allows for experimental features to be enabled | ||
// and disabled. | ||
type ExperimentalConfig struct { | ||
Jira Jira `json:"jira,omitempty" mapstructure:"jira" yaml:"jira,omitempty"` | ||
} | ||
|
||
func (c *ExperimentalConfig) deprecations(v *viper.Viper) []deprecated { | ||
return nil | ||
} | ||
|
||
func (c *ExperimentalConfig) validate() error { | ||
return c.Jira.validate() | ||
} | ||
|
||
// ExperimentalFlag is a structure which has properties to configure | ||
// experimental feature enablement. | ||
type ExperimentalFlag struct { | ||
Enabled bool `json:"enabled,omitempty" mapstructure:"enabled" yaml:"enabled,omitempty"` | ||
} | ||
|
||
type Jira struct { | ||
Enabled bool `json:"enabled,omitempty" mapstructure:"enabled" yaml:"enabled,omitempty"` | ||
InstanceName string `json:"instanceName,omitempty" mapstructure:"instance_name" yaml:"instance_name,omitempty"` | ||
Authentication JiraAuthentication `json:"authentication,omitempty" mapstructure:"authentication" yaml:"authentication,omitempty"` | ||
} | ||
|
||
func (j *Jira) validate() error { | ||
if j.Enabled { | ||
if strings.TrimSpace(j.InstanceName) == "" { | ||
return errors.New("instance name cannot be empty when jira integration is enabled") | ||
} | ||
|
||
if strings.TrimSpace(j.Authentication.OAuth.ClientID) == "" || strings.TrimSpace(j.Authentication.OAuth.ClientSecret) == "" { | ||
return errors.New("invalid oauth parameters for jira integration") | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
type JiraAuthentication struct { | ||
OAuth JiraOauth `json:"oauth,omitempty" mapstructure:"oauth" yaml:"oauth,omitempty"` | ||
} | ||
|
||
type JiraOauth struct { | ||
ClientID string `json:"-" mapstructure:"client_id" yaml:"-"` | ||
ClientSecret string `json:"-" mapstructure:"client_secret" yaml:"-"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
internal/config/testdata/experimental/jira_empty_instance_name.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
log: | ||
level: INFO | ||
encoding: console | ||
grpc_level: ERROR | ||
|
||
ui: | ||
default_theme: system | ||
|
||
analytics: | ||
buffer: | ||
flush_period: "10s" | ||
|
||
cors: | ||
enabled: false | ||
allowed_origins: | ||
- "*" | ||
allowed_headers: | ||
- "Accept" | ||
- "Authorization" | ||
- "Content-Type" | ||
- "X-CSRF-Token" | ||
- "X-Fern-Language" | ||
- "X-Fern-SDK-Name" | ||
- "X-Fern-SDK-Version" | ||
- "X-Flipt-Namespace" | ||
- "X-Flipt-Accept-Server-Version" | ||
|
||
server: | ||
host: 0.0.0.0 | ||
http_port: 8080 | ||
https_port: 443 | ||
grpc_port: 9000 | ||
|
||
metrics: | ||
enabled: true | ||
exporter: prometheus | ||
|
||
storage: | ||
type: database | ||
|
||
diagnostics: | ||
profiling: | ||
enabled: true | ||
|
||
db: | ||
url: file:/var/opt/flipt/flipt.db | ||
max_idle_conn: 2 | ||
prepared_statements_enabled: true | ||
|
||
experimental: | ||
jira: | ||
enabled: true | ||
instance_name: "" | ||
authentication: | ||
oauth: | ||
client_id: "CLIENT_ID" | ||
client_secret: "CLIENT_SECRET" | ||
|
||
meta: | ||
check_for_updates: true | ||
telemetry_enabled: true |
61 changes: 61 additions & 0 deletions
61
internal/config/testdata/experimental/jira_empty_oauth_client_id.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
log: | ||
level: INFO | ||
encoding: console | ||
grpc_level: ERROR | ||
|
||
ui: | ||
default_theme: system | ||
|
||
analytics: | ||
buffer: | ||
flush_period: "10s" | ||
|
||
cors: | ||
enabled: false | ||
allowed_origins: | ||
- "*" | ||
allowed_headers: | ||
- "Accept" | ||
- "Authorization" | ||
- "Content-Type" | ||
- "X-CSRF-Token" | ||
- "X-Fern-Language" | ||
- "X-Fern-SDK-Name" | ||
- "X-Fern-SDK-Version" | ||
- "X-Flipt-Namespace" | ||
- "X-Flipt-Accept-Server-Version" | ||
|
||
server: | ||
host: 0.0.0.0 | ||
http_port: 8080 | ||
https_port: 443 | ||
grpc_port: 9000 | ||
|
||
metrics: | ||
enabled: true | ||
exporter: prometheus | ||
|
||
storage: | ||
type: database | ||
|
||
diagnostics: | ||
profiling: | ||
enabled: true | ||
|
||
db: | ||
url: file:/var/opt/flipt/flipt.db | ||
max_idle_conn: 2 | ||
prepared_statements_enabled: true | ||
|
||
experimental: | ||
jira: | ||
enabled: true | ||
instance_name: "INSTANCE_NAME" | ||
authentication: | ||
oauth: | ||
client_id: "" | ||
client_secret: "CLIENT_SECRET" | ||
|
||
meta: | ||
check_for_updates: true | ||
telemetry_enabled: true |
61 changes: 61 additions & 0 deletions
61
internal/config/testdata/experimental/jira_empty_oauth_client_secret.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
log: | ||
level: INFO | ||
encoding: console | ||
grpc_level: ERROR | ||
|
||
ui: | ||
default_theme: system | ||
|
||
analytics: | ||
buffer: | ||
flush_period: "10s" | ||
|
||
cors: | ||
enabled: false | ||
allowed_origins: | ||
- "*" | ||
allowed_headers: | ||
- "Accept" | ||
- "Authorization" | ||
- "Content-Type" | ||
- "X-CSRF-Token" | ||
- "X-Fern-Language" | ||
- "X-Fern-SDK-Name" | ||
- "X-Fern-SDK-Version" | ||
- "X-Flipt-Namespace" | ||
- "X-Flipt-Accept-Server-Version" | ||
|
||
server: | ||
host: 0.0.0.0 | ||
http_port: 8080 | ||
https_port: 443 | ||
grpc_port: 9000 | ||
|
||
metrics: | ||
enabled: true | ||
exporter: prometheus | ||
|
||
storage: | ||
type: database | ||
|
||
diagnostics: | ||
profiling: | ||
enabled: true | ||
|
||
db: | ||
url: file:/var/opt/flipt/flipt.db | ||
max_idle_conn: 2 | ||
prepared_statements_enabled: true | ||
|
||
experimental: | ||
jira: | ||
enabled: true | ||
instance_name: "INSTANCE_NAME" | ||
authentication: | ||
oauth: | ||
client_id: "CLIENT_ID" | ||
client_secret: "" | ||
|
||
meta: | ||
check_for_updates: true | ||
telemetry_enabled: true |
Oops, something went wrong.