Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(cmd/driver,pkg/options,internal/config): added driver config cmd tests #362

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Nov 30, 2023

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

/area cli
/area tests

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@@ -158,7 +158,10 @@ func (o *driverConfigOptions) RunDriverConfig(ctx context.Context, cmd *cobra.Co

d, err := driverdistro.Discover(info, driverCfg.HostRoot)
if err != nil {
return err
if !errors.Is(err, driverdistro.ErrUnsupported) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When error is ErrUnsupported, just print that we detected an unsupported OS (we failed to determine it), and go on using the fallback generic logic.

@@ -67,7 +68,9 @@ func (o *driverPrintenvOptions) RunDriverPrintenv(_ context.Context) error {

d, err := driverdistro.Discover(kr, driver.HostRoot)
if err != nil {
return err
if !errors.Is(err, driverdistro.ErrUnsupported) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When error is ErrUnsupported go on with undetermined distro target.

@@ -231,7 +231,11 @@ func Load(path string) error {
// Set default registry auth config path
viper.SetDefault(RegistryCredentialConfigKey, DefaultRegistryCredentialConfPath)
// Set default driver
viper.SetDefault(DriverKey, DefaultDriver)
viper.SetDefault(DriverTypeKey, DefaultDriver.Type)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the retrieving of DriverFooKey when falcoctl.yaml is an empty file (as used in tests).
Otherwise Driverer would find an empty DriverTypeKey value and fail during the conversion to a drivertype.Type.

@@ -642,7 +646,7 @@ func UpdateConfigFile(key string, value interface{}, path string) error {
v.Set(key, value)

if err := v.WriteConfig(); err != nil {
return fmt.Errorf("unable to set key %q to config file: %w", IndexesKey, err)
return fmt.Errorf("unable to set key %q to config file: %w", key, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a wrong log.

return &DriverTypes{
Enum: NewEnum(drivertype.GetTypes(), drivertype.TypeKmod),
Enum: NewEnum(types, drivertype.TypeKmod),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get a stable CLI help message, we need to sort the strings so that they always appear with same sorting.

@FedeDP FedeDP force-pushed the new/driver_config_test branch 3 times, most recently from 64f44b6 to 032d96a Compare November 30, 2023 15:02
@FedeDP FedeDP force-pushed the new/driver_config_test branch from 032d96a to 1b5ce09 Compare December 1, 2023 08:04
@poiana
Copy link
Contributor

poiana commented Dec 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alacuku, FedeDP, leogr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit 15aa180 into main Dec 1, 2023
12 checks passed
@poiana poiana deleted the new/driver_config_test branch December 1, 2023 09:40
@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 5, 2023

/milestone v0.7.0

@poiana poiana added this to the v0.7.0 milestone Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants