Skip to content

Add graceful degradation for sha_cmd in get.sh#430

Merged
alexellis merged 1 commit intoopenfaas:masterfrom
rgee0:checkHashGraceful
Jul 16, 2018
Merged

Add graceful degradation for sha_cmd in get.sh#430
alexellis merged 1 commit intoopenfaas:masterfrom
rgee0:checkHashGraceful

Conversation

@rgee0
Copy link
Copy Markdown
Contributor

@rgee0 rgee0 commented Jul 7, 2018

Signed-off-by: Richard Gee richard@technologee.co.uk

Description

This change defaults the command to be used to sha256sum and reverts to
shasum -a 256 if the default isnt found.

Also fixed a typo in the console output attemping --> attempting.

Motivation and Context

The earlier choice of using shasum was made for broadest support reasons. However
the breadth of support could be broader still by introducing graceful degradation
to get.sh.

How Has This Been Tested?

Small change. Tested on MacOS and PWD (where the earlier script was failing) and verified that the command was correctly switching by adding a temporary echo $sha_cmd

  • PWD

Running as root - Attemping to move faas-cli to /usr/local/bin
New version of faas-cli installed to /usr/local/bin
Creating alias 'faas' for 'faas-cli'.
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: d33cb5cdc128b75fc7a9856c30fc0eded39fec1e
Version: 0.6.12
[node1] (local) root@192.168.0.58 ~
$ sudo ./get.sh

You already have the faas-cli!
Overwriting in 1 seconds.. Press Control+C to cancel.

x86_64
Downloading package https://github.com/openfaas/faas-cli/releases/download/0.6.12/faas-cli as /tmp/faas-cli
sha256sum
Download complete.

Running as root - Attemping to move faas-cli to /usr/local/bin
New version of faas-cli installed to /usr/local/bin
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: d33cb5cdc128b75fc7a9856c30fc0eded39fec1e
Version: 0.6.12
  • MacOS
$ ./get.sh

You already have the faas-cli!
Overwriting in 1 seconds.. Press Control+C to cancel.

Downloading package https://github.com/openfaas/faas-cli/releases/download/0.6.12/faas-cli-darwin as /Users/rgee0/go/src/git
hub.com/rgee0/faas-cli/faas-cli-darwin
shasum -a 256
Download complete.

=========================================================
==    As the script was run as a non-root user the     ==
==    following commands may need to be run manually   ==
=========================================================

  sudo cp faas-cli-darwin /usr/local/bin/faas-cli
  sudo ln -sf /usr/local/bin/faas-cli /usr/local/bin/faas

$ sudo ./get.sh

You already have the faas-cli!
Overwriting in 1 seconds.. Press Control+C to cancel.

Downloading package https://github.com/openfaas/faas-cli/releases/download/0.6.12/faas-cli-darwin as /tmp/faas-cli-darwin
shasum -a 256
Download complete.

Running as root - Attemping to move faas-cli to /usr/local/bin
New version of faas-cli installed to /usr/local/bin
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: d33cb5cdc128b75fc7a9856c30fc0eded39fec1e
Version: 0.6.12

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

The earlier choice of using shasum was made for broadest support reasons.  However
the breadth of support could be broader still by introducing graceful degradation
to get.sh.  This change defaults the command to be used to sha256sum and reverts to
shasum -a 256 if the default isnt found.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
@alexellis
Copy link
Copy Markdown
Member

I may have miscommunicated. On MacOS I believe shasum is available by default and on other environments such as Alpine Linux and busybox, it is sha256sum.

@rgee0
Copy link
Copy Markdown
Contributor Author

rgee0 commented Jul 7, 2018

No miscommunication - thats what I alluded to on #425. Of the operating systems tested MacOS is the exception - Ubuntu, Raspbian and Alpine (PWD) all offer sha256sum.

@rgee0
Copy link
Copy Markdown
Contributor Author

rgee0 commented Jul 16, 2018

What more is needed here?

@alexellis alexellis merged commit 0ccdbe0 into openfaas:master Jul 16, 2018
@alexellis
Copy link
Copy Markdown
Member

Thanks for your work. I've deployed it now, it should be live.

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.

2 participants