Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cc0b17ea
Commit
cc0b17ea
authored
Jan 02, 2017
by
Kubernetes Submit Queue
Committed by
GitHub
Jan 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #38574 from k82cn/k8s_38542
Automatic merge from submit-queue Add default imagePullPolicy for initContainers. fixes #38542
parents
3fe288d7
cd6792ae
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
1 deletion
+73
-1
conversion.go
pkg/api/v1/conversion.go
+6
-0
defaults.go
pkg/api/v1/defaults.go
+0
-1
defaults_test.go
pkg/api/v1/defaults_test.go
+67
-0
No files found.
pkg/api/v1/conversion.go
View file @
cc0b17ea
...
@@ -493,6 +493,12 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
...
@@ -493,6 +493,12 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
// taking responsibility to ensure mutation of in is not exposed
// taking responsibility to ensure mutation of in is not exposed
// back to the caller.
// back to the caller.
in
.
Spec
.
InitContainers
=
values
in
.
Spec
.
InitContainers
=
values
// Call defaulters explicitly until annotations are removed
for
i
:=
range
in
.
Spec
.
InitContainers
{
c
:=
&
in
.
Spec
.
InitContainers
[
i
]
SetDefaults_Container
(
c
)
}
}
}
if
err
:=
autoConvert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
in
,
out
,
s
);
err
!=
nil
{
if
err
:=
autoConvert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
in
,
out
,
s
);
err
!=
nil
{
...
...
pkg/api/v1/defaults.go
View file @
cc0b17ea
...
@@ -112,7 +112,6 @@ func SetDefaults_Container(obj *Container) {
...
@@ -112,7 +112,6 @@ func SetDefaults_Container(obj *Container) {
_
,
tag
,
_
,
_
:=
parsers
.
ParseImageName
(
obj
.
Image
)
_
,
tag
,
_
,
_
:=
parsers
.
ParseImageName
(
obj
.
Image
)
// Check image tag
// Check image tag
if
tag
==
"latest"
{
if
tag
==
"latest"
{
obj
.
ImagePullPolicy
=
PullAlways
obj
.
ImagePullPolicy
=
PullAlways
}
else
{
}
else
{
...
...
pkg/api/v1/defaults_test.go
View file @
cc0b17ea
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
v1_test
package
v1_test
import
(
import
(
"encoding/json"
"reflect"
"reflect"
"testing"
"testing"
...
@@ -230,6 +231,72 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
...
@@ -230,6 +231,72 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
}
}
}
}
func
TestSetDefaultReplicationControllerImagePullPolicy
(
t
*
testing
.
T
)
{
containersWithoutPullPolicy
,
_
:=
json
.
Marshal
([]
map
[
string
]
interface
{}{
{
"name"
:
"install"
,
"image"
:
"busybox:latest"
,
},
})
containersWithPullPolicy
,
_
:=
json
.
Marshal
([]
map
[
string
]
interface
{}{
{
"name"
:
"install"
,
"imagePullPolicy"
:
"IfNotPresent"
,
},
})
tests
:=
[]
struct
{
rc
versioned
.
ReplicationController
expectPullPolicy
versioned
.
PullPolicy
}{
{
rc
:
versioned
.
ReplicationController
{
Spec
:
versioned
.
ReplicationControllerSpec
{
Template
:
&
versioned
.
PodTemplateSpec
{
ObjectMeta
:
versioned
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
"pod.beta.kubernetes.io/init-containers"
:
string
(
containersWithoutPullPolicy
),
},
},
},
},
},
expectPullPolicy
:
versioned
.
PullAlways
,
},
{
rc
:
versioned
.
ReplicationController
{
Spec
:
versioned
.
ReplicationControllerSpec
{
Template
:
&
versioned
.
PodTemplateSpec
{
ObjectMeta
:
versioned
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
"pod.beta.kubernetes.io/init-containers"
:
string
(
containersWithPullPolicy
),
},
},
},
},
},
expectPullPolicy
:
versioned
.
PullIfNotPresent
,
},
}
for
_
,
test
:=
range
tests
{
rc
:=
&
test
.
rc
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
rc
))
rc2
,
ok
:=
obj2
.
(
*
versioned
.
ReplicationController
)
if
!
ok
{
t
.
Errorf
(
"unexpected object: %v"
,
rc2
)
t
.
FailNow
()
}
if
test
.
expectPullPolicy
!=
rc2
.
Spec
.
Template
.
Spec
.
InitContainers
[
0
]
.
ImagePullPolicy
{
t
.
Errorf
(
"expected ImagePullPolicy: %s, got: %s"
,
test
.
expectPullPolicy
,
rc2
.
Spec
.
Template
.
Spec
.
InitContainers
[
0
]
.
ImagePullPolicy
,
)
}
}
}
func
TestSetDefaultService
(
t
*
testing
.
T
)
{
func
TestSetDefaultService
(
t
*
testing
.
T
)
{
svc
:=
&
versioned
.
Service
{}
svc
:=
&
versioned
.
Service
{}
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
svc
))
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
svc
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment