-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for creating a KubeStellar BindingPolicy with --create-…
…bp switch - next - brew install formula and demos - home stretch
- Loading branch information
1 parent
983475a
commit 8a01c34
Showing
3 changed files
with
98 additions
and
0 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
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,69 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type BindingPolicy struct { | ||
APIVersion string `yaml:"apiVersion"` | ||
Kind string `yaml:"kind"` | ||
Metadata Metadata `yaml:"metadata"` | ||
WantSingletonReportedState bool `yaml:"wantSingletonReportedState"` | ||
ClusterSelectors []ClusterSelector `yaml:"clusterSelectors"` | ||
Downsync []Downsync `yaml:"downsync"` | ||
} | ||
|
||
type Metadata struct { | ||
Name string `yaml:"name"` | ||
} | ||
|
||
type ClusterSelector struct { | ||
MatchLabels map[string]string `yaml:"matchLabels"` | ||
} | ||
|
||
type Downsync struct { | ||
ObjectSelectors []ObjectSelector `yaml:"objectSelectors"` | ||
} | ||
|
||
type ObjectSelector struct { | ||
MatchLabels map[string]string `yaml:"matchLabels"` | ||
} | ||
|
||
func (p ParamsStruct) createBP() { | ||
bindingPolicy := BindingPolicy{ | ||
APIVersion: "control.kubestellar.io/v1alpha1", | ||
Kind: "BindingPolicy", | ||
Metadata: Metadata{ | ||
Name: "wec-kwasm-bindingpolicy", | ||
}, | ||
WantSingletonReportedState: true, | ||
ClusterSelectors: []ClusterSelector{ | ||
{ | ||
MatchLabels: map[string]string{ | ||
"location-group": "edge", | ||
}, | ||
}, | ||
}, | ||
Downsync: []Downsync{ | ||
{ | ||
ObjectSelectors: []ObjectSelector{ | ||
{ | ||
MatchLabels: map[string]string{ | ||
p.labelKey: p.labelVal, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
yamlData, err := yaml.Marshal(bindingPolicy) | ||
if err != nil { | ||
fmt.Println("Error marshaling YAML:", err) | ||
return | ||
} | ||
|
||
fmt.Println(string(yamlData)) | ||
} |
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