diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 94117f5..a9e7e80 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -58,7 +58,7 @@ jobs: #!/bin/bash set -e -x - go build -v -x -ldflags="-X 'github.com/rohitramu/kpm/cli/model/utils/constants.VersionString=${APP_VERSION}'" + go build -v -x -ldflags="-X 'github.com/rohitramu/kpm/src/cli/model/utils/constants.VersionString=${APP_VERSION}'" - name: Test if: success() diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1d161e9..3c6aebd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -2,7 +2,7 @@ version: 2 dist: /tmp/goreleaser builds: - ldflags: - - -X 'github.com/rohitramu/kpm/cli/model/utils/constants.VersionString={{ .Env.APP_VERSION }}' + - -X 'github.com/rohitramu/kpm/src/cli/model/utils/constants.VersionString={{ .Env.APP_VERSION }}' archives: - format: binary name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" diff --git a/README.md b/README.md index 7c4c786..428d4e6 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,18 @@ # KPM -- [What is KPM?](#what-is-kpm) +KPM is a command line tool which modularizes the process of generating text files. It was initially developed to generate configuration files for Kubernetes as a more robust alternative to Helm Charts, however it can be used in any situation that requires text file generation. + +- [Template packages](#template-packages) - [Setup](#setup) - [Installation](#installation) - [Command line usage](#command-line-usage) - [Version information](#version-information) - - [Golang templating](#golang-templating) -- [Template packages](#template-packages) - - [List the locally available template packages](#list-the-locally-available-template-packages) - - [Create a parameters file](#create-a-parameters-file) - - [View a template package's default parameters file](#view-a-template-packages-default-parameters-file) - - [Execute a template package](#execute-a-template-package) -- [Authoring a template package](#authoring-a-template-package) - - [Directory structure](#directory-structure) - - [`package.yaml`](#packageyaml) - - [`parameters.yaml`](#parametersyaml) - - [`interface.yaml`](#interfaceyaml) - - [`templates/`](#templates) - - [`helpers/`](#helpers) - - [`dependencies/`](#dependencies) - - [Template functions and logic](#template-functions-and-logic) -- [Testing your package locally](#testing-your-package-locally) -- [Pack your template package](#pack-your-template-package) - - [Unpack a template package](#unpack-a-template-package) - -## What is KPM? - -KPM is a command line tool which simplifies and modularizes the process of generating text files. It was initially developed to generate configuration files for Kubernetes as an alternative to Helm Charts, however it can be used in any situation that requires text file generation. + +## Template packages + +KPM uses the concept of "template packages" to generate files. A template package is simply a collection of individual text file templates. This collection of templates can be thought of as a program which can be executed. A template package accepts inputs in the form of parameters, and produces outputs in the form of generated files. + +See [the docs](docs/README.md) for more information about how to [use template packages](docs/using_packages/README.md) and [author your own template packages](docs/authoring_packages/README.md). There are also [examples](docs/examples/README.md) that you can use as a starting point for authoring your own template packages. ## Setup @@ -44,13 +30,29 @@ Also, choose and remember the appropriate architecture string, `${arch}`, for yo - `arm64` - `386` -These values should will be used to install the appropriate binary. +These values will be used to install the appropriate binary. #### From the GitHub website -Download the KPM executable from the [Releases](https://github.com/rohitramu/kpm/releases) tab. Add this executable to your PATH environment variable so it is available from anywhere on your machine. +Download the KPM executable from the [Releases](https://github.com/rohitramu/kpm/releases) tab. Put this executable somewhere on your PATH so it is available from anywhere on your machine. + +#### Linux + +##### Add `~/bin` to your PATH environment variable + +If `~/bin` is not already on your PATH, add it: + +```sh +export PATH="$PATH:~/bin" +``` + +To make this permanent, add it to your `~/.bashrc` file: + +```sh +echo "export PATH=\"\$PATH:~/bin\"" >> ~/.bashrc +``` -#### Using `wget` on Linux +##### Download and install KPM Note that the file needs to be made executable after download. @@ -99,526 +101,3 @@ To get the version information for the KPM binary, run: ```sh kpm version ``` - -### Golang templating - -KPM uses Golang templating. More information about defining and using templates can be found in the official [Golang template docs](https://golang.org/pkg/text/template/). - -## Template packages - -A template package is simply a collection of templates. This collection of templates can be thought of as a program or function which can be executed. A template package accepts inputs in the form of parameters, and produces outputs in the form of generated files. - -Usage of a template package typically consists of these steps: - -1. [Create a parameters file](#create-a-parameters-file) which can be used as input to the template package. -1. [Run the template package](#execute-a-template-package) with your parameters file. -1. View your generated files! - -### List the locally available template packages - -To see the list of all template packages in the local KPM repository, run the "list" subcommand: - -```sh -kpm ls -``` - -### Create a parameters file - -A parameters file is just a YAML file containing the input values to a template package. The structure of this parameters file is determined by the [interface](#interfaceyaml) of the package that you would like to execute. - -Looking at the [default parameters file](#parametersyaml) is a great way to understand the expected structure of your parameters file, because: - -- All parameters must have default values. -- Package authors are encouraged to add documentation about their package in this file (as comments). - -To see the default parameters file for a package, use the ["view" subcommand](#view-a-template-packages-default-parameters-file). - -### View a template package's default parameters file - -The default parameters file is provided by package authors to specify default values for parameters that the user's parameters file does not set. The default parameters file is also used to document the template package. Most importantly, explanations of how to set each parameter should be included in this file by the package author. - -Users may find it useful to view the default parameters file in order to gain a better understanding of how the template package works. The "view" command can print out the default parameters file for any template package which is available in your local KPM repository: - -```sh -kpm view kpmtool/example -v 1.0.0 -``` - -If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](#pack-your-template-package)) will be used. - -### Execute a template package - -Execute a template package with the "run" subcommand: - -```sh -// Pull the package if you haven't already -kpm pull kpmtool/example -v 1.0.0 - -// Run the package with default parameters -kpm run kpmtool/example -v 1.0.0 - -// Run the package with custom parameters -kpm run kpmtool/example -v 1.0.0 -f my_params.yaml -``` - -If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](#pack-your-template-package)) will be used. - -If an output directory is not specified with the `--output-dir` flag, files will be generated in `/.kpm_generated/`. - -If an output name is not specified with the `--output-name` flag, `-` will be used as the output name. - -## Authoring a template package - -### Directory structure - -A template package must have the following directory structure, but not every file is required (items with trailing slashes are directories): - -```txt - -| -+-- package.yaml -+-- interface.yaml -+-- parameters.yaml -| -+-- templates/ -| | -| +-- my_template.txt -| +-- other template.text -| \-- someConfig.yaml -| -+-- helpers/ -| | -| +-- my_helpers.tpl -| +-- other helpers.tpl -| \-- extraHelpers.tpl -| -+-- dependencies/ -| | -| +-- dependency1.yaml -| +-- dependency_2.yaml -| \-- other-dependency.yaml -\ -``` - -### `package.yaml` - -The package information file defines the name and version of a package. For example, a `package.yaml` file for version `1.0.0` of the package `kpmtool/helloworld` would look like this: - -```yaml -name: kpmtool/helloworld -version: 1.0.0 -``` - -The name of the package may only contain lowercase letters, numbers, forward slashes, underscores, dashes and dots. Also, it must start with a lowercase letter. -The recommended convention for naming packages is to use dots for separating segments (i.e. creating a heirarchy), and using underscores to separate words inside a segment: - -```sh -my_username/my_organization.my_product.my_package_name -``` - -The version must be in the format `"major.minor.revision"`. Leading zeros are not permitted in the `major`, `minor` or `revision` segments of the version string, however a segment may be just `0` (zero). The zero version (`0.0.0`) is not allowed. - -NOTE: This file cannot be a template, and must only contain concrete values. - -### `parameters.yaml` - -A package author must provide a set of default parameters which will be used whenever a user does not provide a parameter. The default parameters file is also a great place to document each parameter using comments. - -NOTE: This file cannot be a template, and must only contain concrete values. - -For example, here is a sample default parameters file: - -```yaml -# The user's name -name: - first: "Mr." - last: 'FooBar' - -# Whether or not to include the custom object -isCustom: true - -# Provide your custom object -custom-object: - hello: world! - other: - - is - - my - - true - - custom: object - -# Choose some colors -colors: -- red -- green -- blue -``` - -### `interface.yaml` - -The interface is a YAML template which defines what parameters the package requires in order to correctly generate output. Parameters which are provided by the user are used as the input to this interface. The resulting YAML is then used as the input to all other templates in the package. - -If a value is not provided by the user for a parameter, the default value will be used. Default values are defined in the [parameters](#parametersyaml) file. - -The values in the interface may be defined as "constants" (i.e. hardcoded values) which can be referenced in templates. However, for more complex string values (e.g. multi-line strings, strings with special characters, etc.), [helper templates](#helpers) should be preferred. See the `constantGreeting` property or the `favorite-things` list below for examples of how hardcoded values may be defined. - -Here is an example interface definition which can accept the parameters from the [example](#parametersyaml) above: - -```yaml -username: {{ .name.first }} {{ .name.last }} -someColors: -{{- range .colors }} -- {{ . }} -{{- end }} -constantGreeting: Hello, World! -favorite-things: -- Music -- Photography -- Car racing -- Basketball -- Software! -isCustom: {{ .isCustom }} -customObj: {{- index . "custom-object" | toYaml | nindent 2 }} -``` - -Since the interface definition is itself a template, all of the normal template functions are available to be used. See the [templates](#templates) section for more details. - -Once the interface is executed with the provided parameters, it is combined with the package definition to become the input to all other templates. Here is an example of what is provided to all templates if we ran the `kpmktool/example` package with the above interface file and the parameters from the [parameters example](#parametersyaml): - -```yaml -package: - name: kpmtool/example - version: 1.0.0 -values: - username: Mr. FooBar - someColors: - - red - - green - - blue - constantGreeting: Hello, World! - favorite-things: - - Music - - Photography - - Car racing - - Basketball - - Software! - isCustom: true - customObj: - hello: world! - other: - - is - - my - - true - - custom: object -``` - -This is why all templates in the package (other than the interface) need to reference the ".values" object to get the values supplied by the interface. - -### `templates/` - -Files in the templates directory are the text templates which will be used to generate the output files. These can be used to generate any text format with any filename. - -Here is an example of a template file which generates a text file by using values provided by the [interface example](#interfaceyaml) above: - -```sh -Hello, {{ .values.username }}! - -Are you enjoying KPM? Let me know if you have any issues: https://github.com/rohitramu/kpm/issues - -You can iterate over an array like this: -{{- range .values.someColors }} - - {{ . }} -{{- end }} - -Wondering how to access values that have special characters in their names? Here is a list of my favorite things: -{{- range $thing := (index .values "favorite-things") }} - - {{ $thing }} -{{- end }} - -Maybe you'd like to indent some text? Here you go (indented by 2 spaces): {{- include "nesting helper" . | nindent 2 }} - -If you want to see an example of a template which generates yaml output, take a look at the "object.yaml" file in the templates folder! - -Hopefully these examples gave you an idea of how you can use KPM to create template packages which generate output files in any format, potentially using fairly complex logic :). -``` - -And here is one more example which outputs a YAML file: - -```yaml -# object.yaml -configuration: - package-name: {{ .package.name }} - colors: {{- include "colors helper" . | trim | nindent 2 }} - your-name: {{ .values.username }} - {{- if .values.isCustom }} - custom: - your-object: {{- .values.customObj | toYaml | trim | nindent 6 }} - {{- end }} -``` - -### `helpers/` - -Helper templates (a.k.a. "named templates" or "partial templates") allow the definition of templates which are useful in other templates in the package. If you find yourself copying and pasting parts of templates, defining helper templates will allow you to simplify your templates and reduce the likelihood of copy-paste errors. - -Helper templates can be inserted by using either the [`template` action or the `include` function](#include). - -A helper template file may contain any number of helper templates, and must have the extension ".tpl". Here is an example helper template file: - -```sh -{{- define "my helper template" -}} -This is my helper template! My username is {{ .values.username }}. -{{- end -}} - - -{{- define "my yaml colors helper" -}} -colors: -{{- range .values.colors }} -- {{ . }} -{{- end }} -{{- end -}} -``` - -These helpers may be used in other templates like this: - -```yaml -message: {{ include "my helper template" . }} -list: {{- include "my yaml colors helper" . | trim | nindent 2 }} -``` - -### `dependencies/` - -Dependency definitions are references to other template packages. A package dependency must contain both the package information (i.e. package name and version) and the parameters to send to that package. - -```yaml -# First, define the package reference -package: - name: kpmtool/helloworld - version: 1.0.0 - -# Next, specify the parameters to send to that package -parameters: - myName: World -``` - -Since dependency definitions are templates themselves, the parameters to send to the referenced package can be quite flexible. The package reference itself can change based on the parameters provided to the parent template! - -```yaml -package: -{{- if .values.sayHello }} - name: kpmtool/helloworld - version: 1.0.0 -{{- else }} - name: kpmtool/example - version: {{ .values.exampleVersion }} -{{- end }} - -parameters: -{{- if not .values.useDefaults }} - colors: {{- .values.colors | toYaml | nindent 2 }} -{{- end }} -``` - -### Template functions and logic - -Template functions and control structures are used to transform data within templates, in order to produce the desired output. - -#### Controlling whitespace - -Controlling whitespace in certain types of files can be very important. - -One example is YAML, where properties are defined on objects by indenting them. In this case, producing incorrect indentation would lead to an incorrect definition of objects. - -Thanks to [Golang templating](#golang-templating), whitespace may be controlled using special syntax when inserting placeholders in templates: - -```yaml -# This will result in the string "hello world" being indented - {{ "hello" }} {{ "world" }} - -# This will result in the string "hello world" being left-justified (i.e. not indented at all) - {{- "hello" }} {{ "world" }} - -# This will result in the string "hello" being indented, and "world" being inserted without -# the spaces or new line after "hello" (i.e. it would become the string " helloworld") - {{ "hello" -}} - {{ "world" }} -``` - -The dash (`-`) character after the start of the placeholder (`{{`) or before the end of the placeholder (`}}`) tells the renderer to remove any whitespace to the left or right before inserting the value. This trims all whitespace, including **spaces, tabs and new lines**. - -#### Conditionals - -Conditional generation of output is done using if-else statements: - -```sh -{{- if .values.show -}} -This text will only appear if the ".values.show" boolean property is set to true. -{{- end -}} -``` - -Multiple conditions can be checked, and you can also specify default behavior if all conditions fail: - -```sh -{{- if (eq .values.color "green") -}} -Go! -{{- else if (eq .values.color "red") -}} -Stop! -{{- else -}} -Caution... -{{- end -}} -``` - -The "with" action is useful when you need to check for whether a property has been defined/supplied: - -```sh -{{- with .values.myProperty }} -This will only appear if ".values.myProperty" has been set. Its value is: {{ . }} -{{- end }} -``` - -The value retrieved by "with" may also be assigned to a variable: - -```sh -{{- with $myProperty := .values.myProperty }} -Congratulations, you set your variable to "{{ $myProperty }}"! -{{- end }} -``` - -#### Loops - -We can iterate over items in an array with the "range" action: - -```sh -{{- range .values.myArray }} -- {{ . }} -{{- end }} -``` - -Each item in the array can be assigned to a variable as well. This is useful when the items are objects rather than value types: - -```sh -{{- range $myObject := .values.myObjectArray }} -- I have both {{ $myObject.property1 }} and {{ $myObject.property2 }}! -{{- end }} -``` - -#### Sprig functions - -Sprig is a large library of useful template functions. All of these functions are available for use inside all templates in a template package, including the [interface definition](#interfaceyaml), [helper templates](#helpers) and [dependency definitions](#dependencies). - -- Documentation: -- GitHub: - -#### Other template functions - -##### `index` - -It is very difficult to reference parameters which have special characters in their name, for example `my-property`. The dash character (`-`) will break the "dot notation", so the following statement will fail: - -```yaml -# This fails because dot notation does not handle special characters, e.g. dashes -{{ .values.my-property }} -``` - -The "index" function comes to the rescue! - -```yaml -# We can reference any property, even if it has a weird name -{{ index .values "my-property" }} -``` - -The index function actually takes a list of keys, so this can be used to access a property at any depth: - -```yaml -# We can reference properties at any depth -{{ index .values.myObject "my-weirdly-named-object" "inner-property" }} -``` - -The index function returns the property as-is, so you can continue to manipulate it afterwards: - -```yaml -# We can continue manipulating the result object from the index function -{{ (index .values.myObject "my-weirdly-named-object") | toYaml | trim | indent 2 }} -``` - -##### `include` - -The `template` action can be used for inserting helper templates. - -```yaml -# This will execute and insert the helper template's output as-is, and won't let you further manipulate it -{{ template "my helper template" . }} -``` - -However, since it does not return the helper template's output as a string, transforming it before inserting it is not possible. The `include` function solves this problem by executing the helper template and then returning the result as a string (rather than immediately inserting it in the document as-is). - -```yaml -# This will execute the helper template, and then allow you to do things like trim whitespace and add indentation (in this case 4 spaces of indentation) -{{ include "my helper template" . | trim | indent 4 }} - -# You can even define your helper template as a YAML object, and then convert it into an object inside the template! -{{ index (include "my helper template" . | toYaml) "myProperty" }} -``` - -##### `indent` vs. `nindent` - -The `indent` function is used to indent all lines of a string by the given number of spaces. This is very useful in files where whitespace and indenting is important, however it can lead to templates which are difficult to read, since the placeholder needs to be left-justified and placed on a new line: - -```yaml -myObject: - myNestedObject: -{{ include "my helper template" . | indent 4 }} - anotherNestedObject: - foo: bar -``` - -The [Sprig library](#sprig-functions) provides a `nindent` function which adds the new line for you before indenting the string. This makes it much easier to read the template definition: - -```yaml -myObject: - myNestedObject: {{- include "my helper template" . | nindent 4 }} - anotherNestedObject: - foo: bar -``` - -## Testing your package locally - -## Pack your template package - -To make your package available to use locally, run the "pack" subcommand: - -```sh -kpm pack /path/to/package/root -``` - -This adds the package to your local KPM repository. - -If you are in the root directory of the package, you can just run the following (note the dot - it represents the current directory): - -```sh -kpm pack . -``` - -The pack command will then add your package to the local KPM repository, using the name and version specified in the [package definition](#packageyaml) file. - -It will be shown by the ["list" subcommand](#list-the-locally-available-template-packages), and can be executed with the ["run" subcommand](#execute-a-template-package): - -```sh -kpm ls -kpm run username/my.package -v 0.1.0 -``` - -### Unpack a template package - -Unpacking (i.e. extracting) a template package to your file system can be useful to inspect its inner workings. - -Unpack a template package by running the "unpack" subcommand: - -```sh -kpm unpack kpmtool/example -v 1.0.0 -``` - -The files in the package will be copied to the directory `/`. - -If an output directory is not provided with the `--output-dir` flag, `/.kpm_exported` will be used. - -If an export name is not provided with the `--export-name` flag, `-` will be used. - -If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](#pack-your-template-package)) will be used. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..6362c2b --- /dev/null +++ b/docs/README.md @@ -0,0 +1,7 @@ +# Documentation + +This folder contains in-depth documentation about KPM. + +- [Using template packages](using_packages/README.md) +- [Authoring your own template packages](authoring_packages/README.md) +- [Example scenarios](examples/README.md) diff --git a/docs/authoring_packages/README.md b/docs/authoring_packages/README.md new file mode 100644 index 0000000..eb511ee --- /dev/null +++ b/docs/authoring_packages/README.md @@ -0,0 +1,77 @@ +# Authoring a template package + +## Directory structure + +A template package must have the following directory structure, but not every file is required (a `*` indicates a required file). Note that items with trailing forward slashes (`/`) are directories. + +```txt + +| ++-- package.yaml * ++-- interface.yaml * ++-- parameters.yaml * +| ++-- templates/ +| | +| +-- my_template.txt +| +-- other template.text +| \-- someConfig.yaml +| ++-- helpers/ +| | +| +-- my_helpers.tpl +| +-- other helpers.tpl +| \-- extraHelpers.tpl +| ++-- dependencies/ +| | +| +-- dependency1.yaml +| +-- dependency_2.yaml +| \-- other-dependency.yaml +\ +``` + +## Testing your template package + +### Pack your template package + +To make your package available to use locally, run the "pack" subcommand: + +```sh +kpm pack /path/to/package/root +``` + +This adds the package to your local KPM repository. + +If you are in the root directory of the package, you can just run the following (note the dot - it represents the current directory): + +```sh +kpm pack . +``` + +The pack command will then add your package to the local KPM repository, using the name and version specified in the [package definition](package_files.md#packageyaml) file. + +It will be shown by the ["list" subcommand](../README.md#list-the-locally-available-template-packages), and can be executed with the ["run" subcommand](../README.md#execute-a-template-package): + +```sh +kpm ls +kpm run username/my.package -v 0.1.0 +``` + +### Unpack a template package + +Unpacking (i.e. extracting) a template package to your file system can be useful to inspect its inner workings. + +Unpack a template package by running the "unpack" subcommand: + +```sh +kpm unpack kpmtool/example -v 1.0.0 +``` + +The files in the package will be copied to the directory `/`. + +If an output directory is not provided with the `--output-dir` flag, `/.kpm_exported` will be used. + +If an export name is not provided with the `--export-name` flag, `-` will be used. + +If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](#pack-your-template-package)) will be used. diff --git a/docs/authoring_packages/package_files.md b/docs/authoring_packages/package_files.md new file mode 100644 index 0000000..af2a0ac --- /dev/null +++ b/docs/authoring_packages/package_files.md @@ -0,0 +1,218 @@ +# Files in a template package + +## `package.yaml` + +The package information file defines the name and version of a package. For example, a `package.yaml` file for version `1.0.0` of the package `kpmtool/helloworld` would look like this: + +```yaml +name: kpmtool/helloworld +version: 1.0.0 +``` + +The name of the package may only contain lowercase letters, numbers, forward slashes, underscores, dashes and dots. Also, it must start with a lowercase letter. +The recommended convention for naming packages is to use dots for separating segments (i.e. creating a heirarchy), and using underscores to separate words inside a segment: + +```sh +my_username/my_organization.my_product.my_package_name +``` + +The version must be in the format `"major.minor.revision"`. Leading zeros are not permitted in the `major`, `minor` or `revision` segments of the version string, however a segment may be just `0` (zero). The zero version (`0.0.0`) is not allowed. + +NOTE: This file will not be evaluated as a template. + +## `parameters.yaml` + +A package author must provide a set of default parameters which will be used whenever a user does not provide a parameter. The default parameters file is also a great place to document each parameter using comments. + +NOTE: This file will not be evaluated as a template. + +For example, here is a sample default parameters file: + +```yaml +# The user's name +name: + first: "Mr." + last: 'FooBar' + +# Whether or not to include the custom object +isCustom: true + +# Provide your custom object +custom-object: + hello: world! + other: + - is + - my + - true + - custom: object + +# Choose some colors +colors: +- red +- green +- blue +``` + +## `interface.yaml` + +The interface is a YAML template which defines what parameters the package requires in order to correctly generate output. Parameters which are provided by the user are used as the input to this interface. The resulting YAML is then used as the input to all other templates in the package. + +If a value is not provided by the user for a parameter, the default value will be used. Default values are defined in the [parameters](#parametersyaml) file. + +The values in the interface may be defined as "constants" (i.e. hardcoded values) which can be referenced in templates. However, for more complex string values (e.g. multi-line strings, strings with special characters, etc.), [helper templates](#helpers) should be preferred. See the `constantGreeting` property or the `favorite-things` list below for examples of how hardcoded values may be defined. + +Here is an example interface definition which can accept the parameters from the [example](#parametersyaml) above: + +```yaml +username: {{ .name.first }} {{ .name.last }} +someColors: +{{- range .colors }} +- {{ . }} +{{- end }} +constantGreeting: Hello, World! +favorite-things: +- Music +- Photography +- Car racing +- Basketball +- Software! +isCustom: {{ .isCustom }} +customObj: {{- index . "custom-object" | toYaml | nindent 2 }} +``` + +Since the interface definition is itself a template, all of the normal template functions are available to be used. See the [templates](#templates) section for more details. + +Once the interface is executed with the provided parameters, it is combined with the package definition to become the input to all other templates. Here is an example of what is provided to all templates if we ran the `kpmktool/example` package with the above interface file and the parameters from the [parameters example](#parametersyaml): + +```yaml +package: + name: kpmtool/example + version: 1.0.0 +values: + username: Mr. FooBar + someColors: + - red + - green + - blue + constantGreeting: Hello, World! + favorite-things: + - Music + - Photography + - Car racing + - Basketball + - Software! + isCustom: true + customObj: + hello: world! + other: + - is + - my + - true + - custom: object +``` + +This is why all templates in the package (other than the interface) need to reference the ".values" object to get the values supplied by the interface. + +## `templates/` + +Files in the templates directory are the text templates which will be used to generate the output files. These can be used to generate any text format with any filename. + +Here is an example of a template file which generates a text file by using values provided by the [interface example](#interfaceyaml) above: + +```sh +Hello, {{ .values.username }}! + +Are you enjoying KPM? Let me know if you have any issues: https://github.com/rohitramu/kpm/issues + +You can iterate over an array like this: +{{- range .values.someColors }} + - {{ . }} +{{- end }} + +Wondering how to access values that have special characters in their names? Here is a list of my favorite things: +{{- range $thing := (index .values "favorite-things") }} + - {{ $thing }} +{{- end }} + +Maybe you'd like to indent some text? Here you go (indented by 2 spaces): {{- include "nesting helper" . | nindent 2 }} + +If you want to see an example of a template which generates yaml output, take a look at the "object.yaml" file in the templates folder! + +Hopefully these examples gave you an idea of how you can use KPM to create template packages which generate output files in any format, potentially using fairly complex logic :). +``` + +And here is one more example which outputs a YAML file: + +```yaml +# object.yaml +configuration: + package-name: {{ .package.name }} + colors: {{- include "colors helper" . | trim | nindent 2 }} + your-name: {{ .values.username }} + {{- if .values.isCustom }} + custom: + your-object: {{- .values.customObj | toYaml | trim | nindent 6 }} + {{- end }} +``` + +## `helpers/` + +Helper templates (a.k.a. "named templates" or "partial templates") allow the sharing of logic between templates in the package. If you find yourself copying and pasting parts of templates, defining helper templates will allow you to simplify your templates and reduce the likelihood of copy-paste errors. + +Helper templates can be inserted by using either the [`template` action or the `include` function](template_logic.md#include). + +A helper template file may contain any number of helper templates, and must have the extension ".tpl". Here is an example helper template file: + +```sh +{{- define "my helper template" -}} +This is my helper template! My username is {{ .values.username }}. +{{- end -}} + + +{{- define "my yaml colors helper" -}} +colors: +{{- range .values.colors }} +- {{ . }} +{{- end }} +{{- end -}} +``` + +These helpers may be used in other templates like this: + +```yaml +message: {{ include "my helper template" . }} +list: {{- include "my yaml colors helper" . | trim | nindent 2 }} +``` + +## `dependencies/` + +Dependency definitions are references to other template packages. A package dependency must contain both the package information (i.e. package name and version) and the parameters to send to that package. + +```yaml +# First, define the package reference +package: + name: kpmtool/helloworld + version: 1.0.0 + +# Next, specify the parameters to send to that package +parameters: + myName: Rohit +``` + +Since dependency definitions are templates themselves, the parameters to send to the referenced package can be quite flexible. The package reference itself can change based on the parameters provided to the parent template! + +```yaml +package: +{{- if .values.sayHello }} + name: kpmtool/helloworld + version: 1.0.0 +{{- else }} + name: kpmtool/example + version: {{ .values.exampleVersion }} +{{- end }} + +parameters: +{{- if not .values.useDefaults }} + colors: {{- .values.colors | toYaml | nindent 2 }} +{{- end }} +``` diff --git a/docs/authoring_packages/template_logic.md b/docs/authoring_packages/template_logic.md new file mode 100644 index 0000000..771c8d1 --- /dev/null +++ b/docs/authoring_packages/template_logic.md @@ -0,0 +1,175 @@ +# Template functions and logic + +There are many powerful functions and control statements that can be used to transform data within templates, in order to produce the desired output. This page will give you an overview of how you can use them to create your own templates. + +- [Golang templating](#golang-templating) +- [Controlling whitespace](#controlling-whitespace) +- [Conditionals](#conditionals) +- [Loops](#loops) +- [Sprig functions](#sprig-functions) +- [Commonly useful template functions](#commonly-useful-template-functions) + - [`index`](#index) + - [`include`](#include) + - [`indent` vs. `nindent`](#indent-vs-nindent) + +## Golang templating + +KPM uses Golang templating. More information about defining and using templates can be found in the official [Golang template docs](https://golang.org/pkg/text/template/). + +## Controlling whitespace + +Controlling whitespace in certain types of files can be very important. + +One example is YAML, where properties are defined on objects by indenting them. In this case, producing incorrect indentation would lead to an incorrect definition of objects. + +Thanks to [Golang templating](#golang-templating), whitespace may be controlled using special syntax when inserting placeholders in templates: + +```yaml +# This will result in the string "hello world" being indented + {{ "hello" }} {{ "world" }} + +# This will result in the string "hello world" being left-justified (i.e. not indented at all) + {{- "hello" }} {{ "world" }} + +# This will result in the string "hello" being indented, and "world" being inserted without +# the spaces or new line after "hello" (i.e. it would become the string " helloworld") + {{ "hello" -}} + {{ "world" }} +``` + +The dash (`-`) character after the start of the placeholder (`{{`) or before the end of the placeholder (`}}`) tells the renderer to remove any whitespace to the left or right before inserting the value. This trims all whitespace, including **spaces, tabs and new lines**. + +## Conditionals + +Conditional generation of output is done using if-else statements: + +```sh +{{- if .values.show -}} +This text will only appear if the ".values.show" boolean property is set to true. +{{- end -}} +``` + +Multiple conditions can be checked, and you can also specify default behavior if all conditions fail: + +```sh +{{- if (eq .values.color "green") -}} +Go! +{{- else if (eq .values.color "red") -}} +Stop! +{{- else -}} +Caution... +{{- end -}} +``` + +The "with" action is useful when you need to check for whether a property has been defined/supplied: + +```sh +{{- with .values.myProperty }} +This will only appear if ".values.myProperty" has been set. Its value is: {{ . }} +{{- end }} +``` + +The value retrieved by "with" may also be assigned to a variable: + +```sh +{{- with $myProperty := .values.myProperty }} +Congratulations, you set your variable to "{{ $myProperty }}"! +{{- end }} +``` + +## Loops + +We can iterate over items in an array with the "range" action: + +```sh +{{- range .values.myArray }} +- {{ . }} +{{- end }} +``` + +Each item in the array can be assigned to a variable as well. This is useful when the items are objects rather than value types: + +```sh +{{- range $myObject := .values.myObjectArray }} +- I have both {{ $myObject.property1 }} and {{ $myObject.property2 }}! +{{- end }} +``` + +## Sprig functions + +Sprig is a large library of useful template functions. Sprig functions are available for use inside all templates in a template package, including the [interface definition](package_files.md#interfaceyaml), [helper templates](package_files.md#helpers) and [dependency definitions](package_files.md#dependencies). + +- Documentation: +- GitHub: + +## Commonly useful template functions + +### `index` + +It is very difficult to reference parameters which have special characters in their name, for example `my-property`. The dash character (`-`) will break the "dot notation", so the following statement will fail: + +```yaml +# This fails because dot notation does not handle special characters, e.g. dashes +{{ .values.my-property }} +``` + +The "index" function comes to the rescue! + +```yaml +# We can reference any property, even if it has a weird name +{{ index .values "my-property" }} +``` + +The index function actually takes a list of keys, so this can be used to access a property at any depth: + +```yaml +# We can reference properties at any depth +{{ index .values.myObject "my-weirdly-named-object" "inner-property" }} +``` + +The index function returns the property as-is, so you can continue to manipulate it afterwards: + +```yaml +# We can continue manipulating the result object from the index function +{{ (index .values.myObject "my-weirdly-named-object") | toYaml | trim | indent 2 }} +``` + +### `include` + +The `template` action can be used for inserting helper templates. + +```yaml +# This will execute and insert the helper template's output as-is, and won't let you further manipulate it +{{ template "my helper template" . }} +``` + +However, since it does not return the helper template's output as a string, transforming it before inserting it is not possible. The `include` function solves this problem by executing the helper template and then returning the result as a string (rather than immediately inserting it in the document as-is). + +```yaml +# This will execute the helper template, and then allow you to do things like trim whitespace and add indentation (in this case 4 spaces of indentation) +{{ include "my helper template" . | trim | indent 4 }} + +# You can even define your helper template as YAML, and then convert it into an object! +{{ index (include "my helper template" . | fromYaml) "myPropertyInsideHelperTemplate" }} +``` + +### `indent` vs. `nindent` + +The `indent` function is used to indent all lines of a string by the given number of spaces. This is very useful in files where whitespace and indenting is important, however it can lead to templates which are difficult to read, since the placeholder needs to be left-justified and placed on a new line: + +```yaml +myObject: + myNestedObject: +{{ include "my helper template" . | indent 4 }} + anotherNestedObject: + foo: bar +``` + +The [Sprig library](#sprig-functions) provides a `nindent` function which adds the new line for you before indenting the string. This makes it much easier to read the template definition: + +```yaml +myObject: + myNestedObject: {{- include "my helper template" . | nindent 4 }} + anotherNestedObject: + foo: bar +``` diff --git a/docs/examples/README.md b/docs/examples/README.md new file mode 100644 index 0000000..33d048b --- /dev/null +++ b/docs/examples/README.md @@ -0,0 +1,7 @@ +# Examples + +This folder contains some examples of how KPM could be used in specific scenarios. You may be able to use one of these as a starting point for your own use-case! + +- [Customizable markdown document](#customizable-markdown-document) + +## Customizable markdown document diff --git a/docs/using_packages/README.md b/docs/using_packages/README.md new file mode 100644 index 0000000..c75da69 --- /dev/null +++ b/docs/using_packages/README.md @@ -0,0 +1,69 @@ +# Using template packages + +- [What is a template package?](#what-is-a-template-package) +- [List the locally available template packages](#list-the-locally-available-template-packages) +- [Create a parameters file](#create-a-parameters-file) +- [The `view` subcommand](#the-view-subcommand) +- [Execute a template package](#execute-a-template-package) + +## What is a template package? + +A template package is simply a collection of templates. This collection of templates can be thought of as a program or function which can be executed. A template package accepts inputs in the form of parameters, and produces outputs in the form of generated files. + +Usage of a template package typically consists of these steps: + +1. [Create a parameters file](#create-a-parameters-file) which can be used as input to the template package. +1. [Run the template package](#execute-a-template-package) with your parameters file. +1. View your generated files! + +## List the locally available template packages + +To see the list of all template packages in the local KPM repository, run the "list" subcommand: + +```sh +kpm ls +``` + +## Create a parameters file + +A parameters file is just a YAML file containing the input values to a template package. The structure of this parameters file is determined by the [interface](../authoring_packages/package_files.md#interfaceyaml) of the package that you would like to execute. + +Looking at the [default parameters file](../authoring_packages/package_files.md#parametersyaml) is a great way to understand the expected structure of your parameters file, because: + +- All parameters must have default values. +- Package authors are encouraged to add documentation about their package in this file (as comments). + +To see the default parameters file for a package, use the ["view" subcommand](#the-view-subcommand). + +## The `view` subcommand + +The default parameters file is provided by package authors to specify default values for parameters that the user's parameters file does not set. The default parameters file is also used to document the template package. Most importantly, explanations of how to set each parameter should be included in this file by the package author. + +Users may find it useful to view the default parameters file in order to gain a better understanding of how the template package works. The "view" command can print out the default parameters file for any template package which is available in your local KPM repository: + +```sh +kpm view kpmtool/example -v 1.0.0 +``` + +If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](../authoring_packages/README.md#pack-your-template-package)) will be used. + +## Execute a template package + +Execute a template package with the "run" subcommand: + +```sh +// Pull the package if you haven't already +kpm pull kpmtool/example -v 1.0.0 + +// Run the package with default parameters +kpm run kpmtool/example -v 1.0.0 + +// Run the package with custom parameters +kpm run kpmtool/example -v 1.0.0 -f my_params.yaml +``` + +If a version is not specified, the highest available version which is in the local KPM repository (i.e. one that has already been [packed](../authoring_packages/README.md#pack-your-template-package)) will be used. + +If an output directory is not specified with the `--output-dir` flag, files will be generated in `/.kpm_generated/`. + +If an output name is not specified with the `--output-name` flag, `-` will be used as the output name. diff --git a/main.go b/main.go index 72b671d..32effd9 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main import ( - "github.com/rohitramu/kpm/cli" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/pkg/utils/log" "runtime/debug" "strconv" diff --git a/package_files.md b/package_files.md new file mode 100644 index 0000000..e69de29 diff --git a/cli/cli.go b/src/cli/cli.go similarity index 66% rename from cli/cli.go rename to src/cli/cli.go index 6b2d973..8e16108 100644 --- a/cli/cli.go +++ b/src/cli/cli.go @@ -3,9 +3,9 @@ package cli import ( "fmt" - "github.com/rohitramu/kpm/cli/implementation/cli_cobra" - "github.com/rohitramu/kpm/cli/model/commands" - "github.com/rohitramu/kpm/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/implementation/cli_cobra" + "github.com/rohitramu/kpm/src/cli/model/commands" + "github.com/rohitramu/kpm/src/cli/model/utils/config" ) func Execute() (err error) { diff --git a/cli/implementation/cli_cobra/generator.go b/src/cli/implementation/cli_cobra/generator.go similarity index 96% rename from cli/implementation/cli_cobra/generator.go rename to src/cli/implementation/cli_cobra/generator.go index 1cacedc..9042e17 100644 --- a/cli/implementation/cli_cobra/generator.go +++ b/src/cli/implementation/cli_cobra/generator.go @@ -7,9 +7,9 @@ import ( "github.com/emirpasic/gods/stacks/linkedliststack" "github.com/spf13/cobra" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) type ExecuteRootCommand func() error diff --git a/cli/model/args/package_directory.go b/src/cli/model/args/package_directory.go similarity index 71% rename from cli/model/args/package_directory.go rename to src/cli/model/args/package_directory.go index b7d080b..c30805c 100644 --- a/cli/model/args/package_directory.go +++ b/src/cli/model/args/package_directory.go @@ -1,8 +1,8 @@ package args import ( - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) func PackageDirectory(shortDescription string) *types.Arg { diff --git a/cli/model/args/package_name.go b/src/cli/model/args/package_name.go similarity index 79% rename from cli/model/args/package_name.go rename to src/cli/model/args/package_name.go index f6d71a7..8a0dedb 100644 --- a/cli/model/args/package_name.go +++ b/src/cli/model/args/package_name.go @@ -1,8 +1,8 @@ package args import ( - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) func PackageName(shortDescription string) *types.Arg { diff --git a/cli/model/args/package_version.go b/src/cli/model/args/package_version.go similarity index 71% rename from cli/model/args/package_version.go rename to src/cli/model/args/package_version.go index 1d5df1a..dead444 100644 --- a/cli/model/args/package_version.go +++ b/src/cli/model/args/package_version.go @@ -1,8 +1,8 @@ package args import ( - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) func PackageVersion(shortDescription string) *types.Arg { diff --git a/cli/model/args/search_term.go b/src/cli/model/args/search_term.go similarity index 70% rename from cli/model/args/search_term.go rename to src/cli/model/args/search_term.go index 0d2ff77..af5b492 100644 --- a/cli/model/args/search_term.go +++ b/src/cli/model/args/search_term.go @@ -1,8 +1,8 @@ package args import ( - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) func SearchTerm(shortDescription string) *types.Arg { diff --git a/cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go similarity index 74% rename from cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go rename to src/cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go index 63135c8..8717321 100644 --- a/cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go +++ b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/find.go @@ -1,15 +1,15 @@ package cmd_kpm_repo import ( - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) var FindCmd = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go similarity index 65% rename from cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go rename to src/cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go index e1ee5ca..f42746a 100644 --- a/cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go +++ b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/list.go @@ -1,11 +1,11 @@ package cmd_kpm_repo import ( - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var ListCmd = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go similarity index 83% rename from cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go rename to src/cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go index da6906e..a10c4ce 100644 --- a/cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go +++ b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/pull.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/template_repository" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/template_repository" ) var PullCmd = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go similarity index 80% rename from cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go rename to src/cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go index 79e9063..5c5c928 100644 --- a/cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go +++ b/src/cli/model/commands/cmd_kpm/cmd_kpm_repo/push.go @@ -3,13 +3,13 @@ package cmd_kpm_repo import ( "errors" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" ) var PushCmd = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/inspect.go b/src/cli/model/commands/cmd_kpm/inspect.go similarity index 77% rename from cli/model/commands/cmd_kpm/inspect.go rename to src/cli/model/commands/cmd_kpm/inspect.go index 9e32cef..a947089 100644 --- a/cli/model/commands/cmd_kpm/inspect.go +++ b/src/cli/model/commands/cmd_kpm/inspect.go @@ -3,14 +3,14 @@ package cmd_kpm import ( "fmt" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) var Inspect = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/list.go b/src/cli/model/commands/cmd_kpm/list.go similarity index 71% rename from cli/model/commands/cmd_kpm/list.go rename to src/cli/model/commands/cmd_kpm/list.go index 86ea99d..7d089a6 100644 --- a/cli/model/commands/cmd_kpm/list.go +++ b/src/cli/model/commands/cmd_kpm/list.go @@ -1,13 +1,13 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var List = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/new.go b/src/cli/model/commands/cmd_kpm/new.go similarity index 73% rename from cli/model/commands/cmd_kpm/new.go rename to src/cli/model/commands/cmd_kpm/new.go index 656a2c0..5f35573 100644 --- a/cli/model/commands/cmd_kpm/new.go +++ b/src/cli/model/commands/cmd_kpm/new.go @@ -1,12 +1,12 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" ) var New = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/pack.go b/src/cli/model/commands/cmd_kpm/pack.go similarity index 71% rename from cli/model/commands/cmd_kpm/pack.go rename to src/cli/model/commands/cmd_kpm/pack.go index 13b93c3..9539290 100644 --- a/cli/model/commands/cmd_kpm/pack.go +++ b/src/cli/model/commands/cmd_kpm/pack.go @@ -1,13 +1,13 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" ) var Pack = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/purge.go b/src/cli/model/commands/cmd_kpm/purge.go similarity index 71% rename from cli/model/commands/cmd_kpm/purge.go rename to src/cli/model/commands/cmd_kpm/purge.go index b560908..0b3add6 100644 --- a/cli/model/commands/cmd_kpm/purge.go +++ b/src/cli/model/commands/cmd_kpm/purge.go @@ -1,13 +1,13 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" ) var Purge = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/remove.go b/src/cli/model/commands/cmd_kpm/remove.go similarity index 78% rename from cli/model/commands/cmd_kpm/remove.go rename to src/cli/model/commands/cmd_kpm/remove.go index 19fe435..198728b 100644 --- a/cli/model/commands/cmd_kpm/remove.go +++ b/src/cli/model/commands/cmd_kpm/remove.go @@ -3,14 +3,14 @@ package cmd_kpm import ( "fmt" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) var Remove = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/repo.go b/src/cli/model/commands/cmd_kpm/repo.go similarity index 64% rename from cli/model/commands/cmd_kpm/repo.go rename to src/cli/model/commands/cmd_kpm/repo.go index c236496..225de83 100644 --- a/cli/model/commands/cmd_kpm/repo.go +++ b/src/cli/model/commands/cmd_kpm/repo.go @@ -1,9 +1,9 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/commands/cmd_kpm/cmd_kpm_repo" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/commands/cmd_kpm/cmd_kpm_repo" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var Repo = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/run.go b/src/cli/model/commands/cmd_kpm/run.go similarity index 83% rename from cli/model/commands/cmd_kpm/run.go rename to src/cli/model/commands/cmd_kpm/run.go index 050ea89..8526505 100644 --- a/cli/model/commands/cmd_kpm/run.go +++ b/src/cli/model/commands/cmd_kpm/run.go @@ -3,14 +3,14 @@ package cmd_kpm import ( "fmt" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) var Run = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/unpack.go b/src/cli/model/commands/cmd_kpm/unpack.go similarity index 82% rename from cli/model/commands/cmd_kpm/unpack.go rename to src/cli/model/commands/cmd_kpm/unpack.go index f5929ee..891ab1e 100644 --- a/cli/model/commands/cmd_kpm/unpack.go +++ b/src/cli/model/commands/cmd_kpm/unpack.go @@ -3,14 +3,14 @@ package cmd_kpm import ( "fmt" - "github.com/rohitramu/kpm/cli/model/args" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/args" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) var Unpack = &types.Command{ diff --git a/cli/model/commands/cmd_kpm/version.go b/src/cli/model/commands/cmd_kpm/version.go similarity index 69% rename from cli/model/commands/cmd_kpm/version.go rename to src/cli/model/commands/cmd_kpm/version.go index 0d4fe25..28856b5 100644 --- a/cli/model/commands/cmd_kpm/version.go +++ b/src/cli/model/commands/cmd_kpm/version.go @@ -1,10 +1,10 @@ package cmd_kpm import ( - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var Version = &types.Command{ diff --git a/cli/model/commands/kpm.go b/src/cli/model/commands/kpm.go similarity index 63% rename from cli/model/commands/kpm.go rename to src/cli/model/commands/kpm.go index d624572..ae73a9f 100644 --- a/cli/model/commands/kpm.go +++ b/src/cli/model/commands/kpm.go @@ -1,10 +1,10 @@ package commands import ( - "github.com/rohitramu/kpm/cli/model/commands/cmd_kpm" - "github.com/rohitramu/kpm/cli/model/flags" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/commands/cmd_kpm" + "github.com/rohitramu/kpm/src/cli/model/flags" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var Kpm = &types.Command{ diff --git a/cli/model/flags/export_dir.go b/src/cli/model/flags/export_dir.go similarity index 76% rename from cli/model/flags/export_dir.go rename to src/cli/model/flags/export_dir.go index edd82b2..a99e497 100644 --- a/cli/model/flags/export_dir.go +++ b/src/cli/model/flags/export_dir.go @@ -3,9 +3,9 @@ package flags import ( "fmt" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var ExportDir = types.NewFlagBuilder[string]("export-dir"). diff --git a/cli/model/flags/export_name.go b/src/cli/model/flags/export_name.go similarity index 80% rename from cli/model/flags/export_name.go rename to src/cli/model/flags/export_name.go index 60d4376..2cc1cbd 100644 --- a/cli/model/flags/export_name.go +++ b/src/cli/model/flags/export_name.go @@ -1,7 +1,7 @@ package flags import ( - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var ExportName = types.NewFlagBuilder[string]("export-name"). diff --git a/cli/model/flags/flags.go b/src/cli/model/flags/flags.go similarity index 71% rename from cli/model/flags/flags.go rename to src/cli/model/flags/flags.go index 6bb3022..483c019 100644 --- a/cli/model/flags/flags.go +++ b/src/cli/model/flags/flags.go @@ -1,9 +1,9 @@ package flags import ( - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var LogLevel = types.NewFlagBuilder[string]("log-level"). diff --git a/cli/model/flags/new_package_output_dir.go b/src/cli/model/flags/new_package_output_dir.go similarity index 71% rename from cli/model/flags/new_package_output_dir.go rename to src/cli/model/flags/new_package_output_dir.go index cf299a6..b39fa36 100644 --- a/cli/model/flags/new_package_output_dir.go +++ b/src/cli/model/flags/new_package_output_dir.go @@ -3,11 +3,11 @@ package flags import ( "fmt" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var NewPackageOutputDir = types.NewFlagBuilder[string]("output-dir"). diff --git a/cli/model/flags/output_dir.go b/src/cli/model/flags/output_dir.go similarity index 70% rename from cli/model/flags/output_dir.go rename to src/cli/model/flags/output_dir.go index dba075c..bc2136d 100644 --- a/cli/model/flags/output_dir.go +++ b/src/cli/model/flags/output_dir.go @@ -3,11 +3,11 @@ package flags import ( "fmt" - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) var OutputDir = types.NewFlagBuilder[string]("output-dir"). diff --git a/cli/model/flags/output_name.go b/src/cli/model/flags/output_name.go similarity index 79% rename from cli/model/flags/output_name.go rename to src/cli/model/flags/output_name.go index 000af84..beb922d 100644 --- a/cli/model/flags/output_name.go +++ b/src/cli/model/flags/output_name.go @@ -1,7 +1,7 @@ package flags import ( - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var OutputName = types.NewFlagBuilder[string]("output-name"). diff --git a/cli/model/flags/parameters_file.go b/src/cli/model/flags/parameters_file.go similarity index 77% rename from cli/model/flags/parameters_file.go rename to src/cli/model/flags/parameters_file.go index bd76819..f8fb1ee 100644 --- a/cli/model/flags/parameters_file.go +++ b/src/cli/model/flags/parameters_file.go @@ -1,7 +1,7 @@ package flags import ( - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var ParametersFile = types.NewFlagBuilder[string]("parameters-file"). diff --git a/cli/model/flags/repo_name.go b/src/cli/model/flags/repo_name.go similarity index 75% rename from cli/model/flags/repo_name.go rename to src/cli/model/flags/repo_name.go index f8b16e3..434e296 100644 --- a/cli/model/flags/repo_name.go +++ b/src/cli/model/flags/repo_name.go @@ -3,8 +3,8 @@ package flags import ( "fmt" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var RepoName = types.NewFlagBuilder[string]("repo"). diff --git a/cli/model/flags/user_confirmation.go b/src/cli/model/flags/user_confirmation.go similarity index 68% rename from cli/model/flags/user_confirmation.go rename to src/cli/model/flags/user_confirmation.go index dce8585..5dffbf3 100644 --- a/cli/model/flags/user_confirmation.go +++ b/src/cli/model/flags/user_confirmation.go @@ -1,8 +1,8 @@ package flags import ( - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/cli/model/utils/types" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/types" ) var UserConfirmation = types.NewFlagBuilder[bool]("confirm"). diff --git a/cli/model/flags/validation.go b/src/cli/model/flags/validation.go similarity index 94% rename from cli/model/flags/validation.go rename to src/cli/model/flags/validation.go index 8240ff0..537972a 100644 --- a/cli/model/flags/validation.go +++ b/src/cli/model/flags/validation.go @@ -3,8 +3,8 @@ package flags import ( "fmt" - "github.com/rohitramu/kpm/cli/model/utils/types" - "github.com/rohitramu/kpm/pkg/utils/files" + "github.com/rohitramu/kpm/src/cli/model/utils/types" + "github.com/rohitramu/kpm/src/pkg/utils/files" ) func CombineValidationFuncs[T any](flagValidationFuncs ...types.FlagIsValidFunc[T]) types.FlagIsValidFunc[T] { diff --git a/cli/model/utils/config/config.go b/src/cli/model/utils/config/config.go similarity index 91% rename from cli/model/utils/config/config.go rename to src/cli/model/utils/config/config.go index e997256..537341c 100644 --- a/cli/model/utils/config/config.go +++ b/src/cli/model/utils/config/config.go @@ -7,11 +7,11 @@ import ( "github.com/caarlos0/env/v9" "gopkg.in/yaml.v3" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/cli/model/utils/directories" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_repository" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/cli/model/utils/directories" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_repository" ) // TODO: Reduce amount of error wrapping. diff --git a/cli/model/utils/constants/command_names.go b/src/cli/model/utils/constants/command_names.go similarity index 100% rename from cli/model/utils/constants/command_names.go rename to src/cli/model/utils/constants/command_names.go diff --git a/cli/model/utils/constants/config.go b/src/cli/model/utils/constants/config.go similarity index 100% rename from cli/model/utils/constants/config.go rename to src/cli/model/utils/constants/config.go diff --git a/cli/model/utils/constants/directory_names.go b/src/cli/model/utils/constants/directory_names.go similarity index 100% rename from cli/model/utils/constants/directory_names.go rename to src/cli/model/utils/constants/directory_names.go diff --git a/cli/model/utils/constants/version.go b/src/cli/model/utils/constants/version.go similarity index 85% rename from cli/model/utils/constants/version.go rename to src/cli/model/utils/constants/version.go index 61d9b4e..86f3c36 100644 --- a/cli/model/utils/constants/version.go +++ b/src/cli/model/utils/constants/version.go @@ -2,7 +2,7 @@ package constants // The version of the CLI app. // -// Can be set during build: `go build -ldflags="-X 'github.com/rohitramu/kpm/cli/model/utils/constants.VersionString=0.0.0'"` +// Can be set during build: `go build -ldflags="-X 'github.com/rohitramu/kpm/src/cli/model/utils/constants.VersionString=0.0.0'"` var VersionString = "0.0.0" // When this binary was built. diff --git a/cli/model/utils/directories/directories.go b/src/cli/model/utils/directories/directories.go similarity index 92% rename from cli/model/utils/directories/directories.go rename to src/cli/model/utils/directories/directories.go index 6f67baa..15c18d4 100644 --- a/cli/model/utils/directories/directories.go +++ b/src/cli/model/utils/directories/directories.go @@ -6,9 +6,9 @@ import ( "path/filepath" "strings" - "github.com/rohitramu/kpm/cli/model/utils/constants" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/cli/model/utils/constants" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) // GetDefaultOutputDir returns the default path of the root directory for generated files. diff --git a/cli/model/utils/types/arg.go b/src/cli/model/utils/types/arg.go similarity index 100% rename from cli/model/utils/types/arg.go rename to src/cli/model/utils/types/arg.go diff --git a/cli/model/utils/types/command.go b/src/cli/model/utils/types/command.go similarity index 89% rename from cli/model/utils/types/command.go rename to src/cli/model/utils/types/command.go index 88e0dc7..47ce735 100644 --- a/cli/model/utils/types/command.go +++ b/src/cli/model/utils/types/command.go @@ -1,7 +1,7 @@ package types import ( - "github.com/rohitramu/kpm/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/config" ) type CommandExecuteFunc func(config *config.KpmConfig, args ArgCollection) error diff --git a/cli/model/utils/types/flag.go b/src/cli/model/utils/types/flag.go similarity index 96% rename from cli/model/utils/types/flag.go rename to src/cli/model/utils/types/flag.go index aedf03e..ceef8b6 100644 --- a/cli/model/utils/types/flag.go +++ b/src/cli/model/utils/types/flag.go @@ -1,7 +1,7 @@ package types import ( - "github.com/rohitramu/kpm/cli/model/utils/config" + "github.com/rohitramu/kpm/src/cli/model/utils/config" ) type FlagCollection struct { diff --git a/cli/model/utils/types/flag_builder.go b/src/cli/model/utils/types/flag_builder.go similarity index 94% rename from cli/model/utils/types/flag_builder.go rename to src/cli/model/utils/types/flag_builder.go index 140588b..ed2dcd0 100644 --- a/cli/model/utils/types/flag_builder.go +++ b/src/cli/model/utils/types/flag_builder.go @@ -1,8 +1,8 @@ package types import ( - "github.com/rohitramu/kpm/cli/model/utils/config" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/cli/model/utils/config" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) type DefaultValueFunc[T any] func(*config.KpmConfig) T diff --git a/pkg/inspect.go b/src/pkg/inspect.go similarity index 89% rename from pkg/inspect.go rename to src/pkg/inspect.go index 20d024a..255ba38 100644 --- a/pkg/inspect.go +++ b/src/pkg/inspect.go @@ -4,10 +4,10 @@ import ( "fmt" "os" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/validation" "golang.org/x/exp/slices" ) diff --git a/pkg/list.go b/src/pkg/list.go similarity index 83% rename from pkg/list.go rename to src/pkg/list.go index 69ba1d2..90dbd06 100644 --- a/pkg/list.go +++ b/src/pkg/list.go @@ -1,8 +1,8 @@ package pkg import ( - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) // ListCmd lists all packages that are available for use in the given KPM home directory. diff --git a/pkg/new-package.go b/src/pkg/new-package.go similarity index 86% rename from pkg/new-package.go rename to src/pkg/new-package.go index a9f469c..ebf5053 100644 --- a/pkg/new-package.go +++ b/src/pkg/new-package.go @@ -4,9 +4,9 @@ import ( "fmt" "path/filepath" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) func NewTemplatePackageCmd( diff --git a/pkg/pack.go b/src/pkg/pack.go similarity index 91% rename from pkg/pack.go rename to src/pkg/pack.go index 662d60f..80a03c9 100644 --- a/pkg/pack.go +++ b/src/pkg/pack.go @@ -1,9 +1,9 @@ package pkg import ( - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) // PackCmd packs a local template package so it is available for use in the given local KPM repository. diff --git a/pkg/purge.go b/src/pkg/purge.go similarity index 86% rename from pkg/purge.go rename to src/pkg/purge.go index e728663..b09daf0 100644 --- a/pkg/purge.go +++ b/src/pkg/purge.go @@ -3,10 +3,10 @@ package pkg import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/local_package_repo" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/user_prompts" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/local_package_repo" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/user_prompts" ) // PurgeCmd removes all versions of a template package from the local KPM repository. diff --git a/pkg/remove.go b/src/pkg/remove.go similarity index 87% rename from pkg/remove.go rename to src/pkg/remove.go index e4172ea..06f8511 100644 --- a/pkg/remove.go +++ b/src/pkg/remove.go @@ -3,9 +3,9 @@ package pkg import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) // RemoveCmd removes a template package from the local KPM repository. diff --git a/pkg/repo_find.go b/src/pkg/repo_find.go similarity index 84% rename from pkg/repo_find.go rename to src/pkg/repo_find.go index 7680bb7..e9ed9c4 100644 --- a/pkg/repo_find.go +++ b/src/pkg/repo_find.go @@ -3,8 +3,8 @@ package pkg import ( "errors" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/template_repository" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_repository" ) func FindPackages( diff --git a/pkg/repo_list.go b/src/pkg/repo_list.go similarity index 69% rename from pkg/repo_list.go rename to src/pkg/repo_list.go index e5cf97b..b432665 100644 --- a/pkg/repo_list.go +++ b/src/pkg/repo_list.go @@ -1,6 +1,6 @@ package pkg -import "github.com/rohitramu/kpm/pkg/utils/template_repository" +import "github.com/rohitramu/kpm/src/pkg/utils/template_repository" func ListPackageRepositories( repos *template_repository.RepositoryCollection, diff --git a/pkg/repo_pull.go b/src/pkg/repo_pull.go similarity index 91% rename from pkg/repo_pull.go rename to src/pkg/repo_pull.go index 446795d..af0d418 100644 --- a/pkg/repo_pull.go +++ b/src/pkg/repo_pull.go @@ -3,8 +3,8 @@ package pkg import ( "errors" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/template_repository" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_repository" ) func PullPackage( diff --git a/pkg/repo_push.go b/src/pkg/repo_push.go similarity index 85% rename from pkg/repo_push.go rename to src/pkg/repo_push.go index 090e42e..9852fa1 100644 --- a/pkg/repo_push.go +++ b/src/pkg/repo_push.go @@ -3,9 +3,9 @@ package pkg import ( "errors" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/template_repository" - "github.com/rohitramu/kpm/pkg/utils/user_prompts" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_repository" + "github.com/rohitramu/kpm/src/pkg/utils/user_prompts" ) func PushPackage( diff --git a/pkg/run.go b/src/pkg/run.go similarity index 93% rename from pkg/run.go rename to src/pkg/run.go index 5ce2a72..fb5a3fd 100644 --- a/pkg/run.go +++ b/src/pkg/run.go @@ -7,11 +7,11 @@ import ( "strings" "text/template" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/templates" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/templates" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) // RunCmd runs the given template package directory and parameters file, diff --git a/pkg/unpack.go b/src/pkg/unpack.go similarity index 90% rename from pkg/unpack.go rename to src/pkg/unpack.go index b7dea05..fa2f593 100644 --- a/pkg/unpack.go +++ b/src/pkg/unpack.go @@ -5,10 +5,10 @@ import ( "os" "path/filepath" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) // UnpackCmd exports a template package to the specified path. diff --git a/pkg/utils/constants/directory_names.go b/src/pkg/utils/constants/directory_names.go similarity index 100% rename from pkg/utils/constants/directory_names.go rename to src/pkg/utils/constants/directory_names.go diff --git a/pkg/utils/constants/field_names.go b/src/pkg/utils/constants/field_names.go similarity index 100% rename from pkg/utils/constants/field_names.go rename to src/pkg/utils/constants/field_names.go diff --git a/pkg/utils/constants/file_names.go b/src/pkg/utils/constants/file_names.go similarity index 100% rename from pkg/utils/constants/file_names.go rename to src/pkg/utils/constants/file_names.go diff --git a/pkg/utils/docker/get_tags.go b/src/pkg/utils/docker/get_tags.go similarity index 96% rename from pkg/utils/docker/get_tags.go rename to src/pkg/utils/docker/get_tags.go index b08bfa5..4efae9c 100644 --- a/pkg/utils/docker/get_tags.go +++ b/src/pkg/utils/docker/get_tags.go @@ -6,8 +6,8 @@ import ( "net/http" "strings" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) type tagsResponse struct { diff --git a/pkg/utils/docker/get_tags_test.go b/src/pkg/utils/docker/get_tags_test.go similarity index 93% rename from pkg/utils/docker/get_tags_test.go rename to src/pkg/utils/docker/get_tags_test.go index 262785f..c0d040a 100644 --- a/pkg/utils/docker/get_tags_test.go +++ b/src/pkg/utils/docker/get_tags_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" . "github.com/smartystreets/goconvey/convey" ) diff --git a/pkg/utils/docker/image_pull.go b/src/pkg/utils/docker/image_pull.go similarity index 81% rename from pkg/utils/docker/image_pull.go rename to src/pkg/utils/docker/image_pull.go index d80d9ad..a71d5e0 100644 --- a/pkg/utils/docker/image_pull.go +++ b/src/pkg/utils/docker/image_pull.go @@ -3,8 +3,8 @@ package docker import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/exec" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/exec" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // PullImage pulls a Docker image from a remote Docker registry. diff --git a/pkg/utils/docker/image_push.go b/src/pkg/utils/docker/image_push.go similarity index 81% rename from pkg/utils/docker/image_push.go rename to src/pkg/utils/docker/image_push.go index 8e99841..e584fc3 100644 --- a/pkg/utils/docker/image_push.go +++ b/src/pkg/utils/docker/image_push.go @@ -3,8 +3,8 @@ package docker import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/exec" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/exec" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // PushImage pushes a Docker image to a remote Docker registry. diff --git a/pkg/utils/docker/package_build.go b/src/pkg/utils/docker/package_build.go similarity index 84% rename from pkg/utils/docker/package_build.go rename to src/pkg/utils/docker/package_build.go index ed9c751..7fb9fd6 100644 --- a/pkg/utils/docker/package_build.go +++ b/src/pkg/utils/docker/package_build.go @@ -3,8 +3,8 @@ package docker import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/exec" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/exec" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // BuildImage builds a new docker image by making a call to the Docker daemon. diff --git a/pkg/utils/docker/package_delete.go b/src/pkg/utils/docker/package_delete.go similarity index 81% rename from pkg/utils/docker/package_delete.go rename to src/pkg/utils/docker/package_delete.go index 373c074..c2aaee7 100644 --- a/pkg/utils/docker/package_delete.go +++ b/src/pkg/utils/docker/package_delete.go @@ -3,8 +3,8 @@ package docker import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/exec" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/exec" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // DeleteImage deletes a local Docker image. diff --git a/pkg/utils/docker/package_extract.go b/src/pkg/utils/docker/package_extract.go similarity index 95% rename from pkg/utils/docker/package_extract.go rename to src/pkg/utils/docker/package_extract.go index 766bb25..385188f 100644 --- a/pkg/utils/docker/package_extract.go +++ b/src/pkg/utils/docker/package_extract.go @@ -5,9 +5,9 @@ import ( "path/filepath" "strings" - "github.com/rohitramu/kpm/pkg/utils/exec" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/exec" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // ExtractImageContents extracts files and directories from a Docker image, and copies them to the local KPM repository. diff --git a/pkg/utils/docker/utils.go b/src/pkg/utils/docker/utils.go similarity index 94% rename from pkg/utils/docker/utils.go rename to src/pkg/utils/docker/utils.go index 0d86c42..f1c2d37 100644 --- a/pkg/utils/docker/utils.go +++ b/src/pkg/utils/docker/utils.go @@ -5,8 +5,8 @@ import ( "path/filepath" "strings" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // DefaultDockerRegistry is the default registry to use (Docker Hub). diff --git a/pkg/utils/exec/exec.go b/src/pkg/utils/exec/exec.go similarity index 91% rename from pkg/utils/exec/exec.go rename to src/pkg/utils/exec/exec.go index 3d7889d..6fd43e6 100644 --- a/pkg/utils/exec/exec.go +++ b/src/pkg/utils/exec/exec.go @@ -4,7 +4,7 @@ import ( "os/exec" "strings" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // Exec runs a command on the command line. diff --git a/pkg/utils/files/files.go b/src/pkg/utils/files/files.go similarity index 98% rename from pkg/utils/files/files.go rename to src/pkg/utils/files/files.go index 662de32..e6d79b7 100644 --- a/pkg/utils/files/files.go +++ b/src/pkg/utils/files/files.go @@ -11,8 +11,8 @@ import ( "github.com/otiai10/copy" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/user_prompts" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/user_prompts" ) // GetWorkingDir returns the current working directory. diff --git a/pkg/utils/local_package_repo/utils.go b/src/pkg/utils/local_package_repo/utils.go similarity index 97% rename from pkg/utils/local_package_repo/utils.go rename to src/pkg/utils/local_package_repo/utils.go index e846bdb..cec7693 100644 --- a/pkg/utils/local_package_repo/utils.go +++ b/src/pkg/utils/local_package_repo/utils.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" "golang.org/x/exp/maps" ) diff --git a/pkg/utils/log/log.go b/src/pkg/utils/log/log.go similarity index 100% rename from pkg/utils/log/log.go rename to src/pkg/utils/log/log.go diff --git a/pkg/utils/template_package/dependency_tree.go b/src/pkg/utils/template_package/dependency_tree.go similarity index 98% rename from pkg/utils/template_package/dependency_tree.go rename to src/pkg/utils/template_package/dependency_tree.go index c3b74a1..796d82f 100644 --- a/pkg/utils/template_package/dependency_tree.go +++ b/src/pkg/utils/template_package/dependency_tree.go @@ -11,10 +11,10 @@ import ( "github.com/emirpasic/gods/stacks/linkedliststack" "golang.org/x/exp/slices" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/templates" - "github.com/rohitramu/kpm/pkg/utils/validation" - "github.com/rohitramu/kpm/pkg/utils/yaml" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/templates" + "github.com/rohitramu/kpm/src/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/yaml" ) // DependencyTree is the definition of the package dependency tree. diff --git a/pkg/utils/template_package/directories.go b/src/pkg/utils/template_package/directories.go similarity index 95% rename from pkg/utils/template_package/directories.go rename to src/pkg/utils/template_package/directories.go index 9f3bd02..87da1bd 100644 --- a/pkg/utils/template_package/directories.go +++ b/src/pkg/utils/template_package/directories.go @@ -3,8 +3,8 @@ package template_package import ( "path/filepath" - "github.com/rohitramu/kpm/pkg/utils/constants" - "github.com/rohitramu/kpm/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/constants" + "github.com/rohitramu/kpm/src/pkg/utils/files" ) func CreateFilesystemRepoDir(repoAbsPath string, lowercaseHumanFriendlyName string, userHasConfirmed bool) (err error) { diff --git a/pkg/utils/template_package/files.go b/src/pkg/utils/template_package/files.go similarity index 98% rename from pkg/utils/template_package/files.go rename to src/pkg/utils/template_package/files.go index 228da10..a64780e 100644 --- a/pkg/utils/template_package/files.go +++ b/src/pkg/utils/template_package/files.go @@ -9,12 +9,12 @@ import ( "github.com/emirpasic/gods/sets/treeset" - "github.com/rohitramu/kpm/pkg/utils/constants" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/templates" - "github.com/rohitramu/kpm/pkg/utils/validation" - "github.com/rohitramu/kpm/pkg/utils/yaml" + "github.com/rohitramu/kpm/src/pkg/utils/constants" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/templates" + "github.com/rohitramu/kpm/src/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/yaml" ) // TODO: Move repo-specific methods to the "template_repository" package. diff --git a/pkg/utils/template_package/generate_sample_package.go b/src/pkg/utils/template_package/generate_sample_package.go similarity index 93% rename from pkg/utils/template_package/generate_sample_package.go rename to src/pkg/utils/template_package/generate_sample_package.go index af28454..d4f93c5 100644 --- a/pkg/utils/template_package/generate_sample_package.go +++ b/src/pkg/utils/template_package/generate_sample_package.go @@ -6,9 +6,9 @@ import ( "path" "regexp" - "github.com/rohitramu/kpm/pkg/utils/constants" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/constants" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" "golang.org/x/exp/maps" ) @@ -79,7 +79,7 @@ Are you enjoying KPM? Let me know if you have any issues: https://github.com/rohitramu/kpm/issues Kind regards, -Rohit (creator of KPM) +Rohit `, "hello.txt"), }, } diff --git a/pkg/utils/template_package/name_and_version.go b/src/pkg/utils/template_package/name_and_version.go similarity index 98% rename from pkg/utils/template_package/name_and_version.go rename to src/pkg/utils/template_package/name_and_version.go index bed172b..c4a2508 100644 --- a/pkg/utils/template_package/name_and_version.go +++ b/src/pkg/utils/template_package/name_and_version.go @@ -3,7 +3,7 @@ package template_package import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/validation" + "github.com/rohitramu/kpm/src/pkg/utils/validation" ) // PackageNamesAndVersions is the mapping of package names to its list of versions. diff --git a/pkg/utils/template_package/template_package.go b/src/pkg/utils/template_package/template_package.go similarity index 100% rename from pkg/utils/template_package/template_package.go rename to src/pkg/utils/template_package/template_package.go diff --git a/pkg/utils/template_repository/errors_package_not_found.go b/src/pkg/utils/template_repository/errors_package_not_found.go similarity index 89% rename from pkg/utils/template_repository/errors_package_not_found.go rename to src/pkg/utils/template_repository/errors_package_not_found.go index b78faf7..9b4ba07 100644 --- a/pkg/utils/template_repository/errors_package_not_found.go +++ b/src/pkg/utils/template_repository/errors_package_not_found.go @@ -3,7 +3,7 @@ package template_repository import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) type ErrPackageNotFoundType struct { diff --git a/pkg/utils/template_repository/repo_types_docker.go b/src/pkg/utils/template_repository/repo_types_docker.go similarity index 93% rename from pkg/utils/template_repository/repo_types_docker.go rename to src/pkg/utils/template_repository/repo_types_docker.go index 4b7801d..1e3dadc 100644 --- a/pkg/utils/template_repository/repo_types_docker.go +++ b/src/pkg/utils/template_repository/repo_types_docker.go @@ -3,8 +3,8 @@ package template_repository import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/docker" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/docker" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) // TODO: Implement Docker repository support. diff --git a/pkg/utils/template_repository/repo_types_filesystem.go b/src/pkg/utils/template_repository/repo_types_filesystem.go similarity index 96% rename from pkg/utils/template_repository/repo_types_filesystem.go rename to src/pkg/utils/template_repository/repo_types_filesystem.go index 0a2322e..0ae96f1 100644 --- a/pkg/utils/template_repository/repo_types_filesystem.go +++ b/src/pkg/utils/template_repository/repo_types_filesystem.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) const repositoryTypeNameFilesystem = "filesystem" diff --git a/pkg/utils/template_repository/types_repository.go b/src/pkg/utils/template_repository/types_repository.go similarity index 93% rename from pkg/utils/template_repository/types_repository.go rename to src/pkg/utils/template_repository/types_repository.go index 38d8c36..db6baf1 100644 --- a/pkg/utils/template_repository/types_repository.go +++ b/src/pkg/utils/template_repository/types_repository.go @@ -3,7 +3,7 @@ package template_repository import ( "fmt" - "github.com/rohitramu/kpm/pkg/utils/template_package" + "github.com/rohitramu/kpm/src/pkg/utils/template_package" ) // TODO: Add a repo type for git. diff --git a/pkg/utils/template_repository/types_repository_collection.go b/src/pkg/utils/template_repository/types_repository_collection.go similarity index 98% rename from pkg/utils/template_repository/types_repository_collection.go rename to src/pkg/utils/template_repository/types_repository_collection.go index 57abef2..9ad371a 100644 --- a/pkg/utils/template_repository/types_repository_collection.go +++ b/src/pkg/utils/template_repository/types_repository_collection.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/emirpasic/gods/maps/linkedhashmap" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" "gopkg.in/yaml.v3" ) diff --git a/pkg/utils/template_repository/types_repository_info.go b/src/pkg/utils/template_repository/types_repository_info.go similarity index 100% rename from pkg/utils/template_repository/types_repository_info.go rename to src/pkg/utils/template_repository/types_repository_info.go diff --git a/pkg/utils/templates/globalfunc.go b/src/pkg/utils/templates/globalfunc.go similarity index 100% rename from pkg/utils/templates/globalfunc.go rename to src/pkg/utils/templates/globalfunc.go diff --git a/pkg/utils/templates/globalfunc_index.go b/src/pkg/utils/templates/globalfunc_index.go similarity index 100% rename from pkg/utils/templates/globalfunc_index.go rename to src/pkg/utils/templates/globalfunc_index.go diff --git a/pkg/utils/templates/globalfunc_yaml.go b/src/pkg/utils/templates/globalfunc_yaml.go similarity index 94% rename from pkg/utils/templates/globalfunc_yaml.go rename to src/pkg/utils/templates/globalfunc_yaml.go index 26449bf..d5b1686 100644 --- a/pkg/utils/templates/globalfunc_yaml.go +++ b/src/pkg/utils/templates/globalfunc_yaml.go @@ -1,7 +1,7 @@ package templates import ( - "github.com/rohitramu/kpm/pkg/utils/yaml" + "github.com/rohitramu/kpm/src/pkg/utils/yaml" ) // FuncNameToYaml is the name of the template function which converts objects to yaml strings. diff --git a/pkg/utils/templates/packagefunc.go b/src/pkg/utils/templates/packagefunc.go similarity index 100% rename from pkg/utils/templates/packagefunc.go rename to src/pkg/utils/templates/packagefunc.go diff --git a/pkg/utils/templates/packagefunc_include.go b/src/pkg/utils/templates/packagefunc_include.go similarity index 94% rename from pkg/utils/templates/packagefunc_include.go rename to src/pkg/utils/templates/packagefunc_include.go index c718df1..381f720 100644 --- a/pkg/utils/templates/packagefunc_include.go +++ b/src/pkg/utils/templates/packagefunc_include.go @@ -4,7 +4,7 @@ import ( "fmt" "text/template" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // FuncNameInclude is the name of the "include" template function. diff --git a/pkg/utils/templates/templates.go b/src/pkg/utils/templates/templates.go similarity index 98% rename from pkg/utils/templates/templates.go rename to src/pkg/utils/templates/templates.go index 6092079..6caeb21 100644 --- a/pkg/utils/templates/templates.go +++ b/src/pkg/utils/templates/templates.go @@ -9,8 +9,8 @@ import ( "github.com/Masterminds/sprig" - "github.com/rohitramu/kpm/pkg/utils/files" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/files" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // NewRootTemplate returns a new root template with options and functions provided. diff --git a/pkg/utils/templates/types.go b/src/pkg/utils/templates/types.go similarity index 100% rename from pkg/utils/templates/types.go rename to src/pkg/utils/templates/types.go diff --git a/pkg/utils/types/mock_file_info.go b/src/pkg/utils/types/mock_file_info.go similarity index 100% rename from pkg/utils/types/mock_file_info.go rename to src/pkg/utils/types/mock_file_info.go diff --git a/pkg/utils/user_prompts/user_prompts.go b/src/pkg/utils/user_prompts/user_prompts.go similarity index 100% rename from pkg/utils/user_prompts/user_prompts.go rename to src/pkg/utils/user_prompts/user_prompts.go diff --git a/pkg/utils/validation/validation.go b/src/pkg/utils/validation/validation.go similarity index 99% rename from pkg/utils/validation/validation.go rename to src/pkg/utils/validation/validation.go index 740627c..08648bb 100644 --- a/pkg/utils/validation/validation.go +++ b/src/pkg/utils/validation/validation.go @@ -5,7 +5,7 @@ import ( "regexp" "strings" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // MaxOutputNameLength is the maximum number of characters allowed in the output name. diff --git a/pkg/utils/yaml/yaml.go b/src/pkg/utils/yaml/yaml.go similarity index 96% rename from pkg/utils/yaml/yaml.go rename to src/pkg/utils/yaml/yaml.go index 13448a6..58f6edf 100644 --- a/pkg/utils/yaml/yaml.go +++ b/src/pkg/utils/yaml/yaml.go @@ -6,7 +6,7 @@ import ( "github.com/ghodss/yaml" - "github.com/rohitramu/kpm/pkg/utils/log" + "github.com/rohitramu/kpm/src/pkg/utils/log" ) // BytesToObject populates an object's properties from the contents of a yaml file.