Can not create resources because of "Resource `metadata.name` must be set" error
Closed this issue · 1 comments
spprichard commented
import Logging
import SwiftkubeClient
import SwiftkubeModel
let logger = Logger(label: "com.example.Swiftkube.main")
guard let client = KubernetesClient(logger: logger) else { fatalError("Could not create client") }
let nginx = core.v1.Pod(
metadata: meta.v1.ObjectMeta(
labels: [
"app" : "swiftkube-demo"],
name: "swiftkube-demo",
namespace: "default"
),
spec: core.v1.PodSpec(
containers: [
core.v1.Container(
image: "nginx",
name: "nginx",
volumeMounts: [
core.v1.VolumeMount(
mountPath: "/usr/share/nginx/html",
name: "shared-data"
),
]
)
]
)
)
let result = try client.pods.create(nginx).wait()
print(result.status)
I get the following error when I run this code
Fatal error: Error raised at top level: SwiftkubeClient.SwiftkubeClientError.badRequest("Resource `metadata.name` must be set."): file
I'm not sure if I am doing something wrong here, from what I can tell this should work. Let me know if I missed something.
iabudiab commented
@spprichard Hey, you're not doing anything wrong, it's just that I broke something in the new version 😿
The fix is coming now, you can use the branch in the dependency