Skip to content

Commit

Permalink
cmd: apply registries first (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicks authored Nov 17, 2020
1 parent 9971d1f commit 902ae44
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkg/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func (o *ApplyOptions) run() error {
var rc *registry.Controller
for _, obj := range objects {
switch obj := obj.(type) {
case *api.Cluster:
if cc == nil {
cc, err = cluster.DefaultController(o.IOStreams)
case *api.Registry:
if rc == nil {
rc, err = registry.DefaultController(ctx, o.IOStreams)
if err != nil {
return err
}
}

newObj, err := cc.Apply(ctx, obj)
newObj, err := rc.Apply(ctx, obj)
if err != nil {
return err
}
Expand All @@ -104,16 +104,20 @@ func (o *ApplyOptions) run() error {
if err != nil {
return err
}
}
}

case *api.Registry:
if rc == nil {
rc, err = registry.DefaultController(ctx, o.IOStreams)
for _, obj := range objects {
switch obj := obj.(type) {
case *api.Cluster:
if cc == nil {
cc, err = cluster.DefaultController(o.IOStreams)
if err != nil {
return err
}
}

newObj, err := rc.Apply(ctx, obj)
newObj, err := cc.Apply(ctx, obj)
if err != nil {
return err
}
Expand All @@ -123,8 +127,12 @@ func (o *ApplyOptions) run() error {
return err
}

case *api.Registry:
// Handled above
continue

default:
return fmt.Errorf("Unrecognized type: %T", obj)
return fmt.Errorf("unrecognized type: %T", obj)
}
}
return nil
Expand Down

0 comments on commit 902ae44

Please sign in to comment.