Skip to content

Commit

Permalink
Ops 16623 rollback pipeline (#227)
Browse files Browse the repository at this point in the history
* OPS-16623 add pipeline build number option

* Update ef_config.py

* fixed ef-version output

* fix for test pass
  • Loading branch information
dsielert committed Jun 10, 2021
1 parent fa9fc03 commit 54b53cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions efopen/ef_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class EFConfig(object):
S3_VERSION_CONTENT_ENCODING = "utf-8"
# Metdata key on a version object to indicate who modified it
S3_VERSION_BUILDNUMBER_KEY = "ef-buildnumber"
# Metdata key on a version object to indicate what the pipeline build number was for subservice relation
S3_VERSION_PIPELINEBUILDNUMBER_KEY = "ef-pipeline-buildnumber"
# Metdata key on a version object to indicate who modified it
S3_VERSION_COMMITHASH_KEY = "ef-commithash"
# Metdata key on a version object to indicate who modified it
Expand Down
25 changes: 24 additions & 1 deletion efopen/ef_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self):
super(EFVersionContext, self).__init__()
# core stuff
self._build_number = None
self._pipeline_build_number = None
self._commit_hash = None
self._force_env_full = None
self._get = None
Expand All @@ -73,6 +74,17 @@ def build_number(self, value):
"""Setter provided because this is writeable from other than init() because --rollback alters it"""
self._build_number = value

@property
def pipeline_build_number(self):
"""Externally defined PIPELINE build number associated with version entity"""
return self._pipeline_build_number

@pipeline_build_number.setter
def pipeline_build_number(self, value):
"""Setter provided because this is writeable from other than init() because --rollback alters it"""
self._pipeline_build_number = value


@property
def commit_hash(self):
"""Commit hash associated with version entity"""
Expand Down Expand Up @@ -183,13 +195,14 @@ def __init__(self, object_version):

metadata = object_version["Metadata"]
self._build_number = metadata.get(EFConfig.S3_VERSION_BUILDNUMBER_KEY,"")
self._pipeline_build_number = metadata.get(EFConfig.S3_VERSION_PIPELINEBUILDNUMBER_KEY,"")
self._commit_hash = metadata.get(EFConfig.S3_VERSION_COMMITHASH_KEY,"")
self._location = metadata.get(EFConfig.S3_VERSION_LOCATION_KEY,"")
self._modified_by = metadata.get(EFConfig.S3_VERSION_MODIFIEDBY_KEY,"")
self._status = metadata.get(EFConfig.S3_VERSION_STATUS_KEY,"")

def __str__(self):
return "{} {} {} {} {} {} {} {}".format(self._value, self._build_number, self._commit_hash, self._last_modified,
return "{} {} {} {} {} {} {} {} {}".format(self._value, self._build_number, self._pipeline_build_number, self._commit_hash, self._last_modified,
self._modified_by, self._version_id, self._location, self._status)

def __repr__(self):
Expand All @@ -202,6 +215,7 @@ def to_json(self):
"""
return {
"build_number": self._build_number,
"pipeline_build_number": self._pipeline_build_number,
"commit_hash": self._commit_hash,
"last_modified": self._last_modified,
"location": self._location,
Expand All @@ -215,6 +229,10 @@ def to_json(self):
def build_number(self):
return self._build_number

@property
def pipeline_build_number(self):
return self._pipeline_build_number

@property
def commit_hash(self):
return self._commit_hash
Expand Down Expand Up @@ -277,6 +295,9 @@ def handle_args_and_set_context(args):
parser.add_argument("--build",
help="On --set, also set the externally defined build number associated with the version entity",
default="")
parser.add_argument("--pipeline_build",
help="On --set, also set the externally defined PIPELINE build number associated with the version entity",
default="")
parser.add_argument("--commit_hash", help="On --set, also set the commit hash associated with the version entity",
default="")
parser.add_argument("--commit", help="Actually --set or --rollback (dry run if omitted)",
Expand All @@ -298,6 +319,7 @@ def handle_args_and_set_context(args):
context = EFVersionContext()
# marshall the inherited context values
context._build_number = parsed_args["build"]
context._pipeline_build_number = parsed_args["pipeline_build"]
context._commit_hash = parsed_args["commit_hash"]
context.commit = parsed_args["commit"]
context.devel = parsed_args["devel"]
Expand Down Expand Up @@ -580,6 +602,7 @@ def cmd_set(context):
Key=s3_key,
Metadata={
EFConfig.S3_VERSION_BUILDNUMBER_KEY: context.build_number,
EFConfig.S3_VERSION_PIPELINEBUILDNUMBER_KEY: context.pipeline_build_number,
EFConfig.S3_VERSION_COMMITHASH_KEY: context.commit_hash,
EFConfig.S3_VERSION_LOCATION_KEY: context.location,
EFConfig.S3_VERSION_MODIFIEDBY_KEY: context.aws_client("sts").get_caller_identity()["Arn"],
Expand Down

0 comments on commit 54b53cd

Please sign in to comment.