Skip to content

Commit

Permalink
Don't warn on new-style access tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jtackaberry committed Jun 13, 2023
1 parent 5f4b6b0 commit f85d925
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions do-snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
do-snapshot.py - snapshot droplets on DigitalOcean
"""
__version__ = '1.1.0'
__version__ = '1.1.1'

import sys
import os
Expand Down Expand Up @@ -209,8 +209,11 @@ def main():

if not args.token:
return log.fatal('must pass API token via --token or DO_TOKEN environment variable')
elif len(args.token) not in (32, 64) or not all(c in string.hexdigits for c in args.token):
log.warning('token looks invalid (unexpected size or non-hex characters)')
elif not args.token.startswith('dop_'):
if len(args.token) in (32, 64) and all(c in string.hexdigits for c in args.token):
log.warning('using legacy token -- recommend regenerating a personal access token')
else:
log.warning('token looks invalid')

args.prefix = args.prefix.replace('$tag', args.tag).strip()
min_age = parse_interval(args.snapshot)
Expand Down

0 comments on commit f85d925

Please sign in to comment.