|
2 | 2 |
|
3 | 3 | [](https://coveralls.io/github/aerogear/mobile-cli?branch=add-go-report-card-to-readme)
|
4 | 4 |
|
| 5 | +# Mobile CLI |
5 | 6 |
|
6 |
| -## The Mobile CLI is a standalone CLI that can also be used a kubectl / oc plugin |
| 7 | +**NOTE: The Mobile CLI is still under construction and not yet fit for use.** |
7 | 8 |
|
8 |
| -## Note this is still under construction and not yet fit for use |
| 9 | +The Mobile CLI is a standalone CLI that can also be used as a kubectl or oc plugin. |
9 | 10 |
|
10 |
| -The mobile CLI focuses on a small set of commands to empower mobile focused developers to consume and take full advantage of the RedHat mobile suite |
11 |
| -of services ontop of Kubernetes / OpenShift. |
| 11 | +It focuses on a small set of commands to empower mobile focused developers to consume and take full advantage of the RedHat mobile suite of services ontop of Kubernetes/OpenShift. |
12 | 12 |
|
13 |
| -It uses a language familiar to mobile developers and abstracts away some of the complexity of dealing with Kubernetes / OpenShift which can be |
14 |
| -initially daunting and overwhelming. |
| 13 | +It uses a language familiar to mobile developers and abstracts away some of the complexity of dealing with Kubernetes/OpenShift which can be initially daunting and overwhelming. |
15 | 14 |
|
16 |
| -### Examples |
17 |
| -Note not all of these commands currently exist but are present below to show the general concept |
| 15 | +## Examples |
| 16 | +**Note: Not all of these commands currently exist but are present below to show the general concept.** |
18 | 17 |
|
19 |
| -``` |
| 18 | +```bash |
20 | 19 | mobile get services
|
21 |
| -
|
22 |
| -mobile provision fh-sync |
23 |
| -
|
24 |
| -mobile --namespace=myproject get clientconfig <MobileClientID> |
25 |
| -
|
26 |
| -mobile create integration fh-sync keycloak |
27 |
| -
|
28 |
| -mobile create clientbuild <MobileClientID> <Git_Source_Url> [buildName] |
29 |
| -
|
30 |
| -mobile get buildartifact <clientBuildID> |
| 20 | +mobile create serviceinstance fh-sync-server --namespace=myproject |
| 21 | +mobile get clientconfig <MobileClientID> --namespace=myproject |
| 22 | +mobile create integration <consuming_service_instance_id> <providing_service_instance_id> --namespace=myproject |
| 23 | +mobile create clientbuild <MobileClientID> <Git_Source_Url> <buildName> |
| 24 | +mobile get clientbuilds <clientBuildID> |
31 | 25 | ```
|
32 | 26 |
|
33 |
| -### Checkout |
| 27 | +## CLI Installation |
| 28 | +### Pre-requisites |
| 29 | +- Have a local Kubernetes or OpenShift cluster with mobile clients and services available via minikube, [mobile core installer](https://github.com/aerogear/mobile-core/blob/master/docs/walkthroughs/local-setup.adoc) or [minishift](https://github.com/aerogear/minishift-mobilecore-addon). |
| 30 | +- Install [glide](https://github.com/Masterminds/glide) (e.g. `brew install glide [Mac]`) |
| 31 | +- Install [go](https://golang.org/doc/install) |
34 | 32 |
|
35 |
| -``` |
| 33 | +### Clone this repository |
| 34 | + |
| 35 | +```bash |
36 | 36 | mkdir -p $GOPATH/src/github.com/aerogear
|
37 | 37 | cd $GOPATH/src/github.com/aerogear
|
38 | 38 | git clone https://github.com/aerogear/mobile-cli
|
39 | 39 | ```
|
40 | 40 |
|
41 |
| -### Build |
| 41 | +### Build the CLI Binary |
42 | 42 |
|
43 |
| -``` |
| 43 | +```bash |
44 | 44 | glide install
|
45 | 45 | make build
|
46 | 46 | ```
|
47 | 47 |
|
48 | 48 | To test, run:
|
49 | 49 |
|
50 |
| -``` |
| 50 | +```bash |
51 | 51 | ./mobile
|
52 | 52 | ```
|
53 | 53 |
|
54 | 54 | ### Build for APB usage
|
55 | 55 |
|
56 | 56 | To use the mobile CLI inside an APB container it needs to be compiled for the linux/amd64 platform:
|
57 | 57 |
|
| 58 | +```bash |
| 59 | +make build_binary_linux |
58 | 60 | ```
|
59 |
| -make build_linux |
60 |
| -``` |
61 |
| - |
62 |
| -### Install |
63 |
| - |
64 |
| -### Pre req |
65 |
| - |
66 |
| -- Have a local kubernetes or oc cluster via something like minikube, oc cluster up or [minishift](https://github.com/aerogear/minishift-mobilecore-addon). |
67 |
| -- Install glide (https://github.com/Masterminds/glide), e.g. `brew install glide` |
68 | 61 |
|
69 | 62 | ### Setup the Custom Resource Definition
|
70 | 63 |
|
71 |
| -``` |
| 64 | +```bash |
72 | 65 | oc login -u system:admin
|
73 | 66 | oc create -f artifacts/mobileclient_crd.yaml
|
74 | 67 | ```
|
@@ -98,124 +91,103 @@ oc edit clusterrole admin # add the above and save
|
98 | 91 | oc edit clusterrole edit # add the above and save
|
99 | 92 | ```
|
100 | 93 |
|
101 |
| -### Setup the plugin |
| 94 | +### Setup as Kubectl/OC plugin |
102 | 95 |
|
103 | 96 | - have the [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) command line tool or the [oc command line tool](https://docs.openshift.org/latest/cli_reference/get_started_cli.html#installing-the-cli) already installed
|
104 | 97 | - it should be version k8s version 1.8 or OpenShift 3.7 or later
|
105 | 98 | - create a new dir ```mkdir -p ~/.kube/plugins/mobile```
|
106 | 99 | - copy the cli_plugin.yaml file to the dir ```cp ./artifacts/cli_plugin.yaml ~/.kube/plugins/mobile```
|
107 |
| -- rename the ```cli_plugin.yaml``` file to ```plugin.yaml``` |
| 100 | +and rename the ```cli_plugin.yaml``` file to ```plugin.yaml``` |
108 | 101 | - install the mobile CLI binary onto your $PATH
|
109 | 102 |
|
110 |
| -### Basic usage |
| 103 | +## Basic usage |
111 | 104 |
|
112 |
| -To access the plugin you can use the following command: |
113 |
| -```kubectl plugin mobile <command>``` |
114 |
| - |
115 |
| -You can also use it standalone as it will pick up on your kube configuration: |
116 |
| -```mobile --namespace=mine <command>``` notice we pass the namespace here. |
| 105 | +To use the mobile CLI as a plugin you can use the following command: |
| 106 | +``` bash |
| 107 | +kubectl plugin mobile <command> |
| 108 | +oc plugin mobile <command> |
| 109 | +``` |
117 | 110 |
|
118 | 111 | **Passing flags**
|
119 | 112 |
|
120 |
| -To pass flags when using the plugin ensure to use the ```--``` option: |
121 |
| -```kubectl plugin mobile -- create client --<someflag> ``` |
| 113 | +To pass flags when using the mobile CLI as a plugin, ensure to use the ```--``` option: |
| 114 | +```bash |
| 115 | +kubectl plugin mobile create client -- --<someflag> |
| 116 | +oc plugin mobile create client -- --<someflag> |
| 117 | +``` |
| 118 | + |
| 119 | +The mobile CLI can also be use standalone as it will pick up on your kube configuration: |
| 120 | +```bash |
| 121 | +mobile <command> --namespace=mine |
| 122 | +``` |
122 | 123 |
|
| 124 | +**NOTE: When the mobile CLI is used as an oc plugin, the namespace does not have to be specified as this |
| 125 | +takes the current namespace selected. However, when using the mobile CLI as a standalone, the namespace must always be specified by using the *--namespace* flag.** |
123 | 126 |
|
124 | 127 | ## Design
|
125 | 128 |
|
126 |
| -The design of the CLI API attempts to give a familiar feel to users familiar wil the kubectl and oc CLIs. |
127 |
| -It is also intended to use parlance familiar to mobile developers in order to help them become more productive |
128 |
| -and avoid needing to know the innards of various kubernetes resources. |
| 129 | +The design of the CLI API attempts to give a familiar feel to users familiar with the kubectl and oc CLIs. It is also intended to use parlance familiar to mobile developers in order to help them become more productive and avoid needing to know the innards of various kubernetes resources. |
129 | 130 |
|
130 | 131 | ## Core Objects or Resources
|
131 | 132 |
|
132 |
| -In a similar fashion to the oc and kubectl CLI, we have some core resources that we work with. Some of these are backed by things like secrets while others are |
133 |
| -defined as custom resources. |
| 133 | +In a similar fashion to the oc and kubectl CLI, we have some core resources that we work with. Some of these are backed by things like secrets while others are defined as custom resources. |
134 | 134 |
|
135 |
| -- **MobileClient:** the mobile client is a resource that represents your mobile client app as part of the OpenShift UI. It gives us the context and information needed to show you relevant information |
136 |
| -around your particular mobile runtime as well as allowing us setup the different kind of client builds required. |
| 135 | +- **MobileClient:** The mobile client is a resource that represents your mobile client application as part of the OpenShift UI. It gives us the context and information needed to show you relevant information around your particular mobile runtime as well as allowing us to setup the different kind of client builds required. |
137 | 136 |
|
138 |
| -- **ClientConfig** the client config, is a resource created by aggregating together all of the available service configs. This resource is configuration |
139 |
| -required in order to consume your mobile aware services from your mobile client. It is used by the client SDKs for the various mobile services. |
| 137 | +- **ClientConfig** The client config, is a resource created by aggregating together all of the available service configs. This resource is the configuration required in order to consume your mobile aware services from your mobile client. It is used by the client SDKs for the various mobile services. |
140 | 138 |
|
141 |
| -- **ServiceConfig:** Contains services' information that is used to configure the Mobile SDK. For more information see [here](./doc/service_config.md). |
| 139 | +- **ServiceConfig:** The service config contains the services' information that is used to configure the Mobile SDK. For more information see [here](./doc/service_config.md). |
142 | 140 |
|
143 |
| -- **ClientBuild** the ClientBuild is backed by a regular BuildConfig however the CLI will help you create this BuildConfig with as little effort as possible. Allowing you to focus on |
144 |
| -just the mobile parts rather than needing to understand how to setup and manage a buildconfig and builds. For example, it will help you manage build credentials, and keys and ensure the build integrates |
145 |
| -seamlessly with the areogear mobile build farm . |
| 141 | +- **ClientBuild** The client build is backed by a regular BuildConfig, however the CLI will help you create this BuildConfig with as little effort as possible. This allows you to focus on just the mobile parts rather than needing to understand how to setup and manage a buildconfig and builds. For example, it will help you manage build credentials, and keys and ensure the build integrates seamlessly with the aereogear mobile build farm. |
146 | 142 |
|
147 |
| -- **Binding** the Binding is backed by a binding resource in the service catalog. Once again we try to remove the need to understand how to create the |
148 |
| -native objects so that you can focus on being productive and building your mobile app. When doing a binding, you will be able to integrate different |
149 |
| -mobile services together. For example when using sync and keycloak you can bind them together and have your sync service protected by keycloak. This is as simple as |
150 |
| -```mobile bind fh-sync keycloak``` |
| 143 | +- **Binding** The binding is backed by a binding resource in the service catalog. Once again we try to remove the need to understand how to create the native objects so that you can focus on being productive and building your mobile app. When doing a binding, you will be able to integrate different mobile services together. For example when using sync and keycloak you can bind them together and have your sync service protected by keycloak. This is as simple as |
| 144 | +```mobile create integration <consuming_service_instance_id> <providing_service_instance_id>``` |
151 | 145 |
|
152 |
| -### Command Structure |
| 146 | +## Command Structure |
153 | 147 |
|
154 |
| -get |
155 |
| - |
156 |
| - - clients |
157 |
| - - get clients #returns a list of mobile clients within the current namespace |
158 |
| - - get client <clientName> # returns a single mobile client |
159 |
| - - serviceinstances |
160 |
| - - get serviceinstances <serviceName> # Returns a list of provisioned serviceInstances based on the service name. |
161 |
| - - services |
162 |
| - - get services # Returns mobile aware services that can be provisioned to your namespace |
163 |
| - - serviceconfig |
164 |
| - - get serviceconfigs # returns a list of mobile aware service configurations (this is the full unfiltered configuration data) |
165 |
| - - get serviceconfig <serviceName> #returns a single mobile aware service configuration (this is the full unfiltered configuration data) |
166 |
| - - clientconfig |
167 |
| - - get clientconfig <clientID> # returns the filtered configuration as should be consumed by mobile clients making use of the sdks |
168 |
| - - clientbuild |
169 |
| - - get clientbuilds #returns a list of mobile client builds |
170 |
| - - get clientbuild <clientBuildName> #returns a single mobile client build |
171 |
| - - integrations |
172 |
| - - get integrations # returns a list of integrations between mobile aware services and their consumers |
173 |
| - - get integration <name> # return a single integration and the name of the services consuming it |
174 |
| - |
175 |
| - |
176 |
| -create |
177 |
| - |
178 |
| - - client |
179 |
| - - create client <clientName> <clientType> <appIdentifier> # will create a representation of the mobile client application |
180 |
| - - serviceinstance |
181 |
| - - create serviceinstance <serviceName> # this command will likely prompt for needed imputs |
182 |
| - - serviceconfig |
183 |
| - - create serviceconfig # this command will likely prompt for needed imputs |
184 |
| - - integration |
185 |
| - - create integration <consuming_service_inst_id> <providing_service_inst_id> # will create the binding and pod preset and optionally redeploy the consuming service |
186 |
| - for example: mobile create integration fh-sync keycloak |
187 |
| - - clientbuild |
188 |
| - - create clientbuild <clientID> <git_Source> [buildName] # will create a Jenkins PipeLine based buildconfig likely will need a several option flags to cover |
189 |
| - things like credentials and keys |
| 148 | +### get |
| 149 | +``` |
| 150 | + client gets a single mobile client in the namespace |
| 151 | + clientbuild get a specific clientbuild for a mobile client |
| 152 | + clientbuilds get clientbuilds for a mobile client |
| 153 | + clientconfig get clientconfig returns a client ready filtered configuration of the available services. |
| 154 | + clients gets a list of mobile clients represented in the namespace |
| 155 | + integration get a single integration |
| 156 | + integrations get a list of the current integrations between services |
| 157 | + serviceconfig get a mobile aware service definition |
| 158 | + serviceconfigs get a list of deployed mobile enabled services |
| 159 | + serviceinstances get a list of provisioned service instances based on the service name. |
| 160 | + services get mobile aware services that can be provisioned to your namespace |
| 161 | +``` |
190 | 162 |
|
191 |
| -delete |
192 |
| - |
193 |
| - - client |
194 |
| - - delete client <clientID> # removes the configmap or mobileclient object if we go with CRD |
195 |
| - - serviceinstance |
196 |
| - - delete serviceinstance <serviceInstanceID> # deletes a service instance and other objects created when provisioning the services instance such as pod presets |
197 |
| - - serviceconfig |
198 |
| - - delete serviceconfig <configName> # remove the configur |
199 |
| - - integration |
200 |
| - - delete integration <consuming_service_inst_id> <providing_service_inst_id> # removes all the objects created when the integratio was enabled. |
201 |
| - for example mobile delete binding fh-sync keycloak |
202 |
| - - clientbuild |
203 |
| - - delete the buildconfig and any other related object that back the client build. |
204 |
| - example: delete clientbuild <clientBuildName> |
205 |
| - |
206 |
| -replace |
207 |
| - |
208 |
| - |
209 |
| -start |
210 |
| - |
211 |
| - - clientbuild <buildName> |
| 163 | +### create |
| 164 | +``` |
| 165 | + client create a mobile client representation in your namespace |
| 166 | + clientbuild create a build for a mobile client |
| 167 | + integration integrate certain mobile services together. mobile get services will show you what can be integrated. |
| 168 | + serviceconfig create a new service config |
| 169 | + serviceinstance create a running instance of the given service |
| 170 | +``` |
212 | 171 |
|
| 172 | +### delete |
| 173 | +``` |
| 174 | + client deletes a single mobile client in the namespace |
| 175 | + clientbuild delete a build for a mobile client |
| 176 | + integration delete the integration between mobile services. |
| 177 | + serviceconfig delete a service config |
| 178 | + serviceinstance deletes a service instance and other objects created when provisioning the services instance, such as pod presets |
| 179 | +``` |
213 | 180 |
|
214 |
| -stop |
| 181 | +### start |
| 182 | +``` |
| 183 | + clientbuild start a build for a mobile client |
| 184 | +``` |
215 | 185 |
|
216 |
| - - clientbuild <buildName> |
| 186 | +### stop |
| 187 | +``` |
| 188 | + clientbuild stop a build for a mobile client |
| 189 | +``` |
217 | 190 |
|
218 |
| - |
219 | 191 | ## Contributing
|
220 | 192 |
|
221 | 193 | Check the [`CONTRIBUTING.md`](https://github.com/aerogear/mobile-cli/blob/master/.github/CONTRIBUTING.md) file.
|
0 commit comments