Skip to content

Commit 5b53c82

Browse files
authored
Merge pull request #973 from NBardelot/feature/add_tar_and_gzip
Add tar and gzip to the git-sync image
2 parents a4b7659 + 4d800b8 commit 5b53c82

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

Dockerfile.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ COPY stage_binaries.sh /
5656
RUN /stage_binaries.sh -o {ARG_STAGING} \
5757
-p base-files \
5858
-p bash \
59+
-p ca-certificates \
5960
-p coreutils \
61+
-p curl \
6062
-p git \
63+
-p gzip \
6164
-p openssh-client \
62-
-p ca-certificates \
63-
-p curl \
6465
-p socat \
66+
-p tar \
6567
-b /bin/grep \
6668
-b /bin/sed \
6769
-f /etc/debian_version \
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# Copyright 2020 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Use for e2e test of --exechook-command.
18+
# This option takes no command arguments, so requires a wrapper script.
19+
20+
git archive --format tar.gz --output archive.tgz HEAD

test_e2e.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ function assert_file_lines_ge() {
122122
fi
123123
}
124124

125+
function assert_tgz_archive() {
126+
if ! tar tzf "$1"; then
127+
fail "failed to list tgz archive content in $1"
128+
fi
129+
}
130+
125131
function assert_metric_eq() {
126132
local val
127133
val="$(curl --silent "http://localhost:$HTTP_PORT/metrics" \
@@ -317,6 +323,7 @@ EXECHOOK_COMMAND="$TEST_TOOLS/exechook_command.sh"
317323
EXECHOOK_COMMAND_FAIL="$TEST_TOOLS/exechook_command_fail.sh"
318324
EXECHOOK_COMMAND_SLEEPY="$TEST_TOOLS/exechook_command_with_sleep.sh"
319325
EXECHOOK_COMMAND_FAIL_SLEEPY="$TEST_TOOLS/exechook_command_fail_with_sleep.sh"
326+
EXECHOOK_COMMAND_GIT_ARCHIVE="$TEST_TOOLS/exechook_command_git_archive.sh"
320327
EXECHOOK_ENVKEY=ENVKEY
321328
EXECHOOK_ENVVAL=envval
322329
RUNLOG="$DIR/runlog"
@@ -3604,6 +3611,20 @@ function e2e::gc_off() {
36043611
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]}"
36053612
}
36063613

3614+
##############################################
3615+
# Test git-archive using tar and gzip
3616+
##############################################
3617+
function e2e::exechook_git_archive() {
3618+
GIT_SYNC \
3619+
--one-time \
3620+
--repo="file://$REPO" \
3621+
--root="$ROOT" \
3622+
--link="link" \
3623+
--exechook-command="/$EXECHOOK_COMMAND_GIT_ARCHIVE"
3624+
assert_file_exists "$ROOT/link/archive.tgz"
3625+
assert_tgz_archive "$ROOT/link/archive.tgz"
3626+
}
3627+
36073628
#
36083629
# main
36093630
#

0 commit comments

Comments
 (0)