Skip to content

Commit

Permalink
sigs,generate: improve validation, update sig-list generation (#350)
Browse files Browse the repository at this point in the history
* sigs,validator: update validator code

Update validator code to take into account new sigs.yaml fields.
Add validation for chairs, leads, labels and directories.

Signed-off-by: Daniel Hiller <[email protected]>

* update sig-list md template - missing values

Signed-off-by: Daniel Hiller <[email protected]>

* generate: add sig validator call

Signed-off-by: Daniel Hiller <[email protected]>

* sigs.yaml: remove non existing dirs and OWNERS

Signed-off-by: Daniel Hiller <[email protected]>

* sigs.yaml,wg-arch,wg-code-quality: correct labels

Update labels to future correct ones.

Signed-off-by: Daniel Hiller <[email protected]>

* sigs.yaml,chairs: add kubevirt community chair

Add aburdenthehand as community chair.

Note: this is only stating the obvious

Signed-off-by: Daniel Hiller <[email protected]>

* sigs.yaml,sig-list: run make generate

Updates yaml formatting and regenerates the sig-list markdown.

Signed-off-by: Daniel Hiller <[email protected]>

---------

Signed-off-by: Daniel Hiller <[email protected]>
  • Loading branch information
dhiller authored Nov 28, 2024
1 parent 46b19a1 commit 012befe
Show file tree
Hide file tree
Showing 12 changed files with 735 additions and 285 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
generate:
go run ./validators/cmd/sigs --dry-run=false
go run ./generators/cmd/sigs

validate-sigs:
Expand Down
2 changes: 1 addition & 1 deletion generators/cmd/sigs/sig-list.gomd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
-}}
{{- /* gotype: kubevirt.io/community/generators/cmd/sigs.SigListTemplateData */ -}}
{{ define "group" }}|[{{ .Name }}]({{ .Dir }}/charter.md) |{{ if .Label }}[{{ .Label }}](https://github.com/kubevirt/kubevirt/labels/{{ .Label }}){{ end }} | {{ if .Leadership }}<ol>{{ range $index2, $chair := .Leadership.Chairs }}<li>[{{ $chair.Name }}](https://github.com/{{ $chair.Github }}), {{ $chair.Company }}</li>{{ end }}</ol>{{ end }} |{{ if .Contact }}[Slack]({{ .Contact.Slack}})<br/> [Mailing List]({{ .Contact.MailingList }}){{ end }} |<ul>{{ range $index3, $meeting := .Meetings }}<li>{{ $meeting.Description }}: [ {{ $meeting.Day }} at {{ $meeting.Time }} {{ $meeting.TZ }} ({{ $meeting.Frequency }}) ]({{ $meeting.URL }})</li>{{ end }}</ul> |{{ end }}
{{ define "group" }}|{{ if .Dir }}[{{ end }}{{ .Name }}{{ if .Dir }}]({{ .Dir }}/charter.md){{ end }} |{{ if .Label }}[{{ .Label }}](https://github.com/kubevirt/kubevirt/labels/{{ .Label }}){{ end }} |{{ if .Leadership }}<ol>{{ range $index2, $chair := .Leadership.Chairs }}<li>[{{ $chair.Name }}](https://github.com/{{ $chair.Github }}), {{ $chair.Company }}</li>{{ end }}</ol>{{ end }} |{{ if .Contact }}[Slack]({{ .Contact.Slack}})<br/> [Mailing List]({{ .Contact.MailingList }}){{ end }} |<ul>{{ range $index3, $meeting := .Meetings }}<li>{{ $meeting.Description }}: [ {{ $meeting.Day }} at {{ $meeting.Time }} {{ $meeting.TZ }} ({{ $meeting.Frequency }}) ]({{ $meeting.URL }})</li>{{ end }}</ul> |{{ end }}
<!---
This is an autogenerated file!

Expand Down
40 changes: 40 additions & 0 deletions pkg/labels/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright the KubeVirt Authors.
*
*/

package labels

import (
"fmt"
"gopkg.in/yaml.v3"
"os"
)

func ReadFile(path string) (*LabelsYAML, error) {
buf, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("error reading %s: %v", path, err)
}

labelsYAML := &LabelsYAML{}
err = yaml.Unmarshal(buf, labelsYAML)
if err != nil {
return nil, fmt.Errorf("in file %q: %v", path, err)
}
return labelsYAML, err
}
43 changes: 43 additions & 0 deletions pkg/labels/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright the KubeVirt Authors.
*
*/

package labels

type PreviousLabel struct {
Name string
Color string `yaml:",omitempty"`
}
type Label struct {
Name string
Color string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
Target string `yaml:",omitempty"`
ProwPlugin string `yaml:",omitempty"`
AddedBy string `yaml:",omitempty"`
Previously []*PreviousLabel `yaml:",omitempty"`
}

type Repo struct {
Labels []*Label
}

type LabelsYAML struct {
Default *Repo
Repos map[string]*Repo
}
40 changes: 40 additions & 0 deletions pkg/orgs/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright the KubeVirt Authors.
*
*/

package orgs

import (
"fmt"
"gopkg.in/yaml.v3"
"os"
)

func ReadFile(path string) (*Orgs, error) {
buf, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("error reading %s: %v", path, err)
}

orgs := &Orgs{}
err = yaml.Unmarshal(buf, orgs)
if err != nil {
return nil, fmt.Errorf("in file %q: %v", path, err)
}
return orgs, err
}
46 changes: 46 additions & 0 deletions pkg/orgs/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright the KubeVirt Authors.
*
*/

