Skip to content

Commit

Permalink
Change cmd-koji-upload to add S3 information in meta.json
Browse files Browse the repository at this point in the history
 - This change is needed due brew/compliance improvements where we need
to keep more information about where the artifacts are archived;
 - Add s3 parameters in order to update meta.json with
bucket, prefix and url information used in S3 upload.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
  • Loading branch information
ravanelli committed Mar 30, 2022
1 parent f92418f commit 5484c2d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/cmd-koji-upload
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ class Upload(_KojiBase):
self._reserve_id_file = None
self._retry_attempts = 2
self._uploaded = False
self._s3 = None
self._s3_bucket = None
self._s3_key = None
self._s3_url = None

if self._tag is None:
raise Exception("build tag must be set")
Expand Down Expand Up @@ -591,6 +595,14 @@ class Upload(_KojiBase):
except:
pass

if self._s3 is not None:
self.build.meta['s3'] = {
'bucket': self._s3_bucket,
'key': self._s3_key,
'public-url': self._s3_url
}
self.build.meta_write()

source = self.build.get_meta_key(
"meta", self.build.ckey("container-config-git"))

Expand Down Expand Up @@ -841,6 +853,18 @@ Environment variables are supported:
'--reserve-id-state-file', required=False,
help='Uses the path for a reservation file previous created')

upload_cmd.add_argument(
'--s3-bucket', required=False,
help='Store bucket information in meta.json')

upload_cmd.add_argument(
'--s3-key', required=False,
help='Store key information in meta.json')

upload_cmd.add_argument(
'--s3-url', required=False,
help='Store url information in meta.json')

args, extra_args = parser.parse_known_args()
set_logger(args.log_level)

Expand Down Expand Up @@ -873,6 +897,12 @@ Environment variables are supported:
Reserve(args.profile).reserve_id(build)
if args.reserve_id_state_file:
upload._reserve_id_file = args.reserve_id_state_file
if args.s3_bucket or args.s3_key or args.s3_url:
upload._s3 = True
upload._s3_bucket = args.s3_bucket
upload._s3_key = args.s3_key
upload._s3_url = args.s3_url

build.build_artifacts()
upload.upload()
elif args._command == 'reserve-id':
Expand Down

0 comments on commit 5484c2d

Please sign in to comment.