Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Add clearer variable names and comments for profiles
Browse files Browse the repository at this point in the history
Signed-off-by: tylerslaton <mtslaton1@gmail.com>
  • Loading branch information
tylerslaton committed Jul 7, 2023
1 parent 6538d49 commit 930a930
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/docs/30-installation/02-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,5 @@ acorn install --propagate-project-annotation ""
When you are installing Acorn, you can specify a profile to use. A profile is a set of installation flag defaults that are pre-defined. You can see the list of available profiles by running `acorn install --help`. The default profile is `default`, and it is used if no profile is specified.

:::note
Once a profile is set, this will set new default values based on the profile. Any default values previously used will be switched to the new profile defaults. However, any install flags that were specified, or have specified, will still be respected.
Once a profile is set, this will set new default values based on the profile. Any default values previously used will be switched to the new profile defaults. However, any install flags that were or are specified will still be respected.
:::
4 changes: 2 additions & 2 deletions pkg/autoupgrade/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ func StartSync(ctx context.Context, client kclient.Client) {

func (d *daemon) sync(ctx context.Context, now time.Time) (time.Duration, error) {
logrus.Debugf("Performing auto-upgrade sync")
defaultNextCheckInterval, _ := time.ParseDuration(profiles.DefaultImageCheckIntervalDefault)
defaultNextCheckInterval, _ := time.ParseDuration(profiles.AutoUpgradeIntervalDefault)
cfg, err := d.client.getConfig(ctx)
if err != nil {
return defaultNextCheckInterval, err
}

// cfg.AutoUpgradeInterval will never be nil here because config.Get will set a default.
if cfgNextCheckInterval, err := time.ParseDuration(*cfg.AutoUpgradeInterval); err != nil {
logrus.Warnf("Error parsing auto-upgrade interval in config %s is invalid, using default of %s: %v", *cfg.AutoUpgradeInterval, profiles.DefaultImageCheckIntervalDefault, err)
logrus.Warnf("Error parsing auto-upgrade interval in config %s is invalid, using default of %s: %v", *cfg.AutoUpgradeInterval, profiles.AutoUpgradeIntervalDefault, err)
} else {
defaultNextCheckInterval = cfgNextCheckInterval
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/profiles/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ var (
// LetsEncryptOptionDefault is the default state for the Let's Encrypt integration
LetsEncryptOptionDefault = "disabled"

// DefaultImageCheckIntervalDefault is the default value for the DefaultImageCheckInterval field
DefaultImageCheckIntervalDefault = "5m"
// AutoUpgradeIntervalDefault is the default value for the DefaultImageCheckInterval field
AutoUpgradeIntervalDefault = "5m"

// Default HttpEndpointPattern set to enable Let's Encrypt
DefaultHttpEndpointPattern = "{{hashConcat 8 .Container .App .Namespace | truncate}}.{{.ClusterDomain}}"
// HttpEndpointPatternDefault is a pattern that works with Let's Encrypt
HttpEndpointPatternDefault = "{{hashConcat 8 .Container .App .Namespace | truncate}}.{{.ClusterDomain}}"

// Features
FeatureImageAllowRules = "image-allow-rules"
Expand All @@ -30,13 +30,13 @@ func defaultProfile() apiv1.Config {
return apiv1.Config{
AcornDNS: ptr(AcornDNSStateDefault),
AcornDNSEndpoint: ptr(AcornDNSEndpointDefault),
AutoUpgradeInterval: ptr(DefaultImageCheckIntervalDefault),
AutoUpgradeInterval: ptr(AutoUpgradeIntervalDefault),
AWSIdentityProviderARN: new(string),
BuilderPerProject: new(bool),
CertManagerIssuer: new(string),
EventTTL: new(string),
Features: FeatureDefaults,
HttpEndpointPattern: ptr(DefaultHttpEndpointPattern),
HttpEndpointPattern: ptr(HttpEndpointPatternDefault),
IgnoreUserLabelsAndAnnotations: new(bool),
IngressClassName: new(string),
IngressControllerNamespace: new(string),
Expand Down
2 changes: 1 addition & 1 deletion pkg/publish/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func toHTTPEndpointHostname(pattern, domain, container, appName, appNamespace st
// This should not happen since the pattern in the config (passed to this through pattern) should
// always be set to the default if the pattern is "". However,if it is not somehow, set it here.
if pattern == "" {
pattern = profiles.DefaultHttpEndpointPattern
pattern = profiles.HttpEndpointPatternDefault
}

endpointOpts := struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/publish/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestToEndpoint(t *testing.T) {
args: args{
domain: "custom-domain.io",
serviceName: "app-name-that-is-very-long-and-should-cause-issues",
pattern: profiles.DefaultHttpEndpointPattern,
pattern: profiles.HttpEndpointPatternDefault,
appInstance: &v1.AppInstance{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{Name: "green-star", Namespace: "namespace"},
Expand Down
5 changes: 1 addition & 4 deletions pkg/system/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ func ValidateResources(resources ...string) error {
req, limit, both := strings.Cut(rs, ":")
if !both {
_, err := resource.ParseQuantity(rs)
if err != nil {
return err
}
return nil
return err
}

parsedReq, err := resource.ParseQuantity(req)
Expand Down

0 comments on commit 930a930

Please sign in to comment.