-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manifests: init embed FS for virtualnodes charts
Signed-off-by: Wei Fu <weifu@microsoft.com>
- Loading branch information
Showing
12 changed files
with
657 additions
and
4 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
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,59 @@ | ||
package manifests | ||
|
||
import ( | ||
"fmt" | ||
"io/fs" | ||
"path/filepath" | ||
"strings" | ||
|
||
"helm.sh/helm/v3/pkg/chart" | ||
"helm.sh/helm/v3/pkg/chart/loader" | ||
) | ||
|
||
// LoadCharts returns charts from embed filesystem. | ||
func LoadCharts(componentName string) (*chart.Chart, error) { | ||
files, err := getFilesFromFSRecursively(componentName) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get chart files: %w", err) | ||
} | ||
|
||
topDir := componentName + string(filepath.Separator) | ||
bufFiles := make([]*loader.BufferedFile, 0, len(files)) | ||
for _, f := range files { | ||
data, err := fs.ReadFile(FS, f) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read file (%s): %w", f, err) | ||
} | ||
|
||
fname := filepath.ToSlash(strings.TrimPrefix(f, topDir)) | ||
bufFiles = append(bufFiles, | ||
&loader.BufferedFile{ | ||
Name: fname, | ||
Data: data, | ||
}, | ||
) | ||
} | ||
return loader.LoadFiles(bufFiles) | ||
} | ||
|
||
func getFilesFromFSRecursively(componentName string) ([]string, error) { | ||
files := make([]string, 0) | ||
|
||
err := fs.WalkDir(FS, componentName, | ||
func(path string, d fs.DirEntry, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if d.IsDir() { | ||
return nil | ||
} | ||
files = append(files, path) | ||
return nil | ||
}, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return files, 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,8 @@ | ||
package manifests | ||
|
||
import "embed" | ||
|
||
// FS embeds the manifests | ||
// | ||
//go:embed virtualcluster/* | ||
var FS embed.FS |
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,4 @@ | ||
{ | ||
"name": "virtualnodes", | ||
"version": "0.0.1" | ||
} |
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,59 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ .Values.name }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- update | ||
- patch | ||
- watch | ||
- list | ||
- get | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes/status | ||
verbs: | ||
- update | ||
- patch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- watch | ||
- list | ||
- delete | ||
- update | ||
- patch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/status | ||
verbs: | ||
- update | ||
- patch | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- create | ||
- update | ||
- patch | ||
- watch | ||
- list | ||
- get |
12 changes: 12 additions & 0 deletions
12
manifests/virtualcluster/nodes/templates/clusterrolebinding.yaml
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,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ .Values.name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ .Values.name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ .Values.name }} | ||
namespace: {{ .Release.Namespace }} |
Oops, something went wrong.