Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (a *Bootstrap) Dependencies() []asset.Asset {
&kubeconfig.Kubelet{},
&manifests.Manifests{},
&manifests.Openshift{},
&manifests.UserManifests{},
}
}

Expand Down Expand Up @@ -334,7 +335,8 @@ func readFile(name string, reader io.Reader, templateData interface{}) (finalNam
func (a *Bootstrap) addParentFiles(dependencies asset.Parents) {
mfsts := &manifests.Manifests{}
openshiftManifests := &manifests.Openshift{}
dependencies.Get(mfsts, openshiftManifests)
userManifests := &manifests.UserManifests{}
dependencies.Get(mfsts, openshiftManifests, userManifests)

a.Config.Storage.Files = append(
a.Config.Storage.Files,
Expand All @@ -344,6 +346,10 @@ func (a *Bootstrap) addParentFiles(dependencies asset.Parents) {
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, "root", 0644, openshiftManifests)...,
)
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, "root", 0644, userManifests)...,
)

for _, asset := range []asset.WritableAsset{
&kubeconfig.Admin{},
Expand Down
63 changes: 63 additions & 0 deletions pkg/asset/manifests/usermanifests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package manifests

import (
"path/filepath"

"github.com/openshift/installer/pkg/asset"
)

const (
userManifestsDir = "user-manifests"
)

// UserManifests picks up any manifests put in by the user
type UserManifests struct {
FileList []*asset.File
}

var _ asset.WritableAsset = (*UserManifests)(nil)

// Name returns a human friendly name for the asset.
func (*UserManifests) Name() string {
return "User's Manifests"
}

// Dependencies returns all of the dependencies directly needed to generate
// the asset.
func (*UserManifests) Dependencies() []asset.Asset {
return []asset.Asset{}
}

// Generate generates asset data (which is an empty file list)
func (um *UserManifests) Generate(dependencies asset.Parents) error {
um.FileList = []*asset.File{}
return nil
}

// Files returns the files generated by the asset.
func (um *UserManifests) Files() []*asset.File {
return um.FileList
}

// Load loads the user supplied manifest files into the 'manifests' directory
func (um *UserManifests) Load(f asset.FileFetcher) (bool, error) {
fileList, err := f.FetchByPattern(filepath.Join(userManifestsDir, "*"))
if err != nil {
return false, err
}
if len(fileList) == 0 {
return false, nil
}

um.FileList = []*asset.File{}
for _, f := range fileList {
_, fileName := filepath.Split(f.Filename)
fModified := &asset.File{
Filename: filepath.Join(manifestDir, fileName),
Data: f.Data,
}
um.FileList = append(um.FileList, fModified)
}

return true, nil
}