Skip to content

Commit

Permalink
Merge branch 'main' into vishwahiremat/generateBicepForSecretStores
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwahiremat committed Jun 13, 2023
2 parents fbe4188 + 02f19d9 commit 6bd12c9
Show file tree
Hide file tree
Showing 131 changed files with 2,371 additions and 3,513 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug Report
about: Report broken functionality within Project Radius
about: Report broken functionality within Radius
title: "<BUG TITLE>"
assignees: ''
labels: ["bug"]
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: Feature Request
about: Request a feature in Project Radius
about: Request a feature in Radius
title: "<FEATURE TITLE>"
assignees: ''
---

## Overview of feature request

<!--What are you proposing Project Radius add/update/remove?-->
<!--What are you proposing Radius add/update/remove?-->

## Acceptance criteria

Expand Down
112 changes: 112 additions & 0 deletions .github/scripts/radius-bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
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.
*/

module.exports = async ({ github, context }) => {
if (context.eventName === 'issue_comment' && context.payload.action === 'created') {
await handleIssueCommentCreate({ github, context });
}
}

// Handle issue comment create event.
async function handleIssueCommentCreate({ github, context }) {
const payload = context.payload;
const issue = context.issue;
const isFromPulls = !!payload.issue.pull_request;
const commentBody = payload.comment.body;
const username = context.actor.toLowerCase();

if (!commentBody) {
console.log('[handleIssueCommentCreate] comment body not found, exiting.');
return;
}

const commandParts = commentBody.split(/\s+/);
const command = commandParts.shift();

switch (command) {
case '/ok-to-test':
await cmdOkToTest(github, issue, isFromPulls, username);
break;
default:
console.log(`[handleIssueCommentCreate] command ${command} not found, exiting.`);
break;
}
}

/**
* Trigger e2e test for the pull request.
* @param {*} github GitHub object reference
* @param {*} issue GitHub issue object
* @param {boolean} isFromPulls is the workflow triggered by a pull request?
*/
async function cmdOkToTest(github, issue, isFromPulls, userName) {
if (!isFromPulls) {
console.log('[cmdOkToTest] only pull requests supported, skipping command execution.');
return;
}

// Check if the user has permission to trigger e2e test with an issue comment
const org = 'project-radius';
console.log(`Checking team membership for: ${userName}`);
const isMember = await checkTeamMembership(github, org, process.env.TEAM_SLUG, userName);
if (!isMember) {
console.log(`${userName} is not a member of the ${teamSlug} team.`);
return;
}

// Get pull request
const pull = await github.pulls.get({
owner: issue.owner,
repo: issue.repo,
pull_number: issue.number,
});

if (pull && pull.data) {
// Get commit id and repo from pull head
const testPayload = {
pull_head_ref: pull.data.head.sha,
pull_head_repo: pull.data.head.repo.full_name,
command: 'ok-to-test',
issue: issue,
};

console.log('Creating repository dispatch event for e2e test');

// Fire repository_dispatch event to trigger e2e test
await github.repos.createDispatchEvent({
owner: issue.owner,
repo: issue.repo,
event_type: 'functional-tests',
client_payload: testPayload,
});

console.log(`[cmdOkToTest] triggered E2E test for ${JSON.stringify(testPayload)}`);
}
}

async function checkTeamMembership(github, org, teamSlug, userName) {
try {
const response = await github.teams.getMembershipForUserInOrg({
org: org,
team_slug: teamSlug,
username: userName,
});
return response.data.state === 'active';
} catch (error) {
console.log(`error: ${error}`)
return false;
}
}
7 changes: 6 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ concurrency:
cancel-in-progress: true

env:
# Go version to install
GOVER: '^1.20'
GOPROXY: https://proxy.golang.org

# gotestsum version - see: https://github.com/gotestyourself/gotestsum
GOTESTSUMVERSION: 1.10.0

# Use radiusdev.azurecr.io for PR build. Otherwise, use radius.azurecr.io.
DOCKER_REGISTRY: ${{ github.event.pull_request.number && 'radiusdev.azurecr.io' || 'radius.azurecr.io' }}

