teamconfig

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const CurrentFormat = 1

CurrentFormat is the only gadak_team_config version this build understands.

Variables

This section is empty.

Functions

func ApplyPlan

func ApplyPlan(ctx context.Context, cfg *config.Config, db *store.DB, plan Plan) error

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. ctx is threaded into every db write (GDK-619) — the plan must not bury its own context.Background(); the CLI passes one at its boundary.

func MarshalDocument

func MarshalDocument(doc Document) ([]byte, error)

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).

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

func BuildDocument(cfg *config.Config, views []store.SavedView, opts ExportOptions) Document

BuildDocument copies whitelist settings and views into a Document. It never copies Site/Email/Token or other never-export fields.

func ParseDocument

func ParseDocument(raw []byte) (Document, error)

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

func (p Plan) SummaryLines() []string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL