Skip to content

Commit

Permalink
improving get deployment method #2
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandorubbo committed Mar 24, 2020
1 parent a5ab4ba commit c3dd8e7
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 8 deletions.
Binary file modified bin/kubectl-snapshot-darwin-386
Binary file not shown.
Binary file modified bin/kubectl-snapshot-darwin-amd64
Binary file not shown.
Binary file modified bin/kubectl-snapshot-linux-386
Binary file not shown.
Binary file modified bin/kubectl-snapshot-linux-amd64
Binary file not shown.
Binary file modified bin/kubectl-snapshot-windows-386.exe
Binary file not shown.
Binary file modified bin/kubectl-snapshot-windows-amd64.exe
Binary file not shown.
5 changes: 1 addition & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ done
chmod +x ./sh/*
cp ./sh/* ./bin/

mkdir -p ~/repos/github/fbrubbo/kubectl-snapshot/bin
cp bin/* ~/repos/github/fbrubbo/kubectl-snapshot/bin


# TO TEST LOCALLY
# 1. ./install.sh
# 2. git push
# 2. git add -A && git commit -m "Message: #issue" && git push
# 4. create new release in github
# 5. get the sha256 hash using https://emn178.github.io/online-tools/sha256_checksum.html
# 6. replace all 'uri' and 'sha256' entries in resource-snapshot.yaml
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"
)

const version = "0.1.2"
const versionDesciption = "First krew plugin version"
const version = "0.1.3"
const versionDesciption = "Small change to improve get deployment name method"

// TODO: sort-by ? How to handle the below scenarios?
func main() {
Expand Down
5 changes: 3 additions & 2 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ func (p Pod) findStatusCondition(test func(Condition) bool) Condition {

//senninha-quotation-redis-slave-0
// zoidberg-pentaho-report-1572104400-rklgx
const stafulsetPattern = `^(.*)-(\d*)$`
const deploymentPattern = `^(.*)-([^-]*)-([^-]*)$`
const stafulsetPattern = `^(.*)-(\d+)$`
const deploymentPattern = `^(.*)-([^-]*)-([^-]+)$`
const jobPattern = `^(.*)-([^-]*)$`
const unknownPattern = `^(.*)$`

// GetDeploymentName should work for most of the cases
// This best effort logic avoid lazy loading objects, but may fall into unknownPattern on corner cases
func (p Pod) GetDeploymentName() string {
name := p.Metadata.Name
var reg *regexp.Regexp
Expand Down
2 changes: 2 additions & 0 deletions resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func TestGetDeploymentName(t *testing.T) {
testPodResource{res: Pod{Metadata: Metadata{Name: "shippingservice-545f46fb7f-f4c5b"}}, expected: "shippingservice"},
testPodResource{res: Pod{Metadata: Metadata{Name: "shipping-service-545f46fb7f-f4c5b"}}, expected: "shipping-service"},
testPodResource{res: Pod{Metadata: Metadata{Name: "forset"}}, expected: "forset"},
testPodResource{res: Pod{Metadata: Metadata{Name: "other-service"}}, expected: "other-service"},
testPodResource{res: Pod{Metadata: Metadata{Name: "other-service-"}}, expected: "other-service-"},
}

log.Infof("%+v", tests)
Expand Down

0 comments on commit c3dd8e7

Please sign in to comment.