Project Creator Guide
This guide shows you how to create projects using the CLC `project create` command.
Introduction
Hazelcast CLC provides a solution that simplifies the creation of Hazelcast projects. The created projects do not require further configuration.
You can find the templates in the Hazelcast Templates GitHub Account.
Create a Viridian Cluster
For this guide, let’s create a Hazelcast Viridian Cluster. First, sign in to the Cloud console, and follow the Get Started with the Hazelcast CLC tutorial.
Create Your First Project with Default Hazelcast Templates
Before creating a project, list the available templates using the following command:
clc template list
When you create a project, the template is stored in $CLC_HOME/templates
directory. To list only the templates stored in your local environment, add the --local
flag to the template list
command.
To fetch the latest updates from repositories, add the --refresh
flag to the command.
These flags are mutually exclusive, which means that you can only use one of them in a command. |
Let’s create our first project by using go-client-getting-startedˆ template. This template includes the following extension files:
go-client-getting-started
├── README.md.keep
├── config.go.template
└── ...
The .template
extension specifies that the file is a Go template that includes placeholders and actions. The .keep
extension identifies files to keep as they are required for the project. For example, a file named README.md in the template is replaced by a file named README.md.keep when the project is created.
Let’s look a bit deeper to config.go.template to see what placeholders are included:
-
config
-
cluster_name
-
cluster_discovery_token
-
cluster_address
-
ssl_key_path
-
ssl_cert_path
-
ssl_key_password
-
cluster_api_base
that are used in this template. You can find a full list of placeholders in the clc project topic.
To create a project, run the following command:
clc -c <your-config> project create go-client-getting-started
This project is created in the current working directory. To create the project in a different directory, add the --output-dir flag to the command. Once created, the project can be run immediately as the placeholders are already configured.
Create and Use User-created Templates
If preferred, you can use templates that you have created. When creating your templates, keep the following points in mind:
-
Use the format used in the Go template.
-
To add default values, create a template.yaml file, add a
defaults
node, and save it in the template root directory. -
Template files must have the .template extension.
-
File names that start with a period (
.
) or underscore () are ignored, unless they also have a _.keep extensions.
-
Any files with a .keep extension are copied to the project with the .keep extension removed. All other files are copied without changes. *Properties are read from the following resources in order:
-
The defaults node of the templates.yaml file.
The keys must not contain any punctuation characters. -
config.yaml
-
User passed key-values in the "KEY=VALUE" format.
The keys must contain only lowercase, numerical, and underscore characters.
-
After creating your template, push it to a GitHub repository that resides in a separate organization. Hazelcast recommends creating an account/organization specifically for your templates.1
To list your templates, use the template list
command with --source
flag:
clc template list --source=<your-organization-name>
To create a project from your template, run the following command:
clc -c <your-config> project create <your-template> --source=<your-organization-name>
You can also use placeholders in your template, which can be passed using the create
command as follows:
clc -c <your-config> project create <your-template> foo=bar --source=<your-organization-name>
In the example above, the foo
placeholder will be replaced with bar
on project creation.
Conclusion
In this guide you saw how to use default Hazelcast templates, and how to create and use your own templates, when creating projects.
The project creator provides a straightforward way to create ready-to-use projects using a single command.
For full details of the usage and parameters of the clc template
and clc project
commands, see the clc template and clc project documentation.