Changeset View
Changeset View
Standalone View
Standalone View
config/variant.go
Show All 28 Lines | |||||
// PhaseInstall | // PhaseInstall | ||||
// | // | ||||
// If VariantConfig.Copies is not set, either copy in application files or | // If VariantConfig.Copies is not set, either copy in application files or | ||||
// define a shared volume. Otherwise, delegate to | // define a shared volume. Otherwise, delegate to | ||||
// ArtifactsConfig.InstructionsForPhase. | // ArtifactsConfig.InstructionsForPhase. | ||||
// | // | ||||
func (vc *VariantConfig) InstructionsForPhase(phase build.Phase) []build.Instruction { | func (vc *VariantConfig) InstructionsForPhase(phase build.Phase) []build.Instruction { | ||||
instructions := vc.CommonConfig.InstructionsForPhase(phase) | instructions := vc.CommonConfig.InstructionsForPhase(phase) | ||||
ainstructions := []build.Instruction{} | |||||
for _, artifact := range vc.allArtifacts() { | |||||
ainstructions = append(ainstructions, artifact.InstructionsForPhase(phase)...) | |||||
} | |||||
instructions = append(ainstructions, instructions...) | |||||
var switchUser string | var switchUser string | ||||
var uid, gid uint | |||||
switch phase { | switch phase { | ||||
case build.PhasePrivileged: | case build.PhasePrivileged: | ||||
switchUser = "root" | switchUser = "root" | ||||
case build.PhasePrivilegeDropped: | case build.PhasePrivilegeDropped: | ||||
switchUser = vc.Lives.As | switchUser = vc.Lives.As | ||||
instructions = build.ApplyUser(vc.Lives.UID, vc.Lives.GID, instructions) | uid, gid = vc.Lives.UID, vc.Lives.GID | ||||
case build.PhasePreInstall: | case build.PhasePreInstall: | ||||
instructions = build.ApplyUser(vc.Lives.UID, vc.Lives.GID, instructions) | uid, gid = vc.Lives.UID, vc.Lives.GID | ||||
case build.PhaseInstall: | case build.PhaseInstall: | ||||
uid, gid = vc.Lives.UID, vc.Lives.GID | |||||
if vc.Copies == "" { | if vc.Copies == "" { | ||||
if vc.SharedVolume.True { | if vc.SharedVolume.True { | ||||
instructions = append(instructions, build.Volume{vc.Lives.In}) | instructions = append(instructions, build.Volume{vc.Lives.In}) | ||||
} else { | } else { | ||||
instructions = append(instructions, build.Copy{[]string{"."}, "."}) | instructions = append(instructions, build.Copy{[]string{"."}, "."}) | ||||
} | } | ||||
} | } | ||||
instructions = build.ApplyUser(vc.Lives.UID, vc.Lives.GID, instructions) | |||||
case build.PhasePostInstall: | case build.PhasePostInstall: | ||||
switchUser = vc.Runs.As | switchUser = vc.Runs.As | ||||
instructions = build.ApplyUser(vc.Runs.UID, vc.Runs.GID, instructions) | uid, gid = vc.Runs.UID, vc.Runs.GID | ||||
if len(vc.EntryPoint) > 0 { | if len(vc.EntryPoint) > 0 { | ||||
instructions = append(instructions, build.EntryPoint{vc.EntryPoint}) | instructions = append(instructions, build.EntryPoint{vc.EntryPoint}) | ||||
} | } | ||||
} | } | ||||
for _, artifact := range vc.allArtifacts() { | |||||
instructions = append(instructions, artifact.InstructionsForPhase(phase)...) | |||||
} | |||||
if switchUser != "" { | if switchUser != "" { | ||||
instructions = append( | instructions = append( | ||||
[]build.Instruction{ | []build.Instruction{ | ||||
build.User{switchUser}, | build.User{switchUser}, | ||||
build.Home(switchUser), | build.Home(switchUser), | ||||
}, | }, | ||||
instructions..., | instructions..., | ||||
) | ) | ||||
} | } | ||||
if uid != 0 { | |||||
instructions = build.ApplyUser(uid, gid, instructions) | |||||
} | |||||
return instructions | return instructions | ||||
} | } | ||||
// VariantDependencies returns all unique names of other variants that are | // VariantDependencies returns all unique names of other variants that are | ||||
// referenced in the VariantConfig.Artifacts configuration. | // referenced in the VariantConfig.Artifacts configuration. | ||||
// | // | ||||
func (vc *VariantConfig) VariantDependencies() []string { | func (vc *VariantConfig) VariantDependencies() []string { | ||||
// get unique set of variant dependencies based on artifacts | // get unique set of variant dependencies based on artifacts | ||||
Show All 35 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 3.0 (CC-BY-SA) unless otherwise noted; code licensed under GNU General Public License (GPL) or other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL