mirror of https://github.com/harness/drone.git
feat: [ML-338]: Rename return_pipeline_yaml capability to display_pipeline_yaml (#2776)
* Fix lint * feat: [ML-338]: Rename return_pipeline_yaml capability to display_pipeline_yamlpull/3571/head
parent
45341cd61e
commit
72472f3b27
|
@ -80,7 +80,7 @@ func (s *HarnessIntelligence) Generate(
|
|||
|
||||
var yaml string
|
||||
for _, value := range resp.Context {
|
||||
out, ok := value.Payload.(*capabilities.ReturnPipelineYamlOutput)
|
||||
out, ok := value.Payload.(*capabilities.DisplayPipelineYamlOutput)
|
||||
if ok {
|
||||
yaml = out.Yaml
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func (s *HarnessIntelligence) Update(
|
|||
|
||||
var yaml string
|
||||
for _, value := range resp.Context {
|
||||
out, ok := value.Payload.(*capabilities.ReturnPipelineYamlOutput)
|
||||
out, ok := value.Payload.(*capabilities.DisplayPipelineYamlOutput)
|
||||
if ok {
|
||||
yaml = out.Yaml
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright 2023 Harness, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package capabilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/harness/gitness/types/capabilities"
|
||||
)
|
||||
|
||||
var DisplayPipelineYamlType capabilities.Type = "display_pipeline_yaml"
|
||||
var DisplayPipelineYamlVersion capabilities.Version = "0"
|
||||
|
||||
type DisplayPipelineYamlInput struct {
|
||||
Yaml string `json:"pipeline_yaml"`
|
||||
}
|
||||
|
||||
func (DisplayPipelineYamlInput) IsCapabilityInput() {}
|
||||
|
||||
type DisplayPipelineYamlOutput struct {
|
||||
Yaml string `json:"pipeline_yaml"`
|
||||
}
|
||||
|
||||
func (DisplayPipelineYamlOutput) IsCapabilityOutput() {}
|
||||
|
||||
const AIContextPayloadTypeDisplayPipelineYaml capabilities.AIContextPayloadType = "other"
|
||||
|
||||
func (DisplayPipelineYamlOutput) GetType() capabilities.AIContextPayloadType {
|
||||
return AIContextPayloadTypeDisplayPipelineYaml
|
||||
}
|
||||
|
||||
func (DisplayPipelineYamlOutput) GetName() string {
|
||||
return string(DisplayPipelineYamlType)
|
||||
}
|
||||
|
||||
func (r *Registry) RegisterDisplayPipelineYamlCapability(
|
||||
logic func(ctx context.Context, input *DisplayPipelineYamlInput) (*DisplayPipelineYamlOutput, error),
|
||||
) error {
|
||||
return r.register(
|
||||
capabilities.Capability{
|
||||
Type: DisplayPipelineYamlType,
|
||||
NewInput: func() capabilities.Input { return &DisplayPipelineYamlInput{} },
|
||||
Logic: newLogic(logic),
|
||||
Version: DisplayPipelineYamlVersion,
|
||||
ReturnToUser: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// ReturnPipelineYaml could take in, eg repoStore store.RepoStore, git git.Interface, as arguments.
|
||||
func DisplayPipelineYaml() func(
|
||||
ctx context.Context,
|
||||
input *DisplayPipelineYamlInput) (*DisplayPipelineYamlOutput, error) {
|
||||
return func(_ context.Context, input *DisplayPipelineYamlInput) (*DisplayPipelineYamlOutput, error) {
|
||||
return &DisplayPipelineYamlOutput{
|
||||
Yaml: input.Yaml,
|
||||
}, nil
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright 2023 Harness, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package capabilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/harness/gitness/types/capabilities"
|
||||
)
|
||||
|
||||
var ReturnPipelineYamlType capabilities.Type = "return_pipeline_yaml"
|
||||
var ReturnPipelineYamlVersion capabilities.Version = "0"
|
||||
|
||||
type ReturnPipelineYamlInput struct {
|
||||
Yaml string `json:"pipeline_yaml"`
|
||||
}
|
||||
|
||||
func (ReturnPipelineYamlInput) IsCapabilityInput() {}
|
||||
|
||||
type ReturnPipelineYamlOutput struct {
|
||||
Yaml string `json:"pipeline_yaml"`
|
||||
}
|
||||
|
||||
func (ReturnPipelineYamlOutput) IsCapabilityOutput() {}
|
||||
|
||||
const AIContextPayloadTypeReturnPipelineYaml capabilities.AIContextPayloadType = "other"
|
||||
|
||||
func (ReturnPipelineYamlOutput) GetType() capabilities.AIContextPayloadType {
|
||||
return AIContextPayloadTypeReturnPipelineYaml
|
||||
}
|
||||
|
||||
func (ReturnPipelineYamlOutput) GetName() string {
|
||||
return string(ReturnPipelineYamlType)
|
||||
}
|
||||
|
||||
func (r *Registry) RegisterReturnPipelineYamlCapability(
|
||||
logic func(ctx context.Context, input *ReturnPipelineYamlInput) (*ReturnPipelineYamlOutput, error),
|
||||
) error {
|
||||
return r.register(
|
||||
capabilities.Capability{
|
||||
Type: ReturnPipelineYamlType,
|
||||
NewInput: func() capabilities.Input { return &ReturnPipelineYamlInput{} },
|
||||
Logic: newLogic(logic),
|
||||
Version: ReturnPipelineYamlVersion,
|
||||
ReturnToUser: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// ReturnPipelineYaml could take in, eg repoStore store.RepoStore, git git.Interface, as arguments.
|
||||
func ReturnPipelineYaml() func(ctx context.Context, input *ReturnPipelineYamlInput) (*ReturnPipelineYamlOutput, error) {
|
||||
return func(_ context.Context, input *ReturnPipelineYamlInput) (*ReturnPipelineYamlOutput, error) {
|
||||
return &ReturnPipelineYamlOutput{
|
||||
Yaml: input.Yaml,
|
||||
}, nil
|
||||
}
|
||||
}
|
|
@ -35,6 +35,6 @@ func ProvideCapabilities(repoStore store.RepoStore, git git.Interface) (*Registr
|
|||
registry := NewRegistry()
|
||||
panicOnErr(registry.RegisterListFilesCapability(ListFiles(repoStore, git)))
|
||||
panicOnErr(registry.RegisterGetFileCapability(GetFile(repoStore, git)))
|
||||
panicOnErr(registry.RegisterReturnPipelineYamlCapability(ReturnPipelineYaml()))
|
||||
panicOnErr(registry.RegisterDisplayPipelineYamlCapability(DisplayPipelineYaml()))
|
||||
return registry, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue