forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/rhcos/release: Extract RHCOS build from release image
Since e2b31b2 (bootkube: Supply machine-os-content to MCO, 2019-01-29, openshift#1149), we have been using the machine-os-content image to seed the machine-config operator. With this commit, use the RHCOS build ID from that image's annotations to calculate our AMI, etc. as well. This gives one less degree of freedom for breaking things ;). Users who want to test clusters based on a different RHCOS build should bump the value in their release image, just like users testing operator updates and other changes. The new pkg/asset/release subpackage allows users to continue using pkg/rhcos without pulling in all of containers/image as a dependency. The pull-secret handling is a bit of a hack, leaning on the fact that users are likely providing clean secrets from [1]. Hopefully soon containers/image will grow an API for injecting in-memory bytes into their more-robust Docker-auth-config parser, but my attempt at that [2] is unlikely to land in the next few days, so I've cludged together a minimal implementation here. [1]: https://cloud.openshift.com/clusters/install#pull-secret [2]: containers/image#588
- Loading branch information
Showing
9 changed files
with
296 additions
and
88 deletions.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Package release contains assets for the release image (also known | ||
// as the update payload). | ||
package release | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/openshift/installer/pkg/asset" | ||
) | ||
|
||
var ( | ||
defaultImage = "registry.svc.ci.openshift.org/openshift/origin-release:v4.0" | ||
) | ||
|
||
// Image is the pull-spec for the release image. | ||
type Image string | ||
|
||
var _ asset.Asset = (*Image)(nil) | ||
|
||
// Name returns the human-friendly name of the asset. | ||
func (i *Image) Name() string { | ||
return "Release Image" | ||
} | ||
|
||
// Dependencies returns no dependencies. | ||
func (i *Image) Dependencies() []asset.Asset { | ||
return nil | ||
} | ||
|
||
// Generate the release image. | ||
func (i *Image) Generate(p asset.Parents) error { | ||
releaseImage := defaultImage | ||
if ri := os.Getenv("OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE"); ri != "" { | ||
logrus.Warn("Found override for Image. Please be warned, this is not advised") | ||
releaseImage = ri | ||
} | ||
*i = Image(releaseImage) | ||
return nil | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package release | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"strings" | ||
|
||
"github.com/containers/image/types" | ||
"github.com/docker/distribution/reference" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type auth struct { | ||
Auth string `json:"auth"` | ||
} | ||
|
||
type config struct { | ||
Auths map[string]auth `json:"auths"` | ||
} | ||
|
||
func addPullSecret(sys *types.SystemContext, pullSecret []byte, named reference.Named) error { | ||
var auths config | ||
err := json.Unmarshal(pullSecret, &auths) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
authority := reference.Domain(named) | ||
auth, ok := auths.Auths[authority] // hack: skipping normalization | ||
if ok { | ||
decoded, err := base64.StdEncoding.DecodeString(auth.Auth) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
parts := strings.SplitN(string(decoded), ":", 2) | ||
if len(parts) != 2 { | ||
return errors.Errorf("invalid pull-secret entry for %q", authority) | ||
} | ||
|
||
sys.DockerAuthConfig = &types.DockerAuthConfig{ | ||
Username: parts[0], | ||
Password: parts[1], | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.