setup

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: EUPL-1.2 Imports: 17 Imported by: 0

Documentation

Overview

Package setup provides workspace bootstrap and package cloning commands.

Two modes of operation:

REGISTRY MODE (repos.yaml exists):

  • Clones all repositories defined in repos.yaml into packages/
  • Skips repos that already exist
  • Supports filtering by type with --only

BOOTSTRAP MODE (no repos.yaml):

  • Clones core-devops to set up the workspace foundation
  • Presents an interactive wizard to select packages (unless --all)
  • Clones selected packages

Flags:

  • --registry: Path to repos.yaml (auto-detected if not specified)
  • --only: Filter by repo type (foundation, module, product)
  • --dry-run: Preview what would be cloned
  • --all: Skip wizard, clone all packages (non-interactive)
  • --name: Project directory name for bootstrap mode
  • --build: Run build after cloning

Uses gh CLI with HTTPS when authenticated, falls back to SSH.

Package setup provides workspace setup and bootstrap commands.

cmd_wizard.go implements the interactive package selection wizard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSetupCommand

func AddSetupCommand(root *cobra.Command)

AddSetupCommand adds the 'setup' command to the given parent command.

func AddSetupCommands

func AddSetupCommands(root *cobra.Command)

AddSetupCommands registers the 'setup' command and all subcommands.

func CreateLabel added in v0.0.3

func CreateLabel(repoFullName string, label LabelConfig) error

CreateLabel creates a new label in a repository.

func CreateWebhook added in v0.0.3

func CreateWebhook(repoFullName string, name string, config WebhookConfig) error

CreateWebhook creates a new webhook in a repository.

func DisableDependabotSecurityUpdates added in v0.0.3

func DisableDependabotSecurityUpdates(repoFullName string) error

DisableDependabotSecurityUpdates disables automated Dependabot security updates.

func EditLabel added in v0.0.3

func EditLabel(repoFullName string, label LabelConfig) error

EditLabel updates an existing label in a repository.

func EnableDependabotAlerts added in v0.0.3

func EnableDependabotAlerts(repoFullName string) error

EnableDependabotAlerts enables Dependabot vulnerability alerts.

func EnableDependabotSecurityUpdates added in v0.0.3

func EnableDependabotSecurityUpdates(repoFullName string) error

EnableDependabotSecurityUpdates enables automated Dependabot security updates.

func FindGitHubConfig added in v0.0.3

func FindGitHubConfig(registryDir, specifiedPath string) (string, error)

FindGitHubConfig searches for github.yaml in common locations. Search order:

  1. Specified path (if non-empty)
  2. .core/github.yaml (relative to registry)
  3. github.yaml (relative to registry)

func SetBranchProtection added in v0.0.3

func SetBranchProtection(repoFullName, branch string, config BranchProtectionConfig) error

SetBranchProtection sets branch protection rules for a branch.

func UpdateSecurityAndAnalysis added in v0.0.3

func UpdateSecurityAndAnalysis(repoFullName string, secretScanning, pushProtection bool) error

UpdateSecurityAndAnalysis updates security_and_analysis settings.

func UpdateWebhook added in v0.0.3

func UpdateWebhook(repoFullName string, hookID int, config WebhookConfig) error

UpdateWebhook updates an existing webhook.

Types

type Aggregate added in v0.0.3

type Aggregate struct {
	Sets []*ChangeSet
}

Aggregate combines multiple change sets into a summary.

func NewAggregate added in v0.0.3

func NewAggregate() *Aggregate

NewAggregate creates a new aggregate.

func (*Aggregate) Add added in v0.0.3

func (a *Aggregate) Add(cs *ChangeSet)

Add adds a change set to the aggregate.

func (*Aggregate) PrintSummary added in v0.0.3

func (a *Aggregate) PrintSummary()

PrintSummary outputs the aggregate summary.

func (*Aggregate) ReposWithChanges added in v0.0.3

func (a *Aggregate) ReposWithChanges() int

ReposWithChanges returns the number of repos that have changes.

func (*Aggregate) TotalChanges added in v0.0.3

func (a *Aggregate) TotalChanges() (creates, updates, deletes, skips int)

TotalChanges returns the total number of changes across all sets.

type AllowDeletions added in v0.0.3

type AllowDeletions struct {
	Enabled bool `json:"enabled"`
}

AllowDeletions indicates if branch deletion is allowed.

type AllowForcePushes added in v0.0.3

type AllowForcePushes struct {
	Enabled bool `json:"enabled"`
}

AllowForcePushes indicates if force pushes are allowed.

type BranchProtectionConfig added in v0.0.3

type BranchProtectionConfig struct {
	Branch                        string   `yaml:"branch"`
	RequiredReviews               int      `yaml:"required_reviews"`
	DismissStale                  bool     `yaml:"dismiss_stale"`
	RequireCodeOwnerReviews       bool     `yaml:"require_code_owner_reviews"`
	RequiredStatusChecks          []string `yaml:"required_status_checks"`
	RequireLinearHistory          bool     `yaml:"require_linear_history"`
	AllowForcePushes              bool     `yaml:"allow_force_pushes"`
	AllowDeletions                bool     `yaml:"allow_deletions"`
	EnforceAdmins                 bool     `yaml:"enforce_admins"`
	RequireConversationResolution bool     `yaml:"require_conversation_resolution"`
}

