|
9 | 9 | "errors" |
10 | 10 | "flag" |
11 | 11 | "fmt" |
| 12 | + "path/filepath" |
12 | 13 | "time" |
13 | 14 |
|
14 | 15 | "github.com/rogpeppe/go-internal/testscript" |
@@ -47,14 +48,11 @@ func installAgent(ts *testscript.TestScript, neg bool, args []string) { |
47 | 48 | flg := flag.NewFlagSet("install", flag.ContinueOnError) |
48 | 49 | profName := flg.String("profile", "default", "profile name") |
49 | 50 | timeout := flg.Duration("timeout", 0, "timeout (zero or lower indicates no timeout)") |
| 51 | + containerNameLabel := flg.String("container_name", "", "environment variable name to place container name in") |
| 52 | + networkNameLabel := flg.String("network_name", "", "environment variable name to place network name in") |
50 | 53 | ts.Check(flg.Parse(args)) |
51 | | - if flg.NArg() != 0 && flg.NArg() != 1 { |
52 | | - ts.Fatalf("usage: install_agent [-profile <profile>] [-timeout <duration>] [<network_name_label>]") |
53 | | - } |
54 | | - |
55 | | - var networkNameLabel string |
56 | | - if flg.NArg() == 1 { |
57 | | - networkNameLabel = flg.Arg(0) |
| 54 | + if flg.NArg() != 0 { |
| 55 | + ts.Fatalf("usage: install_agent [-profile <profile>] [-timeout <duration>] [-container_name <container_name_label>] [-network_name <network_name_label>]") |
58 | 56 | } |
59 | 57 |
|
60 | 58 | stk, ok := stacks[*profName] |
@@ -120,8 +118,12 @@ func installAgent(ts *testscript.TestScript, neg bool, args []string) { |
120 | 118 | // ELASTIC_PACKAGE_CA_CERT is set. ¯\_(ツ)_/¯ |
121 | 119 | installed.deployed, err = dep.SetUp(ctx, info) |
122 | 120 | ts.Check(decoratedWith("setting up agent", err)) |
123 | | - if networkNameLabel != "" { |
124 | | - ts.Setenv(networkNameLabel, installed.deployed.Info().NetworkName) |
| 121 | + depInfo := installed.deployed.Info() |
| 122 | + if *networkNameLabel != "" { |
| 123 | + ts.Setenv(*networkNameLabel, depInfo.NetworkName) |
| 124 | + } |
| 125 | + if *containerNameLabel != "" { |
| 126 | + ts.Setenv(*containerNameLabel, fmt.Sprintf("elastic-package-agent-%s-%s-%s-%s-1", filepath.Base(pkgRoot), ds, info.Test.RunID, depInfo.Name)) |
125 | 127 | } |
126 | 128 | polID := installed.deployed.Info().Policy.ID |
127 | 129 | ts.Check(decoratedWith("getting kibana agent", doKibanaAgent(ctx, stk.kibana, func(a kibana.Agent) (bool, error) { |
|
0 commit comments