diff --git a/documentation/LICENSE.asciidoc b/documentation/LICENSE.asciidoc index a3624467d..ac7d33c75 100644 --- a/documentation/LICENSE.asciidoc +++ b/documentation/LICENSE.asciidoc @@ -61,6 +61,7 @@ The following table shows the components that may be used. The column `inclusion |https://terraform.io/[terraform]|Optional|https://github.com/hashicorp/terraform/blob/main/LICENSE[Mozilla Public License 2.0] |https://www.graalvm.org/[GraalVM] |Optional|https://github.com/oracle/graal/blob/master/LICENSE[GPLv2] (with the “Classpath” Exception) |https://rancherdesktop.io/[Rancher Desktop]|Optional|https://github.com/rancher-sandbox/rancher-desktop/blob/main/LICENSE[ASL 2.0] +|https://github.com/Azure/azure-cli[AzureCLI] |Optional| https://github.com/Azure/azure-cli/blob/dev/LICENSE[MIT] |======================= == Apache Software License - Version 2.0 diff --git a/documentation/az.asciidoc b/documentation/az.asciidoc new file mode 100644 index 000000000..faaaec6ff --- /dev/null +++ b/documentation/az.asciidoc @@ -0,0 +1,45 @@ +:toc: +toc::[] + += Azure CLI + +The Azure CLI commandlet allows to install and use https://github.com/Azure/azure-cli[Azure CLI]. Currently, the command works only for Windows. + +*ATTENTION:* +Currently this feature is new and therefore experimental. +It may change in incompatible ways in the next releases until we reach a stable state. +We hope that all is working fine for you. +However, do not expect everything to work out of the box. + +The arguments (`devon az «args»`) are explained by the following table: + +.Usage of `devon az` +[options="header"] +|======================= +|*Argument(s)* |*Meaning* +|`setup` |setup Azure CLI (install and verify) as per above flow. +|`«args»` |call Azure CLI with the specified arguments. Call `az help` for details or use `az` directly as preferred." (`«args»`) +|======================= + +== Setup +The `az` commandlet will install Azure CLI automatically. Windows user must confirm the User Access Control to run the installation as administrator. +Please note that besides the sandbox concept of devonfw-ide this is a global installation on your system. +When uninstalling Azure CLI, you may have to manually uninstall. + +**Uninstall process instructions:** + +- https://docs.microsoft.com/de-de/cli/azure/install-azure-cli-windows?tabs=azure-cli#uninstall[Windows] + +== Requirements +**Windows users requires the following software:** + +- https://docs.microsoft.com/en-us/powershell//[Powershell] + +== Configuration File +The configuration file is located at `conf/.azure`. Don't forget to set the environment variables of your IDE with `devon` before setting new configurations for Azure. + +== Usage +After the installation is complete, you may need to restart the console. Run `az help` from any shell of your OS directly to get started and use the online documentations and resources on the web to get familiar with Azure CLI. It is not our intention to repeat this here. + +Please note that the `az` commandlet is a link:cli.asciidoc#command-wrapper[command wrapper]. + diff --git a/documentation/cli.asciidoc b/documentation/cli.asciidoc index 19da92104..d7a8bc5f4 100644 --- a/documentation/cli.asciidoc +++ b/documentation/cli.asciidoc @@ -50,6 +50,7 @@ However, when you automate and want to avoid "command not found" errors, you can The following commandlets are currently available: +* link:az.asciidoc[az] * link:build.asciidoc[build] * link:cobigen.asciidoc[cobigen] * link:docker.asciidoc[docker] @@ -73,4 +74,4 @@ The following commandlets are currently available: * link:sonar.asciidoc[sonar] * link:terraform.asciidoc[terraform] * link:vscode.asciidoc[vscode] -* link:yarn.asciidoc[yarn] \ No newline at end of file +* link:yarn.asciidoc[yarn] diff --git a/documentation/devonfw-ide-usage.asciidoc b/documentation/devonfw-ide-usage.asciidoc index b9e3024a8..fa438d452 100644 --- a/documentation/devonfw-ide-usage.asciidoc +++ b/documentation/devonfw-ide-usage.asciidoc @@ -14,6 +14,8 @@ include::variables.asciidoc[leveloffset=2] include::cli.asciidoc[leveloffset=2] +include::az.asciidoc[leveloffset=3] + include::build.asciidoc[leveloffset=3] include::docker.asciidoc[leveloffset=3] diff --git a/documentation/scripts.asciidoc b/documentation/scripts.asciidoc index 5bbbe7a2e..343298659 100644 --- a/documentation/scripts.asciidoc +++ b/documentation/scripts.asciidoc @@ -9,6 +9,7 @@ This directory is the heart of the `devonfw-ide` and contains the required link: ---- /scripts ├──/ https://github.com/devonfw/ide/tree/master/scripts/src/main/resources/scripts/command[command] +│ ├── link:az.asciidoc[az] │ ├── link:build.asciidoc[build] │ ├── link:docker.asciidoc[docker] │ ├── link:eclipse.asciidoc[eclipse] diff --git a/scripts/src/main/resources/scripts/command/az b/scripts/src/main/resources/scripts/command/az new file mode 100644 index 000000000..b3e556d6a --- /dev/null +++ b/scripts/src/main/resources/scripts/command/az @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +# autocompletion list +if [ "${1}" = "shortlist" ] +then + if [ -z "${2}" ] + then + echo "setup help" + fi + exit +fi + +if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi +# shellcheck source=scripts/functions +source "$(dirname "${0}")"/../functions + +function doSetup() { + if command -v az &> /dev/null + then + if [ "${1}" != "silent" ] && ! doIsQuiet + then + doEcho "Azure CLI is already installed at $(command -v az)" + fi + else + doRequireNotBatch + if doIsWindows + then + # Get leatest release + if [ -z "${AZ_VERSION}" ] + then + doEcho "Getting latest release..." + AZ_VERSION=$(curl -s https://api.github.com/repos/Azure/azure-cli/releases/latest | awk -F ":" '/tag_name/ {print $2}'| awk -F "\"" '{print $2}' | awk -F "-" '{print $3}') + fi + + doInstall "-" "${AZ_HOME}" "az" "${AZ_VERSION}" + if [ "${?}" = 0 ] + then + doPackageInstall "${AZ_HOME}" + fi + fi + fi +} + +function doPackageInstall() { + local path_to_package="${1}" + if doIsWindows + then + local winPath + winPath=$(cygpath -w "${path_to_package}") + powershell.exe -Command "Start-Process msiexec.exe -verb runas -Wait -ArgumentList '/I ${winPath}\az-${AZ_VERSION}-windows.msi /QB-!'" &> /dev/null + if [ "${?}" = 0 ] + then + setConfigDir + doEcho "\nAzure CLI ist installed now. Great! \nTo get started you may need to restart your current shell." + else + doEcho "\nThe setup was canceled or failed. Rerun the setup to install Azure CLI." + fi + else + doFail "Sorry, Azure CLI installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." + fi + doRunCommand "rm -rf ${path_to_package}" +} + +# Set directory for azure cli configuration file +function setConfigDir() { + azureconf_dir="${DEVON_IDE_HOME}/conf/.azure" + azurecli_export="export AZURE_CONFIG_DIR=${azureconf_dir}" + if ! grep -q "${azurecli_export}" "${DEVON_IDE_HOME}/conf/devon.properties" + then + doRunCommand "${azurecli_export}" + echo -e "\n${azurecli_export}" >> "${DEVON_IDE_HOME}/conf/devon.properties" + doEcho "Location of Azure's configuration file is set to ${azureconf_dir}" + fi +} + +function doRun() { + doSetup silent + if command -v az &> /dev/null + then + doEcho "Running: Azure CLI ${*}" + setConfigDir + az "${@}" + fi +} + +AZ_HOME="${DEVON_IDE_HOME}/updates/install/az" + +# CLI +case ${1} in +"help" | "-h") + echo "Install Azure CLI." + echo + echo "Arguments:" + echo " setup install Azure CLI on your machine (global installation)." + echo " <> call Azure CLI with the specified arguments. Call az --help for details or use Azure CLI directly as preferred." + echo +;; + +"setup" | "s") + doSetup "${2}" +;; + +*) + doRun "${@}" +;; +esac