Skip to content

Commit 5ee5c35

Browse files
committed
add gvk info to KubeClientReplace Error
1 parent 5e66494 commit 5ee5c35

File tree

1 file changed

+8
-5
lines changed
  • rust/stackable-cockpit/src/utils/k8s

1 file changed

+8
-5
lines changed

rust/stackable-cockpit/src/utils/k8s/client.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ pub enum Error {
3939
KubeClientPatch { source: kube::error::Error },
4040

4141
#[snafu(display("failed to replace Kubernetes object"))]
42-
KubeClientReplace { source: kube::error::Error },
42+
KubeClientReplace {
43+
source: kube::error::Error,
44+
gvk: GroupVersionKind,
45+
},
4346

4447
#[snafu(display("failed to deserialize YAML data"))]
4548
DeserializeYaml { source: serde_yaml::Error },
@@ -48,7 +51,7 @@ pub enum Error {
4851
GVKDiscoveryRun { source: kube::error::Error },
4952

5053
#[snafu(display("GVK {gvk:?} is not known"))]
51-
GVKUnkown { gvk: GroupVersionKind },
54+
GVKUnknown { gvk: GroupVersionKind },
5255

5356
#[snafu(display("failed to deploy manifest because type of object {object:?} is not set"))]
5457
ObjectType { object: DynamicObject },
@@ -131,7 +134,7 @@ impl Client {
131134
let (resource, capabilities) = self
132135
.resolve_gvk(&gvk)
133136
.await?
134-
.context(GVKUnkownSnafu { gvk })?;
137+
.context(GVKUnknownSnafu { gvk })?;
135138

136139
let api: Api<DynamicObject> = match capabilities.scope {
137140
Scope::Cluster => {
@@ -173,7 +176,7 @@ impl Client {
173176
let (resource, _) = self
174177
.resolve_gvk(&gvk)
175178
.await?
176-
.context(GVKUnkownSnafu { gvk })?;
179+
.context(GVKUnknownSnafu { gvk: gvk.clone() })?;
177180

178181
// CRDs are cluster scoped
179182
let api: Api<DynamicObject> = Api::all_with(self.client.clone(), &resource);
@@ -186,7 +189,7 @@ impl Client {
186189
object.metadata.resource_version = resource.resource_version();
187190
api.replace(&object.name_any(), &PostParams::default(), &object)
188191
.await
189-
.context(KubeClientReplaceSnafu)?;
192+
.context(KubeClientReplaceSnafu { gvk })?;
190193
} else {
191194
// Create CRD if a previous version wasn't found
192195
api.create(&PostParams::default(), &object)

0 commit comments

Comments
 (0)