Skip to content

Commit

Permalink
Rename provider -> extension in many places
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Aug 22, 2024
1 parent 68f9bca commit 0dc89f2
Show file tree
Hide file tree
Showing 125 changed files with 650 additions and 658 deletions.
10 changes: 5 additions & 5 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ The following features can be optionally enabled through your `bicepconfig.json`
Should be enabled in tandem with `testFramework` experimental feature flag for expected functionality. Allows you to author boolean assertions using the `assert` keyword comparing the actual value of a parameter, variable, or resource name to an expected value. Assert statements can only be written directly within the Bicep file whose resources they reference. For more information, see [Bicep Experimental Test Framework](https://github.com/Azure/bicep/issues/11967).

### `dynamicTypeLoading`
Requires `extensibility` to be enabled. If enabled, users are able to fetch the azure resource type definitions from an OCI Registry as a runtime dependency. To fetch the type definitions the following syntax can be used. For example `provider 'br:mcr.microsoft.com/bicep/providers/[email protected]' as az`.
The provider definitions also support aliasing via `bicepconfig.json` similar to [`moduleAliases`](https://learn.microsoft.com/azure/azure-resource-manager/bicep/bicep-config-modules#aliases-for-modules). For example `provider 'br/public:[email protected]' as az`.
Requires `extensibility` to be enabled. If enabled, users are able to fetch the azure resource type definitions from an OCI Registry as a runtime dependency. To fetch the type definitions the following syntax can be used. For example `extension 'br:mcr.microsoft.com/bicep/providers/[email protected]' as az`.
The extension definitions also support aliasing via `bicepconfig.json` similar to [`moduleAliases`](https://learn.microsoft.com/azure/azure-resource-manager/bicep/bicep-config-modules#aliases-for-modules). For example `extension 'br/public:[email protected]' as az`.

### `extendableParamFiles`
Enables the ability to extend bicepparam files from other bicepparam files.

### `extensibility`
Allows Bicep to use a provider model to deploy non-ARM resources. Currently, we support Kubernetes provider ([Bicep extensibility Kubernetes provider](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-extensibility-kubernetes-provider)) and Microsoft Graph provider ([Bicep templates for Microsoft Graph](https://aka.ms/graphbicep)).
Allows Bicep to use an extensibility model to deploy non-ARM resources. Currently, we support Kubernetes extension ([Bicep extensibility Kubernetes provider](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-extensibility-kubernetes-provider)) and Microsoft Graph provider ([Bicep templates for Microsoft Graph](https://aka.ms/graphbicep)).

### `extensionRegistry`
Requires `dynamicTypeLoading` and `extensibility` to be enabled. If enabled, users are able to fetch the third party resource type definitions from an OCI Registry as a runtime dependency. To fetch the type definitions the following syntax can be used. For example `extension 'br:thirdpartyregistry.azurecr.io/bicep/extension/[email protected]' as thirdparty`.
Expand Down Expand Up @@ -54,8 +54,8 @@ Should be enabled in tandem with `assertions` experimental feature flag for expe

## Other experimental functionality

### `publish-provider` CLI Command
Command that allows the publishing of providers to container registries. For more information, see [Using the Publish Provider Command](./experimental/publish-provider-command.md).
### `publish-extension` CLI Command
Command that allows the publishing of extensions to container registries. For more information, see [Using the Publish Extension Command](./experimental/publish-extension-command.md).

### Deployment Pane
The Deployment Pane is a UI panel in VSCode that allows you to connect to your Azure subscription and execute validate, deploy & whatif operations and get instant feedback without leaving the editor. For more information, see [Using the Deployment Pane](./experimental/deploy-ui.md).
21 changes: 21 additions & 0 deletions docs/experimental/publish-extension-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Using the `publish-extension` command (Experimental!)

## What is it?
The `publish-extension` command allows you to **publish** extensions to a registry of your choice. Simply specify a file and the registry extension reference.

## Using
`bicep publish-extension <file> --target <ref>`

### Arguments
`<file>` Path to the input file (index JSON file)\
`<ref>` The extension reference

### Options
`force` Overwrite existing published extension

### Examples
`bicep publish-extension` ./index.json --target br:example.azurecr.io/hello/world:v1\
`bicep publish-extension` ./index.json --target br:example.azurecr.io/hello/world:v1 --force

## Raising bugs or feature requests
Please raise bug reports or feature requests under [Bicep Issues](https://github.com/Azure/bicep/issues) as usual.
21 changes: 0 additions & 21 deletions docs/experimental/publish-provider-command.md

This file was deleted.

12 changes: 6 additions & 6 deletions docs/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The following is the active pseudo-grammar of the bicep language.
program -> statement* EOF
statement ->
targetScopeDecl |
providerDecl |
extensionDecl |
compileTimeImportDecl |
metadataDecl |
parameterDecl |
Expand All @@ -20,11 +20,11 @@ statement ->
targetScopeDecl -> "targetScope" "=" expression
providerDecl -> decorator* "provider" interpString(specification) providerWithClause? providerAsClause? NL
extensionDecl -> decorator* "extension" interpString(specification) extensionWithClause? extensionAsClause? NL
providerWithClause -> "with" object
extensionWithClause -> "with" object
providerAsClause -> "as" IDENTIFIER(alias)
extensionAsClause -> "as" IDENTIFIER(alias)
compileTimeImportDecl -> decorator* "import" compileTimeImportTarget compileTimeImportFromClause
Expand All @@ -34,9 +34,9 @@ compileTimeImportTarget ->
importedSymbolsList -> "{" ( NL+ ( importedSymbolsListItem NL+ )* )? "}"
importedSymbolsListItem -> IDENTIFIER(originalSymbolName) providerAsClause?
importedSymbolsListItem -> IDENTIFIER(originalSymbolName) extensionAsClause?
wildcardImport -> "*" providerAsClause
wildcardImport -> "*" extensionAsClause
compileTimeImportFromClause -> "from" interpString(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

/**
* Live tests for "bicep publish-provider".
* Live tests for "bicep publish-extension".
*
* @group live
*/
Expand All @@ -13,20 +13,20 @@ import { invokingBicepCommand } from "./utils/command";
import { pathToExampleFile, readFileSync, writeTempFile } from "./utils/fs";
import { getEnvironment } from "./utils/liveTestEnvironments";

describe("bicep publish-provider live", () => {
const testArea = "publish-provider";
describe("bicep publish-extension live", () => {
const testArea = "publish-extension";
const environment = getEnvironment();

it("should publish provider", () => {
it("should publish extension", () => {
const builder = new BicepRegistryReferenceBuilder(
environment.registryUri,
testArea,
);
const baseFolder = pathToExampleFile("providers" + environment.suffix);
const baseFolder = pathToExampleFile("extensions" + environment.suffix);
const indexJsonPath = path.join(baseFolder, "types/http/index.json");
const target = builder.getBicepReference("http", "0.0.1");

invokingBicepCommand("publish-provider", indexJsonPath, "--target", target)
invokingBicepCommand("publish-extension", indexJsonPath, "--target", target)
.withEnvironmentOverrides(environment.environmentOverrides)
.shouldSucceed();
});
Expand All @@ -36,27 +36,27 @@ describe("bicep publish-provider live", () => {
environment.registryUri,
testArea,
);
const baseFolder = pathToExampleFile("providers" + environment.suffix);
const baseFolder = pathToExampleFile("extensions" + environment.suffix);
const indexJsonPath = path.join(baseFolder, "types/http/index.json");
const target = builder.getBicepReference("http", "0.0.1");

invokingBicepCommand("publish-provider", indexJsonPath, "--target", target)
invokingBicepCommand("publish-extension", indexJsonPath, "--target", target)
.withEnvironmentOverrides(environment.environmentOverrides)
.shouldSucceed();

const bicepContents = readFileSync(
path.join(baseFolder, "main.bicep"),
).replace("$TARGET_REFERENCE", target);
const bicepPath = writeTempFile(
"restore-provider",
"restore-extension",
"main.bicep",
bicepContents,
);

const configContents = readFileSync(
path.join(baseFolder, "bicepconfig.json"),
);
writeTempFile("restore-provider", "bicepconfig.json", configContents);
writeTempFile("restore-extension", "bicepconfig.json", configContents);

// Building with --stdout should emit a valid result.
invokingBicepCommand("build", "--stdout", bicepPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

/**
* Tests for "bicep publish-provider".
* Tests for "bicep publish-extension".
*
* @group CI
*/
Expand All @@ -17,19 +17,19 @@ import {
writeTempFile,
} from "./utils/fs";

describe("bicep publish-provider", () => {
it("should publish provider to the file system", () => {
describe("bicep publish-extension", () => {
it("should publish extension to the file system", () => {
const indexJsonPath = pathToExampleFile(
"providers.prod",
"extensions.prod",
"types",
"http",
"index.json",
);
const targetPath = pathToTempFile("publish-provider", "provider.tgz");
const targetPath = pathToTempFile("publish-extension", "extension.tgz");
ensureParentDirExists(targetPath);

invokingBicepCommand(
"publish-provider",
"publish-extension",
"--target",
targetPath,
indexJsonPath,
Expand All @@ -40,18 +40,18 @@ describe("bicep publish-provider", () => {
expectFileExists(targetPath);

const bicepContents = readFileSync(
pathToExampleFile("providers.prod", "main.bicep"),
).replace("$TARGET_REFERENCE", "./provider.tgz");
pathToExampleFile("extensions.prod", "main.bicep"),
).replace("$TARGET_REFERENCE", "./extension.tgz");
const bicepPath = writeTempFile(
"publish-provider",
"publish-extension",
"main.bicep",
bicepContents,
);

const configContents = readFileSync(
pathToExampleFile("providers.prod", "bicepconfig.json"),
pathToExampleFile("extensions.prod", "bicepconfig.json"),
);
writeTempFile("publish-provider", "bicepconfig.json", configContents);
writeTempFile("publish-extension", "bicepconfig.json", configContents);

// Building with --stdout should emit a valid result.
invokingBicepCommand("build", "--stdout", bicepPath)
Expand Down
22 changes: 11 additions & 11 deletions src/Bicep.Cli.IntegrationTests/PublishProviderCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task Publish_extension_should_succeed()

var registryStr = "example.com";
var registryUri = new Uri($"https://{registryStr}");
var repository = $"test/provider";
var repository = $"test/extension";
var version = "0.0.1";

var (clientFactory, blobClientMocks) = RegistryHelper.CreateMockRegistryClients((registryStr, repository));
Expand All @@ -75,8 +75,8 @@ public async Task Publish_extension_should_succeed()
// this command should output an experimental warning
result.Stderr.Should().Match("WARNING: The 'publish-extension' CLI command group is an experimental feature.*");

// verify the provider was published
mockBlobClient.Should().HaveProvider(version, out var tgzStream);
// verify the extension was published
mockBlobClient.Should().HaveExtension(version, out var tgzStream);

var typeLoader = OciTypeLoader.FromStream(tgzStream);
var azTypeLoader = new AzResourceTypeLoader(typeLoader);
Expand All @@ -99,8 +99,8 @@ public async Task Publish_extension_should_succeed()
var result2 = await Bicep(settings, [.. requiredArgs]);
result2.Should().Succeed().And.NotHaveStdout();

// verify the provider was published
mockBlobClient.Should().HaveProvider(version, out var tgzStream2);
// verify the extension was published
mockBlobClient.Should().HaveExtension(version, out var tgzStream2);

var typeLoader2 = OciTypeLoader.FromStream(tgzStream2);
var azTypeLoader2 = new AzResourceTypeLoader(typeLoader2);
Expand Down Expand Up @@ -150,7 +150,7 @@ public async Task Publish_extension_should_fail_for_malformed_target()
var outputDirectory = FileHelper.GetUniqueTestOutputPath(TestContext);
var indexPath = Path.Combine(outputDirectory, "index.json");

var result = await Bicep(InvocationSettings.Default, "publish-provider", indexPath, "--target", $"asdf:123");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"asdf:123");
result.Should().Fail().And.HaveStderrMatch("*The specified module reference scheme \"asdf\" is not recognized.*");
}

Expand All @@ -160,7 +160,7 @@ public async Task Publish_extension_should_fail_for_missing_index_path()
var outputDirectory = FileHelper.GetUniqueTestOutputPath(TestContext);
var indexPath = Path.Combine(outputDirectory, "index.json");

var result = await Bicep(InvocationSettings.Default, "publish-provider", indexPath, "--target", $"br:example.com/test/provider:0.0.1");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/extension:0.0.1");
result.Should().Fail().And.HaveStderrMatch("*Extension package creation failed: Could not find a part of the path '*'.*");
}

Expand All @@ -170,7 +170,7 @@ public async Task Publish_extension_should_fail_for_malformed_index()
var outputDirectory = FileHelper.GetUniqueTestOutputPath(TestContext);
var indexPath = FileHelper.SaveResultFile(TestContext, "index.json", "malformed", outputDirectory);

var result = await Bicep(InvocationSettings.Default, "publish-provider", indexPath, "--target", $"br:example.com/test/provider:0.0.1");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/extension:0.0.1");
result.Should().Fail().And.HaveStderrMatch("*Extension package creation failed: 'm' is an invalid start of a value.*");
}

Expand All @@ -189,7 +189,7 @@ public async Task Publish_extension_should_fail_for_missing_referenced_types_jso
}
""", outputDirectory);

var result = await Bicep(InvocationSettings.Default, "publish-provider", indexPath, "--target", $"br:example.com/test/provider:0.0.1");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/extension:0.0.1");
result.Should().Fail().And.HaveStderrMatch("*Extension package creation failed: Could not find file '*types.json'.*");
}

Expand All @@ -209,7 +209,7 @@ public async Task Publish_extension_should_fail_for_malformed_types_json()
""", outputDirectory);
FileHelper.SaveResultFile(TestContext, "v1/types.json", "malformed", outputDirectory);

var result = await Bicep(InvocationSettings.Default, "publish-provider", indexPath, "--target", $"br:example.com/test/provider:0.0.1");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/extension:0.0.1");
result.Should().Fail().And.HaveStderrMatch("*Extension package creation failed: 'm' is an invalid start of a value.*");
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public async Task Publish_extension_should_fail_for_bad_type_location()
]
""", outputDirectory);

var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/provider:0.0.1");
var result = await Bicep(InvocationSettings.Default, "publish-extension", indexPath, "--target", $"br:example.com/test/extension:0.0.1");
result.Should().Fail().And.HaveStderrMatch("*Extension package creation failed: Index was outside the bounds of the array.*");
}
}
8 changes: 4 additions & 4 deletions src/Bicep.Cli.IntegrationTests/RestoreCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ public async Task Restore_Artifacts_BackwardsAndForwardsCompatibility(string? me
[DataRow(new string[] { "unknown1", BicepMediaTypes.BicepModuleLayerV1Json, "unknown2" }, null)]
[DataRow(new string[] { BicepMediaTypes.BicepModuleLayerV1Json, "unknown1", "unknown2" }, null)]
[DataRow(new string[] { BicepMediaTypes.BicepModuleLayerV1Json, "unknown1", "unknown1", "unknown2", "unknown2" }, null)]
[DataRow(new string[] { BicepMediaTypes.BicepModuleLayerV1Json, BicepMediaTypes.BicepProviderArtifactLayerV1TarGzip }, null)]
[DataRow(new string[] { BicepMediaTypes.BicepModuleLayerV1Json, BicepMediaTypes.BicepExtensionArtifactLayerV1TarGzip }, null)]
// *** Negative Cases ***
[DataRow(
new string[] { BicepMediaTypes.BicepProviderArtifactLayerV1TarGzip },
new string[] { BicepMediaTypes.BicepExtensionArtifactLayerV1TarGzip },
".*Expected to find a layer with media type application\\/vnd.ms.bicep.module.layer.v1\\+json, but found none.*")]
[DataRow(
new string[] { },
".*Expected to find a layer with media type application\\/vnd.ms.bicep.module.layer.v1\\+json, but found none.*")]
[DataRow(
new string[] { "unknown", BicepMediaTypes.BicepProviderArtifactLayerV1TarGzip },
new string[] { "unknown", BicepMediaTypes.BicepExtensionArtifactLayerV1TarGzip },
".*Expected to find a layer with media type application\\/vnd.ms.bicep.module.layer.v1\\+json, but found none.*")]
[DataRow(
new string[] { "unknown2", "unknown1" },
Expand All @@ -240,7 +240,7 @@ public async Task Restore_Artifacts_BackwardsAndForwardsCompatibility(string? me
$".*Did not expect to find multiple layer media types of application\\/vnd.ms.bicep.module.layer.v1\\+json")]
// TODO: doesn't work because provider error handling is still coupled with module error handling.
[DataRow(
new string[] { BicepMediaTypes.BicepProviderArtifactLayerV1TarGzip, BicepMediaTypes.BicepProviderArtifactLayerV1TarGzip },
new string[] { BicepMediaTypes.BicepExtensionArtifactLayerV1TarGzip, BicepMediaTypes.BicepExtensionArtifactLayerV1TarGzip },
".*Expected to find a layer with media type application\\/vnd.ms.bicep.module.layer.v1\\+json, but found none.*")]
public async Task Restore_Artifacts_LayerMediaTypes(string[] layerMediaTypes, string expectedErrorRegex)
{
Expand Down
Loading

0 comments on commit 0dc89f2

Please sign in to comment.