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

chore: bump sundrio to 0.50.1 #3438

Merged
merged 1 commit into from
Sep 7, 2021
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Bugs
#### Improvements
#### Dependency Upgrade
* Upgrade Sundrio to 0.50.1
#### New Features
#### _**Note**_: Breaking changes in the API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,28 @@
import io.fabric8.kubernetes.api.model.IntOrString;
import io.fabric8.kubernetes.api.model.Quantity;
import io.sundr.builder.internal.functions.TypeAs;
import io.sundr.codegen.functions.ClassTo;
import io.sundr.model.*;
import io.sundr.utils.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

import static io.sundr.model.utils.Types.BOOLEAN;
import static io.sundr.model.utils.Types.BOOLEAN_REF;

import static io.sundr.model.utils.Types.STRING;
import static io.sundr.model.utils.Types.STRING_REF;

import static io.sundr.model.utils.Types.INT;
import static io.sundr.model.utils.Types.INT_REF;

import static io.sundr.model.utils.Types.LONG;
import static io.sundr.model.utils.Types.LONG_REF;

import static io.sundr.model.utils.Types.DOUBLE;
import static io.sundr.model.utils.Types.DOUBLE_REF;

/**
* Encapsulates the common logic supporting OpenAPI schema generation for CRD generation.
*
Expand All @@ -40,27 +54,16 @@ public abstract class AbstractJsonSchema<T, B> {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractJsonSchema.class);

protected static final TypeDef QUANTITY = ClassTo.TYPEDEF.apply(Quantity.class);
protected static final TypeDef DURATION = ClassTo.TYPEDEF.apply(Duration.class);
protected static final TypeDef INT_OR_STRING = ClassTo.TYPEDEF.apply(IntOrString.class);

protected static final TypeDef QUANTITY = TypeDef.forName(Quantity.class.getName());
protected static final TypeDef DURATION = TypeDef.forName(Duration.class.getName());
protected static final TypeDef INT_OR_STRING =TypeDef.forName(IntOrString.class.getName());

protected static final TypeDef BOOLEAN = ClassTo.TYPEDEF.apply(Boolean.class);
protected static final TypeDef STRING = ClassTo.TYPEDEF.apply(String.class);
protected static final TypeDef INT = ClassTo.TYPEDEF.apply(Integer.class);
protected static final TypeDef LONG = ClassTo.TYPEDEF.apply(Long.class);
protected static final TypeDef DOUBLE = ClassTo.TYPEDEF.apply(Double.class);
protected static final TypeDef DATE = ClassTo.TYPEDEF.apply(Date.class);
protected static final TypeRef QUANTITY_REF = QUANTITY.toReference();
protected static final TypeRef DURATION_REF = DURATION.toReference();
protected static final TypeRef INT_OR_STRING_REF = INT_OR_STRING.toReference();


protected static final TypeRef BOOLEAN_REF = BOOLEAN.toReference();
protected static final TypeRef STRING_REF = STRING.toReference();
protected static final TypeRef INT_REF = INT.toReference();
protected static final TypeRef LONG_REF = LONG.toReference();
protected static final TypeRef DOUBLE_REF = DOUBLE.toReference();
protected static final TypeDef DATE = TypeDef.forName(Date.class.getName());
protected static final TypeRef DATE_REF = DATE.toReference();

private static final String INT_OR_STRING_MARKER = "int_or_string";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.sundr.adapter.api.AdapterContext;
import io.sundr.adapter.api.Adapters;
import io.sundr.adapter.reflect.ReflectionContext;
import io.sundr.builder.TypedVisitor;
import io.sundr.model.ClassRef;
import io.sundr.model.ClassRefBuilder;
Expand Down Expand Up @@ -56,11 +56,10 @@ private Types() {
private static final Logger LOGGER = LoggerFactory.getLogger(Types.class);
private static final String NAMESPACED = Namespaced.class.getName();
public static final String JAVA_LANG_VOID = "java.lang.Void";
public static final ReflectionContext REFLECTION_CONTEXT = new ReflectionContext(DefinitionRepository.getRepository());

public static final AdapterContext REFLECTION_CONTEXT = AdapterContext.create(DefinitionRepository.getRepository());

public static TypeDef typeDefFrom(Class<?> clazz) {
return unshallow(Adapters.adapt(clazz, REFLECTION_CONTEXT));
return unshallow(Adapters.adaptType(clazz, REFLECTION_CONTEXT));
}

public static TypeDef unshallow(TypeDef definition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@

import io.fabric8.crd.example.webserver.WebServerWithSpec;
import io.fabric8.crd.example.webserver.WebServerWithStatusProperty;
import io.sundr.codegen.functions.ClassTo;
import io.sundr.adapter.api.AdapterContext;
import io.sundr.adapter.api.Adapters;
import io.sundr.model.TypeDef;
import io.sundr.model.TypeDefBuilder;
import io.sundr.model.repo.DefinitionRepository;

import org.junit.jupiter.api.Test;

class SpecReplicasPathDetectorTest {

public static final AdapterContext CONTEXT = AdapterContext.create(DefinitionRepository.getRepository());

@Test
public void shoudDetectSpecReplicasPath() throws Exception {
TypeDef def = ClassTo.TYPEDEF.apply(WebServerWithStatusProperty.class);
TypeDef def = Adapters.adaptType(WebServerWithStatusProperty.class, CONTEXT);
SpecReplicasPathDetector detector = new SpecReplicasPathDetector();
def = new TypeDefBuilder(def).accept(detector).build();
assertTrue(detector.getPath().isPresent());
Expand All @@ -39,7 +44,7 @@ public void shoudDetectSpecReplicasPath() throws Exception {

@Test
public void shoudDetectNestedSpecReplicasPath() throws Exception {
TypeDef def = ClassTo.TYPEDEF.apply(WebServerWithSpec.class);
TypeDef def = Adapters.adaptType(WebServerWithSpec.class, CONTEXT);
SpecReplicasPathDetector detector = new SpecReplicasPathDetector();
def = new TypeDefBuilder(def).accept(detector).build();
assertTrue(detector.getPath().isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.fabric8.kubernetes.model.annotation.*;
import io.sundr.adapter.api.Adapters;
import io.sundr.adapter.apt.AptContext;
import io.sundr.codegen.CodegenContext;
import io.sundr.model.TypeDef;
import io.sundr.model.repo.DefinitionRepository;

Expand Down Expand Up @@ -62,7 +61,6 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment

// make sure we create the context before using it
AptContext.create(processingEnv.getElementUtils(), processingEnv.getTypeUtils(), DefinitionRepository.getRepository());
CodegenContext.create(processingEnv.getElementUtils(), processingEnv.getTypeUtils());

//Collect all annotated types.
for (TypeElement annotation : annotations) {
Expand All @@ -77,7 +75,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}

private CustomResourceInfo toCustomResourceInfo(TypeElement customResource) {
TypeDef definition = Adapters.adapt(customResource, AptContext.getContext());
TypeDef definition = Adapters.adaptType(customResource, AptContext.getContext());
definition = Types.unshallow(definition);

if (CustomResourceInfo.DESCRIBE_TYPE_DEFS) {
Expand Down
4 changes: 4 additions & 0 deletions extensions/camel-k/model-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/camel-k/model-v1alpha1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/certmanager/model-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/certmanager/model-v1alpha2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/certmanager/model-v1alpha3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/certmanager/model-v1beta1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/chaosmesh/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/knative/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<dependency>
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/service-catalog/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/tekton/model-triggers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/tekton/model-v1alpha1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/tekton/model-v1beta1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/volumesnapshot/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<groupId>io.sundr</groupId>
<artifactId>transform-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>sundr-codegen-velocity-nodeps</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,6 +51,8 @@
*/
public class OpenIDConnectionUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(OpenIDConnectionUtils.class);

public static final String EMPTY = "";
public static final String ID_TOKEN_KUBECONFIG = "id-token";
public static final String ISSUER_KUBECONFIG = "idp-issuer-url";
public static final String REFRESH_TOKEN_KUBECONFIG = "refresh-token";
Expand Down Expand Up @@ -240,7 +241,7 @@ static String getParametersFromDiscoveryResponse(Map<String, Object> responseAsJ
} else {
LOGGER.warn("oidc: oidc: discovery object doesn't contain a {}", key);
}
return StringUtils.EMPTY;
return EMPTY;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import io.fabric8.kubernetes.api.model.ExecConfig;
import io.fabric8.kubernetes.api.model.ExecConfigBuilder;
import io.fabric8.kubernetes.client.lib.FileSystem;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.client.utils.Utils;
import okhttp3.OkHttpClient;
import okhttp3.TlsVersion;
import org.apache.commons.lang.SystemUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -501,11 +501,13 @@ void shouldPropagateImpersonateSettings() {

@Test
void honorClientAuthenticatorCommands() throws Exception {
if (SystemUtils.IS_OS_WINDOWS) {
System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_WIN_FILE);
} else {
Files.setPosixFilePermissions(Paths.get(TEST_TOKEN_GENERATOR_FILE), PosixFilePermissions.fromString("rwxrwxr-x"));
System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_FILE);
switch (FileSystem.getCurrent()) {
case WINDOWS:
System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_WIN_FILE);
break;
default:
Files.setPosixFilePermissions(Paths.get(TEST_TOKEN_GENERATOR_FILE), PosixFilePermissions.fromString("rwxrwxr-x"));
System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_FILE);
}

Config config = Config.autoConfigure(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import io.fabric8.kubernetes.api.model.storage.VolumeAttachment;
import io.fabric8.kubernetes.api.model.storage.v1beta1.CSIDriver;
import io.fabric8.kubernetes.api.model.storage.v1beta1.CSINode;
import io.fabric8.kubernetes.client.lib.FileSystem;
import io.fabric8.kubernetes.client.utils.Utils;
import java.io.File;
import java.util.Collections;
Expand All @@ -80,7 +81,6 @@
import java.util.TreeMap;
import java.util.concurrent.ThreadFactory;

import org.apache.commons.lang.SystemUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -366,12 +366,14 @@ void testGetCommandPlatformPrefix() {

assertNotNull(commandPrefix);
assertEquals(2, commandPrefix.size());
if (SystemUtils.IS_OS_WINDOWS) {
assertEquals("cmd.exe", commandPrefix.get(0));
assertEquals("/c", commandPrefix.get(1));
} else {
assertEquals("sh", commandPrefix.get(0));
assertEquals("-c", commandPrefix.get(1));
switch (FileSystem.getCurrent()) {
case WINDOWS:
assertEquals("cmd.exe", commandPrefix.get(0));
assertEquals("/c", commandPrefix.get(1));
break;
default:
assertEquals("sh", commandPrefix.get(0));
assertEquals("-c", commandPrefix.get(1));
}
}

Expand Down
Loading