Documentation
¶
Overview ¶
Package teamconfig builds and applies team-shareable gadak configuration files (views, field maps, group rules, …) without credentials or personal machine prefs. Export is whitelist-only so new Config fields never leak by default.
Index ¶
- Constants
- func ApplyPlan(cfg *config.Config, db *store.DB, plan Plan) error
- func MarshalDocument(doc Document) ([]byte, error)
- func ScanBytesForCredentials(raw []byte) error
- type Document
- type ExportOptions
- type ExportView
- type ImportOptions
- type Plan
- type SettingAction
- type SettingChange
- type TeamSettings
- type ViewAction
- type ViewChange
Constants ¶
const CurrentFormat = 1
CurrentFormat is the only gadak_team_config version this build understands.
Variables ¶
This section is empty.
Functions ¶
func ApplyPlan ¶
ApplyPlan mutates cfg in place for settings changes and writes views via db. Credential fields on cfg are never assigned — only whitelist keys from the plan. Caller must Save() the config after a successful settings apply when not dry-run.
func MarshalDocument ¶
MarshalDocument encodes with 2-space indent for human/git-friendly files. Before returning, it scans the bytes for credential-shaped strings and refuses to emit them (defense in depth above the field whitelist).
func ScanBytesForCredentials ¶
ScanBytesForCredentials returns an error if raw contains a known secret shape (Atlassian API token, Bearer/Basic, GitHub/Slack tokens, PEM private key). Email addresses are intentionally not scanned — --with-members may include them. Reuses internal/secretscan so this and snapshot generation cannot drift apart.
Types ¶
type Document ¶
type Document struct {
Version int `json:"gadak_team_config"`
ExportedAt string `json:"exported_at"`
Settings TeamSettings `json:"settings"`
Views []ExportView `json:"views"`
}
Document is the on-disk team share file.
func BuildDocument ¶
BuildDocument copies whitelist settings and views into a Document. It never copies Site/Email/Token or other never-export fields.
func ParseDocument ¶
ParseDocument unmarshals raw team-config JSON, rejects unknown versions and any credential-shaped keys (site/email/token/…).
type ExportOptions ¶
type ExportOptions struct {
// WithMembers includes Members (emails). Default false.
WithMembers bool
// Now overrides the export timestamp (tests). Zero means time.Now().UTC().
Now time.Time
}
ExportOptions controls optional inclusions.
type ExportView ¶
type ExportView struct {
Name string `json:"name"`
Config json.RawMessage `json:"config"`
}
ExportView is a saved view without machine-local id/timestamps.
type ImportOptions ¶
type ImportOptions struct {
// Overwrite replaces conflicting settings keys and same-named views.
Overwrite bool
// DryRun builds and returns a plan without applying it.
DryRun bool
}
ImportOptions controls merge behaviour.
type Plan ¶
type Plan struct {
Settings []SettingChange
Views []ViewChange
// Incoming is the validated document (settings + views to apply from).
Incoming Document
}
Plan is a pure value describing what import would do. Dry-run prints it; real import applies the same plan so the two paths cannot diverge.
func BuildPlan ¶
func BuildPlan(current *config.Config, existingViews []store.SavedView, doc Document, opts ImportOptions) Plan
BuildPlan compares the incoming document to the current config and views.
func (Plan) SummaryLines ¶
Summary lines for human output (stable order).
type SettingAction ¶
type SettingAction string
SettingAction describes what happens to one settings key.
const ( SettingAdd SettingAction = "add" SettingSkip SettingAction = "skip" SettingReplace SettingAction = "replace" )
type SettingChange ¶
type SettingChange struct {
Key string // JSON key (e.g. "fields")
Action SettingAction
}
SettingChange is one planned settings field update.
type TeamSettings ¶
type TeamSettings struct {
Projects []string `json:"projects,omitempty"`
Fields []config.FieldSpec `json:"fields,omitempty"`
// FieldMap is a migration-only unmarshal target for team files written
// before export dropped the legacy shape. Import converts it into Fields.
FieldMap map[string]string `json:"fieldMap,omitempty"`
BodyFields []string `json:"bodyFields,omitempty"`
// EditableFields is a migration-only unmarshal target. Import overlays
// it onto Fields (legacy wins per alias) and clears it before merge.
EditableFields map[string]string `json:"editableFields,omitempty"`
Members []config.Member `json:"members,omitempty"`
GroupRules []config.GroupRule `json:"groupRules,omitempty"`
GroupQuery string `json:"groupQuery,omitempty"`
GroupLabels map[string]string `json:"groupLabels,omitempty"`
GroupColors map[string]string `json:"groupColors,omitempty"`
ProductByGroup map[string]config.Product `json:"productByGroup,omitempty"`
Features map[string]bool `json:"features,omitempty"`
QaDashboardURL string `json:"qaDashboardUrl,omitempty"`
StaleThresholdHours int `json:"staleThresholdHours,omitempty"`
Confluence *config.ConfluenceConfig `json:"confluence,omitempty"`
}
TeamSettings holds only the whitelist of Config fields that may be shared. JSON tags match config.Config so a human can diff against ~/.gadak/config.json.
type ViewAction ¶
type ViewAction string
ViewAction describes what happens to one named view.
const ( ViewAdd ViewAction = "add" ViewSkip ViewAction = "skip" ViewReplace ViewAction = "replace" )
type ViewChange ¶
type ViewChange struct {
Name string
Action ViewAction
// ExistingID is set when Action is ViewReplace (keep machine-local id).
ExistingID string
// Config is the incoming view config (for add/replace).
Config json.RawMessage
}
ViewChange is one planned saved-view update.