GetServerFeatureFlags returns the feature flags for server.
()
| 23 | |
| 24 | // GetServerFeatureFlags returns the feature flags for server. |
| 25 | func (v *Version) GetServerFeatureFlags() error { |
| 26 | var op errors.Op = "version.GetServerFeatureFlags" |
| 27 | flags := &ServerFeatureFlags{} |
| 28 | if v.ServerSemver == nil { |
| 29 | flags.HasAccessKey = false |
| 30 | flags.HasAction = true |
| 31 | } else { |
| 32 | // create a constraint to check if the current server version has admin secret |
| 33 | adminSecretConstraint, err := semver.NewConstraint("< " + adminSecretVersion) |
| 34 | if err != nil { |
| 35 | return errors.E(op, fmt.Errorf("building admin secret constraint failed: %w", err)) |
| 36 | } |
| 37 | // check the current version with the constraint |
| 38 | flags.HasAccessKey = adminSecretConstraint.Check(v.ServerSemver) |
| 39 | |
| 40 | // create a constraint to check if the current server version has actions |
| 41 | actionConstraint, err := semver.NewConstraint(">= " + actionVersion) |
| 42 | if err != nil { |
| 43 | return errors.E(op, fmt.Errorf("building action constraint failed: %w", err)) |
| 44 | } |
| 45 | // check the current version with the constraint |
| 46 | flags.HasAction = actionConstraint.Check(v.ServerSemver) |
| 47 | |
| 48 | // cronTriggers Constraint |
| 49 | cronTriggersConstraint, err := semver.NewConstraint(">= " + cronTriggersVersion) |
| 50 | if err != nil { |
| 51 | return errors.E(op, fmt.Errorf("building cron triggers constraint failed: %w", err)) |
| 52 | } |
| 53 | // check the current version with the constraint |
| 54 | flags.HasCronTriggers = cronTriggersConstraint.Check(v.ServerSemver) |
| 55 | } |
| 56 | v.ServerFeatureFlags = flags |
| 57 | return nil |
| 58 | } |
no outgoing calls
no test coverage detected