mirror of
https://github.com/harness/drone.git
synced 2025-05-03 20:39:48 +08:00
feat: [CDE-332]: updated script for gitspace tools installation (#2874)
* feat: [CDE-332]: updated script for containers * feat: [CDE-332]: updated scrpt for containers
This commit is contained in:
parent
ad12a5d6f8
commit
1cb0e477f0
26
app/gitspace/orchestrator/common/detect_os.go
Normal file
26
app/gitspace/orchestrator/common/detect_os.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2023 Harness, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed script/os_info.sh
|
||||
var osDetectScript string
|
||||
|
||||
func GetOSInfoScript() (script string) {
|
||||
return osDetectScript
|
||||
}
|
@ -17,9 +17,9 @@ package ide
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/common"
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/devcontainer"
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/template"
|
||||
"github.com/harness/gitness/types"
|
||||
@ -48,15 +48,12 @@ func (v *VSCode) Setup(
|
||||
ctx context.Context,
|
||||
exec *devcontainer.Exec,
|
||||
) ([]byte, error) {
|
||||
osInfoScript, err := os.ReadFile("app/gitspace/orchestrator/common/script/os_info.sh")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read os_info.sh: %w", err)
|
||||
}
|
||||
osInfoScript := common.GetOSInfoScript()
|
||||
sshServerScript, err := template.GenerateScriptFromTemplate(
|
||||
templateSetupSSHServer, &template.SetupSSHServerPayload{
|
||||
Username: exec.UserIdentifier,
|
||||
AccessType: exec.AccessType,
|
||||
OSInfoScript: string(osInfoScript),
|
||||
OSInfoScript: osInfoScript,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
|
@ -17,8 +17,8 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/common"
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/devcontainer"
|
||||
"github.com/harness/gitness/app/gitspace/orchestrator/template"
|
||||
)
|
||||
@ -35,17 +35,14 @@ func NewUserServiceImpl() Service {
|
||||
}
|
||||
|
||||
func (u *ServiceImpl) Manage(ctx context.Context, exec *devcontainer.Exec) ([]byte, error) {
|
||||
osInfoScript, err := os.ReadFile("app/gitspace/orchestrator/common/script/os_info.sh")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read os_info.sh: %w", err)
|
||||
}
|
||||
osInfoScript := common.GetOSInfoScript()
|
||||
script, err := template.GenerateScriptFromTemplate(
|
||||
templateManagerUser, &template.SetupUserPayload{
|
||||
Username: exec.UserIdentifier,
|
||||
AccessKey: exec.AccessKey,
|
||||
AccessType: exec.AccessType,
|
||||
HomeDir: exec.HomeDir,
|
||||
OSInfoScript: string(osInfoScript),
|
||||
OSInfoScript: osInfoScript,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
|
Loading…
Reference in New Issue
Block a user