Skip to content

Commit

Permalink
chore: terramate list requires no repo checks (#1942)
Browse files Browse the repository at this point in the history
## What this PR does / why we need it:

Improves list performance by not checking for git safeguard info.

## Which issue(s) this PR fixes:
none

## Special notes for your reviewer:

## Does this PR introduce a user-facing change?
```
no
```
  • Loading branch information
i4ki authored Oct 24, 2024
2 parents b107a69 + 7f788d4 commit 859c266
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/terramate/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ func (c *cli) triggerStackByFilter() {
stackFilter := cloud.StatusFilters{
StackStatus: statusFilter,
}
stacksReport, err := c.listStacks(false, "", stackFilter)
stacksReport, err := c.listStacks(false, "", stackFilter, false)
if err != nil {
fatalWithDetailf(err, "unable to list stacks")
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ func (c *cli) triggerStack(basePath string) {
stacks = append(stacks, st.Sortable())
} else {
var err error
stacksReport, err := c.listStacks(false, cloudstack.AnyTarget, cloud.NoStatusFilters())
stacksReport, err := c.listStacks(false, cloudstack.AnyTarget, cloud.NoStatusFilters(), false)
if err != nil {
fatalWithDetailf(err, "computing selected stacks")
}
Expand Down Expand Up @@ -1297,7 +1297,7 @@ func (c *cli) setupChangeDetection(enable []string, disable []string) {
}
}

func (c *cli) listStacks(isChanged bool, target string, stackFilters cloud.StatusFilters) (*stack.Report, error) {
func (c *cli) listStacks(isChanged bool, target string, stackFilters cloud.StatusFilters, checkRepo bool) (*stack.Report, error) {
var (
err error
report *stack.Report
Expand All @@ -1312,7 +1312,7 @@ func (c *cli) listStacks(isChanged bool, target string, stackFilters cloud.Statu
UncommittedChanges: c.changeDetection.uncommitted,
})
} else {
report, err = mgr.List(true)
report, err = mgr.List(checkRepo)
}

if report != nil {
Expand Down Expand Up @@ -1796,7 +1796,7 @@ func (c *cli) printStacks() {
DriftStatus: parseDriftStatusFilter(driftStatusStr),
}

report, err := c.listStacks(c.parsedArgs.Changed, c.parsedArgs.List.Target, cloudFilters)
report, err := c.listStacks(c.parsedArgs.Changed, c.parsedArgs.List.Target, cloudFilters, false)
if err != nil {
fatal(err)
}
Expand Down Expand Up @@ -1875,7 +1875,7 @@ func parseDriftStatusFilter(filterStr string) drift.FilterStatus {
}

func (c *cli) printRuntimeEnv() {
report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters())
report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters(), false)
if err != nil {
fatalWithDetailf(err, "listing stacks")
}
Expand Down Expand Up @@ -2067,7 +2067,7 @@ func (c *cli) generateDebug() {
}

func (c *cli) printStacksGlobals() {
report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters())
report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters(), false)
if err != nil {
fatalWithDetailf(err, "listing stacks globals: listing stacks")
}
Expand Down Expand Up @@ -2096,7 +2096,7 @@ func (c *cli) printMetadata() {
Str("action", "cli.printMetadata()").
Logger()

report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters())
report, err := c.listStacks(c.parsedArgs.Changed, cloudstack.AnyTarget, cloud.NoStatusFilters(), false)
if err != nil {
fatalWithDetailf(err, "loading metadata: listing stacks")
}
Expand Down Expand Up @@ -2155,7 +2155,7 @@ func (c *cli) checkGenCode() bool {
}

func (c *cli) ensureStackID() {
report, err := c.listStacks(false, cloudstack.AnyTarget, cloud.NoStatusFilters())
report, err := c.listStacks(false, cloudstack.AnyTarget, cloud.NoStatusFilters(), false)
if err != nil {
fatalWithDetailf(err, "listing stacks")
}
Expand Down Expand Up @@ -2416,7 +2416,7 @@ func (c *cli) friendlyFmtDir(dir string) (string, bool) {
}

func (c *cli) computeSelectedStacks(ensureCleanRepo bool, target string, stackFilters cloud.StatusFilters) (config.List[*config.SortableStack], error) {
report, err := c.listStacks(c.parsedArgs.Changed, target, stackFilters)
report, err := c.listStacks(c.parsedArgs.Changed, target, stackFilters, true)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 859c266

Please sign in to comment.