universityofadelaide / openshift-client
简单的 PHP OpenShift 客户端。
0.1.2
2019-05-09 01:30 UTC
Requires
- guzzlehttp/guzzle: ^6.2.1
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2024-09-12 17:15:38 UTC
README
提供简单的独立客户端和包装器,用于处理由 universityofadelaide/openshift-restclient-php 生成的较为冗长的 Swagger 代码生成器。
入门
使用 composer 需求客户端
composer require universityofadelaide/openshift-client dev-master
用法
通过提供 OpenShift API URL 和认证令牌创建 Client
类的实例
use UniversityOfAdelaide\OpenShift\Client; ... $client = new Client('https://192.168.64.2:8443/api/v1/', 'big_secret_token_hash', 'project');
如何测试
在项目的根目录中创建一个 test.php
或类似的文件。
将以下内容添加到该文件中
require_once __DIR__ . './../../autoload.php'; use UniversityOfAdelaide\OpenShift\Client; $host = 'https://pathToOpenshift.host'; $token = 'yourOpenShiftToken'; $namespace = 'project'; // Get the arguments required $client = new Client($host, $token, $namespace, TRUE); // Attempt to create a secret. $response = $client->createSecret('superSecret', ['username' => 'pied_piper', 'pass', 'middleout']);
如何使用 phpunit 和 minishift 进行测试
确保您有 oc 命令可用。
令牌每 24 小时过期一次,如果令牌已过期,您需要再次登录。
oc login -u developer -p developer
# Assumes myproject (default) is available. # From the /vendor/universityofadelaide/openshift-client directory ../../bin/phpunit tests/ClientTest.php $(minishift console --url) $(oc whoami -t) myproject client_test.json
实际部署
在 OpenShift 中手动创建一个 mysql 容器,记下数据库名称、用户名和密码,并将这些信息放入 client_test.json 的 envVars 部分。
测试清理脚本
删除测试期间创建的所有对象
# Assuming all the names for items created contain 'pied' name=pied; for type in dc bc is svc pvc route pods job cronjob secrets; do for item in $(oc get "${type}" | grep ${name} | awk '{ print $1 }'); do oc delete ${type} ${item}; done; done
待办事项
- 完成接口的实现。
- 提高测试覆盖率,测试响应的 JSON 对象,而不仅仅是状态码。