Skip to content
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

Stud 3115 #1974

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9224a9a
Rename packages to use OneCloud
bmeyers22 Feb 22, 2019
bcc54ae
Custom generator that will generate arguments and flags right from th…
bmeyers22 Feb 22, 2019
b3a45b8
Allow both persistent and local flags for root vs command. Removed de…
bmeyers22 Feb 22, 2019
65c085b
Merge pull request #1 from OneCloudInc/feature-oc-generator
bmeyers22 Feb 22, 2019
4b2965f
Fixed tests and added dep
bmeyers22 Feb 22, 2019
fe83a62
Merge pull request #4 from OneCloudInc/release-0.0.4
bmeyers22 Feb 22, 2019
8b91f1a
Merge tag '0.0.4' into develop
bmeyers22 Feb 22, 2019
96868d8
Only change the CLI tool to use OneCloudInc
bmeyers22 Feb 22, 2019
e4569a2
Merge pull request #5 from OneCloudInc/release-0.0.5
bmeyers22 Feb 22, 2019
b549b4c
Merge tag '0.0.5' into develop
bmeyers22 Feb 22, 2019
5cecced
Use RunE
bmeyers22 Feb 22, 2019
01e6d77
Merge pull request #6 from OneCloudInc/release-0.0.6
bmeyers22 Feb 22, 2019
12d6bd8
Merge tag '0.0.6' into develop
bmeyers22 Feb 22, 2019
ce89c5a
Placeholder for performing decryption logic; cobra now distributed us…
ryancurtin Dec 7, 2021
93ca442
Adds the ability to decrypt arguments using the reaper service
ryancurtin Dec 14, 2021
f927bb8
Adds test for reaper decryptor
ryancurtin Dec 14, 2021
b430be0
Ensures that payload is built correctly
ryancurtin Dec 14, 2021
2a36c3f
Explicitly sending JSON request
ryancurtin Dec 16, 2021
c21dc0f
Fixes CircleCI
ryancurtin Dec 16, 2021
ef632ed
Converting cobra to use OneCloudInc/cobra in all cases
ryancurtin Dec 16, 2021
1223d49
Fixes issue references
ryancurtin Dec 16, 2021
1f5bfa1
Code review fixes - seeding random number generator and handling erro…
ryancurtin Dec 16, 2021
18ca9a4
Merge pull request #7 from OneCloudInc/hotfix-0.1.0
ryancurtin Dec 16, 2021
6163b0a
Merge tag '0.1.0' into develop
ryancurtin Dec 16, 2021
061ea08
Merge branch 'release-1.4.0'
ryancurtin Dec 20, 2021
4e75f5d
Returns an early error if decryption fails
ryancurtin Apr 18, 2022
ed21388
Merge pull request #8 from OneCloudInc/hotfix-1.4.1
ryancurtin Apr 18, 2022
c19a6fa
RM-156177 Release v1.4.2 (#9)
joecotton-wk Aug 11, 2022
0af0c7e
STUD-2265 - JWT Claims Fix (#12)
austinarbor-wk May 30, 2023
2f31f26
Test Push
waynepaffhausen-wk Jun 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions .circleci/config.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Purpose

Brief description of the purpose of this change.

## Solution

High level overview of what was done. This is the roadmap for those who are going to CR.

## Semantic Versioning (check one)

- [ ] The following were changed in a non-backward compatible way and requires a major version bump:
- _[link to the breaking change in the diff]_
- [ ] Something public was added or changed in backward compatible way, this requires a minor version bump
- [ ] No public changes nor new features (backwards-compatible refactor or bug fix), so this can be included in a patch
release

## How to QA

- [ ] run the following related examples: **(fill in)**
- [ ] Other necessary steps needed to fully exercise the solution should be added here. **(fill in)**
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: sunday
commit-message:
prefix: fix
prefix-development: chore
include: scope
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI process for Cobra
on: [push, pull_request]

permissions:
contents: read
id-token: write

jobs:
wayne-test1:
runs-on: small
container:
image: amazonlinux:2023
steps:
- name: Install dependencies
run: |
apt-get update && apt-get upgrade -y
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ tags
*.exe

cobra.test

.idea
vendor
test-reports/
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is a Golang library; it doesn't produce
# any artifacts.
FROM scratch
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SHELL := /bin/bash

test: tools
rm -rf test-reports
mkdir test-reports
go clean -testcache
go test -v 2>&1 `go list ./... | grep -v /vendor/` | go-junit-report -iocopy -set-exit-code -out test-reports/unit-test-report.xml

tools:
go install github.com/jstemmer/go-junit-report/[email protected]
106 changes: 56 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ Cobra is both a library for creating powerful modern CLI applications as well as

Many of the most widely used Go projects are built using Cobra including:

* [Kubernetes](http://kubernetes.io/)
* [Hugo](http://gohugo.io)
* [rkt](https://github.com/coreos/rkt)
* [etcd](https://github.com/coreos/etcd)
* [Moby (former Docker)](https://github.com/moby/moby)
* [Docker (distribution)](https://github.com/docker/distribution)
* [OpenShift](https://www.openshift.com/)
* [Delve](https://github.com/derekparker/delve)
* [GopherJS](http://www.gopherjs.org/)
* [CockroachDB](http://www.cockroachlabs.com/)
* [Bleve](http://www.blevesearch.com/)
* [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
* [Giant Swarm's gsctl](https://github.com/giantswarm/gsctl)
* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
* [rclone](http://rclone.org/)
* [nehm](https://github.com/bogem/nehm)
* [Pouch](https://github.com/alibaba/pouch)
- [Kubernetes](http://kubernetes.io/)
- [Hugo](http://gohugo.io)
- [rkt](https://github.com/coreos/rkt)
- [etcd](https://github.com/coreos/etcd)
- [Moby (former Docker)](https://github.com/moby/moby)
- [Docker (distribution)](https://github.com/docker/distribution)
- [OpenShift](https://www.openshift.com/)
- [Delve](https://github.com/derekparker/delve)
- [GopherJS](http://www.gopherjs.org/)
- [CockroachDB](http://www.cockroachlabs.com/)
- [Bleve](http://www.blevesearch.com/)
- [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
- [Giant Swarm's gsctl](https://github.com/giantswarm/gsctl)
- [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
- [rclone](http://rclone.org/)
- [nehm](https://github.com/bogem/nehm)
- [Pouch](https://github.com/alibaba/pouch)

[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra)
Expand All @@ -30,21 +30,21 @@ Many of the most widely used Go projects are built using Cobra including:

- [Overview](#overview)
- [Concepts](#concepts)
* [Commands](#commands)
* [Flags](#flags)
- [Commands](#commands)
- [Flags](#flags)
- [Installing](#installing)
- [Getting Started](#getting-started)
* [Using the Cobra Generator](#using-the-cobra-generator)
* [Using the Cobra Library](#using-the-cobra-library)
* [Working with Flags](#working-with-flags)
* [Positional and Custom Arguments](#positional-and-custom-arguments)
* [Example](#example)
* [Help Command](#help-command)
* [Usage Message](#usage-message)
* [PreRun and PostRun Hooks](#prerun-and-postrun-hooks)
* [Suggestions when "unknown command" happens](#suggestions-when-unknown-command-happens)
* [Generating documentation for your command](#generating-documentation-for-your-command)
* [Generating bash completions](#generating-bash-completions)
- [Using the Cobra Generator](#using-the-cobra-generator)
- [Using the Cobra Library](#using-the-cobra-library)
- [Working with Flags](#working-with-flags)
- [Positional and Custom Arguments](#positional-and-custom-arguments)
- [Example](#example)
- [Help Command](#help-command)
- [Usage Message](#usage-message)
- [PreRun and PostRun Hooks](#prerun-and-postrun-hooks)
- [Suggestions when "unknown command" happens](#suggestions-when-unknown-command-happens)
- [Generating documentation for your command](#generating-documentation-for-your-command)
- [Generating bash completions](#generating-bash-completions)
- [Contributing](#contributing)
- [License](#license)

Expand All @@ -57,19 +57,20 @@ Cobra is also an application that will generate your application scaffolding to
develop a Cobra-based application.

Cobra provides:
* Easy subcommand-based CLIs: `app server`, `app fetch`, etc.
* Fully POSIX-compliant flags (including short & long versions)
* Nested subcommands
* Global, local and cascading flags
* Easy generation of applications & commands with `cobra init appname` & `cobra add cmdname`
* Intelligent suggestions (`app srver`... did you mean `app server`?)
* Automatic help generation for commands and flags
* Automatic help flag recognition of `-h`, `--help`, etc.
* Automatically generated bash autocomplete for your application
* Automatically generated man pages for your application
* Command aliases so you can change things without breaking them
* The flexibility to define your own help, usage, etc.
* Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps

- Easy subcommand-based CLIs: `app server`, `app fetch`, etc.
- Fully POSIX-compliant flags (including short & long versions)
- Nested subcommands
- Global, local and cascading flags
- Easy generation of applications & commands with `cobra init appname` & `cobra add cmdname`
- Intelligent suggestions (`app srver`... did you mean `app server`?)
- Automatic help generation for commands and flags
- Automatic help flag recognition of `-h`, `--help`, etc.
- Automatically generated bash autocomplete for your application
- Automatically generated man pages for your application
- Command aliases so you can change things without breaking them
- The flexibility to define your own help, usage, etc.
- Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps

# Concepts

Expand All @@ -82,7 +83,7 @@ to use the application because they will natively understand how to use it.

The pattern to follow is
`APPNAME VERB NOUN --ADJECTIVE.`
or
or
`APPNAME COMMAND ARG --FLAG`

A few good real world examples may better illustrate this point.
Expand Down Expand Up @@ -119,11 +120,12 @@ library](https://github.com/spf13/pflag), a fork of the flag standard library
which maintains the same interface while adding POSIX compliance.

# Installing

Using Cobra is easy. First, use `go get` to install the latest version
of the library. This command will install the `cobra` generator executable
along with the library and its dependencies:

go get -u github.com/spf13/cobra/cobra
go get -u github.com/Workiva/cobra/cobra

Next, include Cobra in your application:

Expand Down Expand Up @@ -352,6 +354,7 @@ command := cobra.Command{
### Bind Flags with Config

You can also bind your flags with [viper](https://github.com/spf13/viper):

```go
var author string

Expand All @@ -371,6 +374,7 @@ More in [viper documentation](https://github.com/spf13/viper#working-with-flags)

Flags are optional by default. If instead you wish your command to report an error
when a flag has not been set, mark it as required:

```go
rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.MarkFlagRequired("region")
Expand Down Expand Up @@ -488,7 +492,7 @@ Cobra automatically adds a help command to your application when you have subcom
This will be called when a user runs 'app help'. Additionally, help will also
support all other commands as input. Say, for instance, you have a command called
'create' without any additional configuration; Cobra will work when 'app help
create' is called. Every command will automatically have the '--help' flag added.
create' is called. Every command will automatically have the '--help' flag added.

### Example

Expand Down Expand Up @@ -518,7 +522,6 @@ command and flag definitions are needed.

Use "cobra [command] --help" for more information about a command.


Help is just a command like any other. There is no special logic or behavior
around it. In fact, you can provide your own if you want.

Expand All @@ -541,6 +544,7 @@ When the user provides an invalid flag or invalid command, Cobra responds by
showing the user the 'usage'.

### Example

You may recognize this from the help above. That's because the default help
embeds the usage as part of its output.

Expand All @@ -564,6 +568,7 @@ embeds the usage as part of its output.
Use "cobra [command] --help" for more information about a command.

### Defining your own usage

You can provide your own usage function or template for Cobra to use.
Like help, the function and template are overridable through public methods:

Expand All @@ -581,15 +586,15 @@ the version template. The template can be customized using the

## PreRun and PostRun Hooks

It is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`. The `Persistent*Run` functions will be inherited by children if they do not declare their own. These functions are run in the following order:
It is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`. The `Persistent*Run` functions will be inherited by children if they do not declare their own. These functions are run in the following order:

- `PersistentPreRun`
- `PreRun`
- `Run`
- `PostRun`
- `PersistentPostRun`

An example of two commands which use all of these features is below. When the subcommand is executed, it will run the root command's `PersistentPreRun` but not the root command's `PersistentPostRun`:
An example of two commands which use all of these features is below. When the subcommand is executed, it will run the root command's `PersistentPreRun` but not the root command's `PersistentPostRun`:

```go
package main
Expand Down Expand Up @@ -650,6 +655,7 @@ func main() {
```

Output:

```
Inside rootCmd PersistentPreRun with args: []
Inside rootCmd PreRun with args: []
Expand Down Expand Up @@ -714,7 +720,7 @@ Cobra can generate documentation based on subcommands, flags, etc. in the follow

## Generating bash completions

Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible. Read more about it in [Bash Completions](bash_completions.md).
Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible. Read more about it in [Bash Completions](bash_completions.md).

# Contributing

Expand Down
1 change: 1 addition & 0 deletions aviary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: 1
15 changes: 7 additions & 8 deletions cobra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ commands you want. It's the easiest way to incorporate Cobra into your applicati

In order to use the cobra command, compile it using the following command:

go get github.com/spf13/cobra/cobra
go get github.com/Workiva/cobra/cobra

This will create the cobra executable under your `$GOPATH/bin` directory.

Expand All @@ -28,9 +28,9 @@ cobra init github.com/spf13/newApp
Once an application is initialized, Cobra can create additional commands for you.
Let's say you created an app and you wanted the following commands for it:

* app serve
* app config
* app config create
- app serve
- app config
- app config create

In your project directory (where your main.go file is) you would run the following:

Expand All @@ -40,9 +40,9 @@ cobra add config
cobra add create -p 'configCmd'
```

*Note: Use camelCase (not snake_case/snake-case) for command names.
_Note: Use camelCase (not snake_case/snake-case) for command names.
Otherwise, you will encounter errors.
For example, `cobra add add-user` is incorrect, but `cobra add addUser` is valid.*
For example, `cobra add add-user` is incorrect, but `cobra add addUser` is valid._

Once you have run these three commands you would have an app structure similar to
the following:
Expand All @@ -56,8 +56,7 @@ the following:
main.go
```

At this point you can run `go run main.go` and it would run your app. `go run
main.go serve`, `go run main.go config`, `go run main.go config create` along
At this point you can run `go run main.go` and it would run your app. `go run main.go serve`, `go run main.go config`, `go run main.go config create` along
with `go run main.go help serve`, etc. would all work.

Obviously you haven't added your own code to these yet. The commands are ready
Expand Down
Loading