Skip to content

Commit

Permalink
Add optional installation of Bicep
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Christensen <[email protected]>
  • Loading branch information
kichristensen committed Jul 7, 2024
1 parent 732c043 commit 477bf5a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/az/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type MixinConfig struct {

// Extensions is a list of az CLI extensions to install.
Extensions []string `yaml:"extensions,omitempty"`

// Indicates if Bicep should be installed
InstallBicep bool `yaml:"installBicep,omitempty"`
}

// buildConfig is the set of configuration options for the mixin's portion of the Dockerfile
Expand All @@ -50,10 +53,14 @@ RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get install -y --no-install-recommends \
{{ if .InstallBicep }}libicu72 \{{ end }}
{{ if eq .ClientVersion ""}}azure-cli{{else}}azure-cli={{.ClientVersion}}-1~$(lsb_release -cs){{end}}
{{ range $ext := .Extensions }}
RUN az extension add -y --name {{ $ext }}
{{ end }}
{{ if .InstallBicep }}
RUN az bicep install
{{ end }}
`

// Build installs the az cli and any configured extensions.
Expand Down
1 change: 1 addition & 0 deletions pkg/az/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestMixin_Build(t *testing.T) {
}{
{name: "build with config", inputFile: "testdata/build-input-with-config.yaml", wantOutputFile: "testdata/build-with-config.txt"},
{name: "build without config", inputFile: "testdata/build-input-without-config.yaml", wantOutputFile: "testdata/build-without-config.txt"},
{name: "build with bicep", inputFile: "testdata/build-input-with-bicep.yaml", wantOutputFile: "testdata/build-with-bicep.txt"},
}

for _, tc := range testcases {
Expand Down
4 changes: 4 additions & 0 deletions pkg/az/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"items": {
"type": "string"
}
},
"installBicep": {
"description": "Indicates if Bicep should be install",
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
2 changes: 2 additions & 0 deletions pkg/az/testdata/build-with-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get install -y --no-install-recommends \

azure-cli=1.2.3-1~$(lsb_release -cs)

RUN az extension add -y --name iot


2 changes: 2 additions & 0 deletions pkg/az/testdata/build-without-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get install -y --no-install-recommends \

azure-cli


0 comments on commit 477bf5a

Please sign in to comment.