@@ -14,14 +14,15 @@ public class ConfluentCloudService {
1414 private static org .slf4j .Logger log = LoggerFactory .getLogger (ConfluentCloudService .class );
1515
1616 private final ObjectMapper objectMapper ;
17+ private static final String confluentExecutable ;
1718 private static final String ccloudExecutable ;
1819
1920 public ConfluentCloudService (ObjectMapper objectMapper ) {
2021 this .objectMapper = objectMapper ;
2122 }
2223
2324 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." );
2526 try {
2627 String result = execCmd (new String []{ccloudExecutable , "service-account" , "list" , "-o" , "json" });
2728 return objectMapper .readValue (result , new TypeReference <List <ServiceAccount >>() {
@@ -33,11 +34,11 @@ public List<ServiceAccount> getServiceAccounts() {
3334 }
3435
3536 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 );
3738 try {
3839 String serviceName = isUser ? String .format ("user-%s" , name ) : name ;
3940 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" });
4142 return objectMapper .readValue (result , ServiceAccount .class );
4243 } catch (IOException ex ) {
4344 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 {
5051 }
5152
5253 static {
54+ confluentExecutable = System .getenv ("CONFLUENT_EXECUTABLE_PATH" ) != null ? System .getenv ("CONFLUENT_EXECUTABLE_PATH" ) : "confluent" ;
55+ log .info ("Using confluent executable at: {}" , confluentExecutable );
5356 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 );
5558 }
5659}
0 commit comments