Skip to content

Commit

Permalink
shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
dudo committed May 13, 2024
1 parent 46805c4 commit 5452e4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
9 changes: 0 additions & 9 deletions pkg/annotations.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package pkg

import (
"crypto/sha1"
"encoding/hex"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -256,10 +254,3 @@ func (cronitorParser CronitorConfigParser) GetGraceSeconds() int {
}
return -1
}

func generateHashFromName(name string) string {
h := sha1.New()
h.Write([]byte(name))
bs := h.Sum(nil)
return hex.EncodeToString(bs)
}
8 changes: 4 additions & 4 deletions pkg/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestGetCronitorID(t *testing.T) {
name: "hashed name as ID",
annotationIDInference: "name",
annotationCronitorID: "",
expectedID: "7bec37031fa63007a383ade88997bea5bba68d99",
expectedID: "3278d16696a89a92d297b7c46bfd286b20dc3896",
},
{
name: "specific cronitor id",
Expand Down Expand Up @@ -111,19 +111,19 @@ func TestGetCronitorName(t *testing.T) {
name: "default behavior",
annotationNamePrefix: "",
annotationCronitorName: "",
expectedName: "default/name-test-cronjob",
expectedName: "default/test-cronjob",
},
{
name: "no prefix for name",
annotationNamePrefix: "none",
annotationCronitorName: "",
expectedName: "name-test-cronjob",
expectedName: "test-cronjob",
},
{
name: "explicit prefix of namespace",
annotationNamePrefix: "namespace",
annotationCronitorName: "",
expectedName: "default/name-test-cronjob",
expectedName: "default/test-cronjob",
},
{
name: "specific cronitor name",
Expand Down
11 changes: 10 additions & 1 deletion pkg/util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package pkg

import (
"crypto/sha1"
"encoding/hex"
"encoding/json"
"fmt"
"strings"
Expand All @@ -24,7 +26,7 @@ func CronJobFromAnnotations(annotations []Annotation) (v1.CronJob, error) {
"apiVersion": "batch/v1beta1",
"kind": "CronJob",
"metadata": {
"name": "name-test-cronjob",
"name": "test-cronjob",
"namespace": "default",
"annotations": {%s}
},
Expand Down Expand Up @@ -60,3 +62,10 @@ func CronJobFromAnnotations(annotations []Annotation) (v1.CronJob, error) {

return cronJob, err
}

func generateHashFromName(name string) string {
h := sha1.New()
h.Write([]byte(name))
bs := h.Sum(nil)
return hex.EncodeToString(bs)
}

0 comments on commit 5452e4e

Please sign in to comment.