Skip to content

Commit

Permalink
Adds Manual Approval Gate CLI in opc
Browse files Browse the repository at this point in the history
Signed-off-by: PuneetPunamiya <ppunamiy@redhat.com>
  • Loading branch information
PuneetPunamiya authored and piyush-garg committed May 14, 2024
1 parent 7e5728c commit 65a0163
Show file tree
Hide file tree
Showing 55 changed files with 7,404 additions and 9 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
PAC_VERSION := $(shell sed -n '/[ ]*github.com\/openshift-pipelines\/pipelines-as-code v[0-9]*\.[0-9]*\.[0-9]*/ { s/.* v//;p ;}' go.mod)
TKN_VERSION := $(shell sed -n '/[ ]*github.com\/tektoncd\/cli v[0-9]*\.[0-9]*\.[0-9]*/ { s/.* v//;p ;}' go.mod)
RESULTS_VERSION := $(shell sed -n '/[ ]*github.com\/tektoncd\/results v[0-9]*\.[0-9]*\.[0-9]*/ { s/.* v//;p ;}' go.mod)
MAG_VERSION := $(shell sed -n '/[ ]*github.com\/openshift-pipelines\/manual-approval-gate v[0-9]*\.[0-9]*\.[0-9]*/ { s/.* v//;p ;}' go.mod)

GO := go
GOVERSION := 1.21
GOVERSION := 1.22
OPC_VERSION := devel
BINARYNAME := opc
GOLANGCI_LINT := golangci-lint
Expand All @@ -26,13 +27,15 @@ build: mkbin generate ## builds binary and updates version in pkg/version
windows: mkbin generate
env GOOS=windows GOARCH=amd64 $(GO) build -mod=vendor $(FLAGS) -v -o bin/$(BINARYNAME).exe main.go

generate: version-file ## updates version of pipeline-as-code, cli and results in pkg/version file
generate: version-file ## updates version of pipeline-as-code, cli, mag and results in pkg/version file
version-file:
echo '{"pac": "$(PAC_VERSION)", "tkn": "$(TKN_VERSION)", "results": "$(RESULTS_VERSION)", "opc": "$(OPC_VERSION)"}' > pkg/version.json
echo '{"pac": "$(PAC_VERSION)", "tkn": "$(TKN_VERSION)", "results": "$(RESULTS_VERSION)", "manualapprovalgate": "$(MAG_VERSION)", "opc": "$(OPC_VERSION)"}' > pkg/version.json

version-updates: ## updates pipeline-as-code, cli and results version in go.mod
version-updates: ## updates pipeline-as-code, cli, mag and results version in go.mod
$(GO) get -u github.com/openshift-pipelines/pipelines-as-code
$(GO) mod vendor
$(GO) get -u github.com/openshift-pipelines/manual-approval-gate
$(GO) mod vendor
$(GO) get -u github.com/tektoncd/cli
$(GO) mod vendor
$(GO) get -u github.com/tektoncd/results
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/openshift-pipelines/opc
go 1.22.0

