Skip to content

Commit

Permalink
Try SSH from Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Feb 26, 2025
1 parent 0a28202 commit 9b54aa6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ type TypeStruct struct {
State string
Mem string
CPU string
SSH string
}
5 changes: 5 additions & 0 deletions backend/internal/service/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func Exec(item models.Item, typesMap map[string]map[string]string) (bool, string

str = strings.Replace(str, "$ITEMNAME", item.Name, -1)

ssh := t["SSH"]
if ssh != "" {
str = ssh + " " + str
}

log.Println("EXEC:", str)
cmd := exec.Command("sh", "-c", str)

Expand Down
2 changes: 2 additions & 0 deletions backend/internal/web/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func typesToStruct(types map[string]map[string]string) (typeStructArray []models
oneStruct.State = value["State"]
oneStruct.Mem = value["Mem"]
oneStruct.CPU = value["CPU"]
oneStruct.SSH = value["SSH"]

typeStructArray = append(typeStructArray, oneStruct)
}
Expand All @@ -38,6 +39,7 @@ func toOneType(tStruct models.TypeStruct) (tmpMap map[string]string) {
tmpMap["State"] = tStruct.State
tmpMap["Mem"] = tStruct.Mem
tmpMap["CPU"] = tStruct.CPU
tmpMap["SSH"] = tStruct.SSH

return tmpMap
}
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/web/public/assets/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/src/components/TypeAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function TypeAdd(_props:any) {
State: "",
CPU: "",
Mem: "",
SSH: "",
}

return (
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/TypeEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function TypeEdit(_props: any) {
Logs: _props.typeItem.Logs,
State: _props.typeItem.State,
CPU: _props.typeItem.CPU,
Mem: _props.typeItem.Mem
Mem: _props.typeItem.Mem,
SSH: _props.typeItem.SSH
};

const [isModalOpen, setModalOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -70,6 +71,8 @@ function TypeEdit(_props: any) {
<form>
<label htmlFor="nid" className="form-label text-primary">Name</label>
<input className="form-control mb-3" defaultValue={oldType.Name} id="nid" name="Name" onChange={handleChange} placeholder="Not empty string"></input>
<label htmlFor="sshid" className="form-label text-primary">SSH (optional)</label>
<input className="form-control mb-3" defaultValue={oldType.SSH} id="sshid" name="SSH" onChange={handleChange} placeholder=""></input>
<p>Use variable <code>$ITEMNAME</code> in the commands below</p>
<label htmlFor="gid" className="form-label text-primary">Start</label>
<input className="form-control mb-3" defaultValue={oldType.Start} id="gid" name="Start" onChange={handleChange} placeholder="docker start $ITEMNAME"></input>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/functions/exports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export interface TypeStruct {
State: string;
CPU: string;
Mem: string;
SSH: string;
};

0 comments on commit 9b54aa6

Please sign in to comment.