Skip to content

Commit 17447ed

Browse files
committed
Update Readme and fixing docs
1 parent bee6b73 commit 17447ed

File tree

6 files changed

+123
-161
lines changed

6 files changed

+123
-161
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
bin/
2+
build/
3+
notes
4+
bin/craft
5+
.vscode
6+
craft.tar.gz
7+
# Binaries for programs and plugins
8+
*.exe
9+
*.exe~
10+
*.dll
11+
*.so
12+
*.dylib
13+
bin
14+
*.db
15+
# Test binary, build with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
20+
21+
# Kubernetes Generated files - skip generated files, except for vendored files
22+
23+
!vendor/**/zz_generated.*
24+
25+
# editor and IDE paraphernalia
26+
.idea
27+
*.swp
28+
*.swo
29+
*~
30+
31+
# docs generated
32+
docs/book

README.md

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,21 @@
11
# Custom Resource Abstraction Fabrication Tool
22

3-
__NOTE__: For users of CRAFT, a detailed documentation can be found [here](). This README is primarily aimed for developers.
3+
For new users of CRAFT, a detailed documentation can be found [here](https://salesforce.github.io/craft).
44

55
## Contribution
66
Please refer [Contribution.md](Contribution.md) before pushing the code. If you wish to make a contribution, create a branch, push your code into the branch and create a PR. For more details, check [this article](https://opensource.com/article/19/7/create-pull-request-github).
77

88
## Installing craft and its dependencies
99
Dependencies for CRAFT are `kustomize` and `kubebuilder`.
1010

11-
Latest CRAFT release can be found [here](). Download the craft.tar.gz file and run the following command:
1211

1312
```
14-
sudo tar -C /usr/local/ -xzf ~/Downloads/craft.tar.gz
15-
export PATH=$PATH:/usr/local/craft/bin
16-
```
17-
18-
In case the file is downloaded somewhere other than Downloads, replace ~/Downloads/craft.tar.gz by the path where you downloaded the file.
19-
20-
## Commands of CRAFT
21-
### craft version
22-
Usage :
23-
```
24-
craft version
25-
```
26-
Displays the information about craft, namely version, revision, build user, build date & time, go version.
27-
28-
### craft init
29-
Usage :
30-
```
31-
craft init
32-
```
33-
Initialises a new project with sample controller.json and resource.json
34-
35-
### craft create
36-
Usage :
37-
```
38-
craft create -c "controller.json" -r "resource.json --podDockerFile "dockerFile" -p
39-
```
40-
Creates operator source code in $GOPATH/src, builds operator.yaml, builds and pushes operator and resource docker images.
41-
42-
#### craft build
43-
Has 3 sub commands, code, deploy and image.
13+
# dowload latest craft binary from releases and extract
14+
curl -L https://github.com/salesforce/craft/releases/download/0.1.7/craft.tar.gz | tar -xz -C /tmp/
4415
45-
#### build code
46-
Usage:
47-
```
48-
craft build code -c "controller.json" -r "resource.json
49-
```
50-
Creates code in $GOPATH/src/operator.
51-
52-
#### build deploy
53-
Usage:
54-
```
55-
craft build deploy -c "controller.json" -r "resource.json
56-
```
57-
Builds operator.yaml for deployment onto cluster.
58-
59-
#### build image
60-
Usage:
61-
```
62-
craft build image -b -c "controller.json" --podDockerFile "dockerFile"
63-
```
64-
Builds operator and resource docker images.
65-
66-
#### validate
67-
Usage:
68-
```
69-
craft validate -v "operator.yaml"
16+
# move to a path that you can use for long term
17+
sudo mv /tmp/craft /usr/local/craft
18+
export PATH=$PATH:/usr/local/craft/bin
7019
```
71-
Validates operator.yaml to see if everything is in shape
20+
## CRAFT Usage
21+
To know more about how to use craft cli you can refer to [here](https://salesforce.github.io/craft/craft_cli.html)

docs/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
* [Step3: Deploy Operator onto the cluster](tutorial/deploy_operator.md)
1515
* [Operator source code](operator_source_code/README.md)
1616
* [Controllers and Reconcilers](operator_source_code/controller_reconciler.md)
17-
17+
* [Craft CLI](craft_cli.md)

docs/src/craft_cli.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Commands of CRAFT
2+
### craft version
3+
Usage :
4+
```
5+
craft version
6+
```
7+
Displays the information about craft, namely version, revision, build user, build date & time, go version.
8+
9+
### craft init
10+
Usage :
11+
```
12+
craft init
13+
```
14+
Initialises a new project with sample controller.json and resource.json
15+
16+
### craft create
17+
Usage :
18+
```
19+
craft create -c "controller.json" -r "resource.json --podDockerFile "dockerFile" -p
20+
```
21+
Creates operator source code in $GOPATH/src, builds operator.yaml, builds and pushes operator and resource docker images.
22+
23+
#### craft build
24+
Has 3 sub commands, code, deploy and image.
25+
26+
#### build code
27+
Usage:
28+
```
29+
craft build code -c "controller.json" -r "resource.json
30+
```
31+
Creates code in $GOPATH/src/operator.
32+
33+
#### build deploy
34+
Usage:
35+
```
36+
craft build deploy -c "controller.json" -r "resource.json
37+
```
38+
Builds operator.yaml for deployment onto cluster.
39+
40+
#### build image
41+
Usage:
42+
```
43+
craft build image -b -c "controller.json" --podDockerFile "dockerFile"
44+
```
45+
Builds operator and resource docker images.
46+
47+
#### validate
48+
Usage:
49+
```
50+
craft validate -v "operator.yaml"
51+
```
52+
Validates operator.yaml to see if everything is in shape

docs/src/quick_setup/README.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,19 @@
99

1010
## Installation
1111

12-
The latest version of CRAFT can be found [here](https://github.com/salesforce/craft/releases/). Extract it into **/usr/local** directory.
13-
14-
```
15-
sudo tar -C /usr/local -xzf ~/Downloads/craft.tar.gz
1612
```
13+
# dowload latest craft binary from releases and extract
14+
curl -L https://github.com/salesforce/craft/releases/download/0.1.7/craft.tar.gz | tar -xz -C /tmp/
1715
18-
Note: Replace **/Downloads/craft.tar.gz** with the directory where you downloaded the latest version of CRAFT.
19-
20-
Next, add the /usr/local/craft/bin directory to your PATH environment variable.
21-
22-
```
16+
# move to a path that you can use for long term
17+
sudo mv /tmp/craft /usr/local/craft
2318
export PATH=$PATH:/usr/local/craft/bin
2419
```
25-
26-
You can also add CRAFT to your PATH environment variable permanently.
27-
20+
Instead of having to add to PATH everytime you open a new terminal, we can add our path to PATH permanently.
2821
```
29-
sudo vim /etc/paths
22+
$ sudo vim /etc/paths
3023
```
31-
32-
Add the line **/usr/local/craft/bin** at the end of the file and save the file.
33-
24+
Add the line "/usr/local/craft/bin" at the end of the file and save the file.
3425
## Create a CRAFT Application
3526

3627
From the command line, **cd** into a directory where you'd like to store your CRAFT application and run this command:
@@ -44,6 +35,6 @@ This will initiate a CRAFT application in your current directory and create the
4435
- controller.json: This file holds Custom Resource Definition (CRD) information like group, domain, operator image, and reconciliation frequency.
4536
- resource.json: This file contains the schema information for validating inputs while creating the CRD.
4637

47-
##Next Steps
38+
## Next Steps
4839

49-
Follow the Wordpress operator tutorial to understand how to use CRAFT to create and deploy an operator into a cluster. This deep-dive tutorial demonstrates the entire scope and scale of a CRAFT application.
40+
Follow the Wordpress operator tutorial to understand how to use CRAFT to create and deploy an operator into a cluster. This deep-dive tutorial demonstrates the entire scope and scale of a CRAFT application.

docs/src/tutorial/step2.md

Lines changed: 21 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,29 @@
1-
# Resource.json - What does it do?
1+
# Creating the Operator using CRAFT
22

3-
Resource.json contains the schema information for validating inputs while creating the CRD. The resource.json has a list of properties and required attributes for a certain operator which should be followed by the input. The scaffold of resource.json looks like this.
3+
Now that we have created controller.json, resource.json and the DockerFile, let's create the Operator using CRAFT.
44

5-
"type": "object"
6-
"properties": {},
7-
"required": [],
5+
First, let us check whether CRAFT is working in our machine.
6+
```
7+
$ craft version
8+
```
9+
This should display the version and other info regarding CRAFT.
810

9-
The properties field contains the field name, data type and the data patterns. The required field contains the data names which are mandatory for the operator to be created.
11+
---
12+
***!TIP***
1013

11-
Note : Resource.json is same for an operator, irrespective of who the developer is. Even though controller.json can vary for an operator, resource.json must stay the same.
14+
If this gives an error saying "$GOPATH is not set", then set GOPATH to the location where you've installed Go.
1215

13-
To populate resource.json, we need to go through the resource code and identify the required fields and their properties.
14-
The resource.json for Wordpress looks like this:
16+
---
1517

18+
Now that we have verified that CRAFT is working properly, creating the Operator with CRAFT is a fairly straight forward process:
1619
```
17-
"type": "object",
18-
"properties": {
19-
"bootstrap_email": {
20-
"pattern": "^(.*)$",
21-
"type": "string"
22-
},
23-
"bootstrap_password": {
24-
"pattern": "^(.*)$",
25-
"type": "string"
26-
},
27-
"bootstrap_title": {
28-
"pattern": "^(.*)$",
29-
"type": "string"
30-
},
31-
"bootstrap_url": {
32-
"pattern": "^(.*)$",
33-
"type": "string"
34-
},
35-
"bootstrap_user": {
36-
"pattern": "^(.*)$",
37-
"type": "string"
38-
},
39-
"db_password": {
40-
"pattern": "^(.*)$",
41-
"type": "string"
42-
},
43-
"dbVolumeMount": {
44-
"pattern": "^(.*)$",
45-
"type": "string"
46-
},
47-
"host": {
48-
"pattern": "^(.*)$",
49-
"type": "string"
50-
},
51-
"instance": {
52-
"enum": [
53-
"prod",
54-
"dev"
55-
],
56-
"type": "string"
57-
},
58-
"name": {
59-
"pattern": "^(.*)$",
60-
"type": "string"
61-
},
62-
"replicas": {
63-
"format": "int64",
64-
"type": "integer",
65-
"minimum": 1,
66-
"maximum": 5
67-
},
68-
"user": {
69-
"pattern": "^(.*)$",
70-
"type": "string"
71-
},
72-
"wordpressVolumeMount": {
73-
"pattern": "^(.*)$",
74-
"type": "string"
75-
}
76-
},
77-
"required": [
78-
"bootstrap_email",
79-
"bootstrap_password",
80-
"bootstrap_title",
81-
"bootstrap_url",
82-
"bootstrap_user",
83-
"db_password",
84-
"dbVolumeMount",
85-
"host",
86-
"instance",
87-
"name",
88-
"replicas",
89-
"user",
90-
"wordpressVolumeMount"
91-
]
20+
craft create -c config/controller.json -r config/resource.json \
21+
--podDockerFile resource/DockerFile -p
9222
```
23+
---
24+
***NOTE***
25+
26+
If the execution in the terminal stops at a certain point, do not assume that it has hanged. The command takes a little while to execute, so give it some time.
27+
28+
---
29+
This will create the Operator template in $GOPATH/src, build operator.yaml for deployment, build and push Docker images for operator and resource. We shall see what these are individually in the next section.

0 commit comments

Comments
 (0)