Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
75dae97
improve comments for Link struct and its fields in linkedfiles.go
teresaromero Sep 24, 2025
83e13ad
refactor: enhance newLinkedFile function for better error handling an…
teresaromero Sep 24, 2025
9139bb2
test: add unit test for newLinkedFile function to validate link file …
teresaromero Sep 24, 2025
60672b2
decoupled repoRoot from lint cmd and docs
teresaromero Sep 25, 2025
211c7c9
update repository root handling across multiple components
teresaromero Sep 25, 2025
0b61910
standardize repository root handling across build, lint, and links ma…
teresaromero Sep 25, 2025
ce07ec3
ensure repository root is properly closed in multiple command actions…
teresaromero Sep 25, 2025
0deae99
add repoRoot parameter to build command action
teresaromero Sep 29, 2025
1fc643a
update linked file handling to use absolute paths and improve clarity
teresaromero Sep 29, 2025
6820b49
add copyright notice to packages_test.go file
teresaromero Sep 29, 2025
2c16cab
refactor linkedfiles_test.go to use os.MkdirAll for directory creation
teresaromero Sep 29, 2025
403527e
implement repository root handling in benchmark and install commands,…
teresaromero Sep 29, 2025
96d5129
read repoRoot at test runner cmd
teresaromero Sep 29, 2025
90ba403
refactor linkedfiles_test.go to use filepath.Join for constructing li…
teresaromero Sep 29, 2025
aeeee55
inject repoRoot to needed test options
teresaromero Sep 29, 2025
385fc89
Update data stream tests to include repoRoot parameter
teresaromero Sep 29, 2025
9edca9b
Ensure repoRoot is closed in all data stream test cases
teresaromero Sep 30, 2025
c60b836
Remove unnecessary directory change in createAndCheckDataStream function
teresaromero Sep 30, 2025
679c566
Merge branch 'main' into 2797-detach-repo-root
teresaromero Oct 6, 2025
ef3497f
refactor at copyLicenceTextFile to ensure license inside reporoot, re…
teresaromero Oct 6, 2025
1f591bf
Merge branch 'main' into 2797-detach-repo-root
teresaromero Oct 8, 2025
ec2a7e1
refactor linkefiles management to use relative paths and root
teresaromero Oct 9, 2025
169777f
revert linksDefinitionsFilePath from public to private
teresaromero Oct 9, 2025
9229664
add validation for RepoRoot in Options
teresaromero Oct 9, 2025
0436a37
clarify variable name for included file path in newLinkedFile function
teresaromero Oct 9, 2025
9793ffd
simplify checksum comparison logic in newLinkedFile function
teresaromero Oct 9, 2025
5d6ef55
refactor findRepositoryLicensePath to use repoRoot
teresaromero Oct 9, 2025
ecfeb9b
refactor copyLicenseTextFile to use repoRoot.Stat
teresaromero Oct 9, 2025
4412b0b
refactor FindPackageRoot and handle error on FindPackageRootFrom calls
teresaromero Oct 9, 2025
9b7a721
remove repoRoot.Write and Read
teresaromero Oct 9, 2025
091d117
Merge branch 'main' into 2797-detach-repo-root
teresaromero Oct 15, 2025
66274da
rename repoRoot to repositoryRoot for clarity
teresaromero Oct 15, 2025
5429121
fix: correct grammar in comments for license file handling
teresaromero Oct 15, 2025
b3e73ac
update copyLicenseTextFile function to improve clarity and error hand…
teresaromero Oct 15, 2025
563522f
enhance findRepositoryLicensePath function to check for empty license…
teresaromero Oct 15, 2025
bfe509e
improve path handling in TestFindRepositoryLicense and TestCopyLicen…
teresaromero Oct 15, 2025
59436db
rename test function and update comment for clarity
teresaromero Oct 15, 2025
248a704
remove unnecessary blank lines in test files for improved readability
teresaromero Oct 15, 2025
c74c6c8
rename PackageRoot to PackageRootPath for consistency across builder …
teresaromero Oct 15, 2025
68ed0d8
add repository root handling in benchmark and test runner commands
teresaromero Oct 15, 2025
54d8502
rename newLinkMap to newEmptyLinkMap and revert related functions to …
teresaromero Oct 15, 2025
3b32fcc
update findRepositoryLicensePath to use os.ReadFile and improve error…
teresaromero Oct 15, 2025
8af2c99
remove RepositoryRoot references from FleetAgentPolicy, rename RootPa…
teresaromero Oct 16, 2025
d08ed58
refactor copyLicenseTextFile to enforce absolute target license path …
teresaromero Oct 16, 2025
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
13 changes: 13 additions & 0 deletions cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/elasticsearch"
"github.com/elastic/elastic-package/internal/files"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/logger"
"github.com/elastic/elastic-package/internal/packages"
Expand Down Expand Up @@ -302,6 +303,11 @@ func rallyCommandAction(cmd *cobra.Command, args []string) error {
}
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -336,6 +342,7 @@ func rallyCommandAction(cmd *cobra.Command, args []string) error {
rally.WithRallyDryRun(rallyDryRun),
rally.WithRallyPackageFromRegistry(packageName, packageVersion),
rally.WithRallyCorpusAtPath(corpusAtPath),
rally.WithRepoRoot(repoRoot),
}

esMetricsClient, err := initializeESMetricsClient(ctx)
Expand Down Expand Up @@ -473,6 +480,11 @@ func streamCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("locating package root failed: %w", err)
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -507,6 +519,7 @@ func streamCommandAction(cmd *cobra.Command, args []string) error {
stream.WithESAPI(esClient.API),
stream.WithKibanaClient(kc),
stream.WithProfile(profile),
stream.WithRepoRoot(repoRoot),
}

runner := stream.NewStreamBenchmark(stream.NewOptions(withOpts...))
Expand Down
14 changes: 13 additions & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func buildCommandAction(cmd *cobra.Command, args []string) error {
}
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}
defer repoRoot.Close()

linksFilePath, err := docs.LinksDefinitionsFilePath(repoRoot)
if err != nil {
return fmt.Errorf("locating links file failed: %w", err)
}

packageRoot, err := packages.MustFindPackageRoot()
if err != nil {
return fmt.Errorf("locating package root failed: %w", err)
Expand All @@ -72,7 +83,7 @@ func buildCommandAction(cmd *cobra.Command, args []string) error {
}
logger.Debugf("Use build directory: %s", buildDir)

targets, err := docs.UpdateReadmes(packageRoot, buildDir)
targets, err := docs.UpdateReadmes(linksFilePath, packageRoot, buildDir)
if err != nil {
return fmt.Errorf("updating files failed: %w", err)
}
Expand All @@ -88,6 +99,7 @@ func buildCommandAction(cmd *cobra.Command, args []string) error {
CreateZip: createZip,
SignPackage: signPackage,
SkipValidation: skipValidation,
RepoRoot: repoRoot,
})
if err != nil {
return fmt.Errorf("building package failed: %w", err)
Expand Down
7 changes: 7 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/files"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/kibana"
"github.com/elastic/elastic-package/internal/packages"
Expand Down Expand Up @@ -82,11 +83,17 @@ func installCommandAction(cmd *cobra.Command, _ []string) error {
}
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

installer, err := installer.NewForPackage(cmd.Context(), installer.Options{
Kibana: kibanaClient,
RootPath: packageRootPath,
SkipValidation: skipValidation,
ZipPath: zipPathFile,
RepoRoot: repoRoot,
})
if err != nil {
return fmt.Errorf("package installation failed: %w", err)
Expand Down
29 changes: 24 additions & 5 deletions cmd/links.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package cmd
import (
"fmt"
"os"
"path/filepath"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -56,8 +55,14 @@ func linksCheckCommandAction(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("reading current working directory failed: %w", err)
}
// Find the repository root to create the links filesystem reference tied to the repository root
repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("finding repository root: %w", err)
}
defer repoRoot.Close()

linksFS, err := files.CreateLinksFSFromPath(pwd)
linksFS, err := files.CreateLinksFSFromPath(repoRoot, pwd)
if err != nil {
return fmt.Errorf("creating links filesystem failed: %w", err)
}
Expand All @@ -68,7 +73,7 @@ func linksCheckCommandAction(cmd *cobra.Command, args []string) error {
}
for _, f := range linkedFiles {
if !f.UpToDate {
cmd.Printf("%s is outdated.\n", filepath.Join(f.WorkDir, f.LinkFilePath))
cmd.Printf("%s is outdated.\n", f.LinkFilePath)
}
}
if len(linkedFiles) > 0 {
Expand All @@ -95,7 +100,14 @@ func linksUpdateCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("reading current working directory failed: %w", err)
}

linksFS, err := files.CreateLinksFSFromPath(pwd)
// Find the repository root to create the links filesystem reference tied to the repository root
repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("finding repository root: %w", err)
}
defer repoRoot.Close()

linksFS, err := files.CreateLinksFSFromPath(repoRoot, pwd)
if err != nil {
return fmt.Errorf("creating links filesystem failed: %w", err)
}
Expand Down Expand Up @@ -135,7 +147,14 @@ func linksListCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("reading current working directory failed: %w", err)
}

linksFS, err := files.CreateLinksFSFromPath(pwd)
// Find the repository root to create the links filesystem reference tied to the repository root
repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("finding repository root: %w", err)
}
defer repoRoot.Close()

linksFS, err := files.CreateLinksFSFromPath(repoRoot, pwd)
if err != nil {
return fmt.Errorf("creating links filesystem failed: %w", err)
}
Expand Down
15 changes: 14 additions & 1 deletion cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/docs"
"github.com/elastic/elastic-package/internal/files"
"github.com/elastic/elastic-package/internal/logger"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/validation"
Expand Down Expand Up @@ -45,7 +46,19 @@ func setupLintCommand() *cobraext.Command {

func lintCommandAction(cmd *cobra.Command, args []string) error {
cmd.Println("Lint the package")
readmeFiles, err := docs.AreReadmesUpToDate()

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}
defer repoRoot.Close()

linksFilePath, err := docs.LinksDefinitionsFilePath(repoRoot)
if err != nil {
return fmt.Errorf("locating links file failed: %w", err)
}

readmeFiles, err := docs.AreReadmesUpToDate(linksFilePath)
if err != nil {
for _, f := range readmeFiles {
if !f.UpToDate {
Expand Down
18 changes: 18 additions & 0 deletions cmd/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/files"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/logger"
"github.com/elastic/elastic-package/internal/packages"
Expand Down Expand Up @@ -153,6 +154,11 @@ func testRunnerAssetCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("locating package root failed: %w", err)
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

manifest, err := packages.ReadPackageManifestFromPackageRoot(packageRootPath)
if err != nil {
return fmt.Errorf("reading package manifest failed (path: %s): %w", packageRootPath, err)
Expand All @@ -177,6 +183,7 @@ func testRunnerAssetCommandAction(cmd *cobra.Command, args []string) error {
GlobalTestConfig: globalTestConfig.Asset,
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
RepoRoot: repoRoot,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand Down Expand Up @@ -494,6 +501,11 @@ func testRunnerSystemCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("locating package root failed: %w", err)
}

repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

runSetup, err := cmd.Flags().GetBool(cobraext.SetupFlagName)
if err != nil {
return cobraext.FlagParsingError(err, cobraext.SetupFlagName)
Expand Down Expand Up @@ -578,6 +590,7 @@ func testRunnerSystemCommandAction(cmd *cobra.Command, args []string) error {
GlobalTestConfig: globalTestConfig.System,
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
RepoRoot: repoRoot,
})

logger.Debugf("Running suite...")
Expand Down Expand Up @@ -658,6 +671,10 @@ func testRunnerPolicyCommandAction(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("locating package root failed: %w", err)
}
repoRoot, err := files.FindRepositoryRoot()
if err != nil {
return fmt.Errorf("locating repository root failed: %w", err)
}

dataStreams, err := getDataStreamsFlag(cmd, packageRootPath)
if err != nil {
Expand Down Expand Up @@ -691,6 +708,7 @@ func testRunnerPolicyCommandAction(cmd *cobra.Command, args []string) error {
GlobalTestConfig: globalTestConfig.Policy,
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
RepoRoot: repoRoot,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand Down
8 changes: 8 additions & 0 deletions internal/benchrunner/runners/rally/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package rally

import (
"os"
"time"

"github.com/elastic/elastic-package/internal/elasticsearch"
Expand All @@ -29,6 +30,7 @@ type Options struct {
PackageName string
PackageVersion string
CorpusAtPath string
RepoRoot *os.Root
}

type ClientOptions struct {
Expand Down Expand Up @@ -118,3 +120,9 @@ func WithRallyCorpusAtPath(c string) OptionFunc {
opts.CorpusAtPath = c
}
}

func WithRepoRoot(r *os.Root) OptionFunc {
return func(opts *Options) {
opts.RepoRoot = r
}
}
1 change: 1 addition & 0 deletions internal/benchrunner/runners/rally/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (r *runner) installPackageFromPackageRoot(ctx context.Context) error {
Kibana: r.options.KibanaClient,
RootPath: r.options.PackageRootPath,
SkipValidation: true,
RepoRoot: r.options.RepoRoot,
})
if err != nil {
return fmt.Errorf("failed to initialize package installer: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions internal/benchrunner/runners/stream/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package stream

import (
"os"
"time"

"github.com/elastic/elastic-package/internal/elasticsearch"
Expand All @@ -25,6 +26,7 @@ type Options struct {
PackageRootPath string
Variant string
Profile *profile.Profile
RepoRoot *os.Root
}

type ClientOptions struct {
Expand Down Expand Up @@ -107,3 +109,9 @@ func WithTimestampField(t string) OptionFunc {
opts.TimestampField = t
}
}

func WithRepoRoot(r *os.Root) OptionFunc {
return func(opts *Options) {
opts.RepoRoot = r
}
}
1 change: 1 addition & 0 deletions internal/benchrunner/runners/stream/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func (r *runner) installPackageFromPackageRoot(ctx context.Context) error {
Kibana: r.options.KibanaClient,
RootPath: r.options.PackageRootPath,
SkipValidation: true,
RepoRoot: r.options.RepoRoot,
})

if err != nil {
Expand Down
Loading