A bunch of broken stuff
This commit is contained in:
@ -7,13 +7,12 @@ import (
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/cluster"
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/mirror"
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/release"
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/repository"
|
||||
"github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Repositories repository.Repositories
|
||||
Repositories Repositories
|
||||
Releases release.Releases
|
||||
Clusters cluster.Clusters
|
||||
Charts chart.Charts
|
||||
|
40
pkg/config/repository.go
Normal file
40
pkg/config/repository.go
Normal file
@ -0,0 +1,40 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
/*
|
||||
* Helm repo kinds: default/oci
|
||||
*/
|
||||
const (
|
||||
HELM_REPO_OCI = "oci"
|
||||
HELM_REPO_DEFAULT = "default"
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
Name string
|
||||
Helm *RepositoryHelm
|
||||
Git *RepositoryGit
|
||||
}
|
||||
|
||||
type RepositoryHelm struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
type RepositoryGit struct {
|
||||
URL string
|
||||
// Git ref
|
||||
Ref string
|
||||
// Path inside a git repo
|
||||
Path string
|
||||
}
|
||||
|
||||
type Repositories []*Repository
|
||||
|
||||
func (r *Repository) ValidateConfig() error {
|
||||
if r.Helm != nil && r.Git != nil {
|
||||
return fmt.Errorf("repo %s is invalid, only one repo kind can be specified", r.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
56
pkg/config/repository_test.go
Normal file
56
pkg/config/repository_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package config_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.badhouseplants.net/allanger/shoebill/pkg/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestBothRepoKindsError(t *testing.T) {
|
||||
repo := &config.Repository{
|
||||
Name: "test",
|
||||
Helm: &config.RepositoryHelm{
|
||||
URL: "test",
|
||||
},
|
||||
Git: &config.RepositoryGit{
|
||||
URL: "test",
|
||||
Ref: "test",
|
||||
Path: "test",
|
||||
},
|
||||
}
|
||||
err := repo.ValidateConfig()
|
||||
|
||||
assert.ErrorContains(t, err,
|
||||
"repo test is invalid, only one repo kind can be specified",
|
||||
fmt.Sprintf("haven't got an unexpected err: %s", err))
|
||||
}
|
||||
|
||||
func TestHelmRepoNoError(t *testing.T) {
|
||||
repo := &config.Repository{
|
||||
Name: "test",
|
||||
Helm: &config.RepositoryHelm{
|
||||
URL: "test",
|
||||
},
|
||||
}
|
||||
err := repo.ValidateConfig()
|
||||
|
||||
assert.NoError(t, err,
|
||||
fmt.Sprintf("got an unexpected err: %s", err))
|
||||
}
|
||||
|
||||
func TestGitRepoNoError(t *testing.T) {
|
||||
repo := &config.Repository{
|
||||
Name: "test",
|
||||
Git: &config.RepositoryGit{
|
||||
URL: "test",
|
||||
Ref: "test",
|
||||
Path: "test",
|
||||
},
|
||||
}
|
||||
err := repo.ValidateConfig()
|
||||
|
||||
assert.NoError(t, err,
|
||||
fmt.Sprintf("got an unexpected err: %s", err))
|
||||
}
|
Reference in New Issue
Block a user