Skip to content

Commit 3ad2c8a

Browse files
fix: software as a service, package build|verify (#203)
* deleting image file at root of repo * adding script * fixing software as a service results * version 0.2.2 * style and linter fixes * Fixing #202 * style and linter fixes
1 parent 0113ff4 commit 3ad2c8a

File tree

17 files changed

+127
-21
lines changed

17 files changed

+127
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ coverage.xml
5353
*.py,cover
5454
.hypothesis/
5555
.pytest_cache/
56+
.cnab
5657

5758
# Translations
5859
*.mo

partnercenter/azext_partnercenter/operations/marketplace_offer_listing_media/_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ def load_help():
3737
examples:
3838
- name: List the media for an offer's listing
3939
text: |-
40-
az partnercenter marketplace offer listing media list --offer-id MyOfferId
40+
az partnercenter marketplace offer listing media list --offer-id MyOfferId --type Image
4141
"""

partnercenter/azext_partnercenter/operations/marketplace_offer_package/_cnab_util.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
import yaml
1313
from knack.util import CLIError
1414

15+
DATA_DIR = "/data"
16+
1517

1618
def verify(manifest_file):
1719
container = _get_container(manifest_file)
18-
result = container.exec_run('cpa verify --directory ./cpaMount')
19-
vr = VerifyResult(result.output.decode("utf-8"))
20-
return vr.to_list()
20+
result = container.exec_run('cpa verify', workdir=DATA_DIR)
21+
return result
2122

2223

2324
def bundle(manifest_file):
2425
container = _get_container(manifest_file)
2526
acr_name = _get_acr_name(manifest_file)
2627
result = container.exec_run('az acr login -n ' + acr_name)
27-
result = container.exec_run('cpa buildbundle', workdir='/cpaMount')
28+
result = container.exec_run('cpa buildbundle', workdir=DATA_DIR)
2829
return result
2930

3031

@@ -48,7 +49,10 @@ def _run_container(container_name, mount_path):
4849

4950
img = 'mcr.microsoft.com/container-package-app:latest'
5051
cmd = 'sleep infinity'
51-
volumes = ['/var/run/docker.sock:/var/run/docker.sock', f'{mount_path}:/cpaMount', f'{absolute_path}:/root/.azure']
52+
53+
print(mount_path)
54+
55+
volumes = ['/var/run/docker.sock:/var/run/docker.sock', f'{mount_path}:/data', f'{absolute_path}:/root/.azure']
5256
container = client.containers.run(img, cmd, detach=True, volumes=volumes, name=container_name)
5357
return container
5458

partnercenter/azext_partnercenter/operations/marketplace_offer_package/custom.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313

1414
def build_package(client, offer_id, manifest_file=None):
15-
_execute_action_by_offer_type(client, offer_id, lambda: _build_cnab_bundle(manifest_file))
15+
return _execute_action_by_offer_type(client, offer_id, manifest_file, _build_cnab_bundle)
1616

1717

1818
def verify_package(client, offer_id, manifest_file=None):
19-
_execute_action_by_offer_type(client, offer_id, lambda: _verify_cnab_bundle(manifest_file))
19+
return _execute_action_by_offer_type(client, offer_id, manifest_file, _verify_cnab_bundle)
2020

2121

22-
def _execute_action_by_offer_type(client, offer_id, action):
22+
def _execute_action_by_offer_type(client, offer_id, manifest_file, action):
2323
offer = client.get(offer_id)
2424
if offer is None:
2525
raise ResourceNotFoundError('An Offer was not found with that ID.', 'Please check the value set for parameter --offer-id.')
@@ -30,20 +30,22 @@ def _execute_action_by_offer_type(client, offer_id, action):
3030
offer_setup = client.get_setup(offer_id)
3131
# if the offer type is "AzureApplication" AND the offer is setup to sell through Microsoft, we can build a CNAB bundle for it
3232
if offer_setup.sell_through_microsoft:
33-
action()
34-
else:
35-
raise InvalidArgumentValueError(f'{offer_id} offer is not setup to support a CNAB bundle. The offer type must be {OfferType.AZUREAPPLICATION} and setup to sell through Microsoft',
36-
f'Update the offer\'s setup to sell through Microsoft.\n\n az partercenter marketplace offer setup --offer-id {offer_id} --sell-through-microsoft')
33+
return action(manifest_file)
34+
35+
raise InvalidArgumentValueError(f'{offer_id} offer is not setup to support a CNAB bundle. The offer type must be {OfferType.AZUREAPPLICATION} and setup to sell through Microsoft',
36+
f'Update the offer\'s setup to sell through Microsoft.\n\n az partercenter marketplace offer setup --offer-id {offer_id} --sell-through-microsoft')
3737

3838
# if we got to this point, the offer type isn't supported
3939
raise CLIError(f'{offer_id} offer is a {offer_type} type which is currently not supported by the CLI. Please submit an issue to get support at {ISSUES_URL}.')
4040

4141

4242
def _verify_cnab_bundle(manifest_file):
4343
result = verify(manifest_file)
44+
print(result.output.decode("utf-8"))
4445
return result
4546

4647

4748
def _build_cnab_bundle(manifest_file):
4849
result = bundle(manifest_file)
49-
return result.output
50+
print(result.output.decode("utf-8"))
51+
return result

partnercenter/azext_partnercenter/operations/marketplace_offer_plan_technicalconfiguration/_help.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ def load_help():
2727
type: command
2828
short-summary: Adds a package to the technical configuration of a plan
2929
"""
30+
31+
helps['partnercenter marketplace offer plan technical-configuration package delete'] = """
32+
type: command
33+
short-summary: Deletes a package to the technical configuration of a plan
34+
"""

partnercenter/azext_partnercenter/operations/marketplace_offer_plan_technicalconfiguration/params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def load_arguments(commands_loader, _):
2020
c.argument('tag', arg_group='CNAB Resource', options_list=['--tag'], help='The name of the image repository.')
2121
c.argument('digest', arg_group='CNAB Resource', options_list=['--digest'], help='The digest of the bundle with a format of sha256:<hashcode>')
2222

23-
with commands_loader.argument_context('partnercenter marketplace offer plan technical-configuration delete') as c:
23+
with commands_loader.argument_context('partnercenter marketplace offer plan technical-configuration package delete') as c:
2424
c.argument('repository_name', arg_group='CNAB Resource', options_list=['--repository'], help='The name of the image repository in the Azure Container Registry.')
2525
c.argument('tag', arg_group='CNAB Resource', options_list=['--tag'], help='The name of the image repository.')

partnercenter/azext_partnercenter/tests/data/marketplace_offer_package/aks_offer/mainTemplate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
5+
"extensionResourceName": {
6+
"type": "string",
7+
"metadata": {
8+
"description": "resource name of the extension"
9+
}
10+
},
511
"resourceName": {
612
"type": "string",
713
"metadata": {

partnercenter/azext_partnercenter/tests/data/marketplace_offer_package/aks_offer/manifest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ restrictions:
1313
helmChart: "./azure-vote"
1414
clusterArmTemplate: "./mainTemplate.json"
1515
uiDefinition: "./createUIDefinition.json"
16-
registryServer: "youracr.azurecr.io"
16+
registryServer: "thfalgoupartner.azurecr.io"
1717
extensionRegistrationParameters:
1818
defaultScope: "cluster"
1919
namespace: "contoso"
2020
billingIdentifier: microsoft.marketplace.example.azure-vote
21-
21+

partnercenter/azext_partnercenter/tests/data/marketplace_offer_package/aks_offer/porter.yaml

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)