3
3
package sampleapp
4
4
5
5
import (
6
- "context"
7
6
"errors"
8
7
"fmt"
9
8
"os"
@@ -13,17 +12,13 @@ import (
13
12
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
14
13
15
14
"github.com/spf13/cobra"
16
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17
15
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
18
16
"open-cluster-management.io/clusteradm/pkg/cmd/create/sampleapp/scenario"
19
17
)
20
18
21
19
const (
22
20
defaultSampleAppName = "sampleapp"
23
21
pathToAppManifests = "scenario/sampleapp"
24
- clusterSetLabel = "cluster.open-cluster-management.io/clusterset"
25
- placementLabel = "placement"
26
- placementLabelValue = "sampleapp"
27
22
)
28
23
29
24
func (o * Options ) complete (cmd * cobra.Command , args []string ) (err error ) {
@@ -67,48 +62,12 @@ func (o *Options) Run() (err error) {
67
62
68
63
func (o * Options ) runWithClient (clusterClient clusterclientset.Interface , dryRun bool ) error {
69
64
70
- // Label all managed clusters with clusterset and placement labels
71
- err := o .checkManagedClusterBinding (clusterClient , dryRun )
72
- if err != nil {
73
- return err
74
- }
75
-
76
65
// Apply sample application manifest to hub cluster
77
- err = o .deployApp ()
78
- if err != nil {
79
- return err
80
- }
81
-
82
- return nil
83
- }
84
-
85
- func (o * Options ) checkManagedClusterBinding (clusterClient clusterclientset.Interface , dryRun bool ) error {
86
-
87
- // Skip if dryRun
88
- if dryRun {
89
- return nil
90
- }
91
-
92
- // Get managed clusters
93
- clusters , err := clusterClient .ClusterV1 ().ManagedClusters ().List (context .TODO (), metav1.ListOptions {})
66
+ err := o .deployApp ()
94
67
if err != nil {
95
68
return err
96
69
}
97
70
98
- // Check for binding labels in managed clusters
99
- for _ , cluster := range clusters .Items {
100
- managedCluster , err := clusterClient .ClusterV1 ().ManagedClusters ().Get (context .TODO (), cluster .Name , metav1.GetOptions {})
101
- if err != nil {
102
- return err
103
- }
104
- if cs , ok := managedCluster .Labels [clusterSetLabel ]; ! ok || (cs != fmt .Sprintf ("app-%s" , o .SampleAppName )) {
105
- fmt .Fprintf (o .Streams .Out , "[WARNING] Label \" %s=%s\" has not been found in ManagedCluster %s, could not establish binding.\n " , clusterSetLabel , fmt .Sprintf ("app-%s" , o .SampleAppName ), cluster .Name )
106
- }
107
- if p , ok := managedCluster .Labels [placementLabel ]; ! ok || (p != placementLabelValue ) {
108
- fmt .Fprintf (o .Streams .Out , "[WARNING] Label \" %s=%s\" has not been found in ManagedCluster %s, could not establish binding.\n " , placementLabel , placementLabelValue , cluster .Name )
109
- }
110
- }
111
-
112
71
return nil
113
72
}
114
73
0 commit comments