Expand Down Expand Up @@ -274,7 +279,7 @@ jobs:
HELM_CHARTS_DIR: deploy/Chart
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
helm package ${{ env.HELM_CHARTS_DIR }} --version ${{ env.CHART_VERSION }} --destination ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
helm package ${{ env.HELM_CHARTS_DIR }} --version ${{ env.CHART_VERSION }} --app-version ${{ env.REL_VERSION }} --destination ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: az CLI login
run: |
az login --service-principal \
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ on:
- release/*
# Dispatch on external events
repository_dispatch:
types: [e2e-test]
types: [functional-tests]

env:
# Go version
GOVER: '^1.20'
GOPROXY: https://proxy.golang.org

# gotestsum version - see: https://github.com/gotestyourself/gotestsum
GOTESTSUM_VER: 1.10.0

# Helm version
HELM_VER: 'v3.11.3'
# KinD cluster version
Expand Down Expand Up @@ -155,6 +158,7 @@ jobs:
<details>
<summary> Click here to see the list of tools in the current test run</summary>
* gotestsum ${{ env.GOTESTSUM_VER }}
* KinD: ${{ env.KIND_VER }}
* Dapr: ${{ env.DAPR_VER }}
* Azure KeyVault CSI driver: ${{ env.AZURE_KEYVAULT_CSI_DRIVER_VER }}
Expand Down Expand Up @@ -387,6 +391,9 @@ jobs:
which rad || { echo "cannot find rad"; exit 1; }
rad bicep download
rad version
- name: Install gotestsum (test reporting tool)
run: |
go install gotest.tools/gotestsum@v${{ env.GOTESTSUM_VER }}
- uses: marocchino/sticky-pull-request-comment@v2
if: failure() && env.PR_NUMBER != ''
continue-on-error: true
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/radius-bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: radius-bot

on:
issue_comment:
types: [created]

jobs:
radius-bot:
name: Run Radius Bot script
runs-on: [self-hosted, 1ES.Pool=1ES-Radius ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Comment analyzer
uses: actions/github-script@v4
env:
TEAM_SLUG: 'Radius-Eng'
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
script: |
const script = require('./.github/scripts/radius-bot.js')
await script({github, context})
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Radius
# Radius

Project Radius is a developer-centric cloud-native application platform.
Radius is a developer-centric cloud-native application platform.

The core of Radius is using the declarative **application model** to describe complete applications that can be managed and deployed with an intelligent control plane. Radius uses the [Bicep](https://github.com/azure/bicep) language as a file-format and infrastructure-as-code tool.

Expand All @@ -17,7 +17,7 @@ Radius consists of:

## Getting started

Visit the Project Radius [docs site](https://radapp.dev/getting-started/) to get up and running with Radius in minutes.
Visit the Radius [docs site](https://radapp.dev/getting-started/) to get up and running with Radius in minutes.

## Contributing

Expand Down
63 changes: 15 additions & 48 deletions cadl/Applications.Link/mongoDatabases.cadl
Original file line number Diff line number Diff line change
Expand Up @@ -59,51 +59,22 @@ model MongoDatabaseListSecretsResult is MongoDatabaseSecrets;

@doc("The secret values for the given MongoDatabase resource")
model MongoDatabaseSecrets {
@doc("Username to use when connecting to the target Mongo database")
username?: string;

@doc("Password to use when connecting to the target Mongo database")
password?: string;

@doc("Connection string used to connect to the target Mongo database")
connectionString?: string;
}

@doc("MongoDatabase Properties for Mode Resource")
model ResourceMongoDatabaseProperties extends MongoDatabaseProperties{
@doc("Fully qualified resource ID of a supported resource with Mongo API to use for this link")
resource: string;

@doc("Host name of the target Mongo database")
host?: string;

@doc("Port value of the target Mongo database")
port?: int32;

@doc("Database name of the target Mongo database")
@doc("MongoDatabase link properties")
model MongoDatabaseProperties extends BasicResourceProperties{
@doc("Provisioning state of the mongo database link at the time the operation was called")
@visibility("read")
database?: string;

@doc("How to build the Mongo database link. Options are to build automatically via 'recipe' or 'resource', or build manually via 'values'. Selection determines which set of fields to additionally require.")
mode: "resource";
}
@doc("MongoDatabase Properties for Mode Values")
model ValuesMongoDatabaseProperties extends MongoDatabaseProperties{
@doc("Host name of the target Mongo database")
host: string;

@doc("Port value of the target Mongo database")
port: int32;
provisioningState?: ProvisioningState;

@doc("Database name of the target Mongo database")
@visibility("read")
database?: string;
@doc("Secret values provided for the resource")
secrets?: MongoDatabaseSecrets;

@doc("How to build the Mongo database link. Options are to build automatically via 'recipe' or 'resource', or build manually via 'values'. Selection determines which set of fields to additionally require.")
mode: "values";
}
@doc("MongoDatabase Properties for Mode Recipe")
model RecipeMongoDatabaseProperties extends MongoDatabaseProperties{
@doc("Host name of the target Mongo database")
host?: string;

Expand All @@ -114,21 +85,17 @@ model RecipeMongoDatabaseProperties extends MongoDatabaseProperties{
@visibility("read")
database?: string;

@doc("The recipe used to automatically deploy underlying infrastructure for the mongodatabases link")
recipe: Recipe;
@doc("The recipe used to automatically deploy underlying infrastructure for the MongoDB link")
recipe?: Recipe;

@doc("How to build the Mongo database link. Options are to build automatically via 'recipe' or 'resource', or build manually via 'values'. Selection determines which set of fields to additionally require.")
mode: "recipe";
}
@doc("MongoDatabase link properties")
@discriminator("mode")
model MongoDatabaseProperties extends BasicResourceProperties{
@doc("Provisioning state of the mongo database link at the time the operation was called")
@visibility("read")
provisioningState?: ProvisioningState;
@doc("List of the resource IDs that support the MongoDB resource")
resources?: ResourceReference[];

@doc("Secrets values provided for the resource")
secrets?: MongoDatabaseSecrets;
@doc("Specifies how the underlying service/resource is provisioned and managed.")
resourceProvisioning?: ResourceProvisioning;

@doc("Username to use when connecting to the target Mongo database")
username?: string;
}

#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template"
Expand Down
2 changes: 1 addition & 1 deletion cadl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface InterfaceName
There may be more or less depending on the resource being modeled
## {rootScope}
At the time of writing this, the Radius team's spec has not been approved by ARM. As a result, the Cadl team has created a custom `RootScopeResourceOperations` object. This makes it so that the paths generated for resources are prepended by `{rootScope}` as required in Project Radius.
At the time of writing this, the Radius team's spec has not been approved by ARM. As a result, the Cadl team has created a custom `RootScopeResourceOperations` object. This makes it so that the paths generated for resources are prepended by `{rootScope}` as required in Radius.
To utilize this object, do the following:
1. Import `customRootScope.cadl` into the resource file.
Expand Down
4 changes: 2 additions & 2 deletions cmd/rad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ import (
// RootCmd is the root command of the rad CLI. This is exported so we can generate docs for it.
var RootCmd = &cobra.Command{
Use: "rad",
Short: "Project Radius CLI",
Long: `Project Radius CLI`,
Short: "Radius CLI",
Long: `Radius CLI`,
SilenceErrors: true,
SilenceUsage: true,
}
Expand Down
31 changes: 16 additions & 15 deletions deploy/Chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
apiVersion: v2
description: Radius provides a declarative way to manage your infrastructure and applications.
name: radius
description: Radius controller for Kubernetes
type: application
# We automate versioning of the chart during publishing.
# The value here is only used for a dev build.
version: '42.42.42-dev'
dependencies:
- name: de
version: '42.42.42-dev'
repository: "file://de"
- name: ucp
version: '42.42.42-dev'
repository: "file://ucp"
- name: rp
version: '42.42.42-dev'
repository: "file://rp"
# version is the chart version, which will be replaced when this chart is packaged.
version: '0.42.42-dev'
# appVersion is the version of Radius, which will be replaced when this chart is packaged.
appVersion: 'latest'
home: https://radapp.dev
sources:
- https://github.com/project-radius/radius/tree/main/deploy/Chart
maintainers:
- name: Radius Authors
url: https://github.com/project-radius/radius
icon: https://radapp.dev/images/logo.png
keywords:
- radius
- iac
- bicep
Loading

0 comments on commit 6bd12c9

Please sign in to comment.