-
Notifications
You must be signed in to change notification settings - Fork 103
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
support preprod dual install #1834
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3a0cf6
add identifier to launcher.flags, add ServiceName helpers to launcher…
zackattack01 bf9c0bb
add windows serviceName tests
zackattack01 63b8965
remove unused ServiceName implementations, fix up options tests
zackattack01 9b67fb2
use shared defaultLauncherIdentifier const
zackattack01 5fd96f4
make enrollSecret for flare shipper read from knapsack's EnrollSecret…
zackattack01 978c39a
fixup shipper tests
zackattack01 6cf90e4
add multiple installation check to flare
zackattack01 0002586
only write out identifier to flags file if non-default
zackattack01 56de510
fix windows pkg util
zackattack01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package launcher | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/serenize/snaker" | ||
) | ||
|
||
var nonAlphanumericRegex = regexp.MustCompile(`[^a-zA-Z0-9]+`) | ||
|
||
// ServiceName embeds the given identifier into our service name template after sanitization, | ||
// and returns the camelCased service name generated to match our packaging logic | ||
func ServiceName(identifier string) string { | ||
// this check might be overkill but is intended to prevent any backwards compatibility/misconfiguration issues | ||
if strings.TrimSpace(identifier) == "" { | ||
identifier = DefaultLauncherIdentifier | ||
} | ||
|
||
sanitizedServiceName := nonAlphanumericRegex.ReplaceAllString(identifier, "_") // e.g. identifier=kolide-k2 becomes kolide_k2 | ||
sanitizedServiceName = fmt.Sprintf("launcher_%s_svc", sanitizedServiceName) // wrapped as launcher_kolide_k2_svc | ||
return snaker.SnakeToCamel(sanitizedServiceName) // will produce LauncherKolideK2Svc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package launcher | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_ServiceName(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, tt := range []struct { | ||
testCaseName string | ||
identifier string | ||
expectedServiceName string | ||
}{ | ||
{ | ||
testCaseName: "empty identifier expecting default service name", | ||
identifier: " ", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
{ | ||
testCaseName: "default identifier expecting default service name", | ||
identifier: "kolide-k2", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
{ | ||
testCaseName: "preprod identifier expecting preprod service name", | ||
identifier: "kolide-preprod-k2", | ||
expectedServiceName: "LauncherKolidePreprodK2Svc", | ||
}, | ||
{ | ||
testCaseName: "mangled identifier expecting default service name", | ||
identifier: "kolide-!@_k2", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
} { | ||
tt := tt | ||
t.Run(tt.testCaseName, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
serviceName := ServiceName(tt.identifier) | ||
require.Equal(t, tt.expectedServiceName, serviceName, "expected sanitized service name value to match") | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird not to push this through the normal checkup interface. But okay...