Skip to content

Commit

Permalink
remove unused code (#432)
Browse files Browse the repository at this point in the history
This commit removes the unused `internal/yml` package.

Signed-off-by: Andreas Auernhammer <github@aead.dev>
  • Loading branch information
aead committed Jan 11, 2024
1 parent eb1faa7 commit bd277c4
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 314 deletions.
81 changes: 0 additions & 81 deletions internal/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,11 @@ package cli

import (
"errors"
"os"
"strconv"

"github.com/minio/kes/internal/yml"
"gopkg.in/yaml.v3"
)

// InitConfig is a structure containing all
// possible KES initialization configuration
// fields.
type InitConfig struct {
Version string `yaml:"version"`

Address yml.String `yaml:"address"`

System struct {
Admin struct {
Identity yml.Identity `yaml:"identity"`
} `yaml:"admin"`
} `yaml:"system"`

TLS struct {
PrivateKey yml.String `yaml:"key"`
Certificate yml.String `yaml:"cert"`
Password yml.String `yaml:"password"`

Proxy struct {
Identity []yml.Identity `yaml:"identity"`
Header struct {
ClientCert yml.String `yaml:"cert"`
} `yaml:"header"`
} `yaml:"proxy"`

Client struct {
VerifyCerts yml.Bool `yaml:"verify_cert"`
} `yaml:"client"`
} `yaml:"tls"`

Unseal struct {
Environment struct {
Name string `yaml:"name"`
} `yaml:"environment"`
} `yaml:"unseal"`

Enclave map[string]struct {
Admin struct {
Identity yml.Identity `yaml:"identity"`
} `yaml:"admin"`

Policy map[string]struct {
Allow []string `yaml:"allow"`
Deny []string `yaml:"deny"`
Identity []yml.Identity `yaml:"identities"`
} `yaml:"policy"`
} `yaml:"enclave"`
}

// ReadInitConfig reads and parses the InitConfig YAML representation
// from the given file.
func ReadInitConfig(filename string) (*InitConfig, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer f.Close()

var node yaml.Node
if err := yaml.NewDecoder(f).Decode(&node); err != nil {
return nil, err
}

version, err := findVersion(&node)
if err != nil {
return nil, err
}
if version != "v1" {
return nil, errors.New("cli: invalid init config version '" + version + "'")
}

var config InitConfig
if err := node.Decode(&config); err != nil {
return nil, err
}
return &config, nil
}

// findVersion finds the version field in the
// the given YAML document AST.
//
Expand Down
15 changes: 0 additions & 15 deletions internal/cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ import (
"gopkg.in/yaml.v3"
)

func TestReadInitConfig(t *testing.T) {
for i, test := range readInitConfigTests {
_, err := ReadInitConfig(test.Filename)
if err != nil {
t.Fatalf("Test %d: failed to read init config: %v", i, err)
}
}
}

var readInitConfigTests = []struct {
Filename string
}{
{Filename: "./testdata/env.yml"},
}

func TestFindVersion(t *testing.T) {
for i, test := range findVersionsTests {
version, err := findVersion(test.Root)
Expand Down
30 changes: 0 additions & 30 deletions internal/cli/testdata/env.yml

This file was deleted.

188 changes: 0 additions & 188 deletions internal/yml/types.go

This file was deleted.

0 comments on commit bd277c4

Please sign in to comment.