Giter Club home page Giter Club logo

gonut's Introduction

gonut License Go Report Card Build and Tests Go Reference Release GitHub go.mod Go version

gonut

Introducing gonut

gonut is a portable tool to help you verify whether you can push a sample app to a Cloud Foundry. It will push an app to Cloud Foundry and delete it afterwards. The apps are embedded into the gonut binary, so you just have to install gonut and you are set.

It is written in Go and uses pina-golada to include arbitrary sample app data in the final binary.

gonut example

How do I get started

Installation options are either using Homebrew or a convenience download script.

  • On macOS systems, a Homebrew tap is available to install gonut:

    brew install homeport/tap/gonut
  • Use a convenience script to download the latest release to install it in a suitable location on your local machine:

    curl -fsL http://ibm.biz/Bd2t2v | bash

Contributing

We are happy to have other people contributing to the project. If you decide to do that, here's how to:

  • get Go (gonut requires Go version 1.11 or greater)
  • fork the project
  • create a new branch
  • make your changes
  • open a PR.

Git commit messages should be meaningful and follow the rules nicely written down by Chris Beams:

The seven rules of a great Git commit message

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

Running test cases and binaries generation

There are multiple make targets, but running all does everything you want in one call.

make all

Test it with Linux on your macOS system

Best way is to use Docker to spin up a container:

docker run \
  --interactive \
  --tty \
  --rm \
  --volume $GOPATH/src/github.com/homeport/gonut:/go/src/github.com/homeport/gonut \
  --workdir /go/src/github.com/homeport/gonut \
  golang:1.19 /bin/bash

Git pre-commit hooks

Add a pre-commit hook using this command in the repository directory:

cat <<EOS | cat > .git/hooks/pre-commit && chmod a+rx .git/hooks/pre-commit
#!/usr/bin/env bash

set -euo pipefail
make test

EOS

gonut's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar heavywombat avatar idev4u avatar m-lukas avatar qu1queee avatar tareqmamari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

erdmenger m-lukas

gonut's Issues

Gonut incorrectly reports that there is no staticfile_buildpack

Gonut reports that there is no staticfile_buildpack, but there is one listed.

# gonut push static --summary full
Skipping push of Staticfile sample app, because there is no staticfile_buildpack installed.
#
#
# cf buildpacks
Getting buildpacks...

buildpack                               position   enabled   locked   filename
liberty-for-java                        1          true      false    buildpack_liberty-for-java_v3.31-20190423-1354.zip
sdk-for-nodejs                          2          true      false    buildpack_sdk-for-nodejs_v3.26-20190313-1440.zip
dotnet-core                             3          true      false    buildpack_dotnet-core_v2.2-20190327-1013.zip
swift_buildpack                         4          true      false    buildpack_swift_v2.0.20-20190401-2122.zip
java_buildpack                          5          true      false    java-buildpack-v3.13.zip
ruby_buildpack                          6          true      false    ruby_buildpack-cached-v1.6.34.zip
nodejs_buildpack                        7          true      false    nodejs_buildpack-cached-v1.5.29.zip
go_buildpack                            8          true      false    go_buildpack-cached-v1.7.18.zip
python_buildpack                        9          true      false    python_buildpack-cached-v1.5.15.zip
php_buildpack                           10         true      false    php_buildpack-cached-v4.3.27.zip
xpages_buildpack                        11         true      false    xpages_buildpack_v1.2.6-20170331-1518.zip
staticfile_buildpack                    12         true      false    staticfile_buildpack-cached-v1.3.17.zip
binary_buildpack                        13         true      false    binary_buildpack-cached-v1.0.9.zip

@m-lukas FYI

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

fatal: The remote end hung up unexpectedly

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Check panic in Google Cloud Platform Cloud Shell

# gonut push go
panic: runtime error: slice bounds out of range
goroutine 20 [running]:
github.com/gonvenience/bunt.(*String).Substring(...)
        /home/travis/gopath/pkg/mod/github.com/gonvenience/[email protected]/model.go:46
