mattermost-community-enterp.../cmd/mmctl/commands/importer/utils.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

67 lines
1.5 KiB
Go

// 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()
}