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

add decode check for config #2092

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/clusterfile/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ func decodeClusterFile(reader io.Reader, clusterfile *ClusterFile) error {
if err := yaml.Unmarshal(ext.Raw, &cfg); err != nil {
return fmt.Errorf("failed to decode %s[%s]: %v", metaType.Kind, metaType.APIVersion, err)
}

if cfg.Spec.Path == "" {
return fmt.Errorf("failed to decode config %s, config path is empty", cfg.Name)
}

if cfg.Spec.Data == "" {
return fmt.Errorf("failed to decode config %s, config data is empty", cfg.Name)
}

clusterfile.configs = append(clusterfile.configs, cfg)
case constants.PluginKind:
var plu v1.Plugin
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *Dumper) Dump(configs []v1.Config) error {
}

if err := c.WriteFiles(configs); err != nil {
return fmt.Errorf("failed to write config files %v", err)
return fmt.Errorf("failed to dump config files %v", err)
}
return nil
}
Expand Down