@@ -14,14 +14,15 @@ public class ConfluentCloudService {
14
14
private static org .slf4j .Logger log = LoggerFactory .getLogger (ConfluentCloudService .class );
15
15
16
16
private final ObjectMapper objectMapper ;
17
+ private static final String confluentExecutable ;
17
18
private static final String ccloudExecutable ;
18
19
19
20
public ConfluentCloudService (ObjectMapper objectMapper ) {
20
21
this .objectMapper = objectMapper ;
21
22
}
22
23
23
24
public List <ServiceAccount > getServiceAccounts () {
24
- log .info ("Fetching service account list from Confluent Cloud via ccloud tool." );
25
+ log .info ("Fetching service account list from Confluent Cloud via confluent tool." );
25
26
try {
26
27
String result = execCmd (new String []{ccloudExecutable , "service-account" , "list" , "-o" , "json" });
27
28
return objectMapper .readValue (result , new TypeReference <List <ServiceAccount >>() {
@@ -33,11 +34,11 @@ public List<ServiceAccount> getServiceAccounts() {
33
34
}
34
35
35
36
public ServiceAccount createServiceAccount (String name , boolean isUser ) {
36
- log .info ("Creating service account {} in Confluent Cloud via ccloud tool." , name );
37
+ log .info ("Creating service account {} in Confluent Cloud via confluent tool." , name );
37
38
try {
38
39
String serviceName = isUser ? String .format ("user-%s" , name ) : name ;
39
40
String description = isUser ? String .format ("User: %s" , name ) : String .format ("Service account: %s" , name );
40
- String result = execCmd (new String []{ccloudExecutable , "service-account" , "create" , serviceName , "--description" , description , "-o" , "json" });
41
+ String result = execCmd (new String []{confluentExecutable , "iam" , "service-account" , "create" , serviceName , "--description" , description , "-o" , "json" });
41
42
return objectMapper .readValue (result , ServiceAccount .class );
42
43
} catch (IOException ex ) {
43
44
throw new ConfluentCloudException (String .format ("There was an error creating Confluent Cloud service account: %s." , name ));
@@ -50,7 +51,9 @@ public static String execCmd(String[] cmd) throws java.io.IOException {
50
51
}
51
52
52
53
static {
54
+ confluentExecutable = System .getenv ("CONFLUENT_EXECUTABLE_PATH" ) != null ? System .getenv ("CONFLUENT_EXECUTABLE_PATH" ) : "confluent" ;
55
+ log .info ("Using confluent executable at: {}" , confluentExecutable );
53
56
ccloudExecutable = System .getenv ("CCLOUD_EXECUTABLE_PATH" ) != null ? System .getenv ("CCLOUD_EXECUTABLE_PATH" ) : "ccloud" ;
54
- log .info ("Using ccloud executable at: {}" , ccloudExecutable );
57
+ log .info ("Using ccloud executable at: {}" , confluentExecutable );
55
58
}
56
59
}
0 commit comments