-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
24 changed files
with
510 additions
and
145 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
29 changes: 28 additions & 1 deletion
29
src/main/java/br/unifor/ppgia/resiliencebench/BenchmarkReconciler.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
54 changes: 54 additions & 0 deletions
54
src/main/java/br/unifor/ppgia/resiliencebench/resources/CustomResourceRepository.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,54 @@ | ||
package br.unifor.ppgia.resiliencebench.resources; | ||
|
||
import io.fabric8.kubernetes.api.model.KubernetesResourceList; | ||
import io.fabric8.kubernetes.api.model.ObjectMeta; | ||
import io.fabric8.kubernetes.client.CustomResource; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.dsl.MixedOperation; | ||
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; | ||
import io.fabric8.kubernetes.client.dsl.Replaceable; | ||
import io.fabric8.kubernetes.client.dsl.Resource; | ||
|
||
import java.util.List; | ||
|
||
public class CustomResourceRepository<T extends CustomResource> { | ||
|
||
private final KubernetesClient kubernetesClient; | ||
private final Class<T> resourceClass; | ||
private final MixedOperation<T, KubernetesResourceList<T>, Resource<T>> resources; | ||
|
||
@SuppressWarnings("unchecked") | ||
public CustomResourceRepository(KubernetesClient kubernetesClient, Class<T> resourceClass) { | ||
this.kubernetesClient = kubernetesClient; | ||
this.resourceClass = resourceClass; | ||
this.resources = kubernetesClient.resources(resourceClass); | ||
} | ||
|
||
private NonNamespaceOperation<T, KubernetesResourceList<T>, Resource<T>> inNamespace(T resource) { | ||
return this.resources.inNamespace(resource.getMetadata().getNamespace()); | ||
} | ||
|
||
public T create(T resource) { | ||
return inNamespace(resource).resource(resource).create(); | ||
} | ||
|
||
public T update(T resource) { | ||
return inNamespace(resource).resource(resource).createOr(Replaceable::update); | ||
} | ||
|
||
public void delete(T resource) { | ||
inNamespace(resource).resource(resource).delete(); | ||
} | ||
|
||
public T get(ObjectMeta meta) { | ||
return this.resources.inNamespace(meta.getNamespace()).withName(meta.getName()).get(); | ||
} | ||
|
||
public List<T> list(String namespace) { | ||
return this.resources.inNamespace(namespace).list().getItems(); | ||
} | ||
|
||
// public boolean exists(ObjectMeta metadata) { | ||
// return this.get(metadata) != null; | ||
// } | ||
} |
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
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
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
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
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
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
Oops, something went wrong.