package orgs

import "strings"

type Org struct {
Admins []string
Members []string
}

func (receiver Org) HasMember(githubHandle string) bool {
lowerCaseHandle := strings.ToLower(githubHandle)
for _, admin := range receiver.Admins {
if strings.ToLower(admin) == lowerCaseHandle {
return true
}
}
for _, member := range receiver.Members {
if strings.ToLower(member) == lowerCaseHandle {
return true
}
}
return false
}

type Orgs struct {
Orgs map[string]Org
}
164 changes: 164 additions & 0 deletions pkg/orgs/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright the KubeVirt Authors.
*
*/

package orgs

import "testing"

func TestOrg_HasMember(t *testing.T) {
type fields struct {
Admins []string
Members []string
}
type args struct {
githubHandle string
}
tests := []struct {
name string
fields fields
args args
want bool
}{
{
name: "has member",
fields: fields{
Admins: []string{
"admin1",
"admin2",
"admin3",
},
Members: []string{
"member1",
"member2",
"member3",
},
},
args: args{
"member1",
},
want: true,
},
{
name: "has admin",
fields: fields{
Admins: []string{
"admin1",
"admin2",
"admin3",
},
Members: []string{
"member1",
"member2",
"member3",
},
},
args: args{
"admin3",
},
want: true,
},
{
name: "has member (lowercase)",
fields: fields{
Admins: []string{
"admin1",
"admin2",
"admin3",
},
Members: []string{
"member1",
"member2",
"member3",
},
},
args: args{
"Member1",
},
want: true,
},
{
name: "has admin (lowercase)",
fields: fields{
Admins: []string{
"admin1",
"admin2",
"admin3",
},
Members: []string{
"member1",
"member2",
"member3",
},
},
args: args{
"Admin1",
},
want: true,
},
{
name: "has member (uppercase)",
fields: fields{
Admins: []string{
"admin1",
"admin2",
"admin3",
},
Members: []string{
"Member1",
"member2",
"member3",
},
},
args: args{
"member1",
},
want: true,
},
{
name: "has admin (uppercase)",
fields: fields{
Admins: []string{
"Admin1",
"admin2",
"admin3",
},
Members: []string{
"member1",
"member2",
"member3",
},
},
args: args{
"admin1",
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
receiver := Org{
Admins: tt.fields.Admins,
Members: tt.fields.Members,
}
if got := receiver.HasMember(tt.args.githubHandle); got != tt.want {
t.Errorf("HasMember() = %v, want %v", got, tt.want)
}
})
}
}
File renamed without changes.
Loading

0 comments on commit 012befe

Please sign in to comment.