-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Elastic Agent] Add install/uninstall sub-command #21206
Changes from 33 commits
09fabb5
f99d7f9
4fabf0a
a6f0549
92d64da
de393a3
86983aa
29e507b
7a7716a
d54768e
d260e25
3099b66
c7eeb77
2c6f0bb
189b1e0
1eb59ae
387e4c1
2d9e0bb
bb3b216
a508c2b
29c66de
2d9fe52
729b4b3
f537b2c
5c8b0a4
a6c1857
ff898a2
b574a29
489da3f
3e21b30
be282cb
f570a35
df6e995
ee370ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
"ISC", | ||
"MIT", | ||
"MPL-2.0", | ||
"Public Domain" | ||
"Public Domain", | ||
"Zlib" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes its greenlight. For other reviewers going through this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should add this in a separate PR to have it "documented" in case someone looks for the diff so it does not look like "accidentally" added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can move it to a single PR just for this one thing. Might be weird to add in an individual PR, think it makes better sense in context. |
||
], | ||
"maybelist": [ | ||
"EPL-1.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cli | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// ReadInput shows the text and ask the user to provide input. | ||
func ReadInput(prompt string) (string, error) { | ||
reader := bufio.NewReader(os.Stdin) | ||
return input(reader, prompt) | ||
} | ||
|
||
func input(r io.Reader, prompt string) (string, error) { | ||
reader := bufio.NewScanner(r) | ||
fmt.Print(prompt + " ") | ||
|
||
if !reader.Scan() { | ||
return "", errors.New("error reading user input") | ||
} | ||
return reader.Text(), nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cli | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReadInput(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
res string | ||
}{ | ||
{ | ||
name: "Question 1?", | ||
input: "\n", | ||
res: "", | ||
}, | ||
{ | ||
name: "Question 2?", | ||
input: "full string input\n", | ||
res: "full string input", | ||
}, | ||
{ | ||
name: "Question 3?", | ||
input: "123456789\n", | ||
res: "123456789", | ||
}, | ||
{ | ||
name: "Question 4?", | ||
input: "false\n", | ||
res: "false", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
r := strings.NewReader(test.input) | ||
result, err := input(r, test.name) | ||
assert.NoError(t, err) | ||
assert.Equal(t, test.res, result) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably move this repo under elastic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment this is just pointing to a fix of the upstream, once this lands in the upstream repo then the dependency will not point to my personal repo but instead it will point to: https://github.com/kardianos/service
Which is what is defined in the
go.mod
, its just that I am usingreplace
at the moment to get the needed fix for systemd on link from my repository.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you file an issue to switch it over when upstream is fixed. Otherwise we forget for sure ;-)