Skip to content

Commit

Permalink
Snapshot name bug #59 (#70)
Browse files Browse the repository at this point in the history
Restrict custom prefix to 20 characters
  • Loading branch information
jacksegal authored Nov 14, 2018
1 parent 1b383bc commit e54e5d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Options:
access to [OPTIONAL].
-f gcloud filter expression to query disk selection [OPTIONAL]
-p Prefix to be used for naming snapshots.
Max character length: 20
Default if not set: 'gcs' [OPTIONAL]
-a Service Account to use.
Blank if not set [OPTIONAL]
Expand Down Expand Up @@ -130,13 +131,14 @@ By default snapshots are created with a prefix of `gcs`. To give a custom prefix
Options:

-p Prefix to be used for naming snapshots.
Max character length: 20
Default if not set: 'gcs' [OPTIONAL]

For example:

./gcloud-snapshot.sh -p "my-snap"

(Note: Snapshot names are limited to 62 characters)
(Note: Snapshot prefixes are limited to 20 characters)

### Service Account
By default snapshots are created with the default gcloud service account. To use a custom service account use the -a flag:
Expand Down
8 changes: 7 additions & 1 deletion gcloud-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ usage() {
echo -e " access to [OPTIONAL]."
echo -e " -f gcloud filter expression to query disk selection [OPTIONAL]"
echo -e " -p Prefix to be used for naming snapshots."
echo -e " Max character length: 20"
echo -e " Default if not set: 'gcs' [OPTIONAL]"
echo -e " -a Service Account to use."
echo -e " Blank if not set [OPTIONAL]"
Expand Down Expand Up @@ -92,7 +93,12 @@ setScriptOptions()

# Snapshot Prefix
if [[ -n $opt_p ]]; then
PREFIX=$opt_p
# check if prefix is more than 20 chars
if [ ${#opt_p} -ge 20 ]; then
PREFIX=${opt_p:0:20}
else
PREFIX=$opt_p
fi
else
PREFIX="gcs"
fi
Expand Down

0 comments on commit e54e5d5

Please sign in to comment.