Skip to content

Commit

Permalink
docs: updates flag usage to reflect skip-missing fix and comments in …
Browse files Browse the repository at this point in the history
…helm.go

Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
  • Loading branch information
jpower432 committed Jun 3, 2022
1 parent 0e710d7 commit 8f4f0b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
5 changes: 3 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ Once a full imageset has been created and published, differential imagesets that
## Notes about flag usage
1. The `max-per-registry` flag will control the number of concurrent request per registry. Setting this value can allow for faster image download speeds. The default is 2.
2. The `continue-on-error` flag can be used to continue the mirroring process in the event that an image or images cannot be downloaded. The `skip-missing` flag will account for images that return a 404 status code specified with tags only. By default `oc-mirror` translates tagged image
requests into digests before mirroring. There is an issue to capture improvements to the skip-missing functionality to allow support for digests in the library used for mirroring (https://github.com/openshift/oc/issues/1104).
2. The `skip-missing` flag can be used to continue the mirroring process in the event that an image does not exist.
3. Certain errors (e.g. invalid images digest or tags) can by bypassed with `--continue-on-error`. Use this flag will return an exit code of
1, but the `oc-mirror` operations will continue.
3. The `skip-cleanup` flag can be used to keep the workspace from being deleted after mirroring operations.
> WARNING: Running oc-mirror against a workspace that has not been cleaned can result in unexpected behavior.
Expand Down
24 changes: 9 additions & 15 deletions pkg/cli/mirror/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/openshift/oc-mirror/pkg/api/v1alpha2"
"github.com/openshift/oc-mirror/pkg/config"
"github.com/openshift/oc-mirror/pkg/image"
"github.com/pkg/errors"
)

type HelmOptions struct {
Expand Down Expand Up @@ -60,9 +59,9 @@ func (h *HelmOptions) PullCharts(ctx context.Context, cfg v1alpha2.ImageSetConfi
h.settings.RepositoryConfig = file
defer cleanup()

// Configure downloader
// TODO: allow configuration of credentials
// and certs
// Using VerifyLater options to ensure
// any verification information is downloaded
// and can be used later.
c := downloader.ChartDownloader{
Out: h.Out,
Keyring: defaultKeyring(),
Expand All @@ -88,14 +87,12 @@ func (h *HelmOptions) PullCharts(ctx context.Context, cfg v1alpha2.ImageSetConfi

for _, repo := range cfg.Mirror.Helm.Repositories {

// Add repo to temp file
if err := h.repoAdd(repo); err != nil {
return nil, err
}

for _, chart := range repo.Charts {
klog.Infof("Pulling chart %s", chart.Name)
// TODO: Do something with the returned verifications
ref := fmt.Sprintf("%s/%s", repo.Name, chart.Name)
dest := filepath.Join(h.Dir, config.SourceDir, config.HelmDir)
path, _, err := c.DownloadTo(ref, chart.Version, dest)
Expand Down Expand Up @@ -164,19 +161,16 @@ func getImagesPath(paths ...string) []string {
return append(pathlist, paths...)
}

// render will return a templated chart
// TODO: add input for client.APIVersion
// render will return a templated chart based on default
// values from the chart data and helm chartutils.
func render(ch *helmchart.Chart) (string, error) {
out := new(bytes.Buffer)
valueOpts := make(map[string]interface{})
caps := chartutil.DefaultCapabilities

if ch.Metadata.KubeVersion != "" {
if !chartutil.IsCompatibleRange(ch.Metadata.KubeVersion, caps.KubeVersion.String()) {
return "", errors.Errorf("chart requires kubeVersion: %s which is incompatible with Kubernetes %s", ch.Metadata.KubeVersion, caps.KubeVersion.String())
}
}

// Using placeholders for the name
// and namespace since we are only rendering
// to obtain image information
relOps := chartutil.ReleaseOptions{
Name: "NAME",
Namespace: "RELEASE-NAMESPACE",
Expand All @@ -191,13 +185,13 @@ func render(ch *helmchart.Chart) (string, error) {
return "", fmt.Errorf("error rendering chart %s: %v", ch.Name(), err)
}

// Skip the NOTES.txt files
for k := range files {
if strings.HasSuffix(k, ".txt") {
delete(files, k)
}
}

// Add CRDs
for _, crd := range ch.CRDObjects() {
fmt.Fprintf(out, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:]))
}
Expand Down

0 comments on commit 8f4f0b6

Please sign in to comment.