Skip to content

Commit

Permalink
Simplify test and fix empty values being passed
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Jan 29, 2025
1 parent 1e0b2a5 commit 85f831a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
16 changes: 4 additions & 12 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ COPY --from=build /app/kairos-init /kairos-init

# Target to use the validator directly inside a generated image with kairos-init
FROM ${VALIDATE_IMAGE} AS validate
ARG MODEL=generic
ARG VARIANT=core
ARG FRAMEWORK_VERSION=""
ARG TRUSTED_BOOT=false
COPY --from=build /app/kairos-init /kairos-init
RUN /kairos-init -l debug --validate -m "${MODEL}" -v "${VARIANT}" -f "${FRAMEWORK_VERSION}" -t "${TRUSTED_BOOT}"
RUN /kairos-init -l debug --validate

FROM ${BASE_IMAGE}
ARG MODEL=generic
ARG VARIANT=core
ARG FRAMEWORK_VERSION=""
ARG TRUSTED_BOOT=false

COPY --from=kairos-init /kairos-init /kairos-init
RUN /kairos-init -l debug -s install -m "${MODEL}" -v "${VARIANT}" -f "${FRAMEWORK_VERSION}" -t "${TRUSTED_BOOT}"
RUN /kairos-init -l debug -s init -m "${MODEL}" -v "${VARIANT}" -f "${FRAMEWORK_VERSION}" -t "${TRUSTED_BOOT}"
RUN /kairos-init -l debug --validate -m "${MODEL}" -v "${VARIANT}" -f "${FRAMEWORK_VERSION}" -t "${TRUSTED_BOOT}"
RUN /kairos-init -l debug -s install
RUN /kairos-init -l debug -s init
RUN /kairos-init -l debug --validate
RUN rm /kairos-init
24 changes: 20 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,26 @@ func main() {
logger.Infof("Starting kairos-init version %s", values.GetVersion())
logger.Debug(litter.Sdump(values.GetFullVersion()))

// If the framework version is set in the config use that, otherwise use the version from the values which usually its the latest
if config.DefaultConfig.FrameworkVersion == "" {
logger.Logger.Debug().Str("version", values.GetFrameworkVersion()).Msg("Setting framework version from config")
config.DefaultConfig.FrameworkVersion = values.GetFrameworkVersion()
// Validate flags are being passed with actual values
requiredFlags := []struct {
name string
value string
}{
{"l", config.DefaultConfig.Level},
{"s", config.DefaultConfig.Stage},
{"m", config.DefaultConfig.Model},
{"v", config.DefaultConfig.Variant},
{"r", config.DefaultConfig.Registry},
{"t", trusted},
{"f", config.DefaultConfig.FrameworkVersion},
}

for _, rf := range requiredFlags {
if rf.value == "" {
fmt.Fprintf(os.Stderr, "Error: -%s flag is required to have a value\n", rf.name)
flag.Usage()
os.Exit(1)
}
}

logger.Debug(litter.Sdump(config.DefaultConfig))
Expand Down

0 comments on commit 85f831a

Please sign in to comment.