Skip to content

Commit 72b7a50

Browse files
committed
chore: updates after code review
1 parent 63978de commit 72b7a50

File tree

4 files changed

+78
-79
lines changed

4 files changed

+78
-79
lines changed

docs/content/en/schemas/v1beta7.json

+1-55
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,6 @@
616616
"x-intellij-html-description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
617617
"default": "kaniko-secret"
618618
},
619-
"resources": {
620-
"$ref": "#/definitions/ResourceRequirements",
621-
"description": "define the resource requirements for the kaniko pod.",
622-
"x-intellij-html-description": "define the resource requirements for the kaniko pod."
623-
},
624619
"timeout": {
625620
"type": "string",
626621
"description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (`20m`).",
@@ -632,8 +627,7 @@
632627
"pullSecretName",
633628
"namespace",
634629
"timeout",
635-
"dockerConfig",
636-
"resources"
630+
"dockerConfig"
637631
],
638632
"additionalProperties": false,
639633
"description": "*beta* describes how to do an on-cluster build.",
@@ -1597,54 +1591,6 @@
15971591
"description": "*beta* profiles are used to override any `build`, `test` or `deploy` configuration.",
15981592
"x-intellij-html-description": "<em>beta</em> profiles are used to override any <code>build</code>, <code>test</code> or <code>deploy</code> configuration."
15991593
},
1600-
"ResourceRequirement": {
1601-
"properties": {
1602-
"cpu": {
1603-
"type": "string",
1604-
"description": "the number cores to be used.",
1605-
"x-intellij-html-description": "the number cores to be used.",
1606-
"examples": [
1607-
"2`, `2.0` or `200m"
1608-
]
1609-
},
1610-
"memory": {
1611-
"type": "string",
1612-
"description": "the amount of memory to allocate to the pod.",
1613-
"x-intellij-html-description": "the amount of memory to allocate to the pod.",
1614-
"examples": [
1615-
"1Gi` or `1000Mi"
1616-
]
1617-
}
1618-
},
1619-
"preferredOrder": [
1620-
"cpu",
1621-
"memory"
1622-
],
1623-
"additionalProperties": false,
1624-
"description": "stores the CPU/Memory requirements for the pod.",
1625-
"x-intellij-html-description": "stores the CPU/Memory requirements for the pod."
1626-
},
1627-
"ResourceRequirements": {
1628-
"properties": {
1629-
"limits": {
1630-
"$ref": "#/definitions/ResourceRequirement",
1631-
"description": "resource limits for the Kaniko pod. [More on limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container).",
1632-
"x-intellij-html-description": "resource limits for the Kaniko pod. <a href=\"https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container\">More on limits</a>."
1633-
},
1634-
"requests": {
1635-
"$ref": "#/definitions/ResourceRequirement",
1636-
"description": "resource requests for the Kaniko pod. [More on requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container).",
1637-
"x-intellij-html-description": "resource requests for the Kaniko pod. <a href=\"https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container\">More on requests</a>."
1638-
}
1639-
},
1640-
"preferredOrder": [
1641-
"requests",
1642-
"limits"
1643-
],
1644-
"additionalProperties": false,
1645-
"description": "describes the resource requirements for the kaniko pod.",
1646-
"x-intellij-html-description": "describes the resource requirements for the kaniko pod."
1647-
},
16481594
"ShaTagger": {
16491595
"description": "*beta* tags images with their sha256 digest.",
16501596
"x-intellij-html-description": "<em>beta</em> tags images with their sha256 digest."

docs/content/en/schemas/v1beta8.json

+55-1
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,11 @@
616616
"x-intellij-html-description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
617617
"default": "kaniko-secret"
618618
},
619+
"resources": {
620+
"$ref": "#/definitions/ResourceRequirements",
621+
"description": "define the resource requirements for the kaniko pod.",
622+
"x-intellij-html-description": "define the resource requirements for the kaniko pod."
623+
},
619624
"timeout": {
620625
"type": "string",
621626
"description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (`20m`).",
@@ -627,7 +632,8 @@
627632
"pullSecretName",
628633
"namespace",
629634
"timeout",
630-
"dockerConfig"
635+
"dockerConfig",
636+
"resources"
631637
],
632638
"additionalProperties": false,
633639
"description": "*beta* describes how to do an on-cluster build.",
@@ -1591,6 +1597,54 @@
15911597
"description": "*beta* profiles are used to override any `build`, `test` or `deploy` configuration.",
15921598
"x-intellij-html-description": "<em>beta</em> profiles are used to override any <code>build</code>, <code>test</code> or <code>deploy</code> configuration."
15931599
},
1600+
"ResourceRequirement": {
1601+
"properties": {
1602+
"cpu": {
1603+
"type": "string",
1604+
"description": "the number cores to be used.",
1605+
"x-intellij-html-description": "the number cores to be used.",
1606+
"examples": [
1607+
"2`, `2.0` or `200m"
1608+
]
1609+
},
1610+
"memory": {
1611+
"type": "string",
1612+
"description": "the amount of memory to allocate to the pod.",
1613+
"x-intellij-html-description": "the amount of memory to allocate to the pod.",
1614+
"examples": [
1615+
"1Gi` or `1000Mi"
1616+
]
1617+
}
1618+
},
1619+
"preferredOrder": [
1620+
"cpu",
1621+
"memory"
1622+
],
1623+
"additionalProperties": false,
1624+
"description": "stores the CPU/Memory requirements for the pod.",
1625+
"x-intellij-html-description": "stores the CPU/Memory requirements for the pod."
1626+
},
1627+
"ResourceRequirements": {
1628+
"properties": {
1629+
"limits": {
1630+
"$ref": "#/definitions/ResourceRequirement",
1631+
"description": "[resource limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod.",
1632+
"x-intellij-html-description": "<a href=\"https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container\">resource limits</a> for the Kaniko pod."
1633+
},
1634+
"requests": {
1635+
"$ref": "#/definitions/ResourceRequirement",
1636+
"description": "[resource requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod.",
1637+
"x-intellij-html-description": "<a href=\"https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container\">resource requests</a> for the Kaniko pod."
1638+
}
1639+
},
1640+
"preferredOrder": [
1641+
"requests",
1642+
"limits"
1643+
],
1644+
"additionalProperties": false,
1645+
"description": "describes the resource requirements for the kaniko pod.",
1646+
"x-intellij-html-description": "describes the resource requirements for the kaniko pod."
1647+
},
15941648
"ShaTagger": {
15951649
"description": "*beta* tags images with their sha256 digest.",
15961650
"x-intellij-html-description": "<em>beta</em> tags images with their sha256 digest."

pkg/skaffold/build/kaniko/sources/sources_test.go

+20-21
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ import (
3030

3131
func TestPodTemplate(t *testing.T) {
3232
tests := []struct {
33-
name string
34-
initial *latest.ClusterDetails
35-
image string
36-
args []string
37-
expected *v1.Pod
33+
description string
34+
initial *latest.ClusterDetails
35+
image string
36+
args []string
37+
expected *v1.Pod
3838
}{
3939
{
40-
name: "basic pod",
41-
initial: &latest.ClusterDetails{},
40+
description: "basic pod",
41+
initial: &latest.ClusterDetails{},
4242
expected: &v1.Pod{
4343
ObjectMeta: metav1.ObjectMeta{
4444
GenerateName: "kaniko-",
@@ -77,7 +77,7 @@ func TestPodTemplate(t *testing.T) {
7777
},
7878
},
7979
{
80-
name: "with docker config",
80+
description: "with docker config",
8181
initial: &latest.ClusterDetails{
8282
DockerConfig: &latest.DockerConfig{
8383
SecretName: "docker-cfg",
@@ -133,7 +133,7 @@ func TestPodTemplate(t *testing.T) {
133133
},
134134
},
135135
{
136-
name: "with resource constraints",
136+
description: "with resource constraints",
137137
initial: &latest.ClusterDetails{
138138
Resources: &latest.ResourceRequirements{
139139
Requests: &latest.ResourceRequirement{
@@ -195,23 +195,22 @@ func TestPodTemplate(t *testing.T) {
195195
})
196196

197197
for _, test := range tests {
198-
t.Run(test.name, func(t *testing.T) {
198+
t.Run(test.description, func(t *testing.T) {
199199
actual := podTemplate(test.initial, test.image, test.args)
200200
testutil.CheckDeepEqual(t, test.expected, actual, opt)
201201
})
202202
}
203203
}
204204

205205
func createResourceRequirements(cpuLimit resource.Quantity, memoryLimit resource.Quantity, cpuRequest resource.Quantity, memoryRequest resource.Quantity) v1.ResourceRequirements {
206-
req := v1.ResourceRequirements{}
207-
req.Limits = v1.ResourceList{}
208-
req.Limits[v1.ResourceCPU] = cpuLimit
209-
req.Limits[v1.ResourceMemory] = memoryLimit
210-
211-
req.Requests = v1.ResourceList{}
212-
req.Requests[v1.ResourceCPU] = cpuRequest
213-
req.Requests[v1.ResourceMemory] = memoryRequest
214-
215-
return req
216-
206+
return v1.ResourceRequirements{
207+
Limits: v1.ResourceList{
208+
v1.ResourceCPU: cpuLimit,
209+
v1.ResourceMemory: memoryLimit,
210+
},
211+
Requests: v1.ResourceList{
212+
v1.ResourceCPU: cpuRequest,
213+
v1.ResourceMemory: memoryRequest,
214+
},
215+
}
217216
}

pkg/skaffold/schema/latest/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ type DockerConfig struct {
270270

271271
// ResourceRequirements describes the resource requirements for the kaniko pod.
272272
type ResourceRequirements struct {
273-
// Requests resource requests for the Kaniko pod. [More on requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container).
273+
// Requests [resource requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod.
274274
Requests *ResourceRequirement `yaml:"requests,omitempty"`
275275

276-
// Limits resource limits for the Kaniko pod. [More on limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container).
276+
// Limits [resource limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod.
277277
Limits *ResourceRequirement `yaml:"limits,omitempty"`
278278
}
279279

0 commit comments

Comments
 (0)