-
Notifications
You must be signed in to change notification settings - Fork 81
/
interface.go
42 lines (32 loc) · 990 Bytes
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package consoleui
import (
"context"
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/info"
"k8s.io/client-go/dynamic"
)
type Interface interface {
DetailURL(ns string, pr string) string
TaskLogURL(ns string, pr string, task string) string
UI(ctx context.Context, kdyn dynamic.Interface) error
URL() string
}
type FallBackConsole struct{}
func (f FallBackConsole) DetailURL(ns string, pr string) string {
return "https://giphy.com/search/random-dogs"
}
func (f FallBackConsole) TaskLogURL(ns string, pr string, task string) string {
return "https://giphy.com/search/random-cats"
}
func (f FallBackConsole) UI(ctx context.Context, kdyn dynamic.Interface) error {
return nil
}
func (f FallBackConsole) URL() string {
return "https://giphy.com/explore/random"
}
func New(ctx context.Context, kdyn dynamic.Interface, runinfo *info.Info) Interface {
oc := &OpenshiftConsole{}
if err := oc.UI(ctx, kdyn); err == nil {
return oc
}
return FallBackConsole{}
}