Skip to content

Commit

Permalink
Label ConfigMap and set initial succeeded to false
Browse files Browse the repository at this point in the history
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
  • Loading branch information
arnongilboa committed Nov 2, 2023
1 parent e5ae693 commit 0344ec4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 24 additions & 2 deletions pkg/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,35 @@ package config

import (
kconfig "github.com/kiagnose/kiagnose/kiagnose/config"
kconfigmap "github.com/kiagnose/kiagnose/kiagnose/configmap"

"github.com/kiagnose/kubevirt-storage-checkup/pkg/internal/client"
)

// FIXME: pass something here - maybe golden image ns?
type Config struct {
}

func New(baseConfig kconfig.Config) (Config, error) {
func New(c *client.Client, baseConfig kconfig.Config) (Config, error) {
newConfig := Config{}
return newConfig, nil
err := signConfigMap(c, baseConfig)
return newConfig, err
}

func signConfigMap(c *client.Client, baseConfig kconfig.Config) error {
cm, err := kconfigmap.Get(c, baseConfig.ConfigMapNamespace, baseConfig.ConfigMapName)
if err != nil {
return err
}
if cm.Labels == nil {
cm.Labels = map[string]string{}
}
cm.Labels["kiagnose/checkup-type"] = "kubevirt-vm-storage"
if cm.Data == nil {
cm.Data = map[string]string{}
}
cm.Data["status.succeeded"] = "false"
_, err = kconfigmap.Update(c, cm)

return err
}
9 changes: 1 addition & 8 deletions pkg/mainflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package pkg

import (
"context"
"log"

kconfig "github.com/kiagnose/kiagnose/kiagnose/config"

Expand All @@ -43,21 +42,15 @@ func Run(rawEnv map[string]string, namespace string) error {
return err
}

cfg, err := config.New(baseConfig)
cfg, err := config.New(c, baseConfig)
if err != nil {
return err
}

printConfig(cfg)

l := launcher.New(checkup.New(c, namespace, cfg), reporter.New(c, baseConfig.ConfigMapNamespace, baseConfig.ConfigMapName))

ctx, cancel := context.WithTimeout(context.Background(), baseConfig.Timeout)
defer cancel()

return l.Run(ctx)
}

func printConfig(checkupConfig config.Config) {
log.Println("Using the following config:")
}

0 comments on commit 0344ec4

Please sign in to comment.