Skip to content

Commit

Permalink
remove load for providers, merge with fulcio config
Browse files Browse the repository at this point in the history
Signed-off-by: Javan lacerda <javanlacerda@google.com>
  • Loading branch information
javanlacerda committed Jun 25, 2024
1 parent 0857f5b commit 710eb8d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 53 deletions.
4 changes: 0 additions & 4 deletions cmd/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ func runServeCmd(cmd *cobra.Command, args []string) { //nolint: revive
if err != nil {
log.Logger.Fatalf("error loading --config-path=%s: %v", cp, err)
}
cfg, err = config.LoadCiProvidersConfig(cfg)
if err != nil {
log.Logger.Fatalf("error loading CiProviderConfig: %v", err)
}

var baseca certauth.CertificateAuthority
switch viper.GetString("ca") {
Expand Down
2 changes: 1 addition & 1 deletion config/fulcio-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ data:
"Type": "github-workflow"
}
},
"DefaultTemplateValues": null
"CIIssuerMetadata": null
}
server.yaml: |-
host: 0.0.0.0
Expand Down
48 changes: 0 additions & 48 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"reflect"
"regexp"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -456,52 +454,6 @@ func FromContext(ctx context.Context) *FulcioConfig {
return untyped.(*FulcioConfig)
}

type CiProvidersConfig struct {
Providers map[string]Provider
}
type Provider struct {
Extensions certificate.Extensions `yaml:"extensions,omitempty"`
SubjectAlternativeName string `yaml:"subject-alternative-name,omitempty"`
Defaults map[string]string `yaml:"defaults,omitempty"`
OIDCIssuers []OIDCIssuer `yaml:"oidc-issuers,omitempty"`
MetaIssuers []OIDCIssuer `yaml:"meta-issuers,omitempty"`
}

func LoadCiProvidersConfig(cfg *FulcioConfig) (*FulcioConfig, error) {
var ciProvidersConfig CiProvidersConfig
_, path, _, _ := runtime.Caller(0)
basepath := filepath.Dir(path)
providersConfigFile, err := os.ReadFile(basepath + "/providers_config.yaml")

if err != nil {
fmt.Printf("yamlFile.Get err #%v ", err)
}
err = yaml.Unmarshal(providersConfigFile, &ciProvidersConfig)
if err != nil {
fmt.Printf("Unmarshal: %v", err)
}

cfg.CIIssuerMetadata = make(map[string]DefaultTemplateValues)
for k, v := range ciProvidersConfig.Providers {
cfg.CIIssuerMetadata[k] = DefaultTemplateValues{
v.Defaults,
v.Extensions,
v.SubjectAlternativeName,
}
for _, issuer := range v.OIDCIssuers {
issuer.CIProvider = k
issuer.Type = IssuerTypeCIProvider
cfg.OIDCIssuers[issuer.IssuerURL] = issuer
}
for _, issuer := range v.MetaIssuers {
issuer.CIProvider = k
issuer.Type = IssuerTypeCIProvider
cfg.MetaIssuers[issuer.IssuerURL] = issuer
}
}
return cfg, err
}

// Load a config from disk, or use defaults
func Load(configPath string) (*FulcioConfig, error) {
if _, err := os.Stat(configPath); os.IsNotExist(err) {
Expand Down

0 comments on commit 710eb8d

Please sign in to comment.