Skip to content

Commit

Permalink
Richer Maintainer Metadata (#762)
Browse files Browse the repository at this point in the history
* Fixes Operator Maintainer Metadata to be more rich with a breakdown of name and email.
* We also move the community repository (likely temporarily) from: https://kudo-repository.storage.googleapis.com to `https://kudo-repository.storage.googleapis.com/0.7.0`
  • Loading branch information
kensipe authored Sep 11, 2019
1 parent c4d9c13 commit d733387
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 60 deletions.
7 changes: 6 additions & 1 deletion config/crds/kudo_v1alpha1_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ spec:
type: string
maintainers:
items:
type: string
properties:
name:
type: string
email:
type: string
type: object
type: array
url:
type: string
Expand Down
3 changes: 2 additions & 1 deletion config/samples/first-operator/operator.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: "first-operator"
version: "0.1.0"
maintainers:
- Your name <your@email.com>
- name: Your name
email: <your@email.com>
url: https://kudo.dev
tasks:
app:
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEK
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ=
github.com/gobuffalo/envy v1.6.15 h1:OsV5vOpHYUpP7ZLS6sem1y40/lNX1BZj+ynMiRi21lQ=
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
github.com/gobuffalo/flect v0.1.5 h1:xpKq9ap8MbYfhuPCF0dBH854Gp9CxZjr/IocxELFflo=
github.com/gobuffalo/flect v0.1.5/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -441,6 +444,7 @@ sigs.k8s.io/controller-runtime v0.2.0 h1:5gL30PXOisGZl+Osi4CmLhvMUj77BO3wJeouKF2
sigs.k8s.io/controller-runtime v0.2.0/go.mod h1:ZHqrRDZi3f6BzONcvlUxkqCKgwasGk5FZrnSv9TVZF4=
sigs.k8s.io/controller-tools v0.2.0 h1:AmQ/0JKBJAjyAiPAkrAf9QW06jkx2lc5hpxMjamsFpw=
sigs.k8s.io/controller-tools v0.2.0/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y=
sigs.k8s.io/controller-tools v0.2.1 h1:HoCik83vXOpPi7KSJWdPRmiGntyOzK0v0BTV4U+pl8o=
sigs.k8s.io/kind v0.4.0 h1:C/QMxmF5Sp3yyKkTJ5+VJPcclZyu/JV8wLyihZbsHaI=
sigs.k8s.io/kind v0.4.0/go.mod h1:bgGo2cWxKGQ7esVxtGp9H17Ttlexju92CTMjCg08HNQ=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
Expand Down
20 changes: 13 additions & 7 deletions pkg/apis/kudo/v1alpha1/operator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ import (

// OperatorSpec defines the desired state of Operator
type OperatorSpec struct {
Description string `json:"description,omitempty"`
KudoVersion string `json:"kudoVersion,omitempty"`
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
Maintainers []Maintainer `json:"maintainers,omitempty"`
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
KudoVersion string `json:"kudoVersion,omitempty"`
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
Maintainers []*Maintainer `json:"maintainers,omitempty"`
URL string `json:"url,omitempty"`
}

// Maintainer contains contact info for the maintainer of the Operator
type Maintainer string
// Maintainer describes an Operator maintainer.
type Maintainer struct {
// Name is a user name or organization name.
Name string `json:"name,omitempty"`

// Email is an optional email address to contact the named maintainer.
Email string `json:"email,omitempty"`
}

// OperatorStatus defines the observed state of Operator
type OperatorStatus struct {
Expand Down
26 changes: 24 additions & 2 deletions pkg/apis/kudo/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion pkg/bundle/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Operator struct {
AppVersion string `json:"appVersion,omitempty"`
KUDOVersion string `json:"kudoVersion,omitempty"`
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
Maintainers []v1alpha1.Maintainer `json:"maintainers,omitempty"`
Maintainers []*v1alpha1.Maintainer `json:"maintainers,omitempty"`
URL string `json:"url,omitempty"`
Tasks map[string]v1alpha1.TaskSpec `json:"tasks"`
Plans map[string]v1alpha1.Plan `json:"plans"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/kudoctl/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (b fileBundle) GetPkgFiles() (*PackageFiles, error) {
func ToTarBundle(fs afero.Fs, path string, destination string, overwrite bool) (string, error) {
pkg, err := fromFolder(fs, path)
if err != nil {
//TODO (kensipe): use wrapped err at high verbosity
//return "", fmt.Errorf("invalid operator in path: %v error: %v", path, err)
return "", fmt.Errorf("invalid operator in path: %v", path)
}

Expand Down
9 changes: 6 additions & 3 deletions pkg/kudoctl/bundle/testdata/zk-crd-golden1/operator.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ metadata:
spec:
url: https://zookeeper.apache.org/
maintainers:
- Alena Varkockova <avarkockova@mesosphere.com>
- Tom Runyon <runyontr@gmail.com>
- Ken Sipe <kensipe@gmail.com>
- name: Alena Varkockova
email: avarkockova@mesosphere.com
- name: Tom Runyon
email: runyontr@gmail.com
- name: Ken Sipe
email: kensipe@gmail.com
kudoVersion: 0.2.0
kubernetesVersion: 1.15.0
9 changes: 6 additions & 3 deletions pkg/kudoctl/bundle/testdata/zk-crd-golden2/operator.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ metadata:
spec:
url: https://zookeeper.apache.org/
maintainers:
- Alena Varkockova <avarkockova@mesosphere.com>
- Tom Runyon <runyontr@gmail.com>
- Ken Sipe <kensipe@gmail.com>
- name: Alena Varkockova
email: avarkockova@mesosphere.com
- name: Tom Runyon
email: runyontr@gmail.com
- name: Ken Sipe
email: kensipe@gmail.com
kudoVersion: 0.2.0
kubernetesVersion: 1.15.0
Binary file modified pkg/kudoctl/bundle/testdata/zk.tar.gz
Binary file not shown.
9 changes: 6 additions & 3 deletions pkg/kudoctl/bundle/testdata/zk/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ appVersion: "3.4.10"
kudoVersion: 0.2.0
kubernetesVersion: 1.15.0
maintainers:
- Alena Varkockova <avarkockova@mesosphere.com>
- Tom Runyon <runyontr@gmail.com>
- Ken Sipe <kensipe@gmail.com>
- name: Alena Varkockova
email: avarkockova@mesosphere.com
- name: Tom Runyon
email: runyontr@gmail.com
- name: Ken Sipe
email: kensipe@gmail.com
url: https://zookeeper.apache.org/
tasks:
infra:
Expand Down
12 changes: 10 additions & 2 deletions pkg/kudoctl/cmd/init/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,22 @@ func operatorCrd() *apiextv1beta1.CustomResourceDefinition {
}

func generateOperator() *apiextv1beta1.CustomResourceDefinition {

maintainers := map[string]apiextv1beta1.JSONSchemaProps{
"name": apiextv1beta1.JSONSchemaProps{Type: "string"},
"email": apiextv1beta1.JSONSchemaProps{Type: "string"},
}

crd := generateCrd("Operator", "operators")
specProps := map[string]apiextv1beta1.JSONSchemaProps{
"description": apiextv1beta1.JSONSchemaProps{Type: "string"},
"kubernetesVersion": apiextv1beta1.JSONSchemaProps{Type: "string"},
"kudoVersion": apiextv1beta1.JSONSchemaProps{Type: "string"},
"maintainers": apiextv1beta1.JSONSchemaProps{
Type: "array",
Items: &apiextv1beta1.JSONSchemaPropsOrArray{Schema: &apiextv1beta1.JSONSchemaProps{Type: "string"}, JSONSchemas: []apiextv1beta1.JSONSchemaProps{}},
Items: &apiextv1beta1.JSONSchemaPropsOrArray{Schema: &apiextv1beta1.JSONSchemaProps{
Type: "object",
Properties: maintainers,
}, JSONSchemas: []apiextv1beta1.JSONSchemaProps{}},
},
"url": apiextv1beta1.JSONSchemaProps{Type: "string"},
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/kudoctl/cmd/testdata/deploy-kudo.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ spec:
type: string
maintainers:
items:
type: string
type: array
properties:
email:
type: string
name:
type: string
type: object
url:
type: string
type: object
Expand Down
4 changes: 2 additions & 2 deletions pkg/kudoctl/cmd/testdata/repo-list.golden
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME URL
*community https://kudo-repository.storage.googleapis.com
NAME URL
*community https://kudo-repository.storage.googleapis.com/0.7.0
6 changes: 3 additions & 3 deletions pkg/kudoctl/cmd/testdata/skip-check-add-list.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME URL
*community https://kudo-repository.storage.googleapis.com
foo badurl
NAME URL
*community https://kudo-repository.storage.googleapis.com/0.7.0
foo badurl
8 changes: 1 addition & 7 deletions pkg/kudoctl/util/repo/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,12 @@ func ToPackageVersion(pf *bundle.PackageFiles, digest string, url string) *Packa
url = url + "/"
}
url = fmt.Sprintf("%s%s-%v.tgz", url, o.Name, o.Version)
m := make([]*Maintainer, len(o.Maintainers))
for i, maintainer := range o.Maintainers {
m[i] = &Maintainer{
Name: string(maintainer),
}
}
pv := PackageVersion{
Metadata: &Metadata{
Name: o.Name,
Version: o.Version,
Description: o.Description,
Maintainers: m,
Maintainers: o.Maintainers,
AppVersion: o.AppVersion,
},
URLs: []string{url},
Expand Down
10 changes: 5 additions & 5 deletions pkg/kudoctl/util/repo/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ func getTestBundleVersion(name string, version string) PackageVersion {
Sources: []string{"https://github.com/kudobuilder/kudo"},
Description: "fancy description is here",
Deprecated: false,
Maintainers: []*Maintainer{
&Maintainer{Name: "Fabian Baier", Email: "<fabian@mesosphere.io>"},
&Maintainer{Name: "Tom Runyon", Email: "<runyontr@gmail.com>"},
&Maintainer{Name: "Ken Sipe", Email: "<kensipe@gmail.com>"}},
Maintainers: []*v1alpha1.Maintainer{
&v1alpha1.Maintainer{Name: "Fabian Baier", Email: "<fabian@mesosphere.io>"},
&v1alpha1.Maintainer{Name: "Tom Runyon", Email: "<runyontr@gmail.com>"},
&v1alpha1.Maintainer{Name: "Ken Sipe", Email: "<kensipe@gmail.com>"}},
},
URLs: urls,
Removed: false,
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestMapPackageFileToPackageVersion(t *testing.T) {
AppVersion: "2.2.2",
KUDOVersion: "0.5.0",
KubernetesVersion: "1.15",
Maintainers: []v1alpha1.Maintainer{"kensipe@gmail.com"},
Maintainers: []*v1alpha1.Maintainer{&v1alpha1.Maintainer{Name: "Ken Sipe"}},
URL: "http://kudo.dev/kafka",
}
pf := bundle.PackageFiles{
Expand Down
17 changes: 3 additions & 14 deletions pkg/kudoctl/util/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

"github.com/kudobuilder/kudo/pkg/apis/kudo/v1alpha1"
"github.com/kudobuilder/kudo/pkg/kudoctl/kudohome"

"github.com/spf13/afero"
Expand Down Expand Up @@ -37,7 +38,7 @@ type Repositories struct {
// Default initialized repository.
var Default = &Configuration{
Name: defaultRepoName,
URL: "https://kudo-repository.storage.googleapis.com",
URL: "https://kudo-repository.storage.googleapis.com/0.7.0",
}

// NewRepositories creates a new repo with only defaults populated
Expand Down Expand Up @@ -166,20 +167,8 @@ type Metadata struct {
Description string `json:"description,omitempty"`

// Maintainers is a list of name and URL/email addresses of the maintainer(s).
Maintainers []*Maintainer `json:"maintainers,omitempty"`
Maintainers []*v1alpha1.Maintainer `json:"maintainers,omitempty"`

// Deprecated reflects whether this operator is deprecated.
Deprecated bool `json:"deprecated,omitempty"`
}

// Maintainer describes an Operator maintainer.
type Maintainer struct {
// Name is a user name or organization name.
Name string `json:"name,omitempty"`

// Email is an optional email address to contact the named maintainer.
Email string `json:"email,omitempty"`

// URL is an optional URL to an address for the named maintainer.
URL string `json:"url,omitempty"`
}
2 changes: 1 addition & 1 deletion pkg/kudoctl/util/repo/testdata/repositories.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ context: community
repoVersion: v1
repositories:
- name: community
url: https://kudo-repository.storage.googleapis.com
url: https://kudo-repository.storage.googleapis.com/0.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ version: "0.1.0"
kudoVersion: 0.3.0
kubernetesVersion: 1.5.1
maintainers:
- Justin Taylor-Barrick <jbarrick-mesosphere@mesosphere.com>
- name: Justin Taylor-Barrick
email: jbarrick-mesosphere@mesosphere.com
tasks:
infra:
resources:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: "upgrade-operator"
version: "0.1.0"
maintainers:
- Your name <your@email.com>
- name: Your name
email: <your@email.com>
url: https://kudo.dev
tasks:
app:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: "upgrade-operator"
version: "0.2.0"
maintainers:
- Your name <your@email.com>
- name: Your name
email: <your@email.com>
url: https://kudo.dev
tasks:
app:
Expand Down

0 comments on commit d733387

Please sign in to comment.