setup

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 6 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 setup implements an interactive setup wizard for the collector binary. Files in this package that are not guarded by a build tag are always compiled, regardless of whether the wizard TUI (charm.land/huh/v2) is linked in.

Index

Constants

This section is empty.

Variables

View Source
var Registry = []Channel{
	{
		ID:    "filesystem",
		Label: "Filesystem (local folder)",
		Vars: []EnvVar{
			{
				Key:          "FILESYSTEM_PATH",
				Label:        "Filesystem path",
				Description:  "Absolute path to the folder to collect from (e.g. /Users/you/Google Drive/My Drive).",
				DefaultValue: "",
			},
			{
				Key:          "FILESYSTEM_ENABLED",
				Label:        "Filesystem enabled",
				Description:  "Always set to true when filesystem path is configured.",
				DefaultValue: "true",
				Hardcoded:    true,
			},
		},
	},
	{
		ID:    "slack",
		Label: "Slack",
		Vars: []EnvVar{
			{
				Key:         "SLACK_BOT_TOKEN",
				Label:       "Slack bot token",
				Description: "OAuth bot token starting with xoxb-.",
				Secret:      true,
			},
			{
				Key:         "SLACK_TEAM_ID",
				Label:       "Slack team ID",
				Description: "Workspace ID (T...). Found at api.slack.com/apps → Basic Information.",
			},
		},
	},
	{
		ID:    "github",
		Label: "GitHub",
		Vars: []EnvVar{
			{
				Key:         "GITHUB_TOKEN",
				Label:       "GitHub personal access token",
				Description: "Fine-grained or classic PAT with repo read scope.",
				Secret:      true,
			},
			{
				Key:         "GITHUB_ORG",
				Label:       "GitHub organization",
				Description: "GitHub organisation or user name whose repositories to collect.",
			},
		},
	},
	{
		ID:    "gdrive",
		Label: "Google Drive (service account)",
		Vars: []EnvVar{
			{
				Key:         "GDRIVE_CREDENTIALS_JSON",
				Label:       "Google service account JSON",
				Description: "Paste the full contents of your service_account.json (will be stored on a single line).",
				Secret:      true,
				Multiline:   true,
			},
		},
	},
	{
		ID:    "notion",
		Label: "Notion",
		Vars: []EnvVar{
			{
				Key:         "NOTION_TOKEN",
				Label:       "Notion integration token",
				Description: "Internal integration secret from notion.so/my-integrations.",
				Secret:      true,
			},
		},
	},
	{
		ID:    "telegram",
		Label: "Telegram",
		Vars: []EnvVar{
			{
				Key:         "TELEGRAM_BOT_TOKEN",
				Label:       "Telegram bot token",
				Description: "Token from @BotFather.",
				Secret:      true,
			},
			{
				Key:         "TELEGRAM_CHAT_IDS",
				Label:       "Telegram chat IDs",
				Description: "Comma-separated list of chat IDs to collect from (e.g. -1001234567890).",
			},
		},
	},
	{
		ID:       "discord",
		Label:    "Discord",
		InfoOnly: true,
		InfoMessage: "Discord collector requires a bot token and guild IDs configured via the API server. " +
			"See README §Discord for setup instructions. No .env keys are written by this wizard.",
	},
}

Registry is the canonical ordered list of collector channels. discord is info-only — it points users to the README §Discord section.

Functions

func EnvFilePath

func EnvFilePath() string

EnvFilePath returns the path to .env relative to the process working directory. Exported for use in tests.

func Run

func Run(_ []string) error

Run is a stub that informs the user they must rebuild with -tags setup. This stub is compiled into the default (production) binary so that cmd/collector/main.go can always import the setup package without pulling in the charm.land/huh/v2 TUI dependency.

func WriteEnv

func WriteEnv(dest string, pairs map[string]string, order []string) error

WriteEnv atomically writes key=value pairs to dest (typically ".env").

Algorithm:

  1. If dest already exists, back it up to <dir>/.env.bak.<unix-ts>.
  2. Write a temp file in the same directory with mode 0600.
  3. os.Rename to atomically replace the destination.

The caller provides the full destination path.

Types

type Channel

type Channel struct {
	// ID is the canonical short name (e.g. "slack", "filesystem").
	ID string

	// Label is the display name shown in the channel picker.
	Label string

	// InfoOnly channels print an informational message instead of prompting.
	InfoOnly bool

	// InfoMessage is printed when InfoOnly is true.
	InfoMessage string

	// Vars is the ordered list of environment variables the wizard writes.
	Vars []EnvVar
}

Channel describes a collector data source and the env vars it requires.

type EnvVar

type EnvVar struct {
	// Key is the variable name written to .env (e.g. "SLACK_BOT_TOKEN").
	Key string

	// Label is a human-readable prompt label shown in the wizard.
	Label string

	// Description is a short explanation shown below the prompt.
	Description string

	// Secret marks the value as sensitive; the wizard masks input.
	// Secret is ignored when Multiline is true: huh.Text has no EchoMode.
	Secret bool

	// Multiline allows multi-line paste (used for JSON credentials).
	Multiline bool

	// DefaultValue is pre-populated when the user leaves the field blank.
	DefaultValue string

	// Hardcoded means the value is always written as DefaultValue and the
	// user is never prompted.
	Hardcoded bool
}

EnvVar describes a single environment variable the wizard can configure.

Jump to

Keyboard shortcuts

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