BranchProtectionConfig defines branch protection rules.

type Change added in v0.0.3

type Change struct {
	Category    ChangeCategory
	Type        ChangeType
	Name        string
	Description string
	Details     map[string]string // Key-value details about the change
}

Change represents a single change to be made.

type ChangeCategory added in v0.0.3

type ChangeCategory string

ChangeCategory groups changes by type.

const (
	CategoryLabel      ChangeCategory = "label"
	CategoryWebhook    ChangeCategory = "webhook"
	CategoryProtection ChangeCategory = "protection"
	CategorySecurity   ChangeCategory = "security"
)

type ChangeSet added in v0.0.3

type ChangeSet struct {
	Repo    string
	Changes []Change
}

ChangeSet tracks all changes for a repository.

func NewChangeSet added in v0.0.3

func NewChangeSet(repo string) *ChangeSet

NewChangeSet creates a new change set for a repository.

func SyncBranchProtection added in v0.0.3

func SyncBranchProtection(repoFullName string, config *GitHubConfig, dryRun bool) (*ChangeSet, error)

SyncBranchProtection synchronizes branch protection for a repository.

func SyncLabels added in v0.0.3

func SyncLabels(repoFullName string, config *GitHubConfig, dryRun bool) (*ChangeSet, error)

SyncLabels synchronizes labels for a repository. Returns a ChangeSet describing what was changed (or would be changed in dry-run mode).

func SyncSecuritySettings added in v0.0.3

func SyncSecuritySettings(repoFullName string, config *GitHubConfig, dryRun bool) (*ChangeSet, error)

SyncSecuritySettings synchronizes security settings for a repository.

func SyncWebhooks added in v0.0.3

func SyncWebhooks(repoFullName string, config *GitHubConfig, dryRun bool) (*ChangeSet, error)

SyncWebhooks synchronizes webhooks for a repository. Webhooks are matched by URL - if a webhook with the same URL exists, it's updated. Otherwise, a new webhook is created.

func (*ChangeSet) Add added in v0.0.3

func (cs *ChangeSet) Add(category ChangeCategory, changeType ChangeType, name, description string)

Add adds a change to the set.

func (*ChangeSet) AddWithDetails added in v0.0.3

func (cs *ChangeSet) AddWithDetails(category ChangeCategory, changeType ChangeType, name, description string, details map[string]string)

AddWithDetails adds a change with additional details.

func (*ChangeSet) Count added in v0.0.3

func (cs *ChangeSet) Count() (creates, updates, deletes, skips int)

Count returns the number of changes by type.

func (*ChangeSet) CountByCategory added in v0.0.3

func (cs *ChangeSet) CountByCategory() map[ChangeCategory]int

CountByCategory returns changes grouped by category.

func (*ChangeSet) HasChanges added in v0.0.3

func (cs *ChangeSet) HasChanges() bool

HasChanges returns true if there are any non-skip changes.

func (*ChangeSet) Print added in v0.0.3

func (cs *ChangeSet) Print(verbose bool)

Print outputs the change set to the console.

type ChangeType added in v0.0.3

type ChangeType string

ChangeType indicates the type of change being made.

const (
	ChangeCreate ChangeType = "create"
	ChangeUpdate ChangeType = "update"
	ChangeDelete ChangeType = "delete"
	ChangeSkip   ChangeType = "skip"
)

type EnforceAdmins added in v0.0.3

type EnforceAdmins struct {
	Enabled bool `json:"enabled"`
}

EnforceAdmins indicates if admins are subject to rules.

type GitHubBranchProtection added in v0.0.3

type GitHubBranchProtection struct {
	RequiredStatusChecks           *RequiredStatusChecks           `json:"required_status_checks"`
	RequiredPullRequestReviews     *RequiredPullRequestReviews     `json:"required_pull_request_reviews"`
	EnforceAdmins                  *EnforceAdmins                  `json:"enforce_admins"`
	RequiredLinearHistory          *RequiredLinearHistory          `json:"required_linear_history"`
	AllowForcePushes               *AllowForcePushes               `json:"allow_force_pushes"`
	AllowDeletions                 *AllowDeletions                 `json:"allow_deletions"`
	RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"`
}

GitHubBranchProtection represents branch protection rules from the GitHub API.

func GetBranchProtection added in v0.0.3

func GetBranchProtection(repoFullName, branch string) (*GitHubBranchProtection, error)

GetBranchProtection fetches branch protection rules for a branch.

type GitHubConfig added in v0.0.3

type GitHubConfig struct {
	Version          int                      `yaml:"version"`
	Labels           []LabelConfig            `yaml:"labels"`
	Webhooks         map[string]WebhookConfig `yaml:"webhooks"`
	BranchProtection []BranchProtectionConfig `yaml:"branch_protection"`
	Security         SecurityConfig           `yaml:"security"`
}

