Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"postUpdateOptions": ["gomodUpdateImportPaths", "gomodTidy"],
"customManagers": [
{
"customType": "regex",
"description": "Surface helm.sh/helm v3 -> v4 major upgrade in go.mod",
"managerFilePatterns": ["/(^|/)go\\.mod$/"],
"matchStrings": [
"helm\\.sh/helm/v3 v(?<currentValue>\\d+\\.\\d+\\.\\d+)"
],
"depNameTemplate": "helm.sh/helm/v4",
"datasourceTemplate": "go",
"versioningTemplate": "semver"
}
]
}
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run tests
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check DCO sign-off
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
runs-on: oracle-vm-2cpu-8gb-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v7
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
Expand Down
265 changes: 144 additions & 121 deletions go.mod

Large diffs are not rendered by default.

580 changes: 300 additions & 280 deletions go.sum

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -83,23 +84,23 @@ func init() {
for _, cmd := range commands.Commands {
rootCmd.AddCommand(cmd)
}

// Add PersistentPreRunE to handle root detection and config loading
originalPersistentPreRunE := rootCmd.PersistentPreRunE
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
// Detect and set project root using fallback strategy
if err := commands.DetectAndSetRoot(cmd, args); err != nil {
return err
}

// Load config after root detection (skip for init and completion commands)
if !isCommandOrParent(cmd, skipConfigCommands...) {
configFile := filepath.Join(commands.Config.RootDir, "Chart.yaml")
if err := loadConfig(configFile); err != nil {
return fmt.Errorf("error loading configuration: %w", err)
}
}

// Ensure talosconfig path is set to project root if not explicitly set via flag
// This is needed for all commands that use talosctl client (template, apply, etc.)
if !cmd.PersistentFlags().Changed("talosconfig") {
Expand All @@ -121,7 +122,7 @@ func init() {
commands.GlobalArgs.Talosconfig = talosconfigPath
}
}

if originalPersistentPreRunE != nil {
return originalPersistentPreRunE(cmd, args)
}
Expand All @@ -130,6 +131,9 @@ func init() {
}

func initConfig() {
if len(os.Args) < 2 {
return
}
cmdName := os.Args[1]
cmd, _, err := rootCmd.Find([]string{cmdName})
if err != nil || cmd == nil {
Expand All @@ -138,7 +142,7 @@ func initConfig() {
if cmd.HasParent() && cmd.Parent() != rootCmd {
cmd = cmd.Parent()
}

if strings.HasPrefix(cmd.Use, "init") {
if strings.HasPrefix(Version, "v") {
commands.Config.InitOptions.Version = strings.TrimPrefix(Version, `v`)
Expand All @@ -151,10 +155,8 @@ func initConfig() {
// isCommandOrParent checks if the command or any of its parents matches one of the given names.
func isCommandOrParent(cmd *cobra.Command, names ...string) bool {
for c := cmd; c != nil; c = c.Parent() {
for _, name := range names {
if c.Name() == name {
return true
}
if slices.Contains(names, c.Name()) {
return true
}
}
return false
Expand Down
Loading