-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d952d4
commit a46d75a
Showing
13 changed files
with
60 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...server/src/main/java/com/repoachiever/converter/AdditionalContentFileToJsonConverter.java
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
api-server/src/main/java/com/repoachiever/converter/ClusterContextToJsonConverter.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...va/com/repoachiever/converter/ContentCredentialsToClusterContextCredentialsConverter.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...ain/java/com/repoachiever/converter/ContentExporterToClusterContextExporterConverter.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...rc/main/java/com/repoachiever/converter/ContentFormatToClusterContextFormatConverter.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...n/java/com/repoachiever/converter/ContentLocationsToClusterContextLocationsConverter.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...ain/java/com/repoachiever/converter/ContentProviderToClusterContextProviderConverter.java
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
...r/src/main/java/com/repoachiever/converter/HealthCheckResponseToReadinessCheckResult.java
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
...server/src/main/java/com/repoachiever/converter/JsonToAdditionalContentDataConverter.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
api-server/src/main/java/com/repoachiever/converter/SecretsConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.objectstorage.converter; | ||
|
||
import com.opencsv.bean.CsvToBeanBuilder; | ||
import com.objectstorage.exception.SecretsConversionException; | ||
import java.io.BufferedReader; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStreamReader; | ||
import java.lang.reflect.InvocationTargetException; | ||
|
||
/** Represents cloud provider secrets converter */ | ||
public class SecretsConverter { | ||
/** | ||
* Converts given credentials CSV file to a certain object. Exposed as a static method to be used | ||
* with Terraform command definitions. | ||
* | ||
* @param content given file content to be processed. | ||
* @return converted credentials. | ||
* @throws SecretsConversionException if any operation in conversion flow failed. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <T> T convert(Class<T> obj, String content) throws SecretsConversionException { | ||
try { | ||
return (T) | ||
new CsvToBeanBuilder( | ||
new BufferedReader( | ||
new InputStreamReader(new ByteArrayInputStream(content.getBytes())))) | ||
.withType(obj.getDeclaredConstructor().newInstance().getClass()) | ||
.withIgnoreLeadingWhiteSpace(true) | ||
.build() | ||
.parse() | ||
.get(1); | ||
} catch (InstantiationException | ||
| IllegalAccessException | ||
| NoSuchMethodException | ||
| InvocationTargetException e) { | ||
throw new SecretsConversionException(e.getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.