Skip to content

Commit 94c396c

Browse files
authored
Update bicep references in recipes (#70)
* update bicep references Signed-off-by: sk593 <[email protected]> * nit Signed-off-by: sk593 <[email protected]> * update bicepconfig workaround Signed-off-by: sk593 <[email protected]> --------- Signed-off-by: sk593 <[email protected]>
1 parent 023ec31 commit 94c396c

17 files changed

+60
-45
lines changed

.github/scripts/validate-bicep.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ then
44
BICEP_EXECUTABLE="$BICEP_PATH/rad-bicep"
55
fi
66

7+
# The Bicep compiler prints out a warning for any experimental features in use.
8+
# We want to ignore these warnings since Radius makes use of some experimental features.
9+
WARNING_MSG="WARNING: The following experimental Bicep features"
710
FILES=$(find . -type f -name "*.bicep")
811
FAILURES=()
912
for F in $FILES
1013
do
1114
echo "validating $F"
12-
# We need to run the rad-bicep and fail in one of two cases:
15+
# We need to run rad-bicep and fail in one of two cases:
1316
# - non-zero exit code
1417
# - non-empty stderr
1518
#
@@ -24,7 +27,7 @@ do
2427
EXITCODE=$?
2528
exec 3>&-
2629

27-
if [[ ! $EXITCODE -eq 0 || ! -z $STDERR ]]
30+
if [[ ! $EXITCODE -eq 0 || (! -z $STDERR && ! $STDERR == $WARNING_MSG* && ! $STDERR == *"Error"* ) ]]
2831
then
2932
echo $STDERR
3033
FAILURES+=$F

.github/workflows/validate-bicep.yaml

+16-18
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,19 @@ jobs:
3535
name: Validate Bicep Code
3636
runs-on: ubuntu-latest
3737
steps:
38-
- name: Check out repo
39-
uses: actions/checkout@v3
40-
- name: Parse release version and set environment variables
41-
run: python ./.github/scripts/get_release_version.py
42-
- name: Download rad-bicep
43-
run: |
44-
./.github/scripts/curl-with-retries.sh https://get.radapp.dev/tools/bicep-extensibility/${{ env.REL_CHANNEL }}/linux-x64/rad-bicep --output rad-bicep
45-
chmod +x rad-bicep
46-
./rad-bicep --version
47-
- name: Verify Bicep files
48-
run: ./.github/scripts/validate-bicep.sh
49-
env:
50-
BICEP_PATH: .
51-
- name: Write error to summary
52-
if: ${{ failure() }}
53-
run: |
54-
echo "## Bicep validation failed" >> $GITHUB_STEP_SUMMARY
55-
echo "One or more Bicep files have failed validation. Please ensure you do not have any Bicep errors. Visit https://docs.radapp.dev/getting-started/install/ to download and install the Bicep VS Code extension to assist with validation." >> $GITHUB_STEP_SUMMARY
38+
- name: Setup and verify bicep CLI
39+
run: |
40+
curl -Lo rad-bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
41+
chmod +x ./rad-bicep
42+
./rad-bicep --version
43+
- name: Check out repo
44+
uses: actions/checkout@v4
45+
- name: Verify Bicep files
46+
run: ./.github/scripts/validate-bicep.sh
47+
env:
48+
BICEP_PATH: .
49+
- name: Write error to summary
50+
if: ${{ failure() }}
51+
run: |
52+
echo "## Bicep validation failed" >> $GITHUB_STEP_SUMMARY
53+
echo "One or more Bicep files have failed validation. Please ensure you do not have any Bicep errors. Visit https://docs.radapp.dev/getting-started/install/ to download and install the Bicep VS Code extension to assist with validation." >> $GITHUB_STEP_SUMMARY

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ rad recipe register azure \
5151
### Bicep
5252

5353
```bicep
54-
import radius as rad
54+
extension radius
5555
5656
resource myenv 'Applications.Core/environments' = {
5757
name: 'myenv'

aws/rediscaches.bicep

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import aws as aws
17+
extension aws
1818

1919
@description('Radius-provided object containing information about the resource calling the Recipe')
2020
param context object

aws/sqldatabases.bicep

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import aws as aws
17+
extension aws
1818

1919
@description('Radius-provided object containing information about the resource calling the Recipe')
2020
param context object

azure/statestores.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = {
5454
}
5555
}
5656

57-
import kubernetes as k8s {
57+
extension kubernetes with {
5858
kubeConfig: ''
5959
namespace: context.runtime.kubernetes.namespace
60-
}
60+
} as k8s
6161

6262
var daprType = 'state.azure.blobstorage'
6363
var daprVersion = 'v1'

bicepconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"experimentalFeaturesEnabled": {
3+
"extensibility": true,
4+
"extensionRegistry": true,
5+
"dynamicTypeLoading": true
6+
},
7+
"extensions": {
8+
"radius": "br:biceptypes.azurecr.io/radius:latest",
9+
"aws": "br:biceptypes.azurecr.io/aws:latest"
10+
},
11+
"cloud": {
12+
"credentialPrecedence": [ "Environment" ]
13+
}
14+
}

docs/contributing/contributing-recipes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To test the recipe locally, follow the steps below:
5353
5454
**Via Radius environment bicep**
5555
```bicep
56-
import radius as radius
56+
extension radius
5757
resource env 'Applications.Core/environments@2023-10-01-preview' = {
5858
name: 'prod'
5959
properties: {

local-dev/extender-postgresql.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ param memoryRequest string = '512Mi'
3737
@description('Memory limit for the postgres deployment')
3838
param memoryLimit string = '1024Mi'
3939

40-
import kubernetes as kubernetes {
40+
extension kubernetes with {
4141
kubeConfig: ''
4242
namespace: context.runtime.kubernetes.namespace
43-
}
43+
} as kubernetes
4444

4545
var uniqueName = 'postgres-${uniqueString(context.resource.id)}'
4646
var port = 5432

local-dev/mongodatabases.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ param username string = 'admin'
2828
#disable-next-line secure-parameter-default
2929
param password string = 'Password1234=='
3030

31-
import kubernetes as kubernetes {
31+
extension kubernetes with {
3232
kubeConfig: ''
3333
namespace: context.runtime.kubernetes.namespace
34-
}
34+
} as kubernetes
3535

3636
var uniqueName = 'mongo-${uniqueString(context.resource.id)}'
3737
var port = 27017

local-dev/pubsubbrokers.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ param memoryRequest string = '128Mi'
2626
@description('Memory limit for the redis deployment')
2727
param memoryLimit string = '1024Mi'
2828

29-
import kubernetes as kubernetes {
29+
extension kubernetes with {
3030
kubeConfig: ''
3131
namespace: context.runtime.kubernetes.namespace
32-
}
32+
} as kubernetes
3333

3434
var uniqueName = 'daprpubsub-${uniqueString(context.resource.id)}'
3535
var port = 6379

local-dev/rabbitmqqueues.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ param memoryRequest string = '256Mi'
2929
@description('Memory limit for the rabbitmq deployment')
3030
param memoryLimit string = '1024Mi'
3131

32-
import kubernetes as kubernetes {
32+
extension kubernetes with {
3333
kubeConfig: ''
3434
namespace: context.runtime.kubernetes.namespace
35-
}
35+
} as kubernetes
3636

3737
var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}'
3838
var port = 5672

local-dev/rediscaches.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717
@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/')
1818
param context object
1919

20-
import kubernetes as kubernetes {
20+
extension kubernetes with {
2121
kubeConfig: ''
2222
namespace: context.runtime.kubernetes.namespace
23-
}
23+
} as kubernetes
2424

2525
resource redis 'apps/Deployment@v1' = {
2626
metadata: {

local-dev/secretstores.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717
@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/')
1818
param context object
1919

20-
import kubernetes as kubernetes {
20+
extension kubernetes with {
2121
kubeConfig: ''
2222
namespace: context.runtime.kubernetes.namespace
23-
}
23+
} as kubernetes
2424

2525
var daprType = 'secretstores.kubernetes'
2626
var daprVersion = 'v1'

local-dev/sqldatabases.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ param memoryLimit string = '1024Mi'
4040
@description('Initial catalog to connect to. Defaults to empty string (no initial catalog).')
4141
param initialCatalog string = ''
4242

43-
import kubernetes as kubernetes {
43+
extension kubernetes with {
4444
kubeConfig: ''
4545
namespace: context.runtime.kubernetes.namespace
46-
}
46+
} as kubernetes
4747

4848
var uniqueName = 'sql-${uniqueString(context.resource.id)}'
4949
var port = 1433

local-dev/statestores.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ param memoryRequest string = '128Mi'
2929
@description('Memory limit for the redis deployment')
3030
param memoryLimit string = '1024Mi'
3131

32-
import kubernetes as kubernetes {
32+
extension kubernetes with {
3333
kubeConfig: ''
3434
namespace: context.runtime.kubernetes.namespace
35-
}
35+
} as kubernetes
3636

3737
var uniqueName = 'daprstate-${uniqueString(context.resource.id)}'
3838
var port = 6379

tests/test-local-dev-recipes.bicep

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import radius as radius
1+
extension radius
22

33
@description('Specifies the image for the container resource.')
44
param magpieimage string
@@ -9,10 +9,10 @@ param registry string
99
@description('The OCI tag for test Bicep recipes.')
1010
param version string
1111

12-
import kubernetes as kubernetes {
12+
extension kubernetes with {
1313
namespace: 'daprrp-rs-secretstore-recipe'
1414
kubeConfig: ''
15-
}
15+
} as kubernetes
1616

1717
resource env 'Applications.Core/environments@2023-10-01-preview' = {
1818
name: 'local-dev-recipe-env'

0 commit comments

Comments
 (0)