Skip to content
Open
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
4 changes: 4 additions & 0 deletions cli/azd/cmd/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func (m *mockProjectManager) Initialize(ctx context.Context, projectConfig *proj
return m.Called(ctx, projectConfig).Error(0)
}

func (m *mockProjectManager) InitializeServices(ctx context.Context, services []*project.ServiceConfig) error {
return m.Called(ctx, services).Error(0)
}

func (m *mockProjectManager) InitializeFrameworks(
ctx context.Context, projectConfig *project.ProjectConfig,
) ([]*project.ServiceConfig, []project.ServiceFrameworkInitFailure, error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package synthesis

import (
"fmt"

"github.com/azure/azure-dev/cli/azd/pkg/foundry"
)

// evaluateCondition matches project.ServiceConfig.IsEnabled.
// Extensions pin a published azd module, so they cannot import
// newer core helpers until that module is bumped.
func evaluateCondition(
value string,
getenv func(string) string,
) (bool, error) {
if value == "" {
return true, nil
}
if getenv == nil {
getenv = func(string) string { return "" }
}
expanded, err := foundry.ExpandEnv(value, getenv)
if err != nil {
return false, fmt.Errorf(
"malformed condition template: %w",
err,
)
}
return isTruthyCondition(expanded), nil
}

func isTruthyCondition(value string) bool {
switch value {
case "1", "true", "TRUE", "True", "yes", "YES", "Yes":
return true
default:
return false
}
}
Loading
Loading