Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
797f99c6
Commit
797f99c6
authored
Nov 21, 2017
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-oci: add support for registry authentication
Signed-off-by:
Felix Abecassis
<
fabecassis@nvidia.com
>
parent
d7c685c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
lxc-oci.in
templates/lxc-oci.in
+25
-3
No files found.
templates/lxc-oci.in
View file @
797f99c6
...
@@ -132,6 +132,10 @@ Special arguments:
...
@@ -132,6 +132,10 @@ Special arguments:
Required arguments:
Required arguments:
[ -u | --url <url> ]: The OCI image URL
[ -u | --url <url> ]: The OCI image URL
Optional arguments:
[ --username <username> ]: The username for the registry
[ --password <password> ]: The password for the registry
LXC internal arguments (do not pass manually!):
LXC internal arguments (do not pass manually!):
[ --name <name> ]: The container name
[ --name <name> ]: The container name
[ --path <path> ]: The path to the container
[ --path <path> ]: The path to the container
...
@@ -143,8 +147,8 @@ EOF
...
@@ -143,8 +147,8 @@ EOF
return
0
return
0
}
}
options
=
$(
getopt
-o
u:h
-l
help
,url:,
name:,path
:,
\
options
=
$(
getopt
-o
u:h
-l
help
,url:,
username:,password
:,
\
rootfs:,mapped-uid:,mapped-gid:
--
"
$@
"
)
name:,path:,
rootfs:,mapped-uid:,mapped-gid:
--
"
$@
"
)
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
usage
usage
...
@@ -153,6 +157,9 @@ fi
...
@@ -153,6 +157,9 @@ fi
eval set
--
"
$options
"
eval set
--
"
$options
"
OCI_URL
=
""
OCI_URL
=
""
OCI_USERNAME
=
OCI_PASSWORD
=
LXC_MAPPED_GID
=
LXC_MAPPED_GID
=
LXC_MAPPED_UID
=
LXC_MAPPED_UID
=
LXC_NAME
=
LXC_NAME
=
...
@@ -163,6 +170,8 @@ while :; do
...
@@ -163,6 +170,8 @@ while :; do
case
"
$1
"
in
case
"
$1
"
in
-h
|
--help
)
usage
&&
exit
1
;;
-h
|
--help
)
usage
&&
exit
1
;;
-u
|
--url
)
OCI_URL
=
$2
;
shift
2
;;
-u
|
--url
)
OCI_URL
=
$2
;
shift
2
;;
--username
)
OCI_USERNAME
=
$2
;
shift
2
;;
--password
)
OCI_PASSWORD
=
$2
;
shift
2
;;
--name
)
LXC_NAME
=
$2
;
shift
2
;;
--name
)
LXC_NAME
=
$2
;
shift
2
;;
--path
)
LXC_PATH
=
$2
;
shift
2
;;
--path
)
LXC_PATH
=
$2
;
shift
2
;;
--rootfs
)
LXC_ROOTFS
=
$2
;
shift
2
;;
--rootfs
)
LXC_ROOTFS
=
$2
;
shift
2
;;
...
@@ -183,6 +192,11 @@ if [ -z "$OCI_URL" ]; then
...
@@ -183,6 +192,11 @@ if [ -z "$OCI_URL" ]; then
exit
1
exit
1
fi
fi
if
[
-n
"
$OCI_PASSWORD
"
]
&&
[
-z
"
$OCI_USERNAME
"
]
;
then
echo
"ERROR: password given but no username specified"
exit
1
fi
USERNS
=
$(
in_userns
)
USERNS
=
$(
in_userns
)
if
[
"
$USERNS
"
!=
"no"
]
;
then
if
[
"
$USERNS
"
!=
"no"
]
;
then
...
@@ -210,7 +224,15 @@ else
...
@@ -210,7 +224,15 @@ else
fi
fi
# Download the image - TODO - cache
# Download the image - TODO - cache
skopeo copy
"
${
OCI_URL
}
"
"oci:
${
DOWNLOAD_TEMP
}
:latest"
skopeo_args
=(
""
)
if
[
-n
"
$OCI_USERNAME
"
]
;
then
CREDENTIALS
=
"
${
OCI_USERNAME
}
"
if
[
-n
"
$OCI_PASSWORD
"
]
;
then
CREDENTIALS
=
"
${
CREDENTIALS
}
:
${
OCI_PASSWORD
}
"
fi
skopeo_args+
=(
--src-creds
"
${
CREDENTIALS
}
"
)
fi
skopeo copy
${
skopeo_args
[@]
}
"
${
OCI_URL
}
"
"oci:
${
DOWNLOAD_TEMP
}
:latest"
# Unpack the rootfs
# Unpack the rootfs
echo
"Unpacking the rootfs"
echo
"Unpacking the rootfs"
...
...
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