Skip to content

Commit

Permalink
grammar fixes, quote vars in bash, fix README links
Browse files Browse the repository at this point in the history
  • Loading branch information
Taimoor Ahmad committed Feb 27, 2024
1 parent 2cc73a6 commit 26726fb
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 92 deletions.
15 changes: 7 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Contributing

1. [About this document](#about-this-document)
3. [Getting the code](#getting-the-code)
4. [Setting up an environment](#setting-up-an-environment)
5. [Local development](#local-development)
7. [Submitting a Pull Request](#submitting-a-pull-request)
1. [Getting the code](#getting-the-code)
1. [Local development](#local-development)
1. [Submitting a Pull Request](#submitting-a-pull-request)

## About this document

Expand Down Expand Up @@ -54,10 +53,10 @@ If you are a member of the `OpsLevel` GitHub organization, you will have push ac

First make sure you have working [golang development environment](https://learn.gopherguides.com/courses/preparing-your-environment-for-go-development) setup.

You will also need an [OpsLevel API Token](https://app.opslevel.com/api_tokens) from your account to successfully make API calls against. Once you have the API token its best to put it in your terminal's environment
You will also need an [OpsLevel API Token](https://app.opslevel.com/api_tokens) from your account to successfully make API calls against. Once you have the API token it is best to put it in your terminal's environment

```sh
export OPSLEVEL_API_TOKEN=XXXXXXXXX
export OPSLEVEL_API_TOKEN=XXXXXXXXX
```

### Local Development Testing
Expand Down Expand Up @@ -97,9 +96,9 @@ Follow the prompts to create your change entry - remember this is what will show

## Submitting a Pull Request

OpsLevel provides a CI environment to test changes through Github Actions. For example, if you submit a pull request to the repo, GitHub will trigger automated code checks and tests upon approval from an OpsLevel maintainer.
OpsLevel provides a CI environment to test changes through GitHub Actions. For example, if you submit a pull request to the repo, GitHub will trigger automated code checks and tests upon approval from an OpsLevel maintainer.

A maintainer will review your PR. They may suggest code revision for style or clarity, or request that you add unit or integration test(s). These are good things! We believe that, with a little bit of help, anyone can contribute high-quality code.
- First time contributors should note code checks + unit tests require a maintainer to approve.
- First time contributors should be aware that code checks + unit tests require a maintainer to approve.

Once all tests are passing and your PR has been approved, a maintainer will merge your changes into the active development branch. And that's it! It will be available in the next release that is cut. Happy developing :tada:
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<p align="center">
<a href="https://github.com/OpsLevel/cli/blob/main/LICENSE" alt="License">
<img src="https://img.shields.io/github/license/OpsLevel/cli.svg" /></a>
<a href="https://goreportcard.com/report/github.com/OpsLevel/cli" alt="Go Report Card">
<img src="https://goreportcard.com/badge/github.com/OpsLevel/cli" /></a>
<a href="https://GitHub.com/OpsLevel/cli/releases/" alt="Release">
<img src="https://img.shields.io/github/v/release/OpsLevel/cli" /></a>
<a href="https://masterminds.github.io/stability/experimental.html" alt="Stability: Experimental">
<img src="https://masterminds.github.io/stability/experimental.svg" /></a>
<a href="https://github.com/OpsLevel/cli/graphs/contributors" alt="Contributors">
<img src="https://img.shields.io/github/contributors/OpsLevel/cli" /></a>
<a href="https://github.com/OpsLevel/cli/pulse" alt="Activity">
<img src="https://img.shields.io/github/commit-activity/m/OpsLevel/cli" /></a>
<a href="https://github.com/OpsLevel/cli/releases" alt="Downloads">
<img src="https://img.shields.io/github/downloads/OpsLevel/cli/total" /></a>
<a href="https://github.com/OpsLevel/cli/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/OpsLevel/cli.svg" alt="License" /></a>
<a href="https://goreportcard.com/report/github.com/OpsLevel/cli">
<img src="https://goreportcard.com/badge/github.com/OpsLevel/cli" alt="Go Report Card" /></a>
<a href="https://GitHub.com/OpsLevel/cli/releases/">
<img src="https://img.shields.io/github/v/release/OpsLevel/cli" alt="Release" /></a>
<a href="https://masterminds.github.io/stability/experimental.html">
<img src="https://masterminds.github.io/stability/experimental.svg" alt="Stability: Experimental" /></a>
<a href="https://github.com/OpsLevel/cli/graphs/contributors">
<img src="https://img.shields.io/github/contributors/OpsLevel/cli" alt="Contributors" /></a>
<a href="https://github.com/OpsLevel/cli/pulse">
<img src="https://img.shields.io/github/commit-activity/m/OpsLevel/cli" alt="Activity" /></a>
<a href="https://github.com/OpsLevel/cli/releases">
<img src="https://img.shields.io/github/downloads/OpsLevel/cli/total" alt="Downloads" /></a>
</p>

[![Overall](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fapp.opslevel.com%2Fapi%2Fservice_level%2FEaWapOq9VQj5FvymQEgCPNJcbF-TOibHn89Arw7d_OY)](https://app.opslevel.com/services/opslevel_cli/maturity-report)
Expand Down Expand Up @@ -99,7 +99,7 @@ Chaos Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvOTY8
### Enable shell autocompletion

We have the ability to generate autocompletion scripts for the shell's `bash`, `zsh`, `fish` and `powershell`. To generate
the completion script for MacOS zsh:
the completion script for macOS zsh:
```sh
opslevel completion zsh > /usr/local/share/zsh/site-functions/_opslevel
Expand Down
14 changes: 8 additions & 6 deletions ci/deploy-deb.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/bin/bash

set -e

DEBIAN_RELEASES=$(debian-distro-info --supported)
UBUNTU_RELEASES=$(ubuntu-distro-info --supported-esm)

mkdir -p cli-repo/deb
cd cli-repo/deb

for release in ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
for release in "${DEBIAN_RELEASES[@]}" "${UBUNTU_RELEASES[@]}"; do
echo "Removing deb package of $release"
reprepro -A i386 remove $release opslevel
reprepro -A amd64 remove $release opslevel
reprepro -A i386 remove "$release" opslevel
reprepro -A amd64 remove "$release" opslevel
done

for release in ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
for release in "${DEBIAN_RELEASES[@]}" "${UBUNTU_RELEASES[@]}"; do
echo "Adding deb package to $release"
reprepro includedeb $release ../../src/dist/*linux-64bit.deb
reprepro includedeb $release ../../src/dist/*linux-32bit.deb
reprepro includedeb "$release" ../../src/dist/*linux-64bit.deb
reprepro includedeb "$release" ../../src/dist/*linux-32bit.deb
done

git add .
Expand Down
14 changes: 8 additions & 6 deletions ci/deploy-rpm.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#!/bin/bash

set -e

function create_rpm_repo () {
version=$1
rpm_path=rpm/releases/${version}/x86_64

RPM_EL=$(find ../src/dist -type f -name "*64bit.rpm" -printf "%f\n" | head -n1 | sed -e "s/_/-/g" -e "s/-linux/.el$version/" -e "s/-64bit/.x86_64/")
echo $RPM_EL
echo "$RPM_EL"

mkdir -p $rpm_path
cp ../src/dist/*64bit.rpm ${rpm_path}/${RPM_EL}
mkdir -p "$rpm_path"
cp ../src/dist/*64bit.rpm "${rpm_path}/${RPM_EL}"

createrepo --update $rpm_path
createrepo --update "$rpm_path"
}

cd cli-repo

VERSIONS=(5 6 7 8)
for version in ${VERSIONS[@]}; do
for version in "${VERSIONS[@]}"; do
echo "Processing RHEL/CentOS $version..."
create_rpm_repo $version
create_rpm_repo "$version"
done

git add .
Expand Down
2 changes: 1 addition & 1 deletion src/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/sh

go build -o $(which opslevel)
go build -o "$(which opslevel)"
64 changes: 32 additions & 32 deletions src/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

var getCheckCmd = &cobra.Command{
Use: "check ID",
Short: "Get details about a rubic check",
Long: `Get details about a rubic check`,
Short: "Get details about a rubric check",
Long: `Get details about a rubric check`,
Args: cobra.ExactArgs(1),
ArgAliases: []string{"ID"},
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -214,11 +214,11 @@ func updateCheck(input CheckInputType, usePrompts bool) (*opslevel.Check, error)

// Resolving foreign keys

func (self *CheckInputType) resolveCategoryAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := self.Spec["category"]; ok {
delete(self.Spec, "category")
func (checkInputType *CheckInputType) resolveCategoryAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := checkInputType.Spec["category"]; ok {
delete(checkInputType.Spec, "category")
if value, ok := opslevel.Cache.TryGetCategory(item.(string)); ok {
self.Spec["categoryId"] = value.Id
checkInputType.Spec["categoryId"] = value.Id
return nil
} else {
fmt.Printf("%s is not a valid category, please select a valid category\n", item.(string))
Expand All @@ -229,9 +229,9 @@ func (self *CheckInputType) resolveCategoryAliases(client *opslevel.Client, useP
if promptErr != nil {
return promptErr
}
self.Spec["categoryId"] = category.Id
checkInputType.Spec["categoryId"] = category.Id
} else {
if self.IsUpdateInput() {
if checkInputType.IsUpdateInput() {
return nil
}

Expand All @@ -240,11 +240,11 @@ func (self *CheckInputType) resolveCategoryAliases(client *opslevel.Client, useP
return nil
}

func (self *CheckInputType) resolveLevelAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := self.Spec["level"]; ok {
delete(self.Spec, "level")
func (checkInputType *CheckInputType) resolveLevelAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := checkInputType.Spec["level"]; ok {
delete(checkInputType.Spec, "level")
if value, ok := opslevel.Cache.TryGetLevel(item.(string)); ok {
self.Spec["levelId"] = value.Id
checkInputType.Spec["levelId"] = value.Id
return nil
} else {
fmt.Printf("%s is not a valid level, please select a valid level\n", item.(string))
Expand All @@ -255,9 +255,9 @@ func (self *CheckInputType) resolveLevelAliases(client *opslevel.Client, useProm
if promptErr != nil {
return promptErr
}
self.Spec["levelId"] = level.Id
checkInputType.Spec["levelId"] = level.Id
} else {
if self.IsUpdateInput() {
if checkInputType.IsUpdateInput() {
return nil
}

Expand All @@ -266,11 +266,11 @@ func (self *CheckInputType) resolveLevelAliases(client *opslevel.Client, useProm
return nil
}

func (self *CheckInputType) resolveTeamAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := self.Spec["owner"]; ok {
delete(self.Spec, "owner")
func (checkInputType *CheckInputType) resolveTeamAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := checkInputType.Spec["owner"]; ok {
delete(checkInputType.Spec, "owner")
if value, ok := opslevel.Cache.TryGetTeam(item.(string)); ok {
self.Spec["ownerId"] = value.Id
checkInputType.Spec["ownerId"] = value.Id
return nil
} else {
fmt.Printf("%s is not a valid team, please select a valid team\n", item.(string))
Expand All @@ -282,19 +282,19 @@ func (self *CheckInputType) resolveTeamAliases(client *opslevel.Client, usePromp
return promptErr
}
if team.Id != "" {
self.Spec["ownerId"] = team.Id
checkInputType.Spec["ownerId"] = team.Id
}
} else {
log.Warn().Msg("no value supplied for field 'owner'")
}
return nil
}

func (self *CheckInputType) resolveFilterAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := self.Spec["filter"]; ok {
delete(self.Spec, "filter")
func (checkInputType *CheckInputType) resolveFilterAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := checkInputType.Spec["filter"]; ok {
delete(checkInputType.Spec, "filter")
if value, ok := opslevel.Cache.TryGetFilter(item.(string)); ok {
self.Spec["filterId"] = value.Id
checkInputType.Spec["filterId"] = value.Id
return nil
} else {
fmt.Printf("%s is not a valid filter, please select a valid filter\n", item.(string))
Expand All @@ -306,19 +306,19 @@ func (self *CheckInputType) resolveFilterAliases(client *opslevel.Client, usePro
return promptErr
}
if filter.Id != "" {
self.Spec["filterId"] = filter.Id
checkInputType.Spec["filterId"] = filter.Id
}
} else {
log.Warn().Msg("no value supplied for field 'filter'")
}
return nil
}

func (self *CheckInputType) resolveIntegrationAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := self.Spec["integration"]; ok {
delete(self.Spec, "integration")
func (checkInputType *CheckInputType) resolveIntegrationAliases(client *opslevel.Client, usePrompt bool) error {
if item, ok := checkInputType.Spec["integration"]; ok {
delete(checkInputType.Spec, "integration")
if value, ok := opslevel.Cache.TryGetIntegration(item.(string)); ok {
self.Spec["integrationId"] = value.Id
checkInputType.Spec["integrationId"] = value.Id
return nil
} else {
fmt.Printf("%s is not a valid integration, please select a valid integration\n", item.(string))
Expand All @@ -329,9 +329,9 @@ func (self *CheckInputType) resolveIntegrationAliases(client *opslevel.Client, u
if promptErr != nil {
return promptErr
}
self.Spec["integrationId"] = integration.Id
checkInputType.Spec["integrationId"] = integration.Id
} else {
if self.IsUpdateInput() {
if checkInputType.IsUpdateInput() {
return nil
}

Expand Down Expand Up @@ -444,8 +444,8 @@ type CheckInputType struct {
Spec map[string]interface{}
}

func (self *CheckInputType) IsUpdateInput() bool {
_, ok := self.Spec["id"]
func (checkInputType *CheckInputType) IsUpdateInput() bool {
_, ok := checkInputType.Spec["id"]
return ok
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// CLIServiceDependencyCreateInput This is used to make the user facing CLI experience better
// than a straight passthrough to the API types which are overly verbose
// than a straight pass through to the API types which are overly verbose
type CLIServiceDependencyCreateInput struct {
Source string `json:"source"`
Target string `json:"target"`
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Commit struct {
AuthoringDate *time.Time `json:"authoring_date,omitempty" yaml:"authoring-date"`
}

// DeployRequest represents a structured request to the OpsLevel deploys webhook endpoint
// DeployEvent represents a structured request to the OpsLevel deploys webhook endpoint
type DeployEvent struct {
Service string `validate:"required" json:"service"`
Deployer Deployer `validate:"required" json:"deployer"`
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ func toASTValue[T astMarshallable](input T) (ast.Value, error) {
}

func getKeyFromMapByMaxValue(m map[string]float64) string {
max := float64(0)
maxValue := float64(0)
var output string
for k, v := range m {
if v > max {
max = v
if v > maxValue {
maxValue = v
output = k
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/rubric.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ var createCategoryCmd = &cobra.Command{
var getCategoryCmd = &cobra.Command{
Use: "category ID",
Aliases: []string{"cat"},
Short: "Get details about a rubic category",
Long: `Get details about a rubic category`,
Short: "Get details about a rubric category",
Long: `Get details about a rubric category`,
Args: cobra.ExactArgs(1),
ArgAliases: []string{"ID"},
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -113,8 +113,8 @@ var createLevelCmd = &cobra.Command{

var getLevelCmd = &cobra.Command{
Use: "level ID",
Short: "Get details about a rubic level",
Long: `Get details about a rubic level`,
Short: "Get details about a rubric level",
Long: `Get details about a rubric level`,
Args: cobra.ExactArgs(1),
ArgAliases: []string{"ID"},
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ opslevel get tag --type=Service my-service-alias foo
tags, err := result.GetTags(client, nil)
cobra.CheckErr(err)

output := []opslevel.Tag{}
output := make([]opslevel.Tag, 0)
for _, tag := range tags.Nodes {
if tagKey == tag.Key {
output = append(output, tag)
Expand Down
Loading

0 comments on commit 26726fb

Please sign in to comment.