Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dapr extension #78

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .partner_extensions.OpenServiceMesh import OpenServiceMesh
from .partner_extensions.AzureMLKubernetes import AzureMLKubernetes
from .partner_extensions.AzurePolicy import AzurePolicy
from .partner_extensions.Dapr import Dapr
from .partner_extensions.DefaultExtension import DefaultExtension
from . import consts

Expand All @@ -38,6 +39,7 @@ def ExtensionFactory(extension_name):
'microsoft.openservicemesh': OpenServiceMesh,
'microsoft.azureml.kubernetes': AzureMLKubernetes,
'microsoft.policyinsights': AzurePolicy,
'microsoft.dapr': Dapr,
}

# Return the extension if we find it in the map, else return the default
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-argument
# pylint: disable=line-too-long
# pylint: disable=too-many-locals

from azure.cli.core.azclierror import InvalidArgumentValueError

from .DefaultExtension import DefaultExtension

from ..vendored_sdks.models import (
Extension,
)


class Dapr(DefaultExtension):
def __init__(self):
# constants for configuration settings.
self.CLUSTER_TYPE = 'global.clusterType'

def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type,
scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):

"""ExtensionType 'Microsoft.Dapr' specific validations & defaults for Create
Must create and return a valid 'ExtensionInstance' object.
"""

if cluster_type.lower() == '' or cluster_type.lower() == 'managedclusters':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? If it isn't needed, then there is no need for CLI customization for Dapr

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some difference for helm charts between managed clusters and connected cluster.

configuration_settings[self.CLUSTER_TYPE] = 'managedclusters'

create_identity = False
extension_instance = Extension(
extension_type=extension_type,
auto_upgrade_minor_version=auto_upgrade_minor_version,
release_train=release_train,
version=version,
scope=scope,
configuration_settings=configuration_settings,
configuration_protected_settings=configuration_protected_settings,
identity=None,
location=""
)
return extension_instance, name, create_identity
ZeroMagic marked this conversation as resolved.
Show resolved Hide resolved