Skip to content

Commit

Permalink
initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
honnix committed Sep 2, 2016
0 parents commit 068cff5
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
all::
check::
install::
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# kubepl

A [Kubernetes](http://kubernetes.io) client.

## Installation

Using SWI-Prolog 7 or later.

?- pack_install('https://github.com/honnix/kubepl.git').

Source code available and pull requests accepted
[here](https://github.com/honnix/kubepl).

@author Hongxin Liang <hxliang1982@gmail.com>

@license Apache License Version 2.0

## Examples

## License

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.
100 changes: 100 additions & 0 deletions examples/ex1.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
:- module(ex1, []).

:- use_module(library(kubepl/sugar)).
:- use_module(library(kubepl/kubepl)).

:- debug(ex1).

ex1_1(IP) :-
%% don't ask me why they are here
expand_file_name('~/Developer/ms_store/ssl/ca.pem', [CA]),
expand_file_name('~/Developer/ms_store/ssl/admin.pem', [Cert]),
expand_file_name('~/Developer/ms_store/ssl/admin-key.pem', [Key]),
atomic_list_concat(['https://',IP,'/api'], URI),
initialize(URI,
'v1',
auth(ssl, [
cacert_file(CA),
certificate_file(Cert),
key_file(Key),
cert_verify_hook(cert_accept_any)
]),
[],
Client),
Client=>create(namespaces, _{}, [pretty=true], _{metadata:_{name:test1}}, Response),
debug(ex1, 'Response ~w', [Response]).

ex1_2(IP) :-
%% don't ask me why they are here
expand_file_name('~/Developer/ms_store/ssl/ca.pem', [CA]),
expand_file_name('~/Developer/ms_store/ssl/admin.pem', [Cert]),
expand_file_name('~/Developer/ms_store/ssl/admin-key.pem', [Key]),
atomic_list_concat(['https://',IP,'/api'], URI),
initialize(URI,
auth(ssl, [
cacert_file(CA),
certificate_file(Cert),
key_file(Key),
cert_verify_hook(cert_accept_any)
]),
[],
Client),
Client=>get('', _{}, [pretty=true], Response),
debug(ex1, 'Response ~w', [Response]).

ex1_3(IP) :-
%% don't ask me why they are here
expand_file_name('~/Developer/ms_store/ssl/ca.pem', [CA]),
expand_file_name('~/Developer/ms_store/ssl/admin.pem', [Cert]),
expand_file_name('~/Developer/ms_store/ssl/admin-key.pem', [Key]),
atomic_list_concat(['https://',IP,'/apis'], URI),
initialize(URI,
auth(ssl, [
cacert_file(CA),
certificate_file(Cert),
key_file(Key),
cert_verify_hook(cert_accept_any)
]),
[],
Client),
Client=>get('', _{}, [pretty=true], Response1),
debug(ex1, 'Response ~w', [Response1]),
Client=>get('extensions', _{}, [pretty=true], Response2),
debug(ex1, 'Response ~w', [Response2]).

ex1_4(IP) :-
%% don't ask me why they are here
expand_file_name('~/Developer/ms_store/ssl/ca.pem', [CA]),
expand_file_name('~/Developer/ms_store/ssl/admin.pem', [Cert]),
expand_file_name('~/Developer/ms_store/ssl/admin-key.pem', [Key]),
atomic_list_concat(['https://',IP,'/version'], URI),
initialize(URI,
auth(ssl, [
cacert_file(CA),
certificate_file(Cert),
key_file(Key),
cert_verify_hook(cert_accept_any)
]),
[],
Client),
Client=>get('', _{}, [pretty=true], Response),
debug(ex1, 'Response ~w', [Response]).

ex1_5(IP) :-
%% don't ask me why they are here
expand_file_name('~/Developer/ms_store/ssl/ca.pem', [CA]),
expand_file_name('~/Developer/ms_store/ssl/admin.pem', [Cert]),
expand_file_name('~/Developer/ms_store/ssl/admin-key.pem', [Key]),
atomic_list_concat(['https://',IP,'/api'], URI),
initialize(URI,
'v1',
auth(ssl, [
cacert_file(CA),
certificate_file(Cert),
key_file(Key),
cert_verify_hook(cert_accept_any)
]),
[],
Client),
Client=>proxy_get(pods, _{namespace:'ms-store', name:wso2am}, [path='test'], Response),
debug(ex1, 'Response ~w', [Response]).
9 changes: 9 additions & 0 deletions pack.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name(kubepl).
version('0.1').
title('Kubernetes Client').
keywords([kubernetes,client]).
author('Hongxin Liang', 'hxliang1982@gmail.com').
packager('Hongxin Liang', 'hxliang1982@gmail.com').
maintainer('Hongxin Liang', 'hxliang1982@gmail.com').
home('https://github.com/honnix/kubepl').
download('https://github.com/honnix/kubepl/archive/v0.1.zip').
Loading

0 comments on commit 068cff5

Please sign in to comment.