require (
github.com/openshift-pipelines/manual-approval-gate v0.2.0
github.com/openshift-pipelines/pipelines-as-code v0.27.0
github.com/spf13/cobra v1.8.0
github.com/tektoncd/cli v0.37.0
Expand Down Expand Up @@ -226,6 +227,8 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/openshift/api v0.0.0-20240422085825-2624175e9673 // indirect
github.com/openshift/client-go v0.0.0-20240422164335-6c851f4919dd // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,14 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/openshift-pipelines/manual-approval-gate v0.2.0 h1:yznaBaby3eV5phOXwL+Qv0/ptizuuY6oZseSf/TKBsA=
github.com/openshift-pipelines/manual-approval-gate v0.2.0/go.mod h1:MPfHaCniOrhaoFEB8t/QHATOCfxJAz5fYZoPSRxK9zE=
github.com/openshift-pipelines/pipelines-as-code v0.27.0 h1:uxpva7/Ad/QEvc40BCBFEWrmYlAjCZ9dZCFYPYWW61c=
github.com/openshift-pipelines/pipelines-as-code v0.27.0/go.mod h1:rzfXtaqbUrsAock3f948p9ekXWc3DFFk9acz5BsEwA4=
github.com/openshift/api v0.0.0-20240422085825-2624175e9673 h1:D4qblu6z2A92fh7u9Nt1YskDtu+GySKiYP/D3tMWQ6A=
github.com/openshift/api v0.0.0-20240422085825-2624175e9673/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
github.com/openshift/client-go v0.0.0-20240422164335-6c851f4919dd h1:z5TPsTaB8Zzvv9fK/kVB6X+FG1GtwM56WfoanhlbyyQ=
github.com/openshift/client-go v0.0.0-20240422164335-6c851f4919dd/go.mod h1:OC07uJXbaW/s21N6XDucROlmfUOhMXD5OrY3ZN3DmiM=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.4.2 h1:zjqfqHjUpPmB3c1GlCvvgsM1G4LkvqQbBDueDOCg/jA=
Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"syscall"

magcli "github.com/openshift-pipelines/manual-approval-gate/pkg/cli"
magcmd "github.com/openshift-pipelines/manual-approval-gate/pkg/cli/cmd"
opccli "github.com/openshift-pipelines/opc/pkg"
paccli "github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac"
Expand All @@ -24,6 +26,7 @@ See https://pipelinesascode.com for more details`
pacShortdesc = "CLI to interact with Pipelines as Code resources"
tknShortDesc = "CLI to interact with Openshift Pipelines resources"
resultsShortDesc = "CLI to interact with Tekton Results API."
magShortDesc = "CLI to interact with Manual Approval Gate."
binaryName = `opc`
)

Expand All @@ -38,11 +41,20 @@ func main() {
pac.Short = pacShortdesc
pac.Long = pacLongDesc
tkn.AddCommand(pac)

// adding manual approval gate cli
p := &magcli.ApprovalTaskParams{}
mag := magcmd.Root(p)
mag.Use = "approvaltask"
mag.Short = magShortDesc
tkn.AddCommand(mag)

// adding results
results := resultscmd.Root()
results.Use = "results"
results.Short = resultsShortDesc
tkn.AddCommand(results)

pluginList := plugins.GetAllTknPluginFromPaths()
newPluginList := []string{}
// remove pac from the plugin list
Expand Down
11 changes: 7 additions & 4 deletions pkg/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ var versionFile string
var versionTmpl string

type versions struct {
Opc string `json:"opc"`
Tkn string `json:"tkn"`
Pac string `json:"pac"`
Results string `json:"results"`
Opc string `json:"opc"`
Tkn string `json:"tkn"`
Pac string `json:"pac"`
Results string `json:"results"`
ManualApprovalGate string `json:"manualapprovalgate"`
}

func VersionCommand(ioStreams *paccli.IOStreams) *cobra.Command {
Expand All @@ -46,6 +47,8 @@ func VersionCommand(ioStreams *paccli.IOStreams) *cobra.Command {
fmt.Fprintln(ioStreams.Out, v.Opc)
case "results":
fmt.Fprintln(ioStreams.Out, v.Results)
case "manualapprovalgate":
fmt.Fprintln(ioStreams.Out, v.ManualApprovalGate)
default:
return fmt.Errorf("unknown component: %v", args[1])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pac": "0.27.0", "tkn": "0.37.0", "results": "0.10.0", "opc": "devel"}
{"pac": "0.27.0", "tkn": "0.37.0", "results": "0.10.0", "manualapprovalgate": "0.2.0", "opc": "devel"}
1 change: 1 addition & 0 deletions pkg/version.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ OpenShift Pipelines Client: {{ .Opc }}
Tekton CLI: {{ .Tkn }}
Pipelines as Code CLI: {{ .Pac }}
Tekton Results CLI: {{ .Results }}
Manual Approval Gate CLI: {{ .ManualApprovalGate }}
201 changes: 201 additions & 0 deletions vendor/github.com/openshift-pipelines/manual-approval-gate/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 65a0163

Please sign in to comment.