forked from nauticalab/devenv-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Flesh out tests for types.go, parser.go; add validation_test.go, update validation.go; add canonical formatting for cpu and memory resources #1
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
Open
maxwellgagnon
wants to merge
8
commits into
main
Choose a base branch
from
tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
29dbfc9
Update tests for example, parser, and types; Add cpu and memory norma…
maxwellgagnon 7133400
Update validation.go, add validation_test.go
maxwellgagnon a562870
Update statefulset.yaml and generate.go to reflect cpu and memory for…
maxwellgagnon 0430a93
Update additional file for cpu/mem formatting
maxwellgagnon 740cd1c
Improve error message descriptions
maxwellgagnon 98c865e
Restore previously removed tests; fix error type
maxwellgagnon 923eed4
normalize resources on demand; address pr comments; add resources.go
maxwellgagnon 62fa7c5
Remove support for int64; clean up code
maxwellgagnon 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -25,91 +25,15 @@ func ExampleLoadDeveloperConfig() { | |
// Access SSH keys | ||
sshKeys, err := cfg.GetSSHKeys() | ||
if err != nil { | ||
log.Fatal(err) | ||
fmt.Println("error:", err) | ||
maxwellgagnon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return | ||
} | ||
fmt.Printf("SSH Keys: %d configured\n", len(sshKeys)) | ||
|
||
// Output: | ||
// Developer: testuser | ||
// CPU: 4 | ||
// CPU: 4000m | ||
// Memory: 16Gi | ||
// User ID: 2000 | ||
// SSH Keys: 1 configured | ||
} | ||
|
||
maxwellgagnon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// ExampleDevEnvConfig_CPU demonstrates flexible CPU resource handling | ||
// with different input types and default values. | ||
func ExampleDevEnvConfig_CPU() { | ||
// Example with string CPU value | ||
cfg1 := &config.DevEnvConfig{ | ||
Name: "alice", | ||
BaseConfig: config.BaseConfig{ | ||
Resources: config.ResourceConfig{ | ||
CPU: "8", // String value | ||
}, | ||
}, | ||
} | ||
fmt.Printf("String CPU: %s\n", cfg1.CPU()) | ||
|
||
// Example with integer CPU value | ||
cfg2 := &config.DevEnvConfig{ | ||
Name: "bob", | ||
BaseConfig: config.BaseConfig{ | ||
Resources: config.ResourceConfig{ | ||
CPU: 4, // Integer value | ||
}, | ||
}, | ||
} | ||
fmt.Printf("Integer CPU: %s\n", cfg2.CPU()) | ||
|
||
// Example with no CPU specified (uses default) | ||
cfg3 := &config.DevEnvConfig{ | ||
Name: "charlie", | ||
// No Resources specified | ||
} | ||
fmt.Printf("Default CPU: %s\n", cfg3.CPU()) | ||
|
||
// Output: | ||
// String CPU: 8 | ||
// Integer CPU: 4 | ||
// Default CPU: 0 | ||
} | ||
|
||
// ExampleDevEnvConfig_GetSSHKeys demonstrates SSH key handling with | ||
// both single string and multiple string array formats. | ||
func ExampleDevEnvConfig_GetSSHKeys() { | ||
// Single SSH key as string | ||
cfg1 := &config.DevEnvConfig{ | ||
Name: "alice", | ||
BaseConfig: config.BaseConfig{ | ||
SSHPublicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB [email protected]", | ||
}, | ||
} | ||
|
||
keys1, err := cfg1.GetSSHKeys() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Printf("Single key: %d SSH key(s)\n", len(keys1)) | ||
|
||
// Multiple SSH keys as slice | ||
cfg2 := &config.DevEnvConfig{ | ||
Name: "bob", | ||
BaseConfig: config.BaseConfig{ | ||
SSHPublicKey: []interface{}{ | ||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB [email protected]", | ||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI [email protected]", | ||
}, | ||
}, | ||
} | ||
|
||
keys2, err := cfg2.GetSSHKeys() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Printf("Multiple keys: %d SSH key(s)\n", len(keys2)) | ||
|
||
// Output: | ||
// Single key: 1 SSH key(s) | ||
// Multiple keys: 2 SSH key(s) | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.