-
Notifications
You must be signed in to change notification settings - Fork 35
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
Set default boolean values #122
Merged
+340
−33
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,14 @@ func ParseDevfile(args ParserArgs) (d DevfileObj, err error) { | |
flattenedDevfile = *args.FlattenedDevfile | ||
} | ||
|
||
return populateAndParseDevfile(d, &resolutionContextTree{}, tool, flattenedDevfile) | ||
d, err = populateAndParseDevfile(d, &resolutionContextTree{}, tool, flattenedDevfile) | ||
|
||
//set defaults only if we are flattening parent and parsing succeeded | ||
if flattenedDevfile && err == nil { | ||
setDefaults(d) | ||
} | ||
|
||
return d, err | ||
} | ||
|
||
// resolverTools contains required structs and data for resolving remote components of a devfile (plugins and parents) | ||
|
@@ -281,6 +288,7 @@ func parseParentAndPlugin(d DevfileObj, resolveCtx *resolutionContextTree, tool | |
d.Data.SetDevfileWorkspaceSpecContent(*mergedContent) | ||
// remove parent from flatterned devfile | ||
d.Data.SetParent(nil) | ||
//setDefaults(d) | ||
|
||
return nil | ||
} | ||
|
@@ -428,3 +436,104 @@ func convertDevWorskapceTemplateToDevObj(dwTemplate v1.DevWorkspaceTemplate) (d | |
return d, nil | ||
|
||
} | ||
|
||
//setDefaults sets the default values for nil boolean properties after the merging of devWorkspaceTemplateSpec is complete | ||
func setDefaults(d DevfileObj) (err error) { | ||
commands, err := d.Data.GetCommands(common.DevfileOptions{}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
//set defaults on the commands | ||
var cmdGroup *v1.CommandGroup | ||
for i := range commands { | ||
command := commands[i] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick question on a glance, since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
cmdGroup = nil | ||
|
||
if command.Exec != nil { | ||
exec := command.Exec | ||
val := exec.GetHotReloadCapable() | ||
exec.HotReloadCapable = &val | ||
cmdGroup = exec.Group | ||
|
||
} else if command.Composite != nil { | ||
composite := command.Composite | ||
val := composite.GetParallel() | ||
composite.Parallel = &val | ||
cmdGroup = composite.Group | ||
|
||
} else if command.Apply != nil { | ||
cmdGroup = command.Apply.Group | ||
} | ||
|
||
if cmdGroup != nil { | ||
setIsDefault(cmdGroup) | ||
} | ||
|
||
} | ||
|
||
//set defaults on the components | ||
|
||
components, err := d.Data.GetComponents(common.DevfileOptions{}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
var endpoints []v1.Endpoint | ||
for i := range components { | ||
component := components[i] | ||
endpoints = nil | ||
|
||
if component.Container != nil { | ||
container := component.Container | ||
val := container.GetDedicatedPod() | ||
container.DedicatedPod = &val | ||
|
||
val = container.GetMountSources() | ||
container.MountSources = &val | ||
|
||
endpoints = container.Endpoints | ||
|
||
} else if component.Kubernetes != nil { | ||
endpoints = component.Kubernetes.Endpoints | ||
|
||
} else if component.Openshift != nil { | ||
|
||
endpoints = component.Openshift.Endpoints | ||
|
||
} else if component.Volume != nil { | ||
volume := component.Volume | ||
val := volume.GetEphemeral() | ||
volume.Ephemeral = &val | ||
|
||
} else if component.Image != nil { | ||
dockerImage := component.Image.Dockerfile | ||
if dockerImage != nil { | ||
val := dockerImage.GetRootRequired() | ||
dockerImage.RootRequired = &val | ||
} | ||
} | ||
|
||
if endpoints != nil { | ||
setEndpoints(endpoints) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
///setIsDefault sets the default value of CommandGroup.IsDefault if nil | ||
func setIsDefault(cmdGroup *v1.CommandGroup) { | ||
val := cmdGroup.GetIsDefault() | ||
cmdGroup.IsDefault = &val | ||
} | ||
|
||
//setEndpoints sets the default value of Endpoint.Secure if nil | ||
func setEndpoints(endpoints []v1.Endpoint) { | ||
for i := range endpoints { | ||
val := endpoints[i].GetSecure() | ||
endpoints[i].Secure = &val | ||
} | ||
} |
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.
should remove this comment?