Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add S3 metadata in meta.json #2731

Merged
merged 3 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions schema/cosa/cosa_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Build struct {
PkgdiffBetweenBuilds PackageSetDifferences `json:"pkgdiff,omitempty"`
PowerVirtualServer []Cloudartifact `json:"powervs,omitempty"`
ReleasePayload *Image `json:"release-payload,omitempty"`
S3 *S3 `json:"s3,omitempty"`
}

type BuildArtifacts struct {
Expand Down Expand Up @@ -147,3 +148,9 @@ type Koji struct {
type PackageSetDifferences []PackageSetDifferencesItems

type PackageSetDifferencesItems interface{}

type S3 struct {
Bucket string `json:"bucket,omitempty"`
Key string `json:"key,omitempty"`
PublicURL string `json:"public-url,omitempty"`
}
21 changes: 21 additions & 0 deletions schema/cosa/schema_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ var generatedSchemaJSON = `{
"parent-advisories-diff",
"advisories-diff",
"release-payload",
"s3",

"coreos-assembler.basearch",
"coreos-assembler.build-timestamp",
Expand Down Expand Up @@ -266,6 +267,26 @@ var generatedSchemaJSON = `{
"default":"",
"minLength": 1
},
"s3": {
"type": "object",
"properties": {
"bucket": {
"$id":"#/properties/bucket",
"type":"string",
"title":"Bucket"
},
"key": {
"$id": "#/properties/key",
"type":"string",
"title":"Key"
},
"public-url": {
"$id":"#/properties/public-url",
"type":"string",
"title":"Public URL"
}
}
},
"koji": {
"type": "object",
"properties": {
Expand Down
11 changes: 3 additions & 8 deletions schema/generate-schema.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#!/bin/bash -xe
mydir=$(readlink -f $(dirname $(basename $0)))
mydir=$(dirname $(readlink -f $0))
tdir="${mydir}/tmp"
mkdir -p "${tdir}"
trap "rm -rfv ${tdir}" EXIT

export GOBIN="$(readlink -f ../tools/bin)"
if [ ! -x "${GOBIN}/schematyper" ]; then
make -C ../tools
fi

schema_version="v1"
schema_json="../schema/${schema_version}.json"
schema_json="${schema_version}.json"
echo "Generating COSA Schema ${schema_version}"

out="${tdir}/cosa_${schema_version}.go"

"${GOBIN}/schematyper" \
"schematyper" \
"${schema_version}.json" \
-o "${out}" \
--package="cosa" \
Expand Down
21 changes: 21 additions & 0 deletions schema/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"parent-advisories-diff",
"advisories-diff",
"release-payload",
"s3",

"coreos-assembler.basearch",
"coreos-assembler.build-timestamp",
Expand Down Expand Up @@ -261,6 +262,26 @@
"default":"",
"minLength": 1
},
"s3": {
"type": "object",
"properties": {
"bucket": {
"$id":"#/properties/bucket",
"type":"string",
"title":"Bucket"
},
"key": {
"$id": "#/properties/key",
"type":"string",
"title":"Key"
},
"public-url": {
"$id":"#/properties/public-url",
"type":"string",
"title":"Public URL"
}
}
},
"koji": {
"type": "object",
"properties": {
Expand Down
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the parameter name to public-url too? I was thinking in let it as url. And only use the public-url structure .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to be consistent, but personally fine with it. I'm not really concerned about cosa koji-upload becoming some API that people outside the CoreOS team starts using.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer it to be consistent, but won't block merging on it for the same reasons Jonathan says. :)

help='Store url information in meta.json')

ravanelli marked this conversation as resolved.
Show resolved Hide resolved
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
21 changes: 21 additions & 0 deletions src/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"parent-advisories-diff",
"advisories-diff",
"release-payload",
"s3",

"coreos-assembler.basearch",
"coreos-assembler.build-timestamp",
Expand Down Expand Up @@ -261,6 +262,26 @@
"default":"",
"minLength": 1
},
"s3": {
"type": "object",
"properties": {
"bucket": {
"$id":"#/properties/bucket",
"type":"string",
"title":"Bucket"
},
"key": {
"$id": "#/properties/key",
"type":"string",
"title":"Key"
},
"public-url": {
"$id":"#/properties/public-url",
"type":"string",
"title":"Public URL"
}
}
},
"koji": {
"type": "object",
"properties": {
Expand Down