-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
269 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenConext\MonitorBundle\Value; | ||
|
||
/** | ||
* Representation of the env vars that describe the build details | ||
* | ||
* By default, the following env vars are evaluated: | ||
* | ||
* OPENCONEXT_APP_VERSION maps to $version | ||
* OPENCONEXT_GIT_SHA maps to $revision | ||
* OPENCONEXT_COMMIT_DATE maps to $commitDate | ||
* | ||
* This VO is created by its factory who actually reads the env-vars | ||
*/ | ||
class BuildEnvVars implements BuildInformation | ||
{ | ||
public function __construct( | ||
private readonly string $version, | ||
private readonly string $revision, | ||
private readonly string $commitDate, | ||
) { | ||
} | ||
|
||
public function getVersion(): string | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function getRevision(): string | ||
{ | ||
return $this->revision; | ||
} | ||
|
||
public function getCommitDate(): string | ||
{ | ||
return $this->commitDate; | ||
} | ||
|
||
public function hasRevision(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function getPath(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function hasVersion(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function hasPath(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function hasCommitDate(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function jsonSerialize(): mixed | ||
{ | ||
return [ | ||
'version' => $this->version, | ||
'revision' => $this->revision, | ||
'commitDate' => $this->commitDate, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenConext\MonitorBundle\Value; | ||
|
||
/** | ||
* Build instance of BuildEnvVars | ||
*/ | ||
class BuildEnvVarsFactory | ||
{ | ||
public static function buildFrom(string $version, string $revision, string $commitDate): BuildEnvVars | ||
{ | ||
return new BuildEnvVars( | ||
$version, | ||
$revision, | ||
$commitDate | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenConext\MonitorBundle\Value; | ||
|
||
use JsonSerializable; | ||
|
||
interface BuildInformation extends JsonSerializable | ||
{ | ||
public function getVersion(): string; | ||
|
||
public function jsonSerialize(): mixed; | ||
|
||
public function getRevision(): string; | ||
|
||
public function hasRevision(): bool; | ||
|
||
public function getPath(): string; | ||
|
||
public function getCommitDate(): string; | ||
|
||
public function hasVersion(): bool; | ||
|
||
public function hasPath(): bool; | ||
|
||
public function hasCommitDate(): bool; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenConext\MonitorBundle\Value; | ||
|
||
use function is_string; | ||
|
||
class BuildInformationFactory | ||
{ | ||
public static function build( | ||
?string $version, | ||
?string $revision, | ||
?string $commitDate, | ||
string $buildPath, | ||
): BuildInformation | ||
{ | ||
if (is_string($revision) && is_string($version) && is_string($commitDate)) { | ||
return BuildEnvVarsFactory::buildFrom($version, $revision, $commitDate); | ||
} | ||
return BuildPathFactory::buildFrom($buildPath); | ||
} | ||
} |
Oops, something went wrong.