Replace name "LogViewerUIConfig" with "LogViewerConfig"
parent
c33d4aa856
commit
2319ac3ff8
|
@ -36,8 +36,8 @@ func (s *ConfigStore) Initialize(ctx context.Context) error {
|
||||||
Auth: chronograf.AuthConfig{
|
Auth: chronograf.AuthConfig{
|
||||||
SuperAdminNewUsers: false,
|
SuperAdminNewUsers: false,
|
||||||
},
|
},
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "time",
|
Name: "time",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
|
|
@ -24,8 +24,8 @@ func TestConfig_Get(t *testing.T) {
|
||||||
Auth: chronograf.AuthConfig{
|
Auth: chronograf.AuthConfig{
|
||||||
SuperAdminNewUsers: false,
|
SuperAdminNewUsers: false,
|
||||||
},
|
},
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "time",
|
Name: "time",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -172,8 +172,8 @@ func TestConfig_Update(t *testing.T) {
|
||||||
Auth: chronograf.AuthConfig{
|
Auth: chronograf.AuthConfig{
|
||||||
SuperAdminNewUsers: false,
|
SuperAdminNewUsers: false,
|
||||||
},
|
},
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "time",
|
Name: "time",
|
||||||
Position: 1,
|
Position: 1,
|
||||||
|
@ -280,8 +280,8 @@ func TestConfig_Update(t *testing.T) {
|
||||||
Auth: chronograf.AuthConfig{
|
Auth: chronograf.AuthConfig{
|
||||||
SuperAdminNewUsers: false,
|
SuperAdminNewUsers: false,
|
||||||
},
|
},
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "time",
|
Name: "time",
|
||||||
Position: 1,
|
Position: 1,
|
||||||
|
|
|
@ -716,7 +716,7 @@ func UnmarshalOrganizationPB(data []byte, o *Organization) error {
|
||||||
|
|
||||||
// MarshalConfig encodes a config to binary protobuf format.
|
// MarshalConfig encodes a config to binary protobuf format.
|
||||||
func MarshalConfig(c *chronograf.Config) ([]byte, error) {
|
func MarshalConfig(c *chronograf.Config) ([]byte, error) {
|
||||||
columns := make([]*LogViewerUIColumn, len(c.LogViewer.Columns))
|
columns := make([]*LogViewerColumn, len(c.LogViewer.Columns))
|
||||||
for i, column := range c.LogViewer.Columns {
|
for i, column := range c.LogViewer.Columns {
|
||||||
encodings := make([]*ColumnEncoding, len(column.Encodings))
|
encodings := make([]*ColumnEncoding, len(column.Encodings))
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ func MarshalConfig(c *chronograf.Config) ([]byte, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
columns[i] = &LogViewerUIColumn{
|
columns[i] = &LogViewerColumn{
|
||||||
Name: column.Name,
|
Name: column.Name,
|
||||||
Position: column.Position,
|
Position: column.Position,
|
||||||
Encodings: encodings,
|
Encodings: encodings,
|
||||||
|
@ -738,7 +738,7 @@ func MarshalConfig(c *chronograf.Config) ([]byte, error) {
|
||||||
Auth: &AuthConfig{
|
Auth: &AuthConfig{
|
||||||
SuperAdminNewUsers: c.Auth.SuperAdminNewUsers,
|
SuperAdminNewUsers: c.Auth.SuperAdminNewUsers,
|
||||||
},
|
},
|
||||||
LogViewer: &LogViewerUIConfig{
|
LogViewer: &LogViewerConfig{
|
||||||
Columns: columns,
|
Columns: columns,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -761,10 +761,10 @@ func UnmarshalConfig(data []byte, c *chronograf.Config) error {
|
||||||
c.Auth.SuperAdminNewUsers = pb.Auth.SuperAdminNewUsers
|
c.Auth.SuperAdminNewUsers = pb.Auth.SuperAdminNewUsers
|
||||||
|
|
||||||
if pb.LogViewer == nil {
|
if pb.LogViewer == nil {
|
||||||
return fmt.Errorf("Log Viewer UI config is nil")
|
return fmt.Errorf("Log Viewer config is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
columns := make([]chronograf.LogViewerUIColumn, len(pb.LogViewer.Columns))
|
columns := make([]chronograf.LogViewerColumn, len(pb.LogViewer.Columns))
|
||||||
|
|
||||||
for i, c := range pb.LogViewer.Columns {
|
for i, c := range pb.LogViewer.Columns {
|
||||||
columns[i].Name = c.Name
|
columns[i].Name = c.Name
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -208,18 +208,18 @@ message Organization {
|
||||||
|
|
||||||
message Config {
|
message Config {
|
||||||
AuthConfig Auth = 1; // Auth is the configuration for options that auth related
|
AuthConfig Auth = 1; // Auth is the configuration for options that auth related
|
||||||
LogViewerUIConfig LogViewer = 2; // LogViewerUI is the configuration for the Log Viewer UI
|
LogViewerConfig LogViewer = 2; // LogViewer is the configuration for the Log Viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
message AuthConfig {
|
message AuthConfig {
|
||||||
bool SuperAdminNewUsers = 1; // SuperAdminNewUsers configuration option that specifies which users will auto become super admin
|
bool SuperAdminNewUsers = 1; // SuperAdminNewUsers configuration option that specifies which users will auto become super admin
|
||||||
}
|
}
|
||||||
|
|
||||||
message LogViewerUIConfig {
|
message LogViewerConfig {
|
||||||
repeated LogViewerUIColumn Columns = 1; // Columns is the array of columns in the log viewer UI
|
repeated LogViewerColumn Columns = 1; // Columns is the array of columns in the log viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
message LogViewerUIColumn {
|
message LogViewerColumn {
|
||||||
string Name = 1; // Name is the unique identifier of the log viewer column
|
string Name = 1; // Name is the unique identifier of the log viewer column
|
||||||
int32 Position = 2; // Position is the position of the column in the log viewer's array of columns
|
int32 Position = 2; // Position is the position of the column in the log viewer's array of columns
|
||||||
repeated ColumnEncoding Encodings = 3; // Encodings is the array of encoded properties associated with a log viewer column
|
repeated ColumnEncoding Encodings = 3; // Encodings is the array of encoded properties associated with a log viewer column
|
||||||
|
|
|
@ -739,8 +739,8 @@ type OrganizationsStore interface {
|
||||||
// Config is the global application Config for parameters that can be set via
|
// Config is the global application Config for parameters that can be set via
|
||||||
// API, with different sections, such as Auth
|
// API, with different sections, such as Auth
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Auth AuthConfig `json:"auth"`
|
Auth AuthConfig `json:"auth"`
|
||||||
LogViewer LogViewerUIConfig `json:"logViewer"`
|
LogViewer LogViewerConfig `json:"logViewer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthConfig is the global application config section for auth parameters
|
// AuthConfig is the global application config section for auth parameters
|
||||||
|
@ -748,13 +748,13 @@ type AuthConfig struct {
|
||||||
SuperAdminNewUsers bool `json:"superAdminNewUsers"`
|
SuperAdminNewUsers bool `json:"superAdminNewUsers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogViewerUIConfig is the config sections for log viewer section of the application
|
// LogViewerConfig is the config sections for log viewer section of the application
|
||||||
type LogViewerUIConfig struct {
|
type LogViewerConfig struct {
|
||||||
Columns []LogViewerUIColumn `json:"columns"`
|
Columns []LogViewerColumn `json:"columns"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogViewerUIColumn is a specific column of the log viewer UI
|
// LogViewerColumn is a specific column of the log viewer UI
|
||||||
type LogViewerUIColumn struct {
|
type LogViewerColumn struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Position int32 `json:"position"`
|
Position int32 `json:"position"`
|
||||||
Encodings []ColumnEncoding `json:"encodings"`
|
Encodings []ColumnEncoding `json:"encodings"`
|
||||||
|
|
|
@ -36,17 +36,17 @@ func newAuthConfigResponse(config chronograf.Config) *authConfigResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type logViewerUIResponse struct {
|
type logViewerResponse struct {
|
||||||
Links selfLinks `json:"links"`
|
Links selfLinks `json:"links"`
|
||||||
chronograf.LogViewerUIConfig
|
chronograf.LogViewerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLogViewerUIConfigResponse(config chronograf.Config) *logViewerUIResponse {
|
func newLogViewerConfigResponse(config chronograf.Config) *logViewerResponse {
|
||||||
return &logViewerUIResponse{
|
return &logViewerResponse{
|
||||||
Links: selfLinks{
|
Links: selfLinks{
|
||||||
Self: "/chronograf/v1/config/logviewer",
|
Self: "/chronograf/v1/config/logviewer",
|
||||||
},
|
},
|
||||||
LogViewerUIConfig: config.LogViewer,
|
LogViewerConfig: config.LogViewer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ func (s *Service) Config(w http.ResponseWriter, r *http.Request) {
|
||||||
encodeJSON(w, http.StatusOK, res, s.Logger)
|
encodeJSON(w, http.StatusOK, res, s.Logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogViewerUIConfig retrieves the log viewer UI section of the global application configuration
|
// LogViewerConfig retrieves the log viewer UI section of the global application configuration
|
||||||
func (s *Service) LogViewerUIConfig(w http.ResponseWriter, r *http.Request) {
|
func (s *Service) LogViewerConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
config, err := s.Store.Config(ctx).Get(ctx)
|
config, err := s.Store.Config(ctx).Get(ctx)
|
||||||
|
@ -84,21 +84,21 @@ func (s *Service) LogViewerUIConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res := newLogViewerUIConfigResponse(*config)
|
res := newLogViewerConfigResponse(*config)
|
||||||
|
|
||||||
encodeJSON(w, http.StatusOK, res, s.Logger)
|
encodeJSON(w, http.StatusOK, res, s.Logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplaceLogViewerUIConfig replaces the log viewer UI section of the global application configuration
|
// ReplaceLogViewerConfig replaces the log viewer UI section of the global application configuration
|
||||||
func (s *Service) ReplaceLogViewerUIConfig(w http.ResponseWriter, r *http.Request) {
|
func (s *Service) ReplaceLogViewerConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
var logViewerUIConfig chronograf.LogViewerUIConfig
|
var logViewerConfig chronograf.LogViewerConfig
|
||||||
if err := json.NewDecoder(r.Body).Decode(&logViewerUIConfig); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&logViewerConfig); err != nil {
|
||||||
invalidJSON(w, s.Logger)
|
invalidJSON(w, s.Logger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := validLogViewerUIConfig(logViewerUIConfig); err != nil {
|
if err := validLogViewerConfig(logViewerConfig); err != nil {
|
||||||
Error(w, http.StatusBadRequest, err.Error(), s.Logger)
|
Error(w, http.StatusBadRequest, err.Error(), s.Logger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,9 @@ func (s *Service) ReplaceLogViewerUIConfig(w http.ResponseWriter, r *http.Reques
|
||||||
Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger)
|
Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
config.LogViewer = logViewerUIConfig
|
config.LogViewer = logViewerConfig
|
||||||
|
|
||||||
res := newLogViewerUIConfigResponse(*config)
|
res := newLogViewerConfigResponse(*config)
|
||||||
if err := s.Store.Config(ctx).Update(ctx, config); err != nil {
|
if err := s.Store.Config(ctx).Update(ctx, config); err != nil {
|
||||||
unknownErrorWithMessage(w, err, s.Logger)
|
unknownErrorWithMessage(w, err, s.Logger)
|
||||||
return
|
return
|
||||||
|
@ -173,14 +173,14 @@ func (s *Service) ReplaceAuthConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
encodeJSON(w, http.StatusOK, res, s.Logger)
|
encodeJSON(w, http.StatusOK, res, s.Logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// validLogViewerUIConfig ensures that the request body log viewer UI config is valid
|
// validLogViewerConfig ensures that the request body log viewer UI config is valid
|
||||||
// to be valid, it must: not be empty, have at least one column, not have multiple
|
// to be valid, it must: not be empty, have at least one column, not have multiple
|
||||||
// columns with the same name or position value, each column must have a visbility
|
// columns with the same name or position value, each column must have a visbility
|
||||||
// of either "visible" or "hidden" and if a column is of type severity, it must have
|
// of either "visible" or "hidden" and if a column is of type severity, it must have
|
||||||
// at least one severity format of type icon, text, or both
|
// at least one severity format of type icon, text, or both
|
||||||
func validLogViewerUIConfig(cfg chronograf.LogViewerUIConfig) error {
|
func validLogViewerConfig(cfg chronograf.LogViewerConfig) error {
|
||||||
if len(cfg.Columns) == 0 {
|
if len(cfg.Columns) == 0 {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: must have at least 1 column")
|
return fmt.Errorf("Invalid log viewer config: must have at least 1 column")
|
||||||
}
|
}
|
||||||
|
|
||||||
nameMatcher := map[string]bool{}
|
nameMatcher := map[string]bool{}
|
||||||
|
@ -193,11 +193,11 @@ func validLogViewerUIConfig(cfg chronograf.LogViewerUIConfig) error {
|
||||||
|
|
||||||
// check that each column has a unique value for the name and position properties
|
// check that each column has a unique value for the name and position properties
|
||||||
if _, ok := nameMatcher[clm.Name]; ok {
|
if _, ok := nameMatcher[clm.Name]; ok {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: Duplicate column name %s", clm.Name)
|
return fmt.Errorf("Invalid log viewer config: Duplicate column name %s", clm.Name)
|
||||||
}
|
}
|
||||||
nameMatcher[clm.Name] = true
|
nameMatcher[clm.Name] = true
|
||||||
if _, ok := positionMatcher[clm.Position]; ok {
|
if _, ok := positionMatcher[clm.Position]; ok {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: Multiple columns with same position value")
|
return fmt.Errorf("Invalid log viewer config: Multiple columns with same position value")
|
||||||
}
|
}
|
||||||
positionMatcher[clm.Position] = true
|
positionMatcher[clm.Position] = true
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ func validLogViewerUIConfig(cfg chronograf.LogViewerUIConfig) error {
|
||||||
if e.Type == "visibility" {
|
if e.Type == "visibility" {
|
||||||
visibility++
|
visibility++
|
||||||
if !(e.Value == "visible" || e.Value == "hidden") {
|
if !(e.Value == "visible" || e.Value == "hidden") {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: invalid visibility in column %s", clm.Name)
|
return fmt.Errorf("Invalid log viewer config: invalid visibility in column %s", clm.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,12 +219,12 @@ func validLogViewerUIConfig(cfg chronograf.LogViewerUIConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if visibility != 1 {
|
if visibility != 1 {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: missing visibility encoding in column %s", clm.Name)
|
return fmt.Errorf("Invalid log viewer config: missing visibility encoding in column %s", clm.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if clm.Name == "severity" {
|
if clm.Name == "severity" {
|
||||||
if iconCount+textCount == 0 || iconCount > 1 || textCount > 1 {
|
if iconCount+textCount == 0 || iconCount > 1 || textCount > 1 {
|
||||||
return fmt.Errorf("Invalid log viewer UI config: invalid number of severity format encodings in column %s", clm.Name)
|
return fmt.Errorf("Invalid log viewer config: invalid number of severity format encodings in column %s", clm.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ func TestConfig(t *testing.T) {
|
||||||
Auth: chronograf.AuthConfig{
|
Auth: chronograf.AuthConfig{
|
||||||
SuperAdminNewUsers: false,
|
SuperAdminNewUsers: false,
|
||||||
},
|
},
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -242,7 +242,7 @@ func TestReplaceAuthConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogViewerUIConfig(t *testing.T) {
|
func TestLogViewerConfig(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
ConfigStore chronograf.ConfigStore
|
ConfigStore chronograf.ConfigStore
|
||||||
}
|
}
|
||||||
|
@ -262,8 +262,8 @@ func TestLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -309,7 +309,7 @@ func TestLogViewerUIConfig(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
r := httptest.NewRequest("GET", "http://any.url", nil)
|
r := httptest.NewRequest("GET", "http://any.url", nil)
|
||||||
|
|
||||||
s.LogViewerUIConfig(w, r)
|
s.LogViewerConfig(w, r)
|
||||||
|
|
||||||
resp := w.Result()
|
resp := w.Result()
|
||||||
content := resp.Header.Get("Content-Type")
|
content := resp.Header.Get("Content-Type")
|
||||||
|
@ -328,7 +328,7 @@ func TestLogViewerUIConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReplaceLogViewerUIConfig(t *testing.T) {
|
func TestReplaceLogViewerConfig(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
ConfigStore chronograf.ConfigStore
|
ConfigStore chronograf.ConfigStore
|
||||||
}
|
}
|
||||||
|
@ -352,8 +352,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -379,8 +379,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
payload: chronograf.LogViewerUIConfig{
|
payload: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 1,
|
Position: 1,
|
||||||
|
@ -433,8 +433,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -460,14 +460,14 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
payload: chronograf.LogViewerUIConfig{
|
payload: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{},
|
Columns: []chronograf.LogViewerColumn{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: `{"code":400,"message":"Invalid log viewer UI config: must have at least 1 column"}`,
|
body: `{"code":400,"message":"Invalid log viewer config: must have at least 1 column"}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -475,8 +475,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "procid",
|
Name: "procid",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -493,8 +493,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
payload: chronograf.LogViewerUIConfig{
|
payload: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "procid",
|
Name: "procid",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -521,7 +521,7 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
wants: wants{
|
wants: wants{
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: `{"code":400,"message":"Invalid log viewer UI config: Duplicate column name procid"}`,
|
body: `{"code":400,"message":"Invalid log viewer config: Duplicate column name procid"}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -529,8 +529,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "procid",
|
Name: "procid",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -547,8 +547,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
payload: chronograf.LogViewerUIConfig{
|
payload: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "procid",
|
Name: "procid",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -575,7 +575,7 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
wants: wants{
|
wants: wants{
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: `{"code":400,"message":"Invalid log viewer UI config: Multiple columns with same position value"}`,
|
body: `{"code":400,"message":"Invalid log viewer config: Multiple columns with same position value"}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -583,8 +583,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
fields: fields{
|
fields: fields{
|
||||||
ConfigStore: &mocks.ConfigStore{
|
ConfigStore: &mocks.ConfigStore{
|
||||||
Config: &chronograf.Config{
|
Config: &chronograf.Config{
|
||||||
LogViewer: chronograf.LogViewerUIConfig{
|
LogViewer: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
@ -606,8 +606,8 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
payload: chronograf.LogViewerUIConfig{
|
payload: chronograf.LogViewerConfig{
|
||||||
Columns: []chronograf.LogViewerUIColumn{
|
Columns: []chronograf.LogViewerColumn{
|
||||||
{
|
{
|
||||||
Name: "severity",
|
Name: "severity",
|
||||||
Position: 1,
|
Position: 1,
|
||||||
|
@ -634,7 +634,7 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
wants: wants{
|
wants: wants{
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
body: `{"code":400,"message":"Invalid log viewer UI config: missing visibility encoding in column severity"}`,
|
body: `{"code":400,"message":"Invalid log viewer config: missing visibility encoding in column severity"}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ func TestReplaceLogViewerUIConfig(t *testing.T) {
|
||||||
buf, _ := json.Marshal(tt.args.payload)
|
buf, _ := json.Marshal(tt.args.payload)
|
||||||
r.Body = ioutil.NopCloser(bytes.NewReader(buf))
|
r.Body = ioutil.NopCloser(bytes.NewReader(buf))
|
||||||
|
|
||||||
s.ReplaceLogViewerUIConfig(w, r)
|
s.ReplaceLogViewerConfig(w, r)
|
||||||
|
|
||||||
resp := w.Result()
|
resp := w.Result()
|
||||||
content := resp.Header.Get("Content-Type")
|
content := resp.Header.Get("Content-Type")
|
||||||
|
|
|
@ -313,8 +313,8 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
|
||||||
|
|
||||||
// Global application config for Chronograf
|
// Global application config for Chronograf
|
||||||
router.GET("/chronograf/v1/config", EnsureSuperAdmin(service.Config))
|
router.GET("/chronograf/v1/config", EnsureSuperAdmin(service.Config))
|
||||||
router.GET("/chronograf/v1/config/logviewer", EnsureViewer(service.LogViewerUIConfig))
|
router.GET("/chronograf/v1/config/logviewer", EnsureViewer(service.LogViewerConfig))
|
||||||
router.PUT("/chronograf/v1/config/logviewer", EnsureEditor(service.ReplaceLogViewerUIConfig))
|
router.PUT("/chronograf/v1/config/logviewer", EnsureEditor(service.ReplaceLogViewerConfig))
|
||||||
router.GET("/chronograf/v1/config/auth", EnsureSuperAdmin(service.AuthConfig))
|
router.GET("/chronograf/v1/config/auth", EnsureSuperAdmin(service.AuthConfig))
|
||||||
router.PUT("/chronograf/v1/config/auth", EnsureSuperAdmin(service.ReplaceAuthConfig))
|
router.PUT("/chronograf/v1/config/auth", EnsureSuperAdmin(service.ReplaceAuthConfig))
|
||||||
|
|
||||||
|
|
|
@ -2876,7 +2876,7 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/LogViewerUIConfig"
|
"$ref": "#/definitions/LogViewerConfig"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/AuthConfig"
|
"$ref": "#/definitions/AuthConfig"
|
||||||
|
@ -2920,7 +2920,7 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/LogViewerUIConfig"
|
"$ref": "#/definitions/LogViewerConfig"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/AuthConfig"
|
"$ref": "#/definitions/AuthConfig"
|
||||||
|
@ -2932,11 +2932,11 @@
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Returns an object with the updated UI settings for a specific section",
|
"description": "Returns an object with the updated settings for a specific section",
|
||||||
"schema": {
|
"schema": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/LogViewerUIConfig"
|
"$ref": "#/definitions/LogViewerConfig"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5144,7 +5144,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LogViewerUIColumn": {
|
"LogViewerColumn": {
|
||||||
"description": "Contains the settings for the log viewer page UI",
|
"description": "Contains the settings for the log viewer page UI",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -5215,7 +5215,7 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LogViewerUIConfig": {
|
"LogViewerConfig": {
|
||||||
"description": "Contains the settings for the log viewer page UI",
|
"description": "Contains the settings for the log viewer page UI",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["columns"],
|
"required": ["columns"],
|
||||||
|
@ -5224,7 +5224,7 @@
|
||||||
"description": "Defines the order, names, and visibility of columns in the log viewer table",
|
"description": "Defines the order, names, and visibility of columns in the log viewer table",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/LogViewerUIColumn"
|
"$ref": "#/definitions/LogViewerColumn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue