Skip to content

Commit

Permalink
feat: migration org.tkit (#9)
Browse files Browse the repository at this point in the history
* feat: migration org.tkit

* fix: sonar issues
  • Loading branch information
andrejpetras authored Feb 1, 2024
1 parent e6e067b commit 1f74f01
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 78 deletions.
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.onecx</groupId>
<groupId>org.tkit.onecx</groupId>
<artifactId>onecx-quarkus3-parent</artifactId>
<version>0.26.0</version>
<version>0.31.0</version>
</parent>

<artifactId>onecx-permission-operator</artifactId>
Expand Down Expand Up @@ -62,7 +62,15 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-reactive-filter</artifactId>
</dependency>

<!-- OTHER -->
<dependency>
<groupId>org.mapstruct</groupId>
Expand Down
50 changes: 0 additions & 50 deletions src/main/helm/crds/permissions.onecx.github.io-v1.yml

This file was deleted.

54 changes: 54 additions & 0 deletions src/main/helm/crds/permissions.onecx.tkit.org-v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Generated by Fabric8 CRDGenerator, manual edits might get overwritten!
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: permissions.onecx.tkit.org
spec:
group: onecx.tkit.org
names:
kind: Permission
plural: permissions
singular: permission
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
appId:
type: string
description:
type: string
name:
type: string
permissions:
additionalProperties:
additionalProperties:
type: string
type: object
type: object
type: object
status:
properties:
appId:
type: string
message:
type: string
observedGeneration:
type: integer
response-code:
type: integer
status:
enum:
- ERROR
- UNDEFINED
- UPDATED
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 1 addition & 1 deletion src/main/helm/templates/product-cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-cluster-role
rules:
- apiGroups:
- onecx.github.io
- onecx.tkit.org
resources:
- permissions
- permissions/status
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;

@Version("v1")
@Group("onecx.github.io")
@Group("onecx.tkit.org")
public class Permission extends CustomResource<PermissionSpec, PermissionStatus> implements Namespaced {
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tkit.onecx.permission.operator.client.PermissionService;

import io.github.onecx.permission.operator.client.PermissionService;
import io.javaoperatorsdk.operator.api.reconciler.*;
import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter;
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import java.util.Map;

Expand All @@ -11,6 +11,12 @@ public class PermissionSpec {
@JsonProperty(value = "appId", required = true)
private String appId;

@JsonProperty(value = "name", required = true)
private String name;

@JsonProperty(value = "description", required = true)
private String description;

@JsonProperty("permissions")
private Map<String, Map<String, String>> permissions;

Expand All @@ -22,6 +28,22 @@ public void setAppId(String appId) {
this.appId = appId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Map<String, Map<String, String>> getPermissions() {
return permissions;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.github.onecx.permission.operator.client;
package org.tkit.onecx.permission.operator.client;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tkit.onecx.permission.operator.Permission;
import org.tkit.onecx.permission.operator.client.mappers.PermissionClientMapper;

import gen.io.github.onecx.permission.operator.v1.api.PermissionOperatorApi;
import io.github.onecx.permission.operator.Permission;
import io.github.onecx.permission.operator.client.mappers.PermissionClientMapper;
import gen.org.tkit.onecx.permission.operator.v1.api.PermissionOperatorApi;

@ApplicationScoped
public class PermissionService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.github.onecx.permission.operator.client.mappers;
package org.tkit.onecx.permission.operator.client.mappers;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.mapstruct.Mapper;
import org.tkit.onecx.permission.operator.PermissionSpec;

import gen.io.github.onecx.permission.operator.v1.model.Permission;
import gen.io.github.onecx.permission.operator.v1.model.PermissionRequest;
import io.github.onecx.permission.operator.PermissionSpec;
import gen.org.tkit.onecx.permission.operator.v1.model.Permission;
import gen.org.tkit.onecx.permission.operator.v1.model.PermissionRequest;

@Mapper
public interface PermissionClientMapper {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ quarkus.kubernetes-client.devservices.override-kubeconfig=true
quarkus.operator-sdk.helm.enabled=true
quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi
quarkus.openapi-generator.codegen.spec.onecx_permission_operator_v1_yaml.config-key=permission_client
quarkus.openapi-generator.codegen.spec.onecx_permission_operator_v1_yaml.base-package=gen.io.github.onecx.permission.operator.v1
quarkus.openapi-generator.codegen.spec.onecx_permission_operator_v1_yaml.base-package=gen.org.tkit.onecx.permission.operator.v1
quarkus.openapi-generator.codegen.spec.onecx_permission_operator_v1_yaml.return-response=true


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
Expand All @@ -11,9 +11,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.tkit.onecx.permission.operator.client.PermissionService;
import org.tkit.onecx.permission.test.AbstractTest;

import io.github.onecx.permission.operator.client.PermissionService;
import io.github.onecx.permission.test.AbstractTest;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
import io.quarkus.test.InjectMock;
import io.quarkus.test.junit.QuarkusTest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.onecx.permission.operator;
package org.tkit.onecx.permission.operator;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -15,11 +15,11 @@
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tkit.onecx.permission.test.AbstractTest;

import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.github.onecx.permission.test.AbstractTest;
import io.javaoperatorsdk.operator.Operator;
import io.quarkus.test.junit.QuarkusTest;

Expand Down Expand Up @@ -136,6 +136,8 @@ void productUpdateNoDescriptionTest() {

var m = new PermissionSpec();
m.setAppId("test-3");
m.setName("test-3");
m.setDescription("description");
m.setPermissions(p1);

var data = new Permission();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.tkit.onecx.permission.test;

public abstract class AbstractTest {
}

0 comments on commit 1f74f01

Please sign in to comment.