Skip to content

Commit 3d78f77

Browse files
fix: spelling and naming
1 parent 035ce46 commit 3d78f77

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

cmd/run.go

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ var runCmd = &cobra.Command{
2222
lines := ReadEachLine(args[0])
2323

2424
for _, line := range lines {
25-
// sops places a management object at the bottom of its yaml
26-
// none of this is important so I just exit the application here.
25+
26+
// sops puts a management object at the bottom of its yaml
27+
// none of this is important, so I just exit the application here.
2728
if line == "sops:" {
2829
os.Exit(1)
2930
}
@@ -56,7 +57,7 @@ var runCmd = &cobra.Command{
5657
//
5758
//
5859

59-
//ReadEachLine standard read text file funcation
60+
//ReadEachLine standard read text file function
6061
func ReadEachLine(filepath string) (fileLines []string) {
6162

6263
readFile, err := os.Open(filepath)
@@ -81,7 +82,7 @@ func ReadEachLine(filepath string) (fileLines []string) {
8182
//
8283
//
8384

84-
//dataCount simple maths function that applies the pattern observed in the unenrypted string.
85+
//dataCount simple maths function that applies the pattern observed in the unencrypted string.
8586
func dataCount(data string) int {
8687

8788
return len(data) - (getGrouping(len(data)) + getPaddingSize(data))
@@ -94,13 +95,13 @@ func getGrouping(length int) int {
9495
}
9596

9697
//getPaddingSize the full encrypted string contains padding that helps identify where the encrypted string sits in the 3 set
97-
func getPaddingSize(encryptedString string) int {
98+
func getPaddingSize(data string) int {
9899

99-
if strings.HasSuffix(encryptedString, "==") {
100+
if strings.HasSuffix(data, "==") {
100101
return 2
101102
}
102103

103-
if strings.HasSuffix(encryptedString, "=") {
104+
if strings.HasSuffix(data, "=") {
104105
return 1
105106
}
106107

@@ -112,7 +113,7 @@ func getPaddingSize(encryptedString string) int {
112113
//
113114
//
114115

115-
type EncryptedString struct {
116+
type SopsEncDataSet struct {
116117
name string
117118
encryption string
118119
data string
@@ -124,34 +125,32 @@ type EncryptedString struct {
124125

125126
//parseLine manages raw text line to object conversion.
126127
//with below helper functions
127-
func parseLine(encryptedString string) EncryptedString {
128-
129-
encryptedStringObject := EncryptedString{
130-
name: getKey(encryptedString),
131-
encryption: getEncryption(encryptedString),
132-
data: getData(encryptedString, "data:"),
133-
iv: getData(encryptedString, "iv:"),
134-
tag: getData(encryptedString, "tag:"),
135-
_type: getData(encryptedString, "type:"),
128+
func parseLine(dataSetString string) SopsEncDataSet {
129+
130+
return SopsEncDataSet{
131+
name: getKey(dataSetString),
132+
encryption: getEncryption(dataSetString),
133+
data: getData(dataSetString, "data:"),
134+
iv: getData(dataSetString, "iv:"),
135+
tag: getData(dataSetString, "tag:"),
136+
_type: getData(dataSetString, "type:"),
136137
}
137138

138-
return encryptedStringObject
139-
140139
}
141140

142-
func getKey(encryptedString string) string {
143-
split := strings.Split(encryptedString, ":")
141+
func getKey(dataSetString string) string {
142+
split := strings.Split(dataSetString, ":")
144143
return split[0]
145144
}
146145

147-
func getEncryption(encryptedString string) string {
148-
split := strings.Split(encryptedString, ",")
146+
func getEncryption(dataSetString string) string {
147+
split := strings.Split(dataSetString, ",")
149148
split = strings.Split(split[0], "[")
150149
return split[0]
151150
}
152151

153-
func getData(encryptedString string, dataToCollect string) string {
154-
split := strings.Split(encryptedString, ",")
152+
func getData(dataSetString string, dataToCollect string) string {
153+
split := strings.Split(dataSetString, ",")
155154

156155
for _, i := range split {
157156

0 commit comments

Comments
 (0)