-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added target in stage spec and solution create in providers.stage.cre…
…ate (#612) * wnew create * resovle comments
- Loading branch information
1 parent
55f5e2d
commit 65a2a9e
Showing
12 changed files
with
374 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
//go:build !azure | ||
// +build !azure | ||
|
||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//go:build !azure | ||
|
||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package helper | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/model" | ||
api_utils "github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/utils" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func GetInstanceTargetName(name string) string { | ||
return name | ||
} | ||
|
||
func GetInstanceRootResource(name string) string { | ||
return "" | ||
} | ||
|
||
func GetInstanceOwnerReferences(apiClient api_utils.ApiClient, ctx context.Context, objectName string, objectNamespace string, instanceState model.InstanceState, user string, pwd string) ([]metav1.OwnerReference, error) { | ||
return nil, nil | ||
} | ||
|
||
func GetSolutionContainerOwnerReferences(apiClient api_utils.ApiClient, ctx context.Context, objectName string, objectNamespace string, user string, pwd string) ([]metav1.OwnerReference, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//go:build azure | ||
|
||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package helper | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/eclipse-symphony/symphony/api/constants" | ||
"github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/model" | ||
api_utils "github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/utils" | ||
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func GetInstanceTargetName(name string) string { | ||
parts := strings.Split(name, "/") | ||
if len(parts) < 3 { | ||
return "" | ||
} | ||
version := parts[len(parts)-1] | ||
solution := parts[len(parts)-3] | ||
return fmt.Sprintf("%s:%s", solution, version) | ||
} | ||
|
||
func GetInstanceRootResource(name string) string { | ||
parts := strings.Split(name, "/") | ||
if len(parts) < 3 { | ||
return "" | ||
} | ||
return parts[len(parts)-3] | ||
} | ||
|
||
func GetInstanceOwnerReferences(apiClient api_utils.ApiClient, ctx context.Context, objectName string, objectNamespace string, instanceState model.InstanceState, user string, pwd string) ([]metav1.OwnerReference, error) { | ||
parts := strings.Split(instanceState.Spec.Solution, constants.ReferenceSeparator) | ||
if len(parts) != 2 { | ||
return nil, v1alpha2.NewCOAError(nil, fmt.Sprintf("Invalid solution name: instance - %s", objectName), v1alpha2.BadRequest) | ||
} | ||
sc, err := apiClient.GetSolutionContainer(ctx, parts[0], objectNamespace, user, pwd) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return []metav1.OwnerReference{ | ||
{ | ||
APIVersion: fmt.Sprintf("%s/%s", model.SolutionGroup, "v1"), | ||
Kind: "SolutionContainer", | ||
Name: sc.ObjectMeta.Name, | ||
UID: sc.ObjectMeta.UID, | ||
}, | ||
}, nil | ||
} | ||
|
||
func GetSolutionContainerOwnerReferences(apiClient api_utils.ApiClient, ctx context.Context, objectName string, objectNamespace string, user string, pwd string) ([]metav1.OwnerReference, error) { | ||
target, err := apiClient.GetTarget(ctx, objectName, objectNamespace, user, pwd) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []metav1.OwnerReference{ | ||
{ | ||
APIVersion: fmt.Sprintf("%s/%s", model.FabricGroup, "v1"), | ||
Kind: "Target", | ||
Name: target.ObjectMeta.Name, | ||
UID: target.ObjectMeta.UID, | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
//go:build !azure | ||
|
||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.