Projects
Eulaceura:Factory
eggo
_service:obs_scm:0004-add-host-name-checker-add...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0004-add-host-name-checker-add-bin-execute-permission.patch of Package eggo
From ae822ab2b0fd07d33adb7c244e78f2fcd31e1c05 Mon Sep 17 00:00:00 2001 From: zhangxiaoyu <zhangxiaoyu58@huawei.com> Date: Wed, 3 Nov 2021 15:16:09 +0800 Subject: [PATCH 04/12] add host name checker, add bin execute permission Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com> --- cmd/checker.go | 6 ++++++ config/all_online_install.config | 1 + config/openEuler.config | 8 ++++---- docs/configuration_file_description.md | 2 +- pkg/utils/dependency/dependency.go | 19 +++++++++++++----- pkg/utils/dependency/install.go | 27 ++++++++++++++------------ 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/cmd/checker.go b/cmd/checker.go index 4530f2b..9d1fda6 100644 --- a/cmd/checker.go +++ b/cmd/checker.go @@ -140,6 +140,12 @@ func checkHostconfig(h *HostConfig) error { if h == nil { return fmt.Errorf("empty hostconfig") } + if h.Name == "" { + return fmt.Errorf("empty host name") + } + if errs := validation.IsDNS1123Subdomain(h.Name); len(errs) > 0 { + return fmt.Errorf("invalid host name: %v", errs) + } if h.Ip == "" { return fmt.Errorf("host: %s ip is null", h.Name) } diff --git a/config/all_online_install.config b/config/all_online_install.config index dfc3ad4..c8a5eae 100644 --- a/config/all_online_install.config +++ b/config/all_online_install.config @@ -17,6 +17,7 @@ workers: arch: arm64 runtime: iSulad runtime-endpoint: unix:///var/run/isulad.sock +pause-image: docker.io/mirrorgcrio/pause:3.2 open-ports: worker: - port: 111 diff --git a/config/openEuler.config b/config/openEuler.config index 07acf9b..a69154b 100755 --- a/config/openEuler.config +++ b/config/openEuler.config @@ -1,17 +1,17 @@ -cluster-id: k8s-openEuler +cluster-id: k8s-openeuler username: root password: "123456" masters: -- name: openEuler1 +- name: openeuler1 ip: 192.168.0.1 port: 22 arch: arm64 workers: -- name: openEuler1 +- name: openeuler1 ip: 192.168.0.1 port: 22 arch: arm64 -- name: openEuler2 +- name: openeuler2 ip: 192.168.0.2 port: 22 arch: arm64 diff --git a/docs/configuration_file_description.md b/docs/configuration_file_description.md index c169f49..4c84e5f 100644 --- a/docs/configuration_file_description.md +++ b/docs/configuration_file_description.md @@ -8,7 +8,7 @@ username: root // 需要部署k8s集群的机器的ssh登录 password: 123456 // 需要部署k8s集群的机器的ssh登录密码,所有机器都需要使用同一个密码 private-key-path: ~/.ssh/pri.key // ssh免密登录的密钥,可以替代password防止密码泄露 masters: // 配置master节点的列表,建议每个master节点同时作为worker节点,否则master节点可以无法直接访问pod -- name: test0 // 该节点的名称,为k8s集群看到的该节点的名称 +- name: test0 // 该节点的名称,为k8s集群看到的该节点的名称,名字需要符合RFC 1123 subdomain规范 ip: 192.168.0.1 // 该节点的ip地址 port: 22 // ssh登录的端口 arch: arm64 // 机器架构,x86_64的填amd64 diff --git a/pkg/utils/dependency/dependency.go b/pkg/utils/dependency/dependency.go index 3d0bf8f..9e6ac22 100644 --- a/pkg/utils/dependency/dependency.go +++ b/pkg/utils/dependency/dependency.go @@ -143,15 +143,23 @@ func (dd *dependencyDeb) Remove(r runner.Runner) error { } // install file and dir -type dependencyFD struct { - srcPath string - software []*api.PackageConfig +type dependencyFileDir struct { + executable bool + srcPath string + software []*api.PackageConfig } -func (df *dependencyFD) Install(r runner.Runner) error { +func (df *dependencyFileDir) Install(r runner.Runner) error { shell := ` #!/bin/bash cd {{ .srcPath }} + +{{- if .executable }} +{{- range $i, $v := .software }} +chmod +x {{ $v.Name }} +{{- end }} +{{- end }} + {{- range $i, $v := .software }} if [ ! -e {{ JoinPath $v.Dst $v.Name }} ]; then mkdir -p {{ $v.Dst }} && cp -r {{ $v.Name }} {{ $v.Dst }} @@ -161,6 +169,7 @@ fi datastore := make(map[string]interface{}) datastore["srcPath"] = df.srcPath datastore["software"] = df.software + datastore["executable"] = df.executable shellStr, err := template.TemplateRender(shell, datastore) if err != nil { @@ -175,7 +184,7 @@ fi return nil } -func (df *dependencyFD) Remove(r runner.Runner) error { +func (df *dependencyFileDir) Remove(r runner.Runner) error { var sb strings.Builder sb.WriteString("sudo -E /bin/sh -c \"") for _, s := range df.software { diff --git a/pkg/utils/dependency/install.go b/pkg/utils/dependency/install.go index 611c006..e2c0621 100644 --- a/pkg/utils/dependency/install.go +++ b/pkg/utils/dependency/install.go @@ -125,23 +125,26 @@ func installFD(r runner.Runner, bin, file, dir []*api.PackageConfig, hcf *api.Ho dp := []dependency{} if len(bin) != 0 { - dp = append(dp, &dependencyFD{ - srcPath: path.Join(packagePath, constants.DefaultBinPath), - software: bin, + dp = append(dp, &dependencyFileDir{ + srcPath: path.Join(packagePath, constants.DefaultBinPath), + software: bin, + executable: true, }) } if len(file) != 0 { - dp = append(dp, &dependencyFD{ - srcPath: path.Join(packagePath, constants.DefaultFilePath), - software: file, + dp = append(dp, &dependencyFileDir{ + srcPath: path.Join(packagePath, constants.DefaultFilePath), + software: file, + executable: false, }) } if len(dir) != 0 { - dp = append(dp, &dependencyFD{ - srcPath: path.Join(packagePath, constants.DefaultDirPath), - software: dir, + dp = append(dp, &dependencyFileDir{ + srcPath: path.Join(packagePath, constants.DefaultDirPath), + software: dir, + executable: false, }) } @@ -233,19 +236,19 @@ func uninstallFD(r runner.Runner, bin, file, dir []*api.PackageConfig, hcf *api. dp := []dependency{} if len(bin) != 0 { - dp = append(dp, &dependencyFD{ + dp = append(dp, &dependencyFileDir{ software: bin, }) } if len(file) != 0 { - dp = append(dp, &dependencyFD{ + dp = append(dp, &dependencyFileDir{ software: file, }) } if len(dir) != 0 { - dp = append(dp, &dependencyFD{ + dp = append(dp, &dependencyFileDir{ software: dir, }) } -- 2.25.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2