github.com/gonvenience/bunt.Substring(0xc000026800, 0x20, 0x0, 0xffffffffffffffe4, 0xc000002819, 0x3)
        /home/travis/gopath/pkg/mod/github.com/gonvenience/[email protected]/convenience.go:65 +0xf7
github.com/gonvenience/text.FixedLength(0xc000026800, 0x20, 0xffffffffffffffea, 0x3, 0x3fda5a5a5a5a5a5a)
        /home/travis/gopath/pkg/mod/github.com/gonvenience/[email protected]/text.go:80 +0x78
github.com/gonvenience/wait.(*ProgressIndicator).Start.func1(0xc0001d2100)
        /home/travis/gopath/pkg/mod/github.com/gonvenience/[email protected]/wait.go:145 +0xaf
created by github.com/gonvenience/wait.(*ProgressIndicator).Start
        /home/travis/gopath/pkg/mod/github.com/gonvenience/[email protected]/wait.go:120 +0xf3
TERM=screen

Improve error output

In case there is an error, e.g. not logged in, provide a well structured easy to read output of the error.

Add oneline output to push command

Add some kind of output to the end of the push command to indicate that everything worked well. This message should be short.

It should be possible to disable this output by using a new --quiet flag.

Add json flag to push command

Add an option to the summary flag called json to push command to enforce a computer readable output of the summary. Pre-req for this issue is #8.

Example:

gonut push static --summary json

Tweak memory size of java sample application

The Java Sample Application, introduced with PR #75, due to the underlying JVM, requires around 572MB of memory. If the memory of the CF app is configurated in manifest.yml to be less than this value, it causes the following error and the application is timing out on start:

ERR Cannot calculate JVM memory configuration: There is insufficient memory remaining for heap. Memory available for allocation 128M is less than allocated memory 572292K (-XX:ReservedCodeCacheSize=240M, -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=60292K, -Xss1M * 250 threads)

However if started properly with sufficient memory, the app indeed uses less then 100MB.
The remaining memory is just reserved by the JVM.
This could possibly be fixed by tweaking the values of the error message in the start command.

Concatenate summary (-o) on push 'all' option and run tests in parallel

Currently, if pushing with the 'all' option, it runs a loop through all sample applications and pushes each app successively. Also it doesn't merge the summaries (if turned on) of the pushed applications but rather shows them in a row in between the staging logs.
To allow better automation and to spead up this process, it might make sense to run the pushes as goroutines and combine the summaries to one.

Add buildpack check

Before executing the CF push command, verify whether the respective buildpack is installed. Add a flag to manually override the check.

Recover unexpected panics

Recover panics from code at the command level and print a meaningful explanation that an unexpected error occurred.

Update colors in gonut version output

With the introduction of the gonut logo and its colors, we should try to use the color style wherever possible. Suggestion: Update the version command to actually mimic the color and emphasis of the word gonut similar to how it is done in the logo.

Add extract command

Add new command called extract to download the sample app data to the local disk.

Add summary flag to push command

Add a summary flag that if set will print out a summary about the push statistics, e.g. create time, upload time, staging time, and starting time.

Add flag to check all stacks

Add a flag to push the app not just to the default configured stack, but to another one or all of them depending on the setup.

Rough idea:

  • do something similar to
    $ cf stacks
    Getting stacks in org system / space dev as admin...
    OK
    
    name         description
    cflinuxfs2   Cloud Foundry Linux-based filesystem
    
  • run the cf push with flag -s <stack> to override the system default.

Add asset flag to use non-built-in sample apps

Add a flag called --asset to use a sample app that is not baked into gonut, but can be a URL (file://, http://, or Git repo location).

Example:
gonut push --asset https://github.com/IBM-Cloud/get-started-node

Alternatively, test whether the --asset flag can be omitted in case the command call itself is unique enough to be understood.
gonut push https://github.com/IBM-Cloud/get-started-node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.