Skip to content

Commit

Permalink
enforce conditaional updates on AutoUpdate* + rename typos
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoShaka committed Oct 31, 2024
1 parent c1f368e commit 21b0779
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api/types/autoupdate/rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ import (

// NewAutoUpdateAgentRollout creates a new auto update version resource.
func NewAutoUpdateAgentRollout(spec *autoupdate.AutoUpdateAgentRolloutSpec) (*autoupdate.AutoUpdateAgentRollout, error) {
version := &autoupdate.AutoUpdateAgentRollout{
rollout := &autoupdate.AutoUpdateAgentRollout{
Kind: types.KindAutoUpdateAgentRollout,
Version: types.V1,
Metadata: &headerv1.Metadata{
Name: types.MetaNameAutoUpdateAgentRollout,
},
Spec: spec,
}
if err := ValidateAutoUpdateAgentRollout(version); err != nil {
if err := ValidateAutoUpdateAgentRollout(rollout); err != nil {
return nil, trace.Wrap(err)
}

return version, nil
return rollout, nil
}

// ValidateAutoUpdateAgentRollout checks that required parameters are set
Expand Down
6 changes: 3 additions & 3 deletions lib/services/autoupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ type AutoUpdateService interface {
DeleteAutoUpdateVersion(ctx context.Context) error

// CreateAutoUpdateAgentRollout creates the AutoUpdateAgentRollout singleton resource.
CreateAutoUpdateAgentRollout(ctx context.Context, plan *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)
CreateAutoUpdateAgentRollout(ctx context.Context, rollout *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)

// UpdateAutoUpdateAgentRollout updates the AutoUpdateAgentRollout singleton resource.
UpdateAutoUpdateAgentRollout(ctx context.Context, plan *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)
UpdateAutoUpdateAgentRollout(ctx context.Context, rollout *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)

// UpsertAutoUpdateAgentRollout sets the AutoUpdateAgentRollout singleton resource.
UpsertAutoUpdateAgentRollout(ctx context.Context, plan *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)
UpsertAutoUpdateAgentRollout(ctx context.Context, rollout *autoupdate.AutoUpdateAgentRollout) (*autoupdate.AutoUpdateAgentRollout, error)

// DeleteAutoUpdateAgentRollout deletes the AutoUpdateAgentRollout singleton resource.
DeleteAutoUpdateAgentRollout(ctx context.Context) error
Expand Down
6 changes: 3 additions & 3 deletions lib/services/local/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *AutoUpdateService) UpdateAutoUpdateConfig(
ctx context.Context,
c *autoupdate.AutoUpdateConfig,
) (*autoupdate.AutoUpdateConfig, error) {
config, err := s.config.UpdateResource(ctx, c)
config, err := s.config.ConditionalUpdateResource(ctx, c)
return config, trace.Wrap(err)
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func (s *AutoUpdateService) UpdateAutoUpdateVersion(
ctx context.Context,
v *autoupdate.AutoUpdateVersion,
) (*autoupdate.AutoUpdateVersion, error) {
version, err := s.version.UpdateResource(ctx, v)
version, err := s.version.ConditionalUpdateResource(ctx, v)
return version, trace.Wrap(err)
}

Expand Down Expand Up @@ -189,7 +189,7 @@ func (s *AutoUpdateService) UpdateAutoUpdateAgentRollout(
ctx context.Context,
v *autoupdate.AutoUpdateAgentRollout,
) (*autoupdate.AutoUpdateAgentRollout, error) {
rollout, err := s.rollout.UpdateResource(ctx, v)
rollout, err := s.rollout.ConditionalUpdateResource(ctx, v)
return rollout, trace.Wrap(err)
}

Expand Down

0 comments on commit 21b0779

Please sign in to comment.