Includes mmctl into the mono-repo (#23091)
* Includes mmctl into the mono-repo * Update to use the new public module paths * Adds docs check to the mmctl CI * Fix public utils import path * Tidy up modules * Fix linter * Update CI tasks to use the new file structure * Update CI references
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
412109b02e
Коммит
951456c780
66
server/cmd/mmctl/commands/importer/utils.go
Обычный файл
66
server/cmd/mmctl/commands/importer/utils.go
Обычный файл
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package importer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ImportFileInfo struct {
|
||||
Source string `json:"archive_name"`
|
||||
FileName string `json:"file_name,omitempty"`
|
||||
CurrentLine uint64 `json:"current_line,omitempty"`
|
||||
TotalLines uint64 `json:"total_lines,omitempty"`
|
||||
}
|
||||
|
||||
type ImportValidationError struct { //nolint:govet
|
||||
ImportFileInfo
|
||||
FieldName string
|
||||
Err error
|
||||
Suggestion string
|
||||
SuggestedValues []any
|
||||
ApplySuggestion func(any) error
|
||||
}
|
||||
|
||||
func (e *ImportValidationError) MarshalJSON() ([]byte, error) {
|
||||
t := struct { //nolint:govet
|
||||
ImportFileInfo
|
||||
FieldName string `json:"field_name,omitempty"`
|
||||
Err string `json:"error,omitempty"`
|
||||
Suggestion string `json:"suggestion,omitempty"`
|
||||
SuggestedValues []any `json:"suggested_values,omitempty"`
|
||||
}{
|
||||
ImportFileInfo: e.ImportFileInfo,
|
||||
FieldName: e.FieldName,
|
||||
Suggestion: e.Suggestion,
|
||||
SuggestedValues: e.SuggestedValues,
|
||||
}
|
||||
|
||||
if e.Err != nil {
|
||||
t.Err = e.Err.Error()
|
||||
}
|
||||
|
||||
return json.Marshal(t)
|
||||
}
|
||||
|
||||
func (e *ImportValidationError) Error() string {
|
||||
msg := &strings.Builder{}
|
||||
msg.WriteString("import validation error")
|
||||
|
||||
if e.FileName != "" || e.Source != "" {
|
||||
fmt.Fprintf(msg, " in %s->%s:%d", e.Source, e.FileName, e.CurrentLine)
|
||||
}
|
||||
|
||||
if e.FieldName != "" {
|
||||
fmt.Fprintf(msg, " field %q", e.FieldName)
|
||||
}
|
||||
|
||||
if e.Err != nil {
|
||||
fmt.Fprintf(msg, ": %s", e.Err)
|
||||
}
|
||||
|
||||
return msg.String()
|
||||
}
|
||||
1050
server/cmd/mmctl/commands/importer/validate.go
Обычный файл
1050
server/cmd/mmctl/commands/importer/validate.go
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Ссылка в новой задаче
Block a user