Skip to content

Commit

Permalink
Update module name. Add param to specify folder name for pruned catalog.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanedell committed Jan 16, 2024
1 parent 22196ad commit bc559d5
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a Golang implementation of [openshift4-mirror](https://repo1.dso.mil/platform-one/distros/red-hat/ocp4/openshift4-mirror). The purpose behind this was to make distribution easier.

Executable files can be downloaded from the [releases page](https://github.com/Shanedell/openshift4-mirror-go/releases). Also a docker image ghcr.io/shanedell/openshift4-mirror-go.
Executable files can be downloaded from the [releases page](https://github.com/shanedell/openshift4-mirror-go/releases). Also a docker image ghcr.io/shanedell/openshift4-mirror-go.

## Options

Expand Down
4 changes: 2 additions & 2 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"errors"

"github.com/Shanedell/openshift4-mirror-go/pkg/app"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/app"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"fmt"

"github.com/Shanedell/openshift4-mirror-go/pkg/app"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/app"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
"github.com/spf13/cobra"
)

Expand Down
14 changes: 12 additions & 2 deletions cmd/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"errors"

"github.com/Shanedell/openshift4-mirror-go/pkg/app"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/app"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
"github.com/spf13/cobra"
)

Expand All @@ -14,6 +14,7 @@ var (
pruneType string
opmVersion string
targetImage string
folderName string
)

var pruneHelp = "prune the Red Hat Operator index image"
Expand Down Expand Up @@ -68,6 +69,14 @@ func NewPruneCommand() *cobra.Command {
"complete image name to tag final image as.",
)

pruneCommand.PersistentFlags().StringVarP(
&folderName,
"folder-name",
"f",
"pruned-catalog",
"folder name for the pruned catalog",
)

return pruneCommand
}

Expand All @@ -92,6 +101,7 @@ func pruneMain(_ *cobra.Command, _ []string) error {
PruneType: pruneType,
OpmVersion: opmVersion,
TargetImage: targetImage,
FolderName: folderName,
}

return app.PruneIndexImage(
Expand Down
4 changes: 2 additions & 2 deletions cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"errors"

"github.com/Shanedell/openshift4-mirror-go/pkg/app"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/app"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ENV LANGUAGE=en_US.UTF-8
LABEL \
name="openshift4-mirror-go" \
description="Utility for mirroring OpenShift 4 content" \
maintainer="Shanedell"
maintainer="shanedell"

USER root

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Shanedell/openshift4-mirror-go
module github.com/shanedell/openshift4-mirror-go

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/Shanedell/openshift4-mirror-go/cmd"
import "github.com/shanedell/openshift4-mirror-go/cmd"

func main() {
cmd.Run()
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"os"
"path/filepath"

"github.com/Shanedell/openshift4-mirror-go/pkg/download"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/download"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func Bundle(bundleDataIn *utils.BundleDataType) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"runtime"
"strings"

"github.com/Shanedell/openshift4-mirror-go/pkg/download"
"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/download"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func cleanupOpmFiles(osName string) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/app/prune_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"path/filepath"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func createIndexFile(imageToPrune string, osName string, jqArgs string, prunedCatalogIndexFile string) error {
Expand Down Expand Up @@ -41,21 +41,21 @@ func createDockerFile(containerRuntimePath string, osName string, prunedCatalogF
return runOpmCommand(cmd, osName, containerRuntimePath, true)
}

func buildImage(imageName string, containerRuntime string, containerRuntimePath string, osName string) error {
func buildImage(imageName string, containerRuntime string, containerRuntimePath string, osName string, prunedCatalogFolder string) error {
cmd := utils.CreateCommand(
containerRuntime,
"build",
"-t", imageName,
"-f", "configs.Dockerfile",
".",
)
cmd.Dir = "pruned-catalog"
cmd.Dir = prunedCatalogFolder

return runOpmCommand(cmd, osName, containerRuntimePath, true)
}

func pruneFile(pruneData *utils.PruneDataType, containerRuntime string, containerRuntimePath string, osName string) error {
prunedCatalogFolder := "pruned-catalog/configs"
prunedCatalogFolder := fmt.Sprintf("%s/configs", pruneData.FolderName)
prunedCatalogIndexFile := fmt.Sprintf("%s/index.json", prunedCatalogFolder)

jqArgs := ""
Expand Down Expand Up @@ -92,7 +92,7 @@ func pruneFile(pruneData *utils.PruneDataType, containerRuntime string, containe
utils.Logger.Info("Finished creating dockerfile...")

utils.Logger.Infof("Building image %s...\n", pruneData.TargetImage)
err = buildImage(pruneData.TargetImage, containerRuntime, containerRuntimePath, osName)
err = buildImage(pruneData.TargetImage, containerRuntime, containerRuntimePath, osName, pruneData.FolderName)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"runtime"
"strings"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func GetContainerRuntime() string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/download/catalogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"regexp"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

// this function is mostly to get the catalog source and image content source policy files
Expand Down
2 changes: 1 addition & 1 deletion pkg/download/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func Clients() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/download/opm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"strings"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func OpmScript(osName string, version string) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/download/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"path/filepath"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func Release() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/download/rhcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"

"github.com/Shanedell/openshift4-mirror-go/pkg/utils"
"github.com/shanedell/openshift4-mirror-go/pkg/utils"
)

func rhcosFilename() (string, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ type PruneDataType struct {
OpmVersion string
PruneType string
TargetImage string
FolderName string
}

0 comments on commit bc559d5

Please sign in to comment.