Skip to content
Open
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
11 changes: 7 additions & 4 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,19 @@ func Execute(rootCmd *cobra.Command, stdin io.Reader, stdout io.Writer, stderr i
}()
}

if err = preRunSetupAPIs(cmd, args); err != nil {
return errors.Wrap(err, "set up APIs")
}

// release lint with REPLICATED_RELEASE_VALIDATION_V2=1 (local lint) reads
// .replicated independently for lint config and doesn't need app context.
// Skip .replicated app resolution only in that specific case to avoid
// unnecessary API calls when the app slug in .replicated doesn't exist.
isV2Lint := cmd.Name() == "lint" && cmd.Parent() != nil && cmd.Parent().Name() == "release" &&
os.Getenv("REPLICATED_RELEASE_VALIDATION_V2") == "1"

// v2 lint runs locally and intentionally works without API credentials.
if !isV2Lint {
if err = preRunSetupAPIs(cmd, args); err != nil {
return errors.Wrap(err, "set up APIs")
}
}
if isV2Lint {
if appSlugOrID == "" {
appSlugOrID = os.Getenv("REPLICATED_APP")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
golang.org/x/term v0.45.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.21.3
helm.sh/helm/v3 v3.21.4
k8s.io/apimachinery v0.36.3
k8s.io/client-go v0.36.3
oras.land/oras-go/v2 v2.6.2
Expand Down Expand Up @@ -66,7 +66,7 @@ require (
github.com/Masterminds/semver/v3 v3.5.0 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.3.0 // indirect
github.com/ProtonMail/go-crypto v1.4.1 // indirect
github.com/ahmetalpbalkan/go-cursor v0.0.0-20131010032410-8136607ea412 // indirect
github.com/andybalholm/brotli v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.1.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA4
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM=
github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
github.com/ahmetalpbalkan/go-cursor v0.0.0-20131010032410-8136607ea412 h1:vOVO0ypMfTt6tZacyI0kp+iCZb1XSNiYDqnzBWYgfe4=
Expand Down Expand Up @@ -926,8 +926,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
helm.sh/helm/v3 v3.21.3 h1:wkamdwI3liEkW6wI1l9aGqQZGxcTKyt8kx0qJLPcmCg=
helm.sh/helm/v3 v3.21.3/go.mod h1:iaJ0iNsPoTZl++7h6vzQFyT0VEVtLYJiyRBDkPOOBTs=
helm.sh/helm/v3 v3.21.4 h1:T/GcIEXU/gNjJnkITlIZ3e9xqkZjhFTmISuStTZ6+Qg=
helm.sh/helm/v3 v3.21.4/go.mod h1:cS2FBb+xfLuaSqvEmbqIeKUVFgHdHVHtVeXb2epof3M=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.36.3 h1:NxB+05W2UGqXWFXcLO0RB5cnqnUPP5v5sVlaOH0Iz4w=
Expand Down
12 changes: 12 additions & 0 deletions pkg/lint2/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ func DiscoverSupportBundlesFromManifests(manifestGlobs []string) ([]string, erro
// Returns true for paths like .git, .github, foo/.hidden/bar, etc.
// Does not consider . or .. as hidden (current/parent directory references).
func isHiddenPath(path string) bool {
// Treat paths relative to the current working directory so that parent
// directories outside the project (e.g., /home/user/.openclaw/...) are not
// considered hidden. Hidden directories should only be evaluated within the
// project tree.
if abs, err := filepath.Abs(path); err == nil {
if cwd, err := os.Getwd(); err == nil {
if rel, err := filepath.Rel(cwd, abs); err == nil && !filepath.IsAbs(rel) {
path = rel
}
}
}

parts := strings.Split(filepath.ToSlash(path), "/")
for _, part := range parts {
if strings.HasPrefix(part, ".") && part != "." && part != ".." {
Expand Down
36 changes: 36 additions & 0 deletions pkg/lint2/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,42 @@ func TestIsHiddenPath(t *testing.T) {
}
}

func TestIsHiddenPath_AbsolutePathUnderHiddenParent(t *testing.T) {
// Paths should be evaluated relative to the project (cwd), not the absolute
// filesystem path. A workspace located under a hidden directory like
// /home/user/.openclaw/project should not cause files inside the project to
// be treated as hidden.
tmpDir := t.TempDir()
projectDir := filepath.Join(tmpDir, ".openclaw", "workspace")
if err := os.MkdirAll(projectDir, 0755); err != nil {
t.Fatal(err)
}

originalWd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
defer func() {
if err := os.Chdir(originalWd); err != nil {
t.Errorf("failed to restore cwd: %v", err)
}
}()

if err := os.Chdir(projectDir); err != nil {
t.Fatal(err)
}

normalFile := filepath.Join(projectDir, "manifests", "helmchart.yaml")
if isHiddenPath(normalFile) {
t.Errorf("isHiddenPath(%q) = true, want false (hidden parent outside project should not matter)", normalFile)
}

hiddenFile := filepath.Join(projectDir, ".hidden", "config.yaml")
if !isHiddenPath(hiddenFile) {
t.Errorf("isHiddenPath(%q) = false, want true (hidden segment inside project should be hidden)", hiddenFile)
}
}

func TestIsChartDirectory(t *testing.T) {
tmpDir := t.TempDir()

Expand Down