Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Add RHCOSBaseURI to templating for bootstrap files
Browse files Browse the repository at this point in the history
This allows us to template in the baseURI from data/data/rhcos.json
when needed for boostrap files (the baremetal platform requires this
to download the appropriate image to provision the masters)
  • Loading branch information
Steven Hardy committed Jul 17, 2019
1 parent 648e9e1 commit 29bd776
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/openshift-metalkube/kni-installer/pkg/asset/machines"
"github.com/openshift-metalkube/kni-installer/pkg/asset/manifests"
"github.com/openshift-metalkube/kni-installer/pkg/asset/tls"
"github.com/openshift-metalkube/kni-installer/pkg/rhcos"
"github.com/openshift-metalkube/kni-installer/pkg/types"
)

Expand All @@ -42,6 +43,7 @@ type bootstrapTemplateData struct {
PullSecret string
ReleaseImage string
Proxy *configv1.ProxyStatus
RHCOSBaseURI string
}

// Bootstrap is an asset that generates the ignition config for bootstrap nodes.
Expand Down Expand Up @@ -208,11 +210,24 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, proxy *c
logrus.Debugf("Using internal constant for release image %s", releaseImage)
}

var rhcosImageBaseURI string
if ri, ok := os.LookupEnv("OPENSHIFT_INSTALL_IMAGE_BASE_URI_OVERRIDE"); ok && ri != "" {
logrus.Warn("Found override for rhcosImageBaseURI. Please be warned, this is not advised")
rhcosImageBaseURI = ri
} else {
rhcosImageBaseURI, err := rhcos.BaseURI()
if err != nil {
return nil, err
}
logrus.Debugf("Using internal constant for release image base URI %s", rhcosImageBaseURI)
}

return &bootstrapTemplateData{
PullSecret: installConfig.PullSecret,
ReleaseImage: releaseImage,
EtcdCluster: strings.Join(etcdEndpoints, ","),
Proxy: &proxy.Status,
RHCOSBaseURI: rhcosImageBaseURI,
}, nil
}

Expand Down
23 changes: 23 additions & 0 deletions pkg/rhcos/baseuri.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package rhcos

import (
"context"
"net/url"

"github.com/pkg/errors"
)

// BaseURI fetches the BaseURI where images can be downloaded from
func BaseURI() (string, error) {
meta, err := fetchRHCOSBuild(context.TODO())
if err != nil {
return "", errors.Wrap(err, "failed to fetch RHCOS metadata")
}

base, err := url.Parse(meta.BaseURI)
if err != nil {
return "", err
}

return base.String(), nil
}

0 comments on commit 29bd776

Please sign in to comment.