Skip to content

Commit

Permalink
fix (extensions/chaosmesh) : Accomodate breaking changes from ChaosMe…
Browse files Browse the repository at this point in the history
…sh model

+ Some go structs have been renamed in newer version of ChaosMesh model. These are:
  - AwsChaos => AWSChaos
  - IoChaos  => IOChaos
  - PodIoChaos => PodIOChaos
+ Scheduler field has been removed from IOChaosSpec

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Aug 26, 2022
1 parent 5a3c264 commit bf6f50f
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package io.fabric8.chaosmesh.client;

import io.fabric8.chaosmesh.v1alpha1.AwsChaos;
import io.fabric8.chaosmesh.v1alpha1.AwsChaosList;
import io.fabric8.chaosmesh.v1alpha1.AWSChaos;
import io.fabric8.chaosmesh.v1alpha1.AWSChaosList;
import io.fabric8.chaosmesh.v1alpha1.DNSChaos;
import io.fabric8.chaosmesh.v1alpha1.DNSChaosList;
import io.fabric8.chaosmesh.v1alpha1.HTTPChaos;
import io.fabric8.chaosmesh.v1alpha1.HTTPChaosList;
import io.fabric8.chaosmesh.v1alpha1.IoChaos;
import io.fabric8.chaosmesh.v1alpha1.IoChaosList;
import io.fabric8.chaosmesh.v1alpha1.IOChaos;
import io.fabric8.chaosmesh.v1alpha1.IOChaosList;
import io.fabric8.chaosmesh.v1alpha1.JVMChaos;
import io.fabric8.chaosmesh.v1alpha1.JVMChaosList;
import io.fabric8.chaosmesh.v1alpha1.KernelChaos;
Expand All @@ -31,8 +31,8 @@
import io.fabric8.chaosmesh.v1alpha1.NetworkChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodChaos;
import io.fabric8.chaosmesh.v1alpha1.PodChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodIoChaos;
import io.fabric8.chaosmesh.v1alpha1.PodIoChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodIOChaos;
import io.fabric8.chaosmesh.v1alpha1.PodIOChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodNetworkChaos;
import io.fabric8.chaosmesh.v1alpha1.PodNetworkChaosList;
import io.fabric8.chaosmesh.v1alpha1.StressChaos;
Expand All @@ -50,11 +50,11 @@ public interface ChaosMeshClient extends Client {

// Serving
/**
* API entrypoint for IoChaos(chaos-mesh.org/v1alpha1)
* API entrypoint for IOChaos(chaos-mesh.org/v1alpha1)
*
* @return MixedOperation for IoChaos class
* @return MixedOperation for IOChaos class
*/
MixedOperation<IoChaos, IoChaosList, Resource<IoChaos>> ioChaos();
MixedOperation<IOChaos, IOChaosList, Resource<IOChaos>> ioChaos();

/**
* API entrypoint for KernelChaos(chaos-mesh.org/v1alpha1)
Expand All @@ -78,11 +78,11 @@ public interface ChaosMeshClient extends Client {
MixedOperation<PodChaos, PodChaosList, Resource<PodChaos>> podChaos();

/**
* API entrypoint for PodIoChaos(chaos-mesh.org/v1alpha1)
* API entrypoint for PodIOChaos(chaos-mesh.org/v1alpha1)
*
* @return MixedOperation for PodIoChaos class
* @return MixedOperation for PodIOChaos class
*/
MixedOperation<PodIoChaos, PodIoChaosList, Resource<PodIoChaos>> podIoChaos();
MixedOperation<PodIOChaos, PodIOChaosList, Resource<PodIOChaos>> podIOChaos();

/**
* API entrypoint for PodNetworkChaos(chaos-mesh.org/v1alpha1)
Expand All @@ -99,9 +99,9 @@ public interface ChaosMeshClient extends Client {
MixedOperation<StressChaos, StressChaosList, Resource<StressChaos>> stressChaos();

/**
* API entrypoint for IoChaos(chaos-mesh.org/v1alpha1)
* API entrypoint for IOChaos(chaos-mesh.org/v1alpha1)
*
* @return MixedOperation for IoChaos class
* @return MixedOperation for IOChaos class
*/
MixedOperation<TimeChaos, TimeChaosList, Resource<TimeChaos>> timeChaos();

Expand All @@ -127,9 +127,9 @@ public interface ChaosMeshClient extends Client {
MixedOperation<DNSChaos, DNSChaosList, Resource<DNSChaos>> dnsChaos();

/**
* API entrypoint for AwsChaos(chaos-mesh.org/v1alpha1)
* API entrypoint for AWSChaos(chaos-mesh.org/v1alpha1)
*
* @return MixedOperation for AwsChaos class
* @return MixedOperation for AWSChaos class
*/
MixedOperation<AwsChaos, AwsChaosList, Resource<AwsChaos>> awsChaos();
MixedOperation<AWSChaos, AWSChaosList, Resource<AWSChaos>> awsChaos();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package io.fabric8.chaosmesh.client;

import io.fabric8.chaosmesh.v1alpha1.AwsChaos;
import io.fabric8.chaosmesh.v1alpha1.AwsChaosList;
import io.fabric8.chaosmesh.v1alpha1.AWSChaos;
import io.fabric8.chaosmesh.v1alpha1.AWSChaosList;
import io.fabric8.chaosmesh.v1alpha1.DNSChaos;
import io.fabric8.chaosmesh.v1alpha1.DNSChaosList;
import io.fabric8.chaosmesh.v1alpha1.HTTPChaos;
import io.fabric8.chaosmesh.v1alpha1.HTTPChaosList;
import io.fabric8.chaosmesh.v1alpha1.IoChaos;
import io.fabric8.chaosmesh.v1alpha1.IoChaosList;
import io.fabric8.chaosmesh.v1alpha1.IOChaos;
import io.fabric8.chaosmesh.v1alpha1.IOChaosList;
import io.fabric8.chaosmesh.v1alpha1.JVMChaos;
import io.fabric8.chaosmesh.v1alpha1.JVMChaosList;
import io.fabric8.chaosmesh.v1alpha1.KernelChaos;
Expand All @@ -31,8 +31,8 @@
import io.fabric8.chaosmesh.v1alpha1.NetworkChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodChaos;
import io.fabric8.chaosmesh.v1alpha1.PodChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodIoChaos;
import io.fabric8.chaosmesh.v1alpha1.PodIoChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodIOChaos;
import io.fabric8.chaosmesh.v1alpha1.PodIOChaosList;
import io.fabric8.chaosmesh.v1alpha1.PodNetworkChaos;
import io.fabric8.chaosmesh.v1alpha1.PodNetworkChaosList;
import io.fabric8.chaosmesh.v1alpha1.StressChaos;
Expand Down Expand Up @@ -75,8 +75,8 @@ public FunctionCallable<NamespacedChaosMeshClient> withRequestConfig(RequestConf
}

@Override
public MixedOperation<IoChaos, IoChaosList, Resource<IoChaos>> ioChaos() {
return resources(IoChaos.class, IoChaosList.class);
public MixedOperation<IOChaos, IOChaosList, Resource<IOChaos>> ioChaos() {
return resources(IOChaos.class, IOChaosList.class);
}

@Override
Expand All @@ -95,8 +95,8 @@ public MixedOperation<PodChaos, PodChaosList, Resource<PodChaos>> podChaos() {
}

@Override
public MixedOperation<PodIoChaos, PodIoChaosList, Resource<PodIoChaos>> podIoChaos() {
return resources(PodIoChaos.class, PodIoChaosList.class);
public MixedOperation<PodIOChaos, PodIOChaosList, Resource<PodIOChaos>> podIOChaos() {
return resources(PodIOChaos.class, PodIOChaosList.class);
}

@Override
Expand Down Expand Up @@ -130,8 +130,8 @@ public MixedOperation<DNSChaos, DNSChaosList, Resource<DNSChaos>> dnsChaos() {
}

@Override
public MixedOperation<AwsChaos, AwsChaosList, Resource<AwsChaos>> awsChaos() {
return resources(AwsChaos.class, AwsChaosList.class);
public MixedOperation<AWSChaos, AWSChaosList, Resource<AWSChaos>> awsChaos() {
return resources(AWSChaos.class, AWSChaosList.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
package io.fabric8.chaosmesh.examples;

import io.fabric8.chaosmesh.client.ChaosMeshClient;
import io.fabric8.chaosmesh.v1alpha1.IoChaosBuilder;
import io.fabric8.chaosmesh.v1alpha1.IOChaosBuilder;

import java.util.Collections;

@SuppressWarnings("java:S106")
public class CreateIoChaos {

//apiVersion: chaos-mesh.org/v1alpha1
//kind: IoChaos
//kind: IOChaos
//metadata:
// name: io-delay-example
//spec:
Expand All @@ -43,21 +43,20 @@ public class CreateIoChaos {
public static void main(String[] args) {
try (ChaosMeshClient client = ClientFactory.newClient(args)) {
System.out.println("Creating a ioChaos");
client.ioChaos().inNamespace("default").create(new IoChaosBuilder()
.withNewMetadata()
.withName("io-delay-example")
.endMetadata()
.withNewSpec()
.withAction("latency")
.withMode("one")
.withNewSelector().withLabelSelectors(Collections.singletonMap("app", "etcd")).endSelector()
.withVolumePath("/var/run/etcd")
.withPath("/var/run/etc/**/*")
.withPercent(50)
.withDuration("400s")
.withNewScheduler().withCron("@every 10m").endScheduler()
.endSpec()
.build());
client.ioChaos().inNamespace("default").create(new IOChaosBuilder()
.withNewMetadata()
.withName("io-delay-example")
.endMetadata()
.withNewSpec()
.withAction("latency")
.withMode("one")
.withNewSelector().withLabelSelectors(Collections.singletonMap("app", "etcd")).endSelector()
.withVolumePath("/var/run/etcd")
.withPath("/var/run/etc/**/*")
.withPercent(50)
.withDuration("400s")
.endSpec()
.build());
}
}
}
Loading

0 comments on commit bf6f50f

Please sign in to comment.