in internal/commands/interceptor/process.go [69:91]
func parseProcess(required bool, idFlagName, nameFlagName, instanceIDFlagName string) func(*cli.Context) error {
return func(ctx *cli.Context) error {
id := ctx.String(idFlagName)
name := ctx.String(nameFlagName)
instanceID := ctx.String(instanceIDFlagName)
if id == "" && name == "" {
if required {
return fmt.Errorf(`either flags "--%s" or "--%s" must be given`, idFlagName, nameFlagName)
}
return nil
}
if name != "" {
if instanceID == "" {
return fmt.Errorf(`"--%s" is specified but its related service name or id is not given`, nameFlagName)
}
id = fmt.Sprintf("%x", sha256.New().Sum([]byte(fmt.Sprintf("%s_%s", instanceID, name))))
}
return ctx.Set(idFlagName, id)
}
}