Skip to content

Commit

Permalink
Merge pull request #1 from kirici/main
Browse files Browse the repository at this point in the history
fix: minor misspellings/wording
  • Loading branch information
wd authored Feb 21, 2024
2 parents 6374903 + d0f31be commit 301a4e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Install
Download the binary from release page, and put it in your PATH. You may need to allow it to be executed from the `settings->Security & Privacity` dialog.
Download the binary from release page, and put it in your PATH. You may need to allow it to be executed from the `settings->Security & Privacy` dialog.

## Usages

Expand All @@ -11,9 +11,9 @@ Usage:
kubectl-history [command]
Available Commands:
diff Show a diff for different reversions of the resource
diff Show a diff for different revisions of the resource
help Help about any command
list List all the reversions of the resource
list List all the revisions of the resource
Flags:
-c, --context string the context scope for the request
Expand All @@ -29,7 +29,7 @@ Use "kubectl-history [command] --help" for more information about a command.

### list command

Use list command to list all the exit reversions: `k history list -n sandbox deploy dong-web`
Use list command to list all the exit revisions: `k history list -n sandbox deploy dong-web`

``` text
# | CREATE TIME | NAME | DESIRED | AVAILIABE | READY
Expand All @@ -53,7 +53,7 @@ Add `-d` to show more details: `k history list -n sandbox deploy dong-web -d`

The command below will get the same result
- `k history diff -n sandbox deploy dong-web` show difference between the latest two versions
- `k history diff -n sandbox deploy dong-web 1` show difference between the version 1 and the latest version
- `k history diff -n sandbox deploy dong-web 1` show difference between version 1 and the latest version
- `k history diff -n sandbox deploy dong-web 1 2` show different between version 1 and 2


Expand Down
6 changes: 3 additions & 3 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func init() {
cmd := &cobra.Command{
Use: fmt.Sprintf("diff %s NAME [old] [new]", SupportedResources),
Short: "Show a diff for different reversions of the resource",
Short: "Show a diff for different revisions of the resource",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("Need resource type and resource name\n\n%s", cmd.UsageString())
Expand Down Expand Up @@ -40,14 +40,14 @@ func runDiff(cmd *cobra.Command, args []string) error {
if len(args) >= 3 {
oldRev, err = strconv.ParseInt(args[2], 10, 64)
if err != nil {
return fmt.Errorf("Parse old reversion faild: %s", err)
return fmt.Errorf("Parse old revision faild: %s", err)
}
}
if len(args) >= 4 {
newRev, err = strconv.ParseInt(args[3], 10, 64)

if err != nil {
return fmt.Errorf("Parse new reversion faild: %s", err)
return fmt.Errorf("Parse new revision faild: %s", err)
}
}
if oldRev == newRev {
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var isShowDetail bool
func init() {
cmd := &cobra.Command{
Use: fmt.Sprintf("list %s NAME", SupportedResources),
Short: "List all the reversions of the resource",
Short: "List all the revisions of the resource",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("Need resource type and resource name\n\n%s", cmd.UsageString())
Expand Down
2 changes: 1 addition & 1 deletion pkg/viewer/cr.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func listControllerRevison(clientset kubernetes.Clientset, owner metav1.Object,
}
crList, err := clientset.AppsV1().ControllerRevisions(owner.GetNamespace()).List(context.TODO(), options)
if err != nil {
return nil, fmt.Errorf("Get controller reversion error: %s", err)
return nil, fmt.Errorf("Get controller revision error: %s", err)
}

var resList []*appsv1.ControllerRevision
Expand Down
7 changes: 3 additions & 4 deletions pkg/viewer/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package viewer

import (
"fmt"

"math"

"github.com/hexops/gotextdiff"
Expand Down Expand Up @@ -51,11 +50,11 @@ func resourceDiff[P *appsv1.ControllerRevision | *appsv1.ReplicaSet](
}
}
if oldRev == math.MaxInt {
return nil, fmt.Errorf("Old reversion %d not found", origOldRev)
return nil, fmt.Errorf("Old revision %d not found", origOldRev)
} else if newRev == math.MaxInt {
return nil, fmt.Errorf("New reversion %d not found", origNewRev)
return nil, fmt.Errorf("New revision %d not found", origNewRev)
} else if oldRev >= newRev {
return nil, fmt.Errorf("Old reversion %d(%d) should small than new reversion %d(%d)", oldRev, origOldRev, newRev, origNewRev)
return nil, fmt.Errorf("Old revision %d(%d) should be smaller than the new revision %d(%d)", oldRev, origOldRev, newRev, origNewRev)
}

oldYaml := getDiffString(oldRs)
Expand Down

0 comments on commit 301a4e9

Please sign in to comment.