@@ -2,7 +2,6 @@ package linux
2
2
3
3
import (
4
4
"fmt"
5
- "io/ioutil"
6
5
"os"
7
6
"testing"
8
7
@@ -16,10 +15,11 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
16
15
testDir , _ := test .NewWriter (t )
17
16
dir := testDir + "/"
18
17
type fields struct {
19
- profile string
20
- extraArgsPath string
21
- basePath string
22
- config constants.CredentialProviderConfigOptions
18
+ profile string
19
+ extraArgsPath string
20
+ legacyExtraArgsPath string
21
+ basePath string
22
+ config constants.CredentialProviderConfigOptions
23
23
}
24
24
type args struct {
25
25
line string
@@ -36,9 +36,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
36
36
{
37
37
name : "test empty string" ,
38
38
fields : fields {
39
- profile : "eksa-packages" ,
40
- extraArgsPath : dir ,
41
- basePath : dir ,
39
+ profile : "eksa-packages" ,
40
+ extraArgsPath : dir ,
41
+ legacyExtraArgsPath : dir ,
42
+ basePath : dir ,
42
43
config : constants.CredentialProviderConfigOptions {
43
44
ImagePatterns : []string {constants .DefaultImagePattern },
44
45
DefaultCacheDuration : constants .DefaultCacheDuration ,
@@ -52,9 +53,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
52
53
{
53
54
name : "test multiple match patterns" ,
54
55
fields : fields {
55
- profile : "eksa-packages" ,
56
- extraArgsPath : dir ,
57
- basePath : dir ,
56
+ profile : "eksa-packages" ,
57
+ extraArgsPath : dir ,
58
+ legacyExtraArgsPath : dir ,
59
+ basePath : dir ,
58
60
config : constants.CredentialProviderConfigOptions {
59
61
ImagePatterns : []string {
60
62
"1234567.dkr.ecr.us-east-1.amazonaws.com" ,
@@ -71,9 +73,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
71
73
{
72
74
name : "skip credential provider if already provided" ,
73
75
fields : fields {
74
- profile : "eksa-packages" ,
75
- extraArgsPath : dir ,
76
- basePath : dir ,
76
+ profile : "eksa-packages" ,
77
+ extraArgsPath : dir ,
78
+ legacyExtraArgsPath : dir ,
79
+ basePath : dir ,
77
80
config : constants.CredentialProviderConfigOptions {
78
81
ImagePatterns : []string {constants .DefaultImagePattern },
79
82
DefaultCacheDuration : constants .DefaultCacheDuration ,
@@ -87,9 +90,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
87
90
{
88
91
name : "test alpha api" ,
89
92
fields : fields {
90
- profile : "eksa-packages" ,
91
- extraArgsPath : dir ,
92
- basePath : dir ,
93
+ profile : "eksa-packages" ,
94
+ extraArgsPath : dir ,
95
+ legacyExtraArgsPath : dir ,
96
+ basePath : dir ,
93
97
config : constants.CredentialProviderConfigOptions {
94
98
ImagePatterns : []string {constants .DefaultImagePattern },
95
99
DefaultCacheDuration : constants .DefaultCacheDuration ,
@@ -104,9 +108,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
104
108
{
105
109
name : "test v1 api 1.27" ,
106
110
fields : fields {
107
- profile : "eksa-packages" ,
108
- extraArgsPath : dir ,
109
- basePath : dir ,
111
+ profile : "eksa-packages" ,
112
+ extraArgsPath : dir ,
113
+ legacyExtraArgsPath : dir ,
114
+ basePath : dir ,
110
115
config : constants.CredentialProviderConfigOptions {
111
116
ImagePatterns : []string {constants .DefaultImagePattern },
112
117
DefaultCacheDuration : constants .DefaultCacheDuration ,
@@ -122,10 +127,11 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
122
127
for _ , tt := range tests {
123
128
t .Run (tt .name , func (t * testing.T ) {
124
129
c := & linuxOS {
125
- profile : tt .fields .profile ,
126
- extraArgsPath : tt .fields .extraArgsPath ,
127
- basePath : tt .fields .basePath ,
128
- config : tt .fields .config ,
130
+ profile : tt .fields .profile ,
131
+ extraArgsPath : tt .fields .extraArgsPath ,
132
+ legacyExtraArgsPath : tt .fields .legacyExtraArgsPath ,
133
+ basePath : tt .fields .basePath ,
134
+ config : tt .fields .config ,
129
135
}
130
136
t .Setenv ("K8S_VERSION" , tt .k8sVersion )
131
137
@@ -143,10 +149,11 @@ func Test_linuxOS_UpdateAWSCredentials(t *testing.T) {
143
149
testDir , _ := test .NewWriter (t )
144
150
dir := testDir + "/"
145
151
type fields struct {
146
- profile string
147
- extraArgsPath string
148
- basePath string
149
- config constants.CredentialProviderConfigOptions
152
+ profile string
153
+ extraArgsPath string
154
+ legacyExtraArgsPath string
155
+ basePath string
156
+ config constants.CredentialProviderConfigOptions
150
157
}
151
158
type args struct {
152
159
sourcePath string
@@ -161,9 +168,10 @@ func Test_linuxOS_UpdateAWSCredentials(t *testing.T) {
161
168
{
162
169
name : "simple credential move" ,
163
170
fields : fields {
164
- profile : "eksa-packages" ,
165
- extraArgsPath : dir ,
166
- basePath : dir ,
171
+ profile : "eksa-packages" ,
172
+ extraArgsPath : dir ,
173
+ legacyExtraArgsPath : dir ,
174
+ basePath : dir ,
167
175
config : constants.CredentialProviderConfigOptions {
168
176
ImagePatterns : []string {constants .DefaultImagePattern },
169
177
DefaultCacheDuration : constants .DefaultCacheDuration ,
@@ -180,10 +188,11 @@ func Test_linuxOS_UpdateAWSCredentials(t *testing.T) {
180
188
t .Run (tt .name , func (t * testing.T ) {
181
189
dstFile := tt .fields .basePath + credOutFile
182
190
c := & linuxOS {
183
- profile : tt .fields .profile ,
184
- extraArgsPath : tt .fields .extraArgsPath ,
185
- basePath : tt .fields .basePath ,
186
- config : tt .fields .config ,
191
+ profile : tt .fields .profile ,
192
+ extraArgsPath : tt .fields .extraArgsPath ,
193
+ legacyExtraArgsPath : tt .fields .legacyExtraArgsPath ,
194
+ basePath : tt .fields .basePath ,
195
+ config : tt .fields .config ,
187
196
}
188
197
if err := c .UpdateAWSCredentials (tt .args .sourcePath , tt .args .profile ); (err != nil ) != tt .wantErr {
189
198
t .Errorf ("UpdateAWSCredentials() error = %v, wantErr %v" , err , tt .wantErr )
@@ -199,12 +208,12 @@ func Test_linuxOS_UpdateAWSCredentials(t *testing.T) {
199
208
if err != nil {
200
209
t .Errorf ("Failed to set file back to readable" )
201
210
}
202
- expectedCreds , err := ioutil .ReadFile (tt .args .sourcePath )
211
+ expectedCreds , err := os .ReadFile (tt .args .sourcePath )
203
212
if err != nil {
204
213
t .Errorf ("Failed to read source credential file" )
205
214
}
206
215
207
- actualCreds , err := ioutil .ReadFile (dstFile )
216
+ actualCreds , err := os .ReadFile (dstFile )
208
217
if err != nil {
209
218
t .Errorf ("Failed to read created credential file" )
210
219
}
@@ -215,10 +224,11 @@ func Test_linuxOS_UpdateAWSCredentials(t *testing.T) {
215
224
216
225
func Test_linuxOS_Initialize (t * testing.T ) {
217
226
type fields struct {
218
- profile string
219
- extraArgsPath string
220
- basePath string
221
- config constants.CredentialProviderConfigOptions
227
+ profile string
228
+ extraArgsPath string
229
+ legacyExtraArgsPath string
230
+ basePath string
231
+ config constants.CredentialProviderConfigOptions
222
232
}
223
233
type args struct {
224
234
config constants.CredentialProviderConfigOptions
0 commit comments