MCPcopy Create free account
hub / github.com/temporalio/temporal / validateSetupConfig

Function validateSetupConfig

tools/common/schema/handler.go:57–84  ·  view source on GitHub ↗
(config *SetupConfig, db DB)

Source from the content-addressed store, hash-verified

55}
56
57func validateSetupConfig(config *SetupConfig, db DB) error {
58 if len(config.SchemaFilePath) == 0 && len(config.SchemaName) == 0 && config.DisableVersioning {
59 return NewConfigError("needs either " + flag(CLIOptSchemaFile) + " or " + flag(CLIOptSchemaName))
60 }
61 if (config.DisableVersioning && len(config.InitialVersion) > 0) ||
62 (!config.DisableVersioning && len(config.InitialVersion) == 0) {
63 return NewConfigError("missing argument; either " + flag(CLIOptDisableVersioning) + " or " +
64 flag(CLIOptVersion) + " but not both must be specified")
65 }
66 if len(config.SchemaFilePath) > 0 && len(config.SchemaName) > 0 {
67 return NewConfigError("either" + flag(CLIOptSchemaFile) + " or " +
68 flag(CLIOptSchemaName) + " must be specified")
69 }
70 if len(config.SchemaName) > 0 {
71 if !slices.Contains(dbschemas.PathsByDB(db.Type()), config.SchemaName) {
72 return NewConfigError(fmt.Sprintf("%s must be one of: %v",
73 flag(CLIOptSchemaName), dbschemas.PathsByDB(db.Type())))
74 }
75 }
76 if !config.DisableVersioning {
77 ver, err := normalizeVersionString(config.InitialVersion)
78 if err != nil {
79 return NewConfigError("invalid " + flag(CLIOptVersion) + " argument:" + err.Error())
80 }
81 config.InitialVersion = ver
82 }
83 return nil
84}
85
86func validateUpdateConfig(config *UpdateConfig, db DB) error {
87 if len(config.SchemaDir) == 0 && len(config.SchemaName) == 0 {

Callers 3

newSetupConfigFunction · 0.85

Calls 6

NewConfigErrorFunction · 0.85
normalizeVersionStringFunction · 0.85
flagFunction · 0.70
ContainsMethod · 0.65
TypeMethod · 0.65
ErrorMethod · 0.65

Tested by 2