@@ -22,8 +22,9 @@ var runCmd = &cobra.Command{
22
22
lines := ReadEachLine (args [0 ])
23
23
24
24
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.
27
28
if line == "sops:" {
28
29
os .Exit (1 )
29
30
}
@@ -56,7 +57,7 @@ var runCmd = &cobra.Command{
56
57
//
57
58
//
58
59
59
- //ReadEachLine standard read text file funcation
60
+ //ReadEachLine standard read text file function
60
61
func ReadEachLine (filepath string ) (fileLines []string ) {
61
62
62
63
readFile , err := os .Open (filepath )
@@ -81,7 +82,7 @@ func ReadEachLine(filepath string) (fileLines []string) {
81
82
//
82
83
//
83
84
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.
85
86
func dataCount (data string ) int {
86
87
87
88
return len (data ) - (getGrouping (len (data )) + getPaddingSize (data ))
@@ -94,13 +95,13 @@ func getGrouping(length int) int {
94
95
}
95
96
96
97
//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 {
98
99
99
- if strings .HasSuffix (encryptedString , "==" ) {
100
+ if strings .HasSuffix (data , "==" ) {
100
101
return 2
101
102
}
102
103
103
- if strings .HasSuffix (encryptedString , "=" ) {
104
+ if strings .HasSuffix (data , "=" ) {
104
105
return 1
105
106
}
106
107
@@ -112,7 +113,7 @@ func getPaddingSize(encryptedString string) int {
112
113
//
113
114
//
114
115
115
- type EncryptedString struct {
116
+ type SopsEncDataSet struct {
116
117
name string
117
118
encryption string
118
119
data string
@@ -124,34 +125,32 @@ type EncryptedString struct {
124
125
125
126
//parseLine manages raw text line to object conversion.
126
127
//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:" ),
136
137
}
137
138
138
- return encryptedStringObject
139
-
140
139
}
141
140
142
- func getKey (encryptedString string ) string {
143
- split := strings .Split (encryptedString , ":" )
141
+ func getKey (dataSetString string ) string {
142
+ split := strings .Split (dataSetString , ":" )
144
143
return split [0 ]
145
144
}
146
145
147
- func getEncryption (encryptedString string ) string {
148
- split := strings .Split (encryptedString , "," )
146
+ func getEncryption (dataSetString string ) string {
147
+ split := strings .Split (dataSetString , "," )
149
148
split = strings .Split (split [0 ], "[" )
150
149
return split [0 ]
151
150
}
152
151
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 , "," )
155
154
156
155
for _ , i := range split {
157
156
0 commit comments