arkade icon indicating copy to clipboard operation
arkade copied to clipboard

How to fail if tool is not supported in os/arch?

Open rberrelleza opened this issue 4 years ago • 8 comments

What's the recommendation on handling binaries that are not available on the users OS or arch? E.g. I'm looking into adding kubie, but they only have binaries for linux and macos on amd64.

Is there a way to fail arkade get with a friendly message?

rberrelleza avatar Jul 24 '20 20:07 rberrelleza

Hi @rberrelleza - not as far as I know, what happens currently - 404?

We could give an error like, Server returned a not found error, APP may not be available for your system.

alexellis avatar Jul 25 '20 08:07 alexellis

If we know which arche/os combos are supported can we create a map/list for a tool and verify the client conforms before trying a get?

could be a

map[string][]string

"linux": ["amd64", "arm64", "i386"],
"macos": ["amd64"]

Hang that off the Tool and add a func (t *Tool) IsSupported(os, arch string) bool then have a func that takes that map, given os and arch and sees if its there?

Waterdrips avatar Jul 27 '20 15:07 Waterdrips

Today, depending on the tool, you might get a 404 or a template-related error (for cases where a variable might not generated or something like that).

I like @Waterdrips approach here. I think we could add that as an optional field, so that we can give the user a more specific error message (e.g. "kubie is not available on Windows") rather than a more cryptic, or implementation specific error, like a 404.

rberrelleza avatar Jul 27 '20 17:07 rberrelleza

I think that handling the HTTP code would be a simple approach. The templates just need to go to an invalid URL when there's no package available

alexellis avatar Jul 27 '20 17:07 alexellis

There shouldn't be errors from the template. Can you show some examples?

alexellis avatar Jul 27 '20 17:07 alexellis

There shouldn't be errors from the template. Can you show some examples?

None of the ones in arkade. This came to me while I was working on adding kubie. It doesn't have a windows or arm release, and didn't know what best practice to follow.

rberrelleza avatar Jul 30 '20 22:07 rberrelleza

I think that just allowing the code to hit a 404 should be OK.

alexellis avatar Aug 17 '20 08:08 alexellis

It seems that we get a "404 not found" message, I'm OK with that. We could perhaps write something like "arkade didn't find a compatible binary for your system"

Adding --os --arch flags to arkade get would be helpful for testing though, where we can inject/override the values.

alexellis avatar Aug 24 '20 10:08 alexellis

Since then, we have the --os and --arch flags with a graceful handling of 404 may I close this?

Shikachuu avatar Aug 12 '22 15:08 Shikachuu

Fine with me!

rberrelleza avatar Aug 12 '22 21:08 rberrelleza

/close

Shikachuu avatar Aug 13 '22 11:08 Shikachuu