Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
96117634
Commit
96117634
authored
4 years ago
by
Benedikt Wetzel
Browse files
Options
Downloads
Patches
Plain Diff
Add comments
parent
ceeeb84f
No related branches found
No related tags found
4 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!101
Add Service Monitor
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sCustomResourceWrapper.kt
+21
-1
21 additions, 1 deletion
...rc/main/kotlin/theodolite/k8s/K8sCustomResourceWrapper.kt
with
21 additions
and
1 deletion
theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sCustomResourceWrapper.kt
+
21
−
1
View file @
96117634
...
...
@@ -4,11 +4,26 @@ import io.fabric8.kubernetes.client.CustomResource
import
io.fabric8.kubernetes.client.NamespacedKubernetesClient
import
io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
class
K8sCustomResourceWrapper
(
private
val
map
:
Map
<
String
,
String
>)
:
CustomResource
()
{
/**
* Fabric8 handles custom resources as plain HashMaps. These need to be handled differently than normal
* Kubernetes resources. The K8sCustomResourceWrapper class provides a wrapper to deploy and delete
* custom resources in a uniform way.
*
* @property map custom resource as plain hashmap
* @constructor Create empty K8s custom resource wrapper
*/
class
K8sCustomResourceWrapper
(
private
val
map
:
Map
<
String
,
String
>)
:
CustomResource
()
{
/**
* Deploy a custom resource
*
* @param client a namespaced Kubernetes client which are used to deploy the CR object.
*/
fun
deploy
(
client
:
NamespacedKubernetesClient
){
val
kind
=
this
.
map
[
"kind"
]
// Search the CustomResourceDefinition to which the CR Object belongs.
// This should be exactly one if the CRD is registered for Kubernetes, zero otherwise.
val
crds
=
client
.
apiextensions
().
v1beta1
().
customResourceDefinitions
().
list
()
crds
.
items
.
filter
{
crd
->
crd
.
toString
().
contains
(
"kind=$kind"
)
}
...
...
@@ -18,6 +33,11 @@ class K8sCustomResourceWrapper(private val map : Map<String,String>) : CustomRes
}
}
/**
* Delete a custom resource
*
* @param client a namespaced Kubernetes client which are used to delete the CR object.
*/
fun
delete
(
client
:
NamespacedKubernetesClient
){
val
kind
=
this
.
map
[
"kind"
]
val
metadata
=
this
.
map
[
"metadata"
]
as
HashMap
<
String
,
String
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment