Skip to content

Commit

Permalink
Merge branch 'edge' into willtsai/k8s-inc-adopt
Browse files Browse the repository at this point in the history
  • Loading branch information
willtsai authored Oct 3, 2023
2 parents 333204a + 1be57e8 commit 8c0d31a
Show file tree
Hide file tree
Showing 15 changed files with 1,000 additions and 232 deletions.
137 changes: 137 additions & 0 deletions .github/scripts/generate_resource_references.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# 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.
# ------------------------------------------------------------

# This script parses the auto-generated resource markdown references
# and generates Hugo pages for each resource.

import os
import sys

hugo_template = """---
type: docs
title: "Reference: {}"
linkTitle: "{}"
description: "Detailed reference documentation for {}"
---
"""

# Ensure that the script is called with the correct number of arguments
if len(sys.argv) != 3:
print("Usage: python generate_resource_references.py <source_directory> <target_directory>")
sys.exit(1)

# Pass in "source_directory" as input parameter
# This directory should contain the auto-generated
# resource markdown files for a given provider (applications, aws, etc.)
# Example: radius/hack/generated/
source_directory = sys.argv[1]

# Pass in "target_directory" as input parameter
# This directory should contain the Hugo content directory
# This script will generate the pages and directories as needed
# Example: docs/docs/content/reference/resources
target_directory = sys.argv[2]

# Get all the directories in the source directory
# Example: applications, aws, etc.
namespace_parents = os.listdir(source_directory)
if not namespace_parents:
print("No namespace parents found in source directory: {}".format(source_directory))
sys.exit(1)

# Iterate through each namespace parent directory for each namespace
for namespace_parent in namespace_parents:
if not os.path.isdir(os.path.join(source_directory, namespace_parent)):
continue

# Create _index.md file for namespace parent
target_namespace_parent_dir = os.path.join(target_directory, namespace_parent, '_index.md')
os.makedirs(os.path.dirname(target_namespace_parent_dir), exist_ok=True)
with open(target_namespace_parent_dir, 'w') as f:
f.write(hugo_template.format(namespace_parent, namespace_parent, namespace_parent))

namespaces = os.listdir(os.path.join(source_directory, namespace_parent))
if not namespaces:
print("No namespaces found in namespace parent: {}".format(namespace_parent))
continue

for namespace in namespaces:
if not os.path.isdir(os.path.join(source_directory, namespace_parent, namespace)):
continue

# Create _index.md file for namespace
target_namespace_dir = os.path.join(target_directory, namespace_parent, namespace, '_index.md')
os.makedirs(os.path.dirname(target_namespace_dir), exist_ok=True)
with open(target_namespace_dir, 'w') as f:
f.write(hugo_template.format(namespace, namespace, namespace))

api_versions = os.listdir(os.path.join(source_directory, namespace_parent, namespace))
if not api_versions:
print("No API versions found in namespace: {}".format(namespace_parent))
continue

for api_version in api_versions:
if not os.path.isdir(os.path.join(source_directory, namespace_parent, namespace, api_version)):
continue

# Create _index.md file for API version
target_api_version_dir = os.path.join(target_directory, namespace_parent, namespace, api_version, '_index.md')
os.makedirs(os.path.dirname(target_api_version_dir), exist_ok=True)
with open(target_api_version_dir, 'w') as f:
f.write(hugo_template.format(api_version, api_version, api_version))

resource_markdown_files = os.listdir(os.path.join(source_directory, namespace_parent, namespace, api_version, 'docs'))
if not resource_markdown_files:
print("No resource markdown files found in namespace {} and API version: {}".format(namespace, api_version))
continue

for resource_markdown_file in resource_markdown_files:
if not resource_markdown_file.endswith(".md"):
continue

resource_name = resource_markdown_file.split(".")[0]
print("Processing resource: {}/{}@{}".format(namespace, resource_name, api_version))
target_resource_dir = os.path.join(target_directory, namespace_parent, namespace, api_version, resource_name)

hugo_content = hugo_template.format('{}/{}@{}'.format(namespace, resource_name, api_version), resource_name, '{}/{}@{}'.format(namespace, resource_name, api_version))
hugo_content += "{{< schemaExample >}}\n\n"

## Check if a Bicep file exists for the resource
#bicep_file = os.path.join(source_directory, namespace_parent, namespace, api_version, 'examples', resource_name + ".bicep")
#if os.path.exists(bicep_file):
# # Copy Bicep file to target directory
# bicep_target_file = os.path.join(target_resource_dir, 'snippets', resource_name + ".bicep")
# print(" Bicep example found")
# os.makedirs(os.path.dirname(bicep_target_file), exist_ok=True)
# os.system("cp {} {}".format(bicep_file, bicep_target_file))
#
# bicep_hugo_link = "snippets/{}.bicep".format(resource_name)
# hugo_content += "## Example\n\n"
# hugo_content += "{{{{< rad file=\"{}\" embed=true marker=""//SNIPPET"" >}}}}\n\n".format(bicep_hugo_link)

# Add in the resource markdown file
markdown_content = open(os.path.join(source_directory, namespace_parent, namespace, api_version, 'docs', resource_markdown_file), 'r').read()
hugo_content += "## Schema\n\n"
hugo_content += markdown_content

# Create the target markdown file
target_markdown_file = os.path.join(target_resource_dir, 'index.md')
os.makedirs(os.path.dirname(target_markdown_file), exist_ok=True)
with open(target_markdown_file, 'w') as f:
f.write(hugo_content)


3 changes: 3 additions & 0 deletions docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ enableGitInfo = true
[[module.mounts]]
source = "content"
target = "content"
[[module.mounts]]
source = "shared-content"
target = "content"
[[module.mounts]]
source = "static"
target = "static"
Expand Down
32 changes: 1 addition & 31 deletions docs/content/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,7 @@ kubectl config current-context

## 2. Install Radius CLI

{{< tabs MacOS "Linux/WSL" "Windows PowerShell" >}}

{{% codetab %}}
```bash
curl -fsSL "https://get.radapp.dev/tools/rad/install.sh" | /bin/bash
```
{{% /codetab %}}

{{% codetab %}}
```bash
wget -q "https://get.radapp.dev/tools/rad/install.sh" -O - | /bin/bash
```
{{% /codetab %}}

{{% codetab %}}
```powershell
iwr -useb "https://get.radapp.dev/tools/rad/install.ps1" | iex
```
{{% /codetab %}}

{{< /tabs >}}

Visit the [rad CLI]({{< ref howto-rad-cli >}}) page for troubleshooting or additional options.

Verify the rad CLI is installed correctly by running `rad version`.

Example output:
```
RELEASE VERSION BICEP COMMIT
{{< param chart_version >}} {{< param version >}} 0.11.13 2e60bfb46de73ec5cc70485d53e67f8eaa914ba7
```
{{< read file= "/shared-content/installation/rad-cli/install-rad-cli.md" >}}

## 3. Initialize Radius

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,14 @@ rad uninstall kubernetes

## Step 3: Install the rad CLI

The rad CLI is the main tool for interacting with Radius. It is used to create and manage Radius environments, and to deploy and manage Radius applications.

Visit the [rad CLI how-to guide]({{< ref howto-rad-cli >}}) for more information on how to install the rad CLI.

{{< button text="How-To: rad CLI" page="howto-rad-cli" newtab="true" >}}
{{< read file= "/shared-content/radius-installation/rad-cli/install-rad-cli.md" >}}

## Step 4: Install the Radius-Bicep VS Code extension

The Radius-Bicep VS Code extension provides a set of tools for working with Bicep files in VS Code. Visit the [VSCode how-to guide]({{< ref howto-vscode-bicep >}}) for more information on how to install the Radius-Bicep VS Code extension.

{{< button text="How-To: VS Code" page="howto-vscode-bicep" newtab="true" >}}

## Step 5: Initialize the Radius control-plane
{{< read file= "/shared-content/radius-installation/vscode-bicep/install-vscode-bicep.md" >}}

The Radius control-plane is a set of services that provide the core functionality of Radius. It is deployed as a set of containers in a Kubernetes cluster.
## Step 5: Initialize the Radius control-plane and the Radius environment

Visit the [environments how-to guide]({{< ref howto-environment >}}) for more information on how to install the Radius control-plane and create your first Radius environment.
{{< read file= "/shared-content/radius-installation/install-radius/initialize-radius.md" >}}

{{< button text="How-To: Init an environment" page="howto-environment" newtab="true" >}}
>If you are looking to upgrade Radius to the latest version, refer to [upgrade Radius on Kubernetes]({{< ref kubernetes-upgrade >}}) for more information.
86 changes: 1 addition & 85 deletions docs/content/guides/tooling/rad-cli/howto-rad-cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,88 +8,4 @@ categories: "How-To"
tags: ["rad CLI", "Bicep"]
---

The `rad` CLI manages your applications, resources, and environments. You can install it on your local machine with the following installation scripts:

{{< tabs MacOS "Linux/WSL" "Windows PowerShell" "Cloud Shell" Binaries >}}

{{% codetab %}}
{{< latest >}}
```bash
curl -fsSL "https://get.radapp.dev/tools/rad/install.sh" | /bin/bash
```
{{< /latest >}}
{{< edge >}}
To install the latest edge version:

```bash
curl -fsSL "https://radiuspublic.blob.core.windows.net/tools/rad/install.sh" | /bin/bash -s edge
```
{{< /edge >}}
{{% /codetab %}}

{{% codetab %}}
{{< latest >}}
```bash
wget -q "https://get.radapp.dev/tools/rad/install.sh" -O - | /bin/bash
```
{{< /latest >}}
{{< edge >}}
To install the latest edge version:

```bash
wget -q "https://radiuspublic.blob.core.windows.net/tools/rad/install.sh" -O - | /bin/bash -s edge
```
{{< /edge >}}
{{% /codetab %}}

