Skip to content

cli: support url with addon-config flag#4666

Merged
Pothulapati merged 2 commits intomainfrom
tarun/addon-url
Jul 2, 2020
Merged

cli: support url with addon-config flag#4666
Pothulapati merged 2 commits intomainfrom
tarun/addon-url

Conversation

@Pothulapati
Copy link
Contributor

Fixes #4664

This PR makes --addon-config to also read from URL's.
Adds a new readFile func which can read from a file path or a url

To Test:

/bin/go-run cli install --ignore-cluster --addon-config https://gist.githubusercontent.com/Pothulapati/b8ed9472dac445f50b104365a54f8c37/raw/d84d52329f5941edacdd809958a3cfbc17a077b6/addon-config.yaml | code -       

Signed-off-by: Tarun Pothulapati [email protected]

@Pothulapati Pothulapati requested a review from a team as a code owner June 25, 2020 10:01
Copy link
Member

@zaharidichev zaharidichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor suggestion

// Read a resource file from a path or URL
func readFile(path string) ([]byte, error) {
if isValidURL(path) {
resp, err := http.Get(path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we can extract the logic that is here https://github.com/linkerd/linkerd2/blob/main/cli/cmd/inject_util.go#L152 into something that we can reuse right here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. Sounds like we might even be able to reuse the entire read() function.

// Read a resource file from a path or URL
func readFile(path string) ([]byte, error) {
if isValidURL(path) {
resp, err := http.Get(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. Sounds like we might even be able to reuse the entire read() function.

Signed-off-by: Tarun Pothulapati <[email protected]>
@Pothulapati Pothulapati merged commit fcc3eb5 into main Jul 2, 2020
@Pothulapati Pothulapati deleted the tarun/addon-url branch July 2, 2020 17:27
@Pothulapati Pothulapati mentioned this pull request Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Urls with --addon-config flag

3 participants