Skip to content

Commit

Permalink
sigs,validator: update validator code
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dhiller committed Nov 6, 2024
1 parent efe7e38 commit 7027034
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 18 deletions.
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
}
43 changes: 43 additions & 0 deletions pkg/orgs/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 orgs

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

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

type Orgs struct {
Orgs map[string]Org
}
File renamed without changes.
19 changes: 12 additions & 7 deletions pkg/sigs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ type Sigs struct {
}

type Group struct {
Dir string
Name string
Dir string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
MissionStatement string `yaml:"mission_statement,omitempty"`
Label string `yaml:",omitempty"`
Leads []*Lead `yaml:",omitempty"`
Leadership *Leadership `yaml:",omitempty"`
Meetings []*Meeting `yaml:",omitempty"`
Contact *Contact `yaml:",omitempty"`
Expand All @@ -40,8 +42,8 @@ type Group struct {
type Contact struct {
Slack string `yaml:"slack"`
MailingList string `yaml:"mailing_list"`
Teams []*Team `yaml:"teams"`
Liaison *OrgMember `yaml:"liaison"`
Teams []*Team `yaml:"teams,omitempty"`
Liaison *OrgMember `yaml:"liaison,omitempty"`
}

type Team struct {
Expand All @@ -56,12 +58,12 @@ type Meeting struct {
TZ string
Frequency string
URL string
ArchiveURL string `yaml:"archive_url"`
RecordingsURL string `yaml:"recordings_url"`
ArchiveURL string `yaml:"archive_url,omitempty"`
RecordingsURL string `yaml:"recordings_url,omitempty"`
}

type Leadership struct {
Chairs []*OrgMember
Chairs []*Chair
}

type OrgMember struct {
Expand All @@ -70,9 +72,12 @@ type OrgMember struct {
Company string `yaml:",omitempty"`
}

type Chair OrgMember
type Lead OrgMember

type SubProject struct {
Name string
Description string `yaml:",omitempty"`
Owners []string
Leads []*OrgMember `yaml:",omitempty"`
Leads []*Lead `yaml:",omitempty"`
}
Loading

0 comments on commit 7027034

Please sign in to comment.