{{% codetab %}}
{{< latest >}}
Run the following in a PowerShell window:

```powershell
iwr -useb "https://get.radapp.dev/tools/rad/install.ps1" | iex
```

You may need to refresh your $PATH environment variable to access `rad`:
```powershell
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path","User")
```
{{< /latest >}}
{{< edge >}}
To install the latest edge version:

```powershell
$script=iwr -useb https://radiuspublic.blob.core.windows.net/tools/rad/install.ps1; $block=[ScriptBlock]::Create($script); invoke-command -ScriptBlock $block -ArgumentList edge
```
{{< /edge >}}
{{% /codetab %}}

{{% codetab %}}
[Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview) is an interactive, authenticated, browser-accessible shell for managing Azure resources.

Azure Cloud Shell for bash doesn't have a sudo command, so users are unable to install Radius to the default `/usr/local/bin` installation path. To install the rad CLI to the home directory, run the following commands:

```bash
export RADIUS_INSTALL_DIR=./
wget -q "https://get.radapp.dev/tools/rad/install.sh" -O - | /bin/bash
```

You can now run the rad CLI with `./rad`.

PowerShell for Cloud Shell is currently not supported.
{{% /codetab %}}

{{% codetab %}}
1. Download the `rad` CLI from one of these URLs:
- MacOS x64: https://get.radapp.dev/tools/rad/{{< param version >}}/macos-x64/rad
- MacOS arm64: https://get.radapp.dev/tools/rad/{{< param version >}}/macos-arm64/rad
- Linux x64: https://get.radapp.dev/tools/rad/{{< param version >}}/linux-x64/rad
- Windows x64: https://get.radapp.dev/tools/rad/{{< param version >}}/windows-x64/rad.exe
1. Ensure the user has permission to execute the binary and place it somewhere on your PATH so it can be invoked easily.
{{% /codetab %}}

{{< /tabs >}}

> You may be prompted for your sudo password during installation, as the installer places the `rad` binary under `/usr/local/bin`. If you are unable to sudo you can install the rad CLI to another directory by setting the `RADIUS_INSTALL_DIR` environment variable with your intended install path. Make sure you add this to your path ([Unix](https://www.howtogeek.com/658904/how-to-add-a-directory-to-your-path-in-linux/), [Windows](https://windowsloop.com/how-to-add-to-windows-path/)) if you wish to reference it via `rad`, like in the docs.
Verify the rad CLI is installed correctly by running `rad`.
{{< read file= "/shared-content/installation/rad-cli/install-rad-cli.md" >}}
62 changes: 1 addition & 61 deletions docs/content/guides/tooling/vscode/howto-vscode-bicep/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,4 @@ categories: "How-To"
tags: ["Bicep", "VSCode"]
---

Visual Studio Code offers the best authoring experience for Radius and Bicep. Download and install the Radius Bicep extension to easily author and validate Bicep templates:

1. Download the latest extensions

{{< tabs Links Terminal >}}

{{% codetab %}}
{{< button link="https://get.radapp.dev/tools/vscode-extensibility/stable/rad-vscode-bicep.vsix" text="Download Bicep extension" >}}

{{< edge >}}
{{< button link="https://get.radapp.dev/tools/vscode-extensibility/edge/rad-vscode-bicep.vsix" text="Download Bicep extension (edge)" >}}
{{< /edge >}}
{{% /codetab %}}

{{% codetab %}}

Stable Version

```bash
curl https://get.radapp.dev/tools/vscode-extensibility/stable/rad-vscode-bicep.vsix --output rad-vscode-bicep.vsix
```

Edge Version

```bash
curl https://get.radapp.dev/tools/vscode-extensibility/edge/rad-vscode-bicep.vsix --output rad-vscode-bicep.vsix
```

{{% /codetab %}}

{{< /tabs >}}

2. Install the `.vsix` file:

{{< tabs UI Terminal >}}

{{% codetab %}}
In VSCode, manually install the extension using the *Install from VSIX* command in the Extensions view command drop-down.

<img src="./vsix-install.png" alt="Screenshot of installing a vsix extension" width=400>

{{% /codetab %}}

{{% codetab %}}
You can also import this extension on the [command-line](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix) with:

```bash
code --install-extension rad-vscode-bicep.vsix
```

If you're on macOS, make sure to [setup the `code` alias](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line).

{{% /codetab %}}

{{< /tabs >}}

3. **Disable the official Bicep extension** if you have it installed. Do not install it if prompted, our custom extension needs to be responsible for handling `.bicep` files and you cannot have both extensions enabled at once.

4. If running on Windows Subsystem for Linux (WSL), make sure to install the extension in WSL as well:

<img src="./wsl-extension.png" alt="Screenshot of installing a vsix extension in WSL" width=400>
{{< read file= "/shared-content/installation/vscode-bicep/install-vscode-bicep.md" >}}
Loading

0 comments on commit 8c0d31a

Please sign in to comment.