Skip to content

Commit

Permalink
Update private preview pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Mar 11, 2021
1 parent 9bbc0e4 commit 8d46cbc
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 14 deletions.
72 changes: 67 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ stages:
variables:
K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest
CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions
EXTENSION_NAME: "k8s-extension"
EXTENSION_FILE_NAME: "k8s_extension"
SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3"
RESOURCE_GROUP: "K8sPartnerExtensionTest"
BASE_CLUSTER_NAME: "k8s-extension-cluster"

EXTENSION_NAME: "k8s-extension"
EXTENSION_FILE_NAME: "k8s_extension"
jobs:
- job: K8sExtensionTestSuite
displayName: "Run the Test Suite"
Expand All @@ -36,7 +37,6 @@ stages:
steps:
- checkout: self
- checkout: K8sPartnerExtensionTest

- bash: |
echo "Installing helm3"
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
Expand All @@ -55,6 +55,7 @@ stages:
versionSpec: 3.6
- bash: |
set -ev
echo "Building extension ${EXTENSION_NAME}..."
# prepare and activate virtualenv
pip install virtualenv
Expand All @@ -71,12 +72,12 @@ stages:
azdev extension build $(EXTENSION_NAME)
workingDirectory: $(CLI_REPO_PATH)
displayName: "Setup and Build $(EXTENSION_NAME) with azdev"
displayName: "Setup and Build Extension with azdev"
- bash: |
K8S_EXTENSION_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2)
echo "##vso[task.setvariable variable=K8S_EXTENSION_VERSION]$K8S_EXTENSION_VERSION"
cp * $(K8S_EXTENSION_REPO_PATH)/extensions
cp * $(K8S_EXTENSION_REPO_PATH)/bin
workingDirectory: $(CLI_REPO_PATH)/dist
displayName: "Copy the Built .whl to Extension Test Path"
Expand Down Expand Up @@ -142,6 +143,67 @@ stages:
.\Cleanup.ps1 -CI
workingDirectory: $(K8S_EXTENSION_REPO_PATH)
condition: succeededOrFailed()

- stage: BuildPublishExtension
dependsOn: []
displayName: "Build and Publish the Extension Artifact"
variables:
CLI_REPO_PATH: $(Agent.BuildDirectory)/s
IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))]
jobs:
- job: BuildPublishExtension
displayName: "Build and Publish the Extension Artifact"
pool:
vmImage: 'ubuntu-16.04'
steps:
- bash: |
if [[ $IS_PRIVATE_BRANCH ]]; then
echo "Using the private preview of k8s-extension to build..."
cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r
cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py
EXTENSION_NAME="k8s-extension-private"
EXTENSION_FILE_NAME="k8s_extension_private"
echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME"
echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME"
else
echo "Using the public version of k8s-extension to build..."
EXTENSION_NAME="k8s-extension"
EXTENSION_FILE_NAME="k8s_extension"
echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME"
echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME"
fi
displayName: "Copy Files, Set Variables based on Private Branch"
- task: UsePythonVersion@0
displayName: 'Use Python 3.6'
inputs:
versionSpec: 3.6
- bash: |
set -ev
echo "Building extension ${EXTENSION_NAME}..."
# prepare and activate virtualenv
pip install virtualenv
python3 -m venv env/
source env/bin/activate
# clone azure-cli
pip install azdev
ls $(CLI_REPO_PATH)
azdev --version
azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME)
azdev extension build $(EXTENSION_NAME)
workingDirectory: $(CLI_REPO_PATH)
displayName: "Setup and Build Extension with azdev"
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(CLI_REPO_PATH)/dist

- stage: AzureCLIOfficial
displayName: "Azure Official CLI Code Checks"
Expand Down
7 changes: 7 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

EXTENSION_NAME = 'k8s-extension'
7 changes: 7 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_consts_private.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

EXTENSION_NAME = 'k8s-extension-private'
13 changes: 7 additions & 6 deletions src/k8s-extension/azext_k8s_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@
# --------------------------------------------------------------------------------------------

from knack.help_files import helps # pylint: disable=unused-import
import azext_k8s_extension._consts as consts


helps['k8s-extension'] = """
helps[f'{consts.EXTENSION_NAME}'] = """
type: group
short-summary: Commands to manage K8s-extensions.
"""

helps['k8s-extension create'] = """
helps[f'{consts.EXTENSION_NAME} create'] = """
type: command
short-summary: Create a K8s-extension.
"""

helps['k8s-extension list'] = """
helps[f'{consts.EXTENSION_NAME} list'] = """
type: command
short-summary: List K8s-extensions.
"""

helps['k8s-extension delete'] = """
helps[f'{consts.EXTENSION_NAME} delete'] = """
type: command
short-summary: Delete a K8s-extension.
"""

helps['k8s-extension show'] = """
helps[f'{consts.EXTENSION_NAME} show'] = """
type: command
short-summary: Show details of a K8s-extension.
"""

helps['k8s-extension update'] = """
helps[f'{consts.EXTENSION_NAME} update'] = """
type: command
short-summary: Update a K8s-extension.
"""
3 changes: 2 additions & 1 deletion src/k8s-extension/azext_k8s_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tags_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
import azext_k8s_extension._consts as consts

from azext_k8s_extension.action import (
AddConfigurationSettings,
Expand All @@ -17,7 +18,7 @@


def load_arguments(self, _):
with self.argument_context('k8s-extension') as c:
with self.argument_context(consts.EXTENSION_NAME) as c:
c.argument('tags', tags_type)
c.argument('location',
validator=get_default_location_from_resource_group)
Expand Down
3 changes: 2 additions & 1 deletion src/k8s-extension/azext_k8s_extension/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pylint: disable=line-too-long
from azure.cli.core.commands import CliCommandType
from azext_k8s_extension._client_factory import (cf_k8s_extension, cf_k8s_extension_operation)
import azext_k8s_extension._consts as consts


def load_command_table(self, _):
Expand All @@ -14,7 +15,7 @@ def load_command_table(self, _):
operations_tmpl='azext_k8s_extension.vendored_sdks.operations#K8sExtensionsOperations.{}',
client_factory=cf_k8s_extension)

with self.command_group('k8s-extension', k8s_extension_sdk, client_factory=cf_k8s_extension_operation,
with self.command_group(consts.EXTENSION_NAME, k8s_extension_sdk, client_factory=cf_k8s_extension_operation,
is_preview=True) \
as g:
g.custom_command('create', 'create_k8s_extension')
Expand Down
3 changes: 2 additions & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from codecs import open
from setuptools import setup, find_packages
import azext_k8s_extension._consts as consts
try:
from azure_bdist_wheel import cmdclass
except ImportError:
Expand Down Expand Up @@ -41,7 +42,7 @@
HISTORY = f.read()

setup(
name='k8s-extension',
name=consts.EXTENSION_NAME,
version=VERSION,
description='Microsoft Azure Command-Line Tools K8s-extension Extension',
# TODO: Update author and email, if applicable
Expand Down

0 comments on commit 8d46cbc

Please sign in to comment.