add testdata

This commit is contained in:
Josh Wolf
2021-06-10 15:01:54 -06:00
parent 541d774857
commit 1891164290
10 changed files with 143 additions and 55 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ type deployOpts struct {
// NewBootstrapCommand new a new sub command of haulerctl that bootstraps a cluster
func NewBootstrapCommand() *cobra.Command {
opts := &deployOpts{
rootOpts: &ro,
rootOpts: &ro,
}
cmd := &cobra.Command{
+1 -1
View File
@@ -25,7 +25,7 @@ func Test_createOpts_Run(t *testing.T) {
Version: "v1.21.1+k3s1",
},
Paths: []string{
//"../../../testdata/docker-registry",
"../../../testdata/docker-registry",
"../../../testdata/rawmanifests",
},
Images: []string{},
+1 -1
View File
@@ -74,7 +74,7 @@ func (r rke2) Images() ([]string, error) { return []string{}, n
func (r rke2) BinURL() string { return "" }
func (r rke2) LibPath() string { return "" }
func (r rke2) EtcPath() string { return "" }
func (r rke2) Config() (*map[string]interface{}, error) { return nil, nil }
func (r rke2) Config() (*map[string]interface{}, error) { return nil, nil }
func (r rke2) SystemObjects() (objs []object.ObjMetadata) { return objs }
//NewDriver will return the appropriate driver given a kind, defaults to k3s
+15 -7
View File
@@ -25,7 +25,7 @@ type Booter interface {
type booter struct {
Package v1alpha1.Package
fs fs.PkgFs
fs fs.PkgFs
}
//NewBooter will build a new booter given a path to a directory containing a hauler package.json
@@ -39,7 +39,7 @@ func NewBooter(pkgPath string) (*booter, error) {
return &booter{
Package: pkg,
fs: fsys,
fs: fsys,
}, nil
}
@@ -47,10 +47,18 @@ func (b booter) Init() error {
d := v1alpha1.NewDriver(b.Package.Spec.Driver.Kind)
//TODO: Feel like there's a better way to do this
if err := b.moveBin(); err != nil { return err }
if err := b.moveImages(d); err != nil { return err }
if err := b.moveBundles(d); err != nil { return err }
if err := b.moveCharts(d); err != nil { return err }
if err := b.moveBin(); err != nil {
return err
}
if err := b.moveImages(d); err != nil {
return err
}
if err := b.moveBundles(d); err != nil {
return err
}
if err := b.moveCharts(d); err != nil {
return err
}
return nil
}
@@ -67,7 +75,7 @@ func (b booter) Boot(ctx context.Context, d v1alpha1.Drive) error {
//TODO: Generic
cmd := exec.Command("/bin/sh", "/opt/hauler/bin/k3s-init.sh")
cmd.Env = append(os.Environ(), []string{
cmd.Env = append(os.Environ(), []string{
"INSTALL_K3S_SKIP_DOWNLOAD=true",
"INSTALL_K3S_SELINUX_WARN=true",
"INSTALL_K3S_SKIP_SELINUX_RPM=true",
+2 -2
View File
@@ -31,7 +31,7 @@ func waitForDriver(ctx context.Context, d v1alpha1.Drive) error {
return errors.New("timed out waiting for driver to provision")
}
time.Sleep(1*time.Second)
time.Sleep(1 * time.Second)
}
cfg, err := kube.NewKubeConfig()
@@ -56,7 +56,7 @@ func installChart(cf *genericclioptions.ConfigFlags, chart *chart.Chart, release
client := action.NewInstall(actionConfig)
client.ReleaseName = releaseName
client.Namespace, cf.Namespace = namespace, stringptr(namespace) // TODO: Not sure why this needs to be set twice
client.Namespace, cf.Namespace = namespace, stringptr(namespace) // TODO: Not sure why this needs to be set twice
client.CreateNamespace = true
client.Wait = true
+1 -1
View File
@@ -19,7 +19,7 @@ type standardLogger struct {
}
type Event struct {
id int
id int
message string
}
+13 -3
View File
@@ -20,6 +20,7 @@ type Imager interface {
}
type discoveredImages []string
func (d discoveredImages) Images() ([]string, error) {
return d, nil
}
@@ -79,7 +80,9 @@ func ResolveRemoteRefs(images ...string) (map[name.Reference]v1.Image, error) {
m := make(map[name.Reference]v1.Image)
for _, i := range images {
if i == "" { continue }
if i == "" {
continue
}
//TODO: This will error out if remote is a v1 image, do better error handling for this
ref, err := name.ParseReference(i)
@@ -98,8 +101,15 @@ func ResolveRemoteRefs(images ...string) (map[name.Reference]v1.Image, error) {
return m, nil
}
//TODO: Add user defined paths
var knownImagePaths = []string{
// Deployments & DaemonSets
"{.spec.template.spec.initContainers[*].image}",
"{.spec.template.spec.containers[*].image}",
// Pods
"{.spec.initContainers[*].image}",
"{.spec.containers[*].image}",
}
////imageFromRuntimeObject will return any images found in known obj specs
@@ -135,6 +145,6 @@ func parseJSONPath(input interface{}, parser *jsonpath.JSONPath, template string
return nil, err
}
r:= strings.Split(buf.String(), " ")
r := strings.Split(buf.String(), " ")
return r, nil
}
}
-25
View File
@@ -1,25 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: podinfo
spec:
selector:
matchLabels:
app: podinfo
tier: frontend
replicas: 1
template:
metadata:
labels:
app: podinfo
tier: frontend
spec:
containers:
- name: podinfo
image: stefanprodan/podinfo:5.2.1
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
+109
View File
@@ -0,0 +1,109 @@
---
# Source: podinfo/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: tester-podinfo
labels:
helm.sh/chart: podinfo-5.2.1
app.kubernetes.io/name: tester-podinfo
app.kubernetes.io/version: "5.2.1"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 9898
targetPort: http
protocol: TCP
name: http
- port: 9999
targetPort: grpc
protocol: TCP
name: grpc
selector:
app.kubernetes.io/name: tester-podinfo
---
# Source: podinfo/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tester-podinfo
labels:
helm.sh/chart: podinfo-5.2.1
app.kubernetes.io/name: tester-podinfo
app.kubernetes.io/version: "5.2.1"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: tester-podinfo
template:
metadata:
labels:
app.kubernetes.io/name: tester-podinfo
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9898"
spec:
terminationGracePeriodSeconds: 30
containers:
- name: podinfo
image: "ghcr.io/stefanprodan/podinfo:5.2.1"
imagePullPolicy: IfNotPresent
command:
- ./podinfo
- --port=9898
- --cert-path=/data/cert
- --port-metrics=9797
- --grpc-port=9999
- --grpc-service-name=podinfo
- --level=info
- --random-delay=false
- --random-error=false
env:
- name: PODINFO_UI_COLOR
value: "#34577c"
ports:
- name: http
containerPort: 9898
protocol: TCP
- name: http-metrics
containerPort: 9797
protocol: TCP
- name: grpc
containerPort: 9999
protocol: TCP
livenessProbe:
exec:
command:
- podcli
- check
- http
- localhost:9898/healthz
initialDelaySeconds: 1
timeoutSeconds: 5
readinessProbe:
exec:
command:
- podcli
- check
- http
- localhost:9898/readyz
initialDelaySeconds: 1
timeoutSeconds: 5
volumeMounts:
- name: data
mountPath: /data
resources:
limits: null
requests:
cpu: 1m
memory: 16Mi
volumes:
- name: data
emptyDir: {}
-14
View File
@@ -1,14 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
type: NodePort
ports:
- port: 80
selector:
app: guestbook
tier: frontend