Feature 11074: Enhanced OSM declarative modelling for applications. OSM's SDK for intent manipulation

Change-Id: I6d03faa143eafcf30380b3b854c54f177dcf8f25
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/docker/osm-nushell-krm-functions/scripts/entrypoint-config.nu b/docker/osm-nushell-krm-functions/scripts/entrypoint-config.nu
new file mode 100644
index 0000000..6f56e7a
--- /dev/null
+++ b/docker/osm-nushell-krm-functions/scripts/entrypoint-config.nu
@@ -0,0 +1,119 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+# Nushell Config File
+#
+
+
+# Default config
+$env.config.color_config = {
+    separator: white
+    leading_trailing_space_bg: { attr: n }
+    header: green_bold
+    empty: blue
+    bool: light_cyan
+    int: white
+    filesize: cyan
+    duration: white
+    datetime: purple
+    range: white
+    float: white
+    string: white
+    nothing: white
+    binary: white
+    cell-path: white
+    row_index: green_bold
+    record: white
+    list: white
+    closure: green_bold
+    glob:cyan_bold
+    block: white
+    hints: dark_gray
+    search_result: { bg: red fg: white }
+    shape_binary: purple_bold
+    shape_block: blue_bold
+    shape_bool: light_cyan
+    shape_closure: green_bold
+    shape_custom: green
+    shape_datetime: cyan_bold
+    shape_directory: cyan
+    shape_external: cyan
+    shape_externalarg: green_bold
+    shape_external_resolved: light_yellow_bold
+    shape_filepath: cyan
+    shape_flag: blue_bold
+    shape_float: purple_bold
+    shape_glob_interpolation: cyan_bold
+    shape_globpattern: cyan_bold
+    shape_int: purple_bold
+    shape_internalcall: cyan_bold
+    shape_keyword: cyan_bold
+    shape_list: cyan_bold
+    shape_literal: blue
+    shape_match_pattern: green
+    shape_matching_brackets: { attr: u }
+    shape_nothing: light_cyan
+    shape_operator: yellow
+    shape_pipe: purple_bold
+    shape_range: yellow_bold
+    shape_record: cyan_bold
+    shape_redirection: purple_bold
+    shape_signature: green_bold
+    shape_string: green
+    shape_string_interpolation: cyan_bold
+    shape_table: blue_bold
+    shape_variable: purple
+    shape_vardecl: purple
+    shape_raw_string: light_purple
+    shape_garbage: {
+        fg: white
+        bg: red
+        attr: b
+    }
+}
+
+
+# Remove Nushell's welcome message
+# --------------------------------
+$env.config.show_banner = false
+
+
+# NU_LIB_DIRS
+# -----------
+# Directories in this environment variable are searched by the
+# `use` and `source` commands.
+# It is searched after the NU_LIB_DIRS constant.
+#
+$env.NU_LIB_DIRS ++= [ "/app/osm" ]
+
+
+# Load the model and environment parameters
+# -----------------------------------------
+let clear_environment_location: path = ($env.CLEAR_ENVIRONMENT_LOCATION? | default "/model/parameters/clear/environment.yaml")
+let secret_environment_location: path = ($env.SECRET_ENVIRONMENT_LOCATION? | default "/model/parameters/secret/environment.yaml")
+let model_location: path = ($env.MODEL_LOCATION? | default "/model/app_instance_model.yaml")
+let environment: record = (
+    open $clear_environment_location | default {}
+    | merge (
+        open $secret_environment_location | default {}
+    )
+)
+let model_instance: record = (open $model_location | default {})
+
+
+# Load the required library
+use /app/osm/operations/app.nu
diff --git a/docker/osm-nushell-krm-functions/scripts/entrypoint.sh b/docker/osm-nushell-krm-functions/scripts/entrypoint.sh
new file mode 100755
index 0000000..9bd7cfe
--- /dev/null
+++ b/docker/osm-nushell-krm-functions/scripts/entrypoint.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+
+# If the main command is "nu", it should run as if it where a basic "nu" container, but with the expected environment variables and libraries.
+# Otherwise, it must be an OSM model operation, so it should be fed by the appropriate instance model in a pipeline
+
+# Check if the first argument is "nu"
+if [ "$1" = "nu" ]; then
+  # If it is just "nu", with no extra arguments, just runs it with the right environment
+  if [ "$#" -eq 1 ]; then
+    exec nu --env-config scripts/entrypoint-config.nu
+  # Otherwise, adds the rest of arguments after the environment is loaded
+  else
+    # Shift the first argument ("nu") off, leaving only the remaining arguments
+    shift
+
+    # Construct the final command with the joined arguments
+    exec nu --env-config scripts/entrypoint-config.nu "$@"
+  fi
+else
+  # Otherwise, launches the command with special configuration and feeding it by the instance model in a pipeline
+  NU_COMMAND="\$model_instance | $@"
+  exec nu --env-config scripts/entrypoint-config.nu -c "${NU_COMMAND}"
+fi