GitHubConfig represents the full GitHub setup configuration.

func LoadGitHubConfig added in v0.0.3

func LoadGitHubConfig(path string) (*GitHubConfig, error)

LoadGitHubConfig reads and parses a GitHub configuration file.

func (*GitHubConfig) Validate added in v0.0.3

func (c *GitHubConfig) Validate() error

Validate checks the configuration for errors.

type GitHubLabel added in v0.0.3

type GitHubLabel struct {
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description"`
}

GitHubLabel represents a label as returned by the GitHub API.

func ListLabels added in v0.0.3

func ListLabels(repoFullName string) ([]GitHubLabel, error)

ListLabels fetches all labels for a repository.

type GitHubRepoResponse added in v0.0.3

type GitHubRepoResponse struct {
	SecurityAndAnalysis *SecurityAndAnalysis `json:"security_and_analysis"`
}

GitHubRepoResponse contains security-related fields from repo API.

type GitHubSecurityStatus added in v0.0.3

type GitHubSecurityStatus struct {
	DependabotAlerts             bool
	DependabotSecurityUpdates    bool
	SecretScanning               bool
	SecretScanningPushProtection bool
}

GitHubSecurityStatus represents the security settings status of a repository.

func GetSecuritySettings added in v0.0.3

func GetSecuritySettings(repoFullName string) (*GitHubSecurityStatus, error)

GetSecuritySettings fetches current security settings for a repository.

type GitHubWebhook added in v0.0.3

type GitHubWebhook struct {
	ID     int                 `json:"id"`
	Name   string              `json:"name"`
	Active bool                `json:"active"`
	Events []string            `json:"events"`
	Config GitHubWebhookConfig `json:"config"`
}

GitHubWebhook represents a webhook as returned by the GitHub API.

func ListWebhooks added in v0.0.3

func ListWebhooks(repoFullName string) ([]GitHubWebhook, error)

ListWebhooks fetches all webhooks for a repository.

type GitHubWebhookConfig added in v0.0.3

type GitHubWebhookConfig struct {
	URL         string `json:"url"`
	ContentType string `json:"content_type"`
	InsecureSSL string `json:"insecure_ssl"`
}

GitHubWebhookConfig contains webhook configuration details.

type LabelConfig added in v0.0.3

type LabelConfig struct {
	Name        string `yaml:"name"`
	Color       string `yaml:"color"`
	Description string `yaml:"description"`
}

LabelConfig defines a GitHub issue/PR label.

type RequiredConversationResolution added in v0.0.3

type RequiredConversationResolution struct {
	Enabled bool `json:"enabled"`
}

RequiredConversationResolution indicates if conversation resolution is required.

type RequiredLinearHistory added in v0.0.3

type RequiredLinearHistory struct {
	Enabled bool `json:"enabled"`
}

RequiredLinearHistory indicates if linear history is required.

type RequiredPullRequestReviews added in v0.0.3

type RequiredPullRequestReviews struct {
	DismissStaleReviews          bool `json:"dismiss_stale_reviews"`
	RequireCodeOwnerReviews      bool `json:"require_code_owner_reviews"`
	RequiredApprovingReviewCount int  `json:"required_approving_review_count"`
}

RequiredPullRequestReviews defines review requirements.

type RequiredStatusChecks added in v0.0.3

type RequiredStatusChecks struct {
	Strict   bool     `json:"strict"`
	Contexts []string `json:"contexts"`
}

RequiredStatusChecks defines required CI checks.

type SecurityAndAnalysis added in v0.0.3

type SecurityAndAnalysis struct {
	SecretScanning               *SecurityFeature `json:"secret_scanning"`
	SecretScanningPushProtection *SecurityFeature `json:"secret_scanning_push_protection"`
	DependabotSecurityUpdates    *SecurityFeature `json:"dependabot_security_updates"`
}

SecurityAndAnalysis contains security feature settings.

type SecurityConfig added in v0.0.3

type SecurityConfig struct {
	DependabotAlerts             bool `yaml:"dependabot_alerts"`
	DependabotSecurityUpdates    bool `yaml:"dependabot_security_updates"`
	SecretScanning               bool `yaml:"secret_scanning"`
	SecretScanningPushProtection bool `yaml:"push_protection"`
}

SecurityConfig defines repository security settings.

type SecurityFeature added in v0.0.3

type SecurityFeature struct {
	Status string `json:"status"` // "enabled" or "disabled"
}

SecurityFeature represents a single security feature status.

type WebhookConfig added in v0.0.3

type WebhookConfig struct {
	URL         string   `yaml:"url"`          // Webhook URL (supports ${ENV_VAR})
	ContentType string   `yaml:"content_type"` // json or form (default: json)
	Secret      string   `yaml:"secret"`       // Optional secret (supports ${ENV_VAR})
	Events      []string `yaml:"events"`       // Events to trigger on
	Active      *bool    `yaml:"active"`       // Whether webhook is active (default: true)
}

WebhookConfig defines a GitHub webhook configuration.

Jump to

Keyboard shortcuts

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