Documentation
¶
Index ¶
- Variables
- type Service
- func (s *Service) EnsureToolDefaultTags(ctx context.Context, toolPath string, defaults []tool.DefaultTag) error
- func (s *Service) GroupTags(ctx context.Context) ([]*entity.Tag, error)
- func (s *Service) SyncSystemTagsForAllAdmins(ctx context.Context) error
- func (s *Service) TagsByIDs(ctx context.Context, ids []string) ([]*entity.Tag, error)
- func (s *Service) ToolTagIDs(ctx context.Context, toolPaths []string) (map[string][]string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Text is the home-page group for text formatting / conversion / // manipulation tools. Text = tool.DefaultTag{ Name: "Text", Description: "Text formatting, conversion, and manipulation.", IsGroup: true, SortOrder: 10, } // API groups developer-facing API tooling: request builders, mocking // servers, anything that helps poke at HTTP endpoints. API = tool.DefaultTag{ Name: "API", Description: "Build, mock, and inspect HTTP APIs.", IsGroup: true, SortOrder: 30, } // Job groups background jobs that run on a cron schedule or are // triggered manually. Job = tool.DefaultTag{ Name: "Job", Description: "Background jobs with cron scheduling.", IsGroup: true, SortOrder: 90, } // System marks built-in maintenance items (jobs/tools/connectors // shipped by wick itself) that end users should not see or manage. // // Three flags work together: // - IsSystem : admin UI refuses to assign this tag to a user, so // no user can ever "carry" it. // - IsFilter : the tag participates in the access-filter rule — // because no user carries it, the item is hidden // from every non-admin /manager surface. // - IsGroup : the home page renders System-tagged items in // their own group when an admin browses there. // // Sort last so the System group sits at the bottom of the home page. System = tool.DefaultTag{ Name: "System", Description: "Built-in maintenance items shipped with wick. Hidden from non-admin users.", IsGroup: true, IsFilter: true, IsSystem: true, SortOrder: 1000, } )
Default tag catalog. Add new shared tags here so every tool references the same spec — rename/flag changes happen in one place, and adding a tag to a tool is just appending `tags.Foo` to Meta().DefaultTags.
Seeding rules (see tags.Service.EnsureToolDefaultTags):
- A tag with a given Name is created once. Existing tags keep their flags — editing IsGroup/IsFilter here does NOT mutate an existing row. Change the flags from /admin/tags instead.
- Links to a tool are written only on the first registration of that tool (no tool_tag rows yet). Admin unlinks survive restarts.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) EnsureToolDefaultTags ¶
func (s *Service) EnsureToolDefaultTags(ctx context.Context, toolPath string, defaults []tool.DefaultTag) error
EnsureToolDefaultTags seeds DefaultTags for a tool on startup. For each spec it ensures the global tag exists by name (creating it with the declared flags if missing; existing tags are left untouched EXCEPT for the IsSystem flag — see below). It then links every spec tag to toolPath only when the tool has *no* tool_tag rows yet — so an admin who later unlinks a tag won't see it return after a restart.
IsSystem is special: it is code-owned (admins cannot toggle it from UI), so this function force-syncs the flag on EXISTING rows whose default declares IsSystem=true. That way a tag created before the IsSystem schema landed gets backfilled with the flag on the next boot — without it, the admin/repo guards (UpdateTag/DeleteTag/SetUserTags) wouldn't recognize the row as protected.
func (*Service) GroupTags ¶
GroupTags returns tags that should render as groups on the home page, ordered by sort_order then name.
func (*Service) SyncSystemTagsForAllAdmins ¶ added in v0.4.0
SyncSystemTagsForAllAdmins reconciles UserTag rows so every existing admin carries every Tag flagged IsSystem. Idempotent — uses FirstOrCreate per (user, tag) pair.
Called once at boot (after EnsureToolDefaultTags has had a chance to seed System tags) so admins who existed before the System-tag schema landed are auto-granted access to System-gated items. Per-user role changes after boot are handled inline by admin.Repo.SetRole — this boot call only catches the migration-time backfill.