Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use proper computation logic of Kind and API version #2679

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions extensions/chaosmesh/client/src/main/resources/resource-handler.vm
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@
* limitations under the License.
*#

#set ($version = "unknown")
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


package io.fabric8.chaosmesh.client.handlers;

import java.util.function.Predicate;
Expand All @@ -40,6 +27,7 @@ import io.fabric8.chaosmesh.client.internal.${model.name}OperationsImpl;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -49,19 +37,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
21 changes: 10 additions & 11 deletions extensions/knative/client/src/main/resources/resource-handler.vm
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
* limitations under the License.
*#

#set ($version = "unknown")
#set ($annotations = $model.annotations)
#set ($group = $model.getPackageName().split("\.")[3])
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


Expand All @@ -41,6 +36,7 @@ import io.fabric8.knative.client.${group}.${apiVersion}.internal.${model.name}Op
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -50,19 +46,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
* limitations under the License.
*#

#set ($version = "unknown")
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


package io.fabric8.servicecatalog.client.handlers;

Expand All @@ -40,6 +28,7 @@ import io.fabric8.servicecatalog.client.internal.${model.name}OperationsImpl;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -49,19 +38,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
20 changes: 10 additions & 10 deletions extensions/tekton/client/src/main/resources/resource-handler.vm
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
* limitations under the License.
*#

#set ($version = "unknown")
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


Expand All @@ -40,6 +36,7 @@ import io.fabric8.tekton.client.internal.$apiVersion.${model.name}OperationsImpl
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -49,19 +46,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@
* limitations under the License.
*#

#set ($version = "unknown")
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


package io.fabric8.volumesnapshot.client.handlers;

import java.util.function.Predicate;
Expand All @@ -40,6 +27,7 @@ import io.fabric8.volumesnapshot.client.internal.${model.name}OperationsImpl;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -49,19 +37,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
24 changes: 11 additions & 13 deletions kubernetes-client/src/main/resources/resource-handler.vm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#if ($annotation.getClassRef().getName().equals("PackageSuffix"))
#if ($annotationName.equals("PackageSuffix"))
#set ($packageSuffix = $annotation.getParameters().get("value"))
#end
#end
Expand All @@ -42,6 +36,7 @@ import io.fabric8.kubernetes.client.dsl.internal$packageSuffix.${model.name}Oper
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -51,19 +46,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down
28 changes: 10 additions & 18 deletions openshift-client/src/main/resources/resource-handler.vm
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*#
#set ($version = "unknown")
#set ($annotations = $model.annotations)
#foreach ($annotation in $annotations)
#set ($annotationName = $annotation.getClassRef().getName())
#if ($annotationName.endsWith("Version"))
#set ($apiVersion = $annotation.getParameters().get("value"))
#end
#if ($annotationName.endsWith("Group"))
#set ($apiGroup = $annotation.getParameters().get("value"))
#end
#end


package io.fabric8.openshift.client.handlers;

Expand All @@ -42,6 +30,7 @@ import io.fabric8.openshift.client.OpenShiftConfig;

import okhttp3.OkHttpClient;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.ListOptions;
import ${model.fullyQualifiedName};
Expand All @@ -51,19 +40,22 @@ import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
private final String kind;
private final String apiVersion;

public ${model.name}Handler() {
kind = HasMetadata.getKind(${model.name}.class);
apiVersion = HasMetadata.getApiVersion(${model.name}.class);
}

@Override
public String getKind() {
return ${model.name}.class.getSimpleName();
return kind;
}

@Override
public String getApiVersion() {
#if (${apiGroup} != "")
return "${apiGroup}/${apiVersion}";
#else
return "${apiVersion}";
#end
return apiVersion;
}

@Override
Expand Down