-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add Capsule-Extensions to Pipeline configuration (#1208)
- Loading branch information
1 parent
02d4b54
commit 330e9d0
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package pipeline | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/rigdev/rig/pkg/api/config/v1alpha1" | ||
"github.com/rigdev/rig/pkg/errors" | ||
"github.com/rigdev/rig/pkg/pipeline" | ||
"github.com/rigdev/rig/pkg/uuid" | ||
) | ||
|
||
type CapsuleExtensionStep struct { | ||
name string | ||
step pipeline.Step[pipeline.CapsuleRequest] | ||
} | ||
|
||
func NewCapsuleExtensionStep(name string, step pipeline.Step[pipeline.CapsuleRequest]) *CapsuleExtensionStep { | ||
return &CapsuleExtensionStep{ | ||
name: name, | ||
step: step, | ||
} | ||
} | ||
|
||
func (s *CapsuleExtensionStep) Apply(ctx context.Context, req pipeline.CapsuleRequest, opts pipeline.Options) error { | ||
if _, ok := req.Capsule().Spec.Extensions[s.name]; ok { | ||
return s.step.Apply(ctx, req, opts) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (s *CapsuleExtensionStep) WatchObjectStatus( | ||
ctx context.Context, namespace, capsule string, callback pipeline.ObjectStatusCallback, | ||
) error { | ||
// TODO: We want to opt out if not relevant for this capsule. | ||
return s.step.WatchObjectStatus(ctx, namespace, capsule, callback) | ||
} | ||
|
||
func (s *CapsuleExtensionStep) PluginIDs() []uuid.UUID { | ||
return s.step.PluginIDs() | ||
} | ||
|
||
type CapsuleExtensionValidationStep struct { | ||
cfg *v1alpha1.OperatorConfig | ||
} | ||
|
||
func NewCapsuleExtensionValidationStep(cfg *v1alpha1.OperatorConfig) *CapsuleExtensionValidationStep { | ||
return &CapsuleExtensionValidationStep{ | ||
cfg: cfg, | ||
} | ||
} | ||
|
||
func (s *CapsuleExtensionValidationStep) Apply( | ||
_ context.Context, req pipeline.CapsuleRequest, _ pipeline.Options, | ||
) error { | ||
for name := range req.Capsule().Spec.Extensions { | ||
if _, ok := s.cfg.Pipeline.CapsuleExtensions[name]; !ok { | ||
return errors.UnimplementedErrorf("capsule extension '%s' not supported by cluster", name) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (s *CapsuleExtensionValidationStep) WatchObjectStatus( | ||
_ context.Context, _, _ string, _ pipeline.ObjectStatusCallback, | ||
) error { | ||
return nil | ||
} | ||
|
||
func (s *CapsuleExtensionValidationStep) PluginIDs() []uuid.UUID { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters