implement resize disk
This commit is contained in:
parent
6a3cefcc62
commit
e5390800bf
4 changed files with 27 additions and 6 deletions
|
|
@ -3,5 +3,6 @@
|
|||
"rebootIfRequired": true,
|
||||
"updateHostname": true,
|
||||
"updatePassword": true,
|
||||
"updateNetworkConfig": true
|
||||
"updateNetworkConfig": true,
|
||||
"resizeDisk": true
|
||||
}
|
||||
|
|
@ -9,11 +9,12 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
PasswordApiEndpoint string `json:"passwordApiEndpoint"`
|
||||
RebootIfRequired bool `json:"rebootIfRequired"`
|
||||
UpdateHostname bool `json:"updateHostname"`
|
||||
UpdatePassword bool `json:"updatePassword"`
|
||||
UpdateNetworkConfig bool `json:"updateNetworkConfig"`
|
||||
PasswordApiEndpoint string `json:"passwordApiEndpoint"`
|
||||
RebootIfRequired bool `json:"rebootIfRequired"`
|
||||
UpdateHostname bool `json:"updateHostname"`
|
||||
UpdatePassword bool `json:"updatePassword"`
|
||||
UpdateNetworkConfig bool `json:"updateNetworkConfig"`
|
||||
ResizeDisk bool `json:"resizeDisk"`
|
||||
}
|
||||
|
||||
var Configuration Config
|
||||
|
|
|
|||
7
main.go
7
main.go
|
|
@ -93,6 +93,13 @@ func application() {
|
|||
}
|
||||
}
|
||||
|
||||
if config.Configuration.ResizeDisk {
|
||||
err := windows.ResizeDisk("C")
|
||||
if err != nil {
|
||||
log.Log.Error("Failed resizing disk", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if rebootRequired {
|
||||
log.Log.Warn("Reboot is required to apply the changes")
|
||||
if len(os.Args) > 1 && os.Args[1] == "firstboot" {
|
||||
|
|
|
|||
12
windows/resizedisk.go
Normal file
12
windows/resizedisk.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package windows
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"jonasled.dev/jonasled/cloud-init-windows/log"
|
||||
)
|
||||
|
||||
func ResizeDisk(driveLetter string) error {
|
||||
log.Log.Info(fmt.Sprintf("Resizing Partition %s to fill disk", driveLetter))
|
||||
return execPsCommand(fmt.Sprintf("Resize-Partition -DriveLetter %s -Size (Get-PartitionSupportedSize -DriveLetter %s).SizeMax", driveLetter, driveLetter))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue