add todos where appropriate

This commit is contained in:
Josh Wolf
2021-05-22 00:32:12 -06:00
parent da844e30e9
commit c36737cae1
4 changed files with 12 additions and 96 deletions

View File

@@ -3,7 +3,6 @@ package app
import (
"context"
"github.com/rancherfederal/hauler/pkg/bundle"
"github.com/spf13/cobra"
)
@@ -32,18 +31,20 @@ func NewBundleCommand() *cobra.Command {
}
func (o *bundleOpts) Run() error {
//TODO
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
b := bundle.NewLayoutStore(o.bundleDir)
images := []string{"alpine:latest", "registry:2.7.1"}
for _, i := range images {
if err := b.Add(ctx, i); err != nil {
return err
}
}
//b := bundle.NewLayoutStore(o.bundleDir)
//
//images := []string{"alpine:latest", "registry:2.7.1"}
//
//for _, i := range images {
// if err := b.Add(ctx, i); err != nil {
// return err
// }
//}
_ = ctx
return nil
}

View File

@@ -1,14 +0,0 @@
package app
const (
packageConfigStr = `apiVersion: hauler.cattle.io/v1alpha1
kind: PackageConfig
metadata:
name: hauler-test
packages:
- name: k3s-main
type: K3s
release: v1.20.5+k3s1
installScriptRef: 355fff3017b06cde44dbd879408a3a6826fa7125
`
)

View File

@@ -1,72 +0,0 @@
package app
import (
"io"
"io/ioutil"
"os"
"path"
"strings"
"testing"
)
func TestPackageOptions_Preprocess(t *testing.T) {
tmpDirName, err := ioutil.TempDir(os.TempDir(), "hauler-test-*")
if err != nil {
t.Fatalf("couldn't create temporary directory: %v", err)
}
defer os.RemoveAll(tmpDirName)
pconfFile, err := ioutil.TempFile(tmpDirName, "package-config-*.yaml")
if err != nil {
t.Fatalf("couldn't create temporary package config file: %v", err)
}
if _, err := io.Copy(pconfFile, strings.NewReader(packageConfigStr)); err != nil {
pconfFile.Close()
t.Fatalf("couldn't write temporary package config file: %v", err)
}
pconfFile.Close()
po := &PackageOptions{
PackageConfigFileName: pconfFile.Name(),
OutputFileName: path.Join(tmpDirName, "hauler-archive.tar"),
}
if err := po.Preprocess(); err != nil {
t.Errorf("unexpected error in preprocess: %v", err)
}
}
func TestPackageOptions_Run(t *testing.T) {
tmpDirName, err := ioutil.TempDir(os.TempDir(), "hauler-test-*")
if err != nil {
t.Fatalf("couldn't create temporary directory: %v", err)
}
defer os.RemoveAll(tmpDirName)
pconfFile, err := ioutil.TempFile(tmpDirName, "package-config-*.yaml")
if err != nil {
t.Fatalf("couldn't create temporary package config file: %v", err)
}
if _, err := io.Copy(pconfFile, strings.NewReader(packageConfigStr)); err != nil {
pconfFile.Close()
t.Fatalf("couldn't write temporary package config file: %v", err)
}
pconfFile.Close()
po := &PackageOptions{
PackageConfigFileName: pconfFile.Name(),
OutputFileName: path.Join(tmpDirName, "hauler-archive.tar"),
}
if err := po.Preprocess(); err != nil {
t.Fatalf("unexpected error in preprocess: %v", err)
}
if err := po.Run(); err != nil {
t.Errorf("unexpected error in run: %v", err)
}
}

View File

@@ -29,5 +29,6 @@ func NewRelocateCommand() *cobra.Command {
}
func (o *relocateOpts) Run() error {
//TODO
return nil
}