Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused code #432

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.