clc project (Beta)

Project commands are a group of project operations.

Usage:

clc project [command] [flags]

clc project create

Creates a project from the given template.

Usage:

clc project create [template-name] [placeholder-values] [flags]

Parameters:

Parameter Required Description Default

--output-dir, -o

Optional

Output directory for the project to be created.

Template name

--source

Optional

The Github organization/user account to search for the templates.

hazelcast-templates

--template, -t

Optional

Name of the template.

Template selector is displayed

placeholder-values

Optional

Template placeholder values can be specified as key-value pairs. You can use lowercase letters, numbers and the underscore character in keys. Example: my_key1=value

Creating and Using Your Own Templates

Templates are located in https://github.com/hazelcast-templates. You can override it by using the --source flag.

  • Templates are in Go template format.

  • You can create a "defaults.yaml" file for default values in template’s root directory.

  • Template files must have the ".template" extension.

  • Files with "." and "_" prefixes are ignored unless they have the ".keep" extension.

  • All files with ".keep" extension are copied by stripping the ".keep" extension.

  • Other files are copied verbatim. *Properties are read from the following resources in order:

    1. defaults.yaml (keys cannot contain punctuation)

    2. config.yaml

    3. User passed key-values in the "KEY=VALUE" format. The keys can only contain lowercase letters, numbers and the underscore character.

Placeholders

You can use the placeholders in "defaults.yaml" and the following configuration item placeholders:

  • clc_home

  • cluster_name

  • cluster_address

  • cluster_user

  • cluster_password

  • cluster_discovery_token

  • ssl_enabled

  • ssl_server

  • ssl_skip_verify

  • ssl_ca_path

  • ssl_key_path

  • ssl_key_password

  • log_path

  • log_level

Actions

  • repeat COUNT: Returns an integer array with number from 0 to COUNT. If COUNT is 0, an array with 0 integers are returned.

    Template:

    {{ range repeat 3 }}
    Number {{.}}
    {{ end -}}

    Output:

    Number 0
    Number 1
    Number 2
  • each VALUE …​: Returns an array with items having the Index and Value.

    Template:

    {{ range each "foo" "bar" 38 }}
    Item {{ .Index }} = {{ .Value }}
    {{ end -}}

    Output:

    Item 0 = foo
    Item 1 = bar
    Item 2 = 38

Custom Template Actions

You can include the template.star script in the root of your project template to add your own actions to the templates. The template.star script file is used only during template generation; it is not copied to the final project.

Each function in the template.star script is converted to actions, except the ones that start with the underscore (_) character. The functions can take 0 or more characters, but must return a single value. The returned value is one of the following types:

  • String

  • Integer

  • Float

  • Boolean

  • Dictionary (map)

  • List

The following template.star script defines the concat function, which concatenates the passed arguments and returns the final value:

def concat(a, b):
    return str(a) + str(b)

You can use it in your template as follows:

{{ $myvar := 38 }}
Result of concat: {{ concat "a string" $myvar }}

Success Note

You can display a success note when a project is created successfully. This note can help to direct the user to the next step for using the project.

  • note-unix: Text to display only on Linux or macOS.

  • note-windows: Text to display only on Windows.

  • note: Text to display if an OS-specific note is not defined.

The sample template.yaml below instructs CLC to display a custom note on Windows and a generic note on other platforms:

note-windows: |
  This note will be displayed only on Windows.
note: |
  This note will be displayed on non-Windows platforms.

Usage

Example (Linux and macOS):

clc project create \
simple-streaming-pipeline\
--output-dir my-project\
my_key1=my_value1 my_key2=my_value2

Example (Windows):

clc project create^
simple-streaming-pipeline^
--output-dir my-project^
my_key1=my_value1 my_key2=my_value2