Skip to content

Commit 02fc1ea

Browse files
committed
pkg/validation/interfaces: Validator's implement Validate() to return
errors.ManifestResult. pkg/validation/internal: default validator implementations pkg/validation/errors: result and error types for validators pkg/internal: bundle parser pkg/manifests: GetManifestsDir() parses and validates a directory of Operator manifests *: update import paths to operator-framework/api go.*: revendor README.md: concise description of pkg/validation
1 parent 3fe9a43 commit 02fc1ea

32 files changed

+2248
-1283
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# api
2-
Contains the API definitions used by OLM and Marketplace
2+
3+
Contains the API definitions used by [Operator Lifecycle Manager][olm] (OLM) and [Marketplace Operator][marketplace]
4+
5+
## `pkg/validation`: Operator Manifest Validation
6+
7+
`pkg/validation` exposes a convenient set of interfaces to validate Kubernetes object manifests, primarily for use in an Operator project.
8+
9+
[olm]:https://github.com/operator-framework/operator-lifecycle-manager
10+
[marketplace]:https://github.com/operator-framework/operator-marketplace

cmd/operator-verify/main.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
package main
22

33
import (
4-
"github.com/dweepgogia/new-manifest-verification/cmd"
4+
"fmt"
5+
"os"
6+
7+
manifests "github.com/operator-framework/api/cmd/operator-verify/manifests"
8+
9+
"github.com/spf13/cobra"
510
)
611

712
func main() {
8-
// Launch CLI tool.
9-
cmd.Execute()
13+
rootCmd := &cobra.Command{
14+
Use: "operator-verify",
15+
Short: "Operator manifest validation tool",
16+
Long: `operator-verify is a CLI tool that calls functions in pkg/validation.`,
17+
}
18+
19+
rootCmd.AddCommand(manifests.NewCmd())
20+
if err := rootCmd.Execute(); err != nil {
21+
fmt.Println(err)
22+
os.Exit(1)
23+
}
1024
}

cmd/operator-verify/manifests/cmd.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package manifests
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/operator-framework/api/pkg/manifests"
8+
"github.com/operator-framework/api/pkg/validation/errors"
9+
10+
log "github.com/sirupsen/logrus"
11+
"github.com/spf13/cobra"
12+
)
13+
14+
func NewCmd() *cobra.Command {
15+
return &cobra.Command{
16+
Use: "manifests",
17+
Short: "Validates all manifests in a directory",
18+
Long: `'operator-verify manifests' validates all manifests in the supplied directory
19+
and prints errors and warnings corresponding to each manifest found to be
20+
invalid. Manifests are only validated if a validator for that manifest
21+
type/kind, ex. CustomResourceDefinition, is implemented in the Operator
22+
validation library.`,
23+
Run: func(cmd *cobra.Command, args []string) {
24+
if len(args) != 1 {
25+
log.Fatalf("command %s requires exactly one argument", cmd.CommandPath())
26+
}
27+
_, _, results := manifests.GetManifestsDir(args[0])
28+
nonEmptyResults := []errors.ManifestResult{}
29+
for _, result := range results {
30+
if result.HasError() || result.HasWarn() {
31+
nonEmptyResults = append(nonEmptyResults, result)
32+
}
33+
}
34+
if len(nonEmptyResults) != 0 {
35+
fmt.Println(nonEmptyResults)
36+
os.Exit(1)
37+
}
38+
},
39+
}
40+
}

cmd/root.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmd/verify.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

go.mod

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/dweepgogia/new-manifest-verification
1+
module github.com/operator-framework/api
22

33
go 1.12
44

@@ -23,51 +23,16 @@ replace (
2323

2424
require (
2525
github.com/blang/semver v3.5.1+incompatible
26-
github.com/coreos/go-semver v0.3.0
27-
github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a // indirect
28-
github.com/docker/distribution v2.7.1+incompatible // indirect
29-
github.com/emicklei/go-restful v2.9.6+incompatible // indirect
30-
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
3126
github.com/ghodss/yaml v1.0.0
32-
github.com/go-openapi/spec v0.19.2
33-
github.com/go-openapi/validate v0.19.2 // indirect
34-
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
35-
github.com/golang/mock v1.3.1
36-
github.com/google/btree v1.0.0 // indirect
37-
github.com/google/gofuzz v1.0.0 // indirect
38-
github.com/googleapis/gnostic v0.3.0 // indirect
39-
github.com/grpc-ecosystem/grpc-gateway v1.9.4 // indirect
40-
github.com/json-iterator/go v1.1.6 // indirect
41-
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
42-
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.1
43-
github.com/mitchellh/hashstructure v1.0.0
44-
github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30 // indirect
45-
github.com/openshift/api v0.0.0-00010101000000-000000000000
46-
github.com/openshift/client-go v0.0.0-00010101000000-000000000000
47-
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190125151539-1e295784b30a
48-
github.com/operator-framework/operator-registry v1.1.1
27+
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
28+
github.com/hashicorp/golang-lru v0.5.3 // indirect
29+
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190926160646-a61144936680
30+
github.com/operator-framework/operator-registry v1.5.3
4931
github.com/pkg/errors v0.8.1
50-
github.com/prometheus/client_golang v0.9.2
5132
github.com/sirupsen/logrus v1.4.2
5233
github.com/spf13/cobra v0.0.5
5334
github.com/stretchr/testify v1.3.0
54-
go.uber.org/atomic v1.4.0 // indirect
55-
go.uber.org/zap v1.10.0 // indirect
56-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
57-
gonum.org/v1/gonum v0.0.0-20190710053202-4340aa3071a0 // indirect
58-
google.golang.org/grpc v1.22.0
59-
k8s.io/api v0.0.0-20190717022910-653c86b0609b
60-
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc
61-
k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887
62-
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170
35+
k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783
36+
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655
6337
k8s.io/client-go v8.0.0+incompatible
64-
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3
65-
k8s.io/component-base v0.0.0-20190717023551-b4f50308a616
66-
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect
67-
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
68-
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
69-
k8s.io/kubernetes v1.11.8-beta.0.0.20190124204751-3a10094374f2
70-
k8s.io/utils v0.0.0-20190712204705-3dccf664f023 // indirect
71-
sigs.k8s.io/structured-merge-diff v0.0.0-00010101000000-000000000000 // indirect
72-
sigs.k8s.io/yaml v1.1.0 // indirect
7338
)

0 commit comments

Comments
 (0)