Skip to content

Commit aa10373

Browse files
committed
Merge remote-tracking branch 'origin/main' into profile-resources
2 parents ed1e62b + c0319b4 commit aa10373

File tree

6 files changed

+66
-96
lines changed

6 files changed

+66
-96
lines changed

cmd/stack.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,7 @@ func setupStackCommand() *cobraext.Command {
181181
}
182182

183183
if shellName == cobraext.ShellInitShellDetect {
184-
shellName, err = stack.AutodetectedShell()
185-
if err != nil {
186-
return fmt.Errorf("cannot detect parent shell from current process: %w", err)
187-
}
184+
shellName = stack.AutodetectedShell()
188185
fmt.Fprintf(cmd.OutOrStderr(), "Detected shell: %s\n", shellName)
189186
} else {
190187
stack.SelectShell(shellName)

go.mod

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/elastic/go-elasticsearch/v7 v7.17.7
1414
github.com/elastic/go-licenser v0.4.1
1515
github.com/elastic/go-resource v0.1.1
16-
github.com/elastic/go-sysinfo v1.9.0
1716
github.com/elastic/go-ucfg v0.8.6
1817
github.com/elastic/package-spec/v2 v2.2.0
1918
github.com/fatih/color v1.13.0
@@ -28,13 +27,13 @@ require (
2827
github.com/olekukonko/tablewriter v0.0.5
2928
github.com/pkg/errors v0.9.1
3029
github.com/pmezard/go-difflib v1.0.0
30+
github.com/shirou/gopsutil/v3 v3.22.11
3131
github.com/spf13/cobra v1.6.1
3232
github.com/stretchr/testify v1.8.1
3333
golang.org/x/oauth2 v0.3.0
3434
golang.org/x/tools v0.4.0
3535
gopkg.in/yaml.v3 v3.0.1
3636
gotest.tools/gotestsum v1.8.2
37-
gotest.tools/v3 v3.4.0
3837
helm.sh/helm/v3 v3.10.3
3938
honnef.co/go/tools v0.3.3
4039
k8s.io/apimachinery v0.26.0
@@ -61,7 +60,6 @@ require (
6160
github.com/davecgh/go-spew v1.1.1 // indirect
6261
github.com/dnephin/pflag v1.0.7 // indirect
6362
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
64-
github.com/elastic/go-windows v1.0.1 // indirect
6563
github.com/elastic/gojsonschema v1.2.1 // indirect
6664
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
6765
github.com/emirpasic/gods v1.18.1 // indirect
@@ -72,6 +70,7 @@ require (
7270
github.com/go-errors/errors v1.4.2 // indirect
7371
github.com/go-git/gcfg v1.5.0 // indirect
7472
github.com/go-logr/logr v1.2.3 // indirect
73+
github.com/go-ole/go-ole v1.2.6 // indirect
7574
github.com/go-openapi/analysis v0.21.1 // indirect
7675
github.com/go-openapi/errors v0.20.3 // indirect
7776
github.com/go-openapi/jsonpointer v0.19.5 // indirect
@@ -105,6 +104,7 @@ require (
105104
github.com/klauspost/pgzip v1.2.5 // indirect
106105
github.com/kr/pretty v0.3.0 // indirect
107106
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
107+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
108108
github.com/mailru/easyjson v0.7.7 // indirect
109109
github.com/mattn/go-colorable v0.1.13 // indirect
110110
github.com/mattn/go-isatty v0.0.16 // indirect
@@ -124,19 +124,22 @@ require (
124124
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
125125
github.com/pierrec/lz4/v4 v4.1.17 // indirect
126126
github.com/pjbgf/sha1cd v0.2.3 // indirect
127-
github.com/prometheus/procfs v0.8.0 // indirect
127+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
128128
github.com/rivo/uniseg v0.4.3 // indirect
129129
github.com/russross/blackfriday/v2 v2.1.0 // indirect
130130
github.com/sergi/go-diff v1.2.0 // indirect
131131
github.com/shopspring/decimal v1.3.1 // indirect
132132
github.com/skeema/knownhosts v1.1.0 // indirect
133133
github.com/spf13/pflag v1.0.5 // indirect
134+
github.com/tklauser/go-sysconf v0.3.11 // indirect
135+
github.com/tklauser/numcpus v0.6.0 // indirect
134136
github.com/ulikunitz/xz v0.5.11 // indirect
135137
github.com/xanzy/ssh-agent v0.3.3 // indirect
136138
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
137139
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
138140
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
139141
github.com/xlab/treeprint v1.1.0 // indirect
142+
github.com/yusufpapurcu/wmi v1.2.2 // indirect
140143
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
141144
go.mongodb.org/mongo-driver v1.11.1 // indirect
142145
go.starlark.net v0.0.0-20221205180719-3fd0dac74452 // indirect
@@ -156,7 +159,7 @@ require (
156159
gopkg.in/inf.v0 v0.9.1 // indirect
157160
gopkg.in/warnings.v0 v0.1.2 // indirect
158161
gopkg.in/yaml.v2 v2.4.0 // indirect
159-
howett.net/plist v1.0.0 // indirect
162+
gotest.tools/v3 v3.4.0 // indirect
160163
k8s.io/api v0.26.0 // indirect
161164
k8s.io/apiextensions-apiserver v0.26.0 // indirect
162165
k8s.io/component-base v0.26.0 // indirect

go.sum

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,8 @@ github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN
105105
github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
106106
github.com/elastic/go-resource v0.1.1 h1:vM173uhPoaZ7C64rKrYbbBn5kxOhstE1+YcGFteAKh8=
107107
github.com/elastic/go-resource v0.1.1/go.mod h1:7F1Wjs6eSFX0i/235yAK/x9bvPNd9/ML92AiULa4XYA=
108-
github.com/elastic/go-sysinfo v1.9.0 h1:usICqY/Nw4Mpn9f4LdtpFrKxXroJDe81GaxxUlCckIo=
109-
github.com/elastic/go-sysinfo v1.9.0/go.mod h1:eBD1wEGVaRnRLGecc9iG1z8eOv5HnEdz9+nWd8UAxcE=
110108
github.com/elastic/go-ucfg v0.8.6 h1:stUeyh2goTgGX+/wb9gzKvTv0YB0231LTpKUgCKj4U0=
111109
github.com/elastic/go-ucfg v0.8.6/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
112-
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
113-
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
114110
github.com/elastic/gojsonschema v1.2.1 h1:cUMbgsz0wyEB4x7xf3zUEvUVDl6WCz2RKcQPul8OsQc=
115111
github.com/elastic/gojsonschema v1.2.1/go.mod h1:biw5eBS2Z4T02wjATMRSfecfjCmwaDPvuaqf844gLrg=
116112
github.com/elastic/package-spec/v2 v2.2.0 h1:hNTtw1PmM9BcehF5g7E4NNNIXNTxravcbrwATucYOAU=
@@ -158,6 +154,8 @@ github.com/go-git/go-git/v5 v5.5.1/go.mod h1:uz5PQ3d0gz7mSgzZhSJToM6ALPaKCdSnl58
158154
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
159155
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
160156
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
157+
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
158+
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
161159
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
162160
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
163161
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
@@ -326,6 +324,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
326324
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
327325
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
328326
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
327+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
329328
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
330329
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
331330
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -408,6 +407,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
408407
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
409408
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
410409
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
410+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
411+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
411412
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
412413
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
413414
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
@@ -491,9 +492,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
491492
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
492493
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
493494
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
495+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
496+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
494497
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
495-
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
496-
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
497498
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
498499
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
499500
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -509,6 +510,8 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
509510
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
510511
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
511512
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
513+
github.com/shirou/gopsutil/v3 v3.22.11 h1:kxsPKS+Eeo+VnEQ2XCaGJepeP6KY53QoRTETx3+1ndM=
514+
github.com/shirou/gopsutil/v3 v3.22.11/go.mod h1:xl0EeL4vXJ+hQMAGN8B9VFpxukEMA0XdevQOe5MZ1oY=
512515
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
513516
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
514517
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@@ -543,6 +546,10 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
543546
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
544547
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
545548
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
549+
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
550+
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
551+
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
552+
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
546553
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
547554
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
548555
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
@@ -574,6 +581,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
574581
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
575582
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
576583
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
584+
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
585+
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
577586
go.etcd.io/etcd/api/v3 v3.5.6 h1:Cy2qx3npLcYqTKqGJzMypnMv2tiRyifZJ17BlWIWA7A=
578587
go.etcd.io/etcd/api/v3 v3.5.6/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8=
579588
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
@@ -692,14 +701,15 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7w
692701
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
693702
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
694703
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
695-
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
704+
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
696705
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
697706
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
698707
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
699708
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
700709
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
701710
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
702711
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
712+
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
703713
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
704714
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
705715
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -827,7 +837,6 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
827837
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
828838
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
829839
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
830-
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
831840
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
832841
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
833842
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -854,8 +863,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
854863
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
855864
honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
856865
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
857-
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
858-
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
859866
k8s.io/api v0.26.0 h1:IpPlZnxBpV1xl7TGk/X6lFtpgjgntCg8PJ+qrPHAC7I=
860867
k8s.io/api v0.26.0/go.mod h1:k6HDTaIFC8yn1i6pSClSqIwLABIcLV9l5Q4EcngKnQg=
861868
k8s.io/apiextensions-apiserver v0.26.0 h1:Gy93Xo1eg2ZIkNX/8vy5xviVSxwQulsnUdQ00nEdpDo=

internal/stack/compose.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ func newServiceStatus(description *docker.ContainerDescription) (*ServiceStatus,
220220
Status: description.State.Status,
221221
Version: getVersionFromDockerImage(description.Config.Image),
222222
}
223-
if description.State.Status == "running" && description.State.Health != nil {
224-
service.Status = fmt.Sprintf("%v (%v)", service.Status, description.State.Health.Status)
223+
if description.State.Status == "running" {
224+
healthStatus := "unknown health"
225+
if health := description.State.Health; health != nil {
226+
healthStatus = health.Status
227+
}
228+
service.Status = fmt.Sprintf("%v (%v)", service.Status, healthStatus)
225229
}
226230
if description.State.Status == "exited" {
227231
service.Status = fmt.Sprintf("%v (%v)", service.Status, description.State.ExitCode)

internal/stack/shellinit.go

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
"path/filepath"
1212
"strings"
1313

14-
"github.com/elastic/go-sysinfo"
15-
"github.com/elastic/go-sysinfo/types"
14+
"github.com/shirou/gopsutil/v3/process"
1615

1716
"github.com/elastic/elastic-package/internal/environment"
1817
"github.com/elastic/elastic-package/internal/logger"
@@ -29,21 +28,19 @@ var (
2928
)
3029

3130
var shellType string
32-
var shellDetectError error
3331

3432
func init() {
35-
shellType, shellDetectError = detectShell()
33+
shellType = detectShell()
3634
}
3735

3836
// SelectShell selects the shell to use.
3937
func SelectShell(shell string) {
4038
shellType = shell
41-
shellDetectError = nil
4239
}
4340

4441
// AutodetectedShell returns an error if shell could not be detected.
45-
func AutodetectedShell() (string, error) {
46-
return shellType, shellDetectError
42+
func AutodetectedShell() string {
43+
return shellType
4744
}
4845

4946
// ShellInit method exposes environment variables that can be used for testing purposes.
@@ -128,43 +125,41 @@ func getShellName(exe string) string {
128125
return shell
129126
}
130127

131-
func detectShell() (string, error) {
128+
func detectShell() string {
129+
shell, err := getParentShell()
130+
if err != nil {
131+
logger.Debugf("Failed to determine parent process info while detecting shell, will assume bash: %v", err)
132+
return "bash"
133+
}
134+
135+
return shell
136+
}
137+
138+
func getParentShell() (string, error) {
132139
ppid := os.Getppid()
133-
parentInfo, err := getParentInfo(ppid)
134-
if errors.Is(err, types.ErrNotImplemented) {
135-
// Sysinfo doesn't implement some features in some platforms.
136-
// This mainly affects osx when building without CGO.
137-
// Assume bash in that case.
138-
// See https://github.com/elastic/elastic-package/issues/1030.
139-
logger.Debug("Failed to determine parent process info while detecting shell, will assume bash")
140-
return "bash", nil
140+
p, err := process.NewProcess(int32(ppid))
141+
if err != nil {
142+
return "", err
141143
}
144+
exe, err := p.Exe()
142145
if err != nil {
143146
return "", err
144147
}
145148

146-
shell := getShellName(parentInfo.Exe)
149+
shell := getShellName(exe)
147150
if shell == "go" {
148-
parentParentInfo, err := getParentInfo(parentInfo.PPID)
151+
parent, err := p.Parent()
149152
if err != nil {
150-
return "", fmt.Errorf("cannot retrieve parent process info: %w", err)
153+
return "", err
151154
}
152-
return getShellName(parentParentInfo.Exe), nil
153-
}
154155

155-
return shell, nil
156-
}
157-
158-
func getParentInfo(ppid int) (types.ProcessInfo, error) {
159-
parent, err := sysinfo.Process(ppid)
160-
if err != nil {
161-
return types.ProcessInfo{}, fmt.Errorf("cannot retrieve information for process %d: %w", ppid, err)
162-
}
156+
exe, err := parent.Exe()
157+
if err != nil {
158+
return "", err
159+
}
163160

164-
parentInfo, err := parent.Info()
165-
if err != nil {
166-
return types.ProcessInfo{}, fmt.Errorf("cannot retrieve information for parent of process %d: %w", ppid, err)
161+
return getShellName(exe), nil
167162
}
168163

169-
return parentInfo, nil
164+
return shell, nil
170165
}

internal/stack/shellinit_internal_test.go

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
package stack
66

77
import (
8-
"os"
9-
"reflect"
108
"strings"
119
"testing"
1210

13-
"github.com/elastic/go-sysinfo"
14-
"github.com/elastic/go-sysinfo/types"
15-
"gotest.tools/v3/assert"
11+
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1613
)
1714

1815
func TestCodeTemplate(t *testing.T) {
@@ -64,41 +61,8 @@ func Test_getShellName(t *testing.T) {
6461
}
6562
}
6663

67-
func Test_getParentInfo(t *testing.T) {
68-
ppid := os.Getppid()
69-
parent, err := sysinfo.Process(ppid)
70-
if err != nil {
71-
panic(err)
72-
}
73-
info, err := parent.Info()
74-
if err != nil {
75-
panic(err)
76-
}
77-
78-
type args struct {
79-
ppid int
80-
}
81-
tests := []struct {
82-
name string
83-
args args
84-
want types.ProcessInfo
85-
wantErr bool
86-
}{
87-
// TODO: Add test cases.
88-
{"test parent", args{ppid}, info, false},
89-
{"bogus ppid", args{999999}, types.ProcessInfo{}, true},
90-
{"no parent", args{1}, types.ProcessInfo{}, true},
91-
}
92-
for _, tt := range tests {
93-
t.Run(tt.name, func(t *testing.T) {
94-
got, err := getParentInfo(tt.args.ppid)
95-
if (err != nil) != tt.wantErr {
96-
t.Errorf("getParentInfo() error = %v, wantErr %v", err, tt.wantErr)
97-
return
98-
}
99-
if !reflect.DeepEqual(got, tt.want) {
100-
t.Errorf("getParentInfo() = %v, want %v", got, tt.want)
101-
}
102-
})
103-
}
64+
func TestGetParentShell(t *testing.T) {
65+
shell, err := getParentShell()
66+
require.NoError(t, err)
67+
assert.NotEmpty(t, shell)
10468
}

0 commit comments

Comments
 (0)