Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract webclient ID from remote installer filename if possible. #3010

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmd/state-remote-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime/debug"
"syscall"
"time"
Expand Down Expand Up @@ -40,6 +41,8 @@ func newParams() *Params {
return &Params{}
}

var filenameRe = regexp.MustCompile(`(?P<name>[^/\\]+?)_(?P<webclientId>[^/\\_.]+)(\.(?P<ext>[^.]+))?$`)

func main() {
var exitCode int

Expand Down Expand Up @@ -96,7 +99,15 @@ func main() {
}

// Store sessionToken to config
err = cfg.Set(anaConst.CfgSessionToken, "remote_"+constants.RemoteInstallerVersion)
webclientId := "remote_" + constants.RemoteInstallerVersion
if matches := filenameRe.FindStringSubmatch(os.Args[0]); matches != nil {
if index := filenameRe.SubexpIndex("webclientId"); index != -1 {
webclientId = matches[index]
} else {
multilog.Error("Invalid subexpression ID for webclient ID")
}
}
err = cfg.Set(anaConst.CfgSessionToken, webclientId)
if err != nil {
logging.Error("Unable to set session token: " + errs.JoinMessage(err))
}
Expand Down
Loading