16
16
import io .airlift .configuration .Config ;
17
17
import io .airlift .configuration .ConfigDescription ;
18
18
import io .airlift .configuration .ConfigSecuritySensitive ;
19
- import io .airlift .configuration .LegacyConfig ;
20
19
import io .airlift .configuration .validation .FileExists ;
21
20
import io .airlift .units .DataSize ;
22
21
import io .airlift .units .Duration ;
30
29
import java .util .Optional ;
31
30
import java .util .concurrent .TimeUnit ;
32
31
32
+ import static com .google .common .base .Preconditions .checkArgument ;
33
33
import static io .airlift .units .DataSize .Unit .MEGABYTE ;
34
- import static java .util .Locale .ENGLISH ;
35
34
36
35
public class GcsFileSystemConfig
37
36
{
38
37
public enum AuthType
39
38
{
40
39
ACCESS_TOKEN ,
41
40
DEFAULT ;
42
-
43
- // Ensures backward compatibility with gcs.use-access-token config
44
- // TRUE is mapped to ACCESS_TOKEN
45
- // FALSE is mapped to DEFAULT
46
- public static AuthType fromString (String value )
47
- {
48
- return switch (value .toUpperCase (ENGLISH )) {
49
- case "TRUE" -> ACCESS_TOKEN ;
50
- case "FALSE" -> DEFAULT ;
51
- default -> valueOf (value .toUpperCase (ENGLISH ));
52
- };
53
- }
54
41
}
55
42
56
43
private DataSize readBlockSize = DataSize .of (2 , MEGABYTE );
@@ -61,7 +48,8 @@ public static AuthType fromString(String value)
61
48
private String projectId ;
62
49
private Optional <String > endpoint = Optional .empty ();
63
50
64
- private AuthType authType = AuthType .DEFAULT ;
51
+ private boolean useGcsAccessToken ;
52
+ private AuthType authType ;
65
53
private String jsonKey ;
66
54
private String jsonKeyFilePath ;
67
55
private int maxRetries = 20 ;
@@ -157,17 +145,37 @@ public GcsFileSystemConfig setEndpoint(Optional<String> endpoint)
157
145
@ NotNull
158
146
public AuthType getAuthType ()
159
147
{
160
- return authType ;
148
+ return Optional . ofNullable ( authType ). orElse ( AuthType . DEFAULT ) ;
161
149
}
162
150
163
- @ LegacyConfig ("gcs.use-access-token" )
164
151
@ Config ("gcs.auth-type" )
165
152
public GcsFileSystemConfig setAuthType (AuthType authType )
166
153
{
167
154
this .authType = authType ;
168
155
return this ;
169
156
}
170
157
158
+ @ Deprecated
159
+ public boolean isUseGcsAccessToken ()
160
+ {
161
+ return useGcsAccessToken ;
162
+ }
163
+
164
+ @ Deprecated
165
+ @ Config ("gcs.use-access-token" )
166
+ public GcsFileSystemConfig setUseGcsAccessToken (boolean useGcsAccessToken )
167
+ {
168
+ checkArgument (authType == null , "Cannot set both gcs.use-access-token and gcs.auth-type" );
169
+ this .useGcsAccessToken = useGcsAccessToken ;
170
+ if (useGcsAccessToken ) {
171
+ this .authType = AuthType .ACCESS_TOKEN ;
172
+ }
173
+ else {
174
+ this .authType = AuthType .DEFAULT ;
175
+ }
176
+ return this ;
177
+ }
178
+
171
179
@ Nullable
172
180
public String getJsonKey ()
173
181
{
0 commit comments