Skip to content

Commit 894624b

Browse files
author
Stan Lagun
committed
Fixes gofmt and golint warnings
This fixes all gofmt and all golint warnings (except for copied petsets package and dot imports): * Missing docstrings were written * Types that don't have to be exported were made private * Some unused client/fake methods were removed
1 parent c174fe7 commit 894624b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+395
-381
lines changed

cmd/deploy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424
"github.com/spf13/cobra"
2525
)
2626

27-
var Deploy *cobra.Command = initDeployCommand()
27+
// Deploy is the deploy CLI command object
28+
var Deploy = initDeployCommand()
2829

2930
func deploy(cmd *cobra.Command, args []string) {
3031
url, err := cmd.Flags().GetString("url")

cmd/run_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func TestLabelFlag(t *testing.T) {
5959

6060
// TestParseArg tests how key-value arguments are parsed in command line interface
6161
func TestParseArg(t *testing.T) {
62-
table := []struct{
63-
arg string
64-
key string
62+
table := []struct {
63+
arg string
64+
key string
6565
value string
6666
error bool
67-
} {
67+
}{
6868
{"x=y", "x", "y", false},
6969
{"x:y", "x", "y", false},
7070
{"x = y", "x", "y", false},

e2e/example_runner.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ import (
3535
"k8s.io/client-go/pkg/runtime"
3636
)
3737

38-
type ExamplesFramework struct {
38+
type examplesFramework struct {
3939
*utils.AppControllerManager
4040
}
4141

42-
func (f *ExamplesFramework) CreateExample(exampleName string) {
42+
func (f *examplesFramework) CreateExample(exampleName string) {
4343
// list all files in directory, for each file run Create
4444
fqDir := filepath.Join(utils.TestContext.Examples, exampleName)
4545
By("Creating example from directory " + fqDir)
@@ -52,7 +52,7 @@ func (f *ExamplesFramework) CreateExample(exampleName string) {
5252
}
5353
}
5454

55-
func (f *ExamplesFramework) Create(fileName string) {
55+
func (f *examplesFramework) Create(fileName string) {
5656
// Load data from filepath
5757
// try to serialize it into Unstructured or UnstructuredList
5858
data, err := ioutil.ReadFile(fileName)
@@ -74,7 +74,7 @@ func (f *ExamplesFramework) Create(fileName string) {
7474
})
7575
}
7676

77-
func (f *ExamplesFramework) handleItemCreation(ust *runtime.Unstructured) {
77+
func (f *examplesFramework) handleItemCreation(ust *runtime.Unstructured) {
7878
// based on kind of item - instantiate correct object and wrap it with resource definition
7979
// if unstructured is of kind Dependency - just create it as is
8080
encodedData, err := json.Marshal(ust)
@@ -98,13 +98,13 @@ func (f *ExamplesFramework) handleItemCreation(ust *runtime.Unstructured) {
9898
Expect(err).NotTo(HaveOccurred())
9999
}
100100

101-
func (f *ExamplesFramework) handleListCreation(ustList *runtime.UnstructuredList) {
101+
func (f *examplesFramework) handleListCreation(ustList *runtime.UnstructuredList) {
102102
for _, ust := range ustList.Items {
103103
f.handleItemCreation(ust)
104104
}
105105
}
106106

107-
func (f *ExamplesFramework) VerifyStatus(task string, options interfaces.DependencyGraphOptions) {
107+
func (f *examplesFramework) VerifyStatus(task string, options interfaces.DependencyGraphOptions) {
108108
var depReport report.DeploymentReport
109109
Eventually(
110110
func() bool {
@@ -123,7 +123,7 @@ func (f *ExamplesFramework) VerifyStatus(task string, options interfaces.Depende
123123
300*time.Second, 5*time.Second).Should(BeTrue(), strings.Join(depReport.AsText(0), "\n"))
124124
}
125125

126-
func (f *ExamplesFramework) CreateRunAndVerify(exampleName string, options interfaces.DependencyGraphOptions) {
126+
func (f *examplesFramework) CreateRunAndVerify(exampleName string, options interfaces.DependencyGraphOptions) {
127127
By("Creating example " + exampleName)
128128
f.CreateExample(exampleName)
129129
By("Running appcontroller scheduler")

e2e/examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
var _ = Describe("Examples Suite", func() {
2525
options := interfaces.DependencyGraphOptions{ReplicaCount: 1}
26-
framework := ExamplesFramework{testutils.NewAppControllerManager()}
26+
framework := examplesFramework{testutils.NewAppControllerManager()}
2727

2828
It("Example 'simple' should finish", func() {
2929
framework.CreateRunAndVerify("simple", options)

e2e/flows_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
var _ = Describe("Flows Suite", func() {
30-
framework := FlowFramework{ExamplesFramework{testutils.NewAppControllerManager()}}
30+
framework := FlowFramework{examplesFramework{testutils.NewAppControllerManager()}}
3131

3232
It("Example 'flows' should finish and create one graph replica", func() {
3333
framework.CreateRunAndVerify("flows", interfaces.DependencyGraphOptions{MinReplicaCount: 1})
@@ -107,7 +107,7 @@ var _ = Describe("Flows Suite", func() {
107107
})
108108

109109
type FlowFramework struct {
110-
ExamplesFramework
110+
examplesFramework
111111
}
112112

113113
func (ff FlowFramework) countPods(prefix string, equal bool) int {

e2e/utils/appcmanager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333
appcontrollerPod = "k8s-appcontroller"
3434
)
3535

36+
// AppControllerManager is the test controller exposes remote AC operations and test primitives for dependency graphs
3637
type AppControllerManager struct {
3738
Client client.Interface
3839
Clientset *kubernetes.Clientset
@@ -42,10 +43,12 @@ type AppControllerManager struct {
4243
acPod *v1.Pod
4344
}
4445

46+
// Run runs dependency graph deployment with default settings
4547
func (a *AppControllerManager) Run() string {
4648
return a.RunWithOptions(interfaces.DependencyGraphOptions{MinReplicaCount: 1})
4749
}
4850

51+
// RunWithOptions runs dependency graph deployment with given settings
4952
func (a *AppControllerManager) RunWithOptions(options interfaces.DependencyGraphOptions) string {
5053
sched := scheduler.New(a.Client, nil, 0)
5154

@@ -54,6 +57,7 @@ func (a *AppControllerManager) RunWithOptions(options interfaces.DependencyGraph
5457
return task
5558
}
5659

60+
// DeleteAppControllerPod deletes pod, where AppController is running
5761
func (a *AppControllerManager) DeleteAppControllerPod() {
5862
By("Removing pod " + appcontrollerPod)
5963
err := a.Client.Pods().Delete(appcontrollerPod, nil)
@@ -64,6 +68,7 @@ func (a *AppControllerManager) DeleteAppControllerPod() {
6468
}, 20*time.Second, 1*time.Second).Should(BeTrue(), "Appcontroller pod wasn't removed in time")
6569
}
6670

71+
// Prepare starts AppController pod
6772
func (a *AppControllerManager) Prepare() {
6873
appControllerObj := &v1.Pod{
6974
ObjectMeta: v1.ObjectMeta{
@@ -105,6 +110,7 @@ func (a *AppControllerManager) Prepare() {
105110
}, 120*time.Second, 5*time.Second).Should(BeTrue())
106111
}
107112

113+
// BeforeEach is an action executed before each test
108114
func (a *AppControllerManager) BeforeEach() {
109115
var err error
110116
a.Clientset, err = KubeClient()
@@ -127,6 +133,7 @@ func (a *AppControllerManager) BeforeEach() {
127133
a.Prepare()
128134
}
129135

136+
// AfterEach is an action executed after each test
130137
func (a *AppControllerManager) AfterEach() {
131138
By("Dumping appcontroller logs")
132139
if CurrentGinkgoTestDescription().Failed && a.acPod != nil {
@@ -137,6 +144,7 @@ func (a *AppControllerManager) AfterEach() {
137144
RemoveServiceAccountFromAdmins(a.Clientset)
138145
}
139146

147+
// NewAppControllerManager creates new instance of AppControllerManager
140148
func NewAppControllerManager() *AppControllerManager {
141149
appc := &AppControllerManager{}
142150
BeforeEach(appc.BeforeEach)

e2e/utils/utils.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ import (
3131
"k8s.io/client-go/pkg/api/v1"
3232
"k8s.io/client-go/pkg/apis/rbac/v1alpha1"
3333
"k8s.io/client-go/rest"
34-
"k8s.io/client-go/tools/clientcmd")
34+
"k8s.io/client-go/tools/clientcmd"
35+
)
3536

3637
var yamlDocumentDelimiter = regexp.MustCompile("(?m)^---")
38+
3739
const rbacServiceAccountAdmin = "system:serviceaccount-admin"
3840

41+
// TContext is a structure for CLI flags
3942
type TContext struct {
4043
Examples string
4144
Version string
4245
}
4346

47+
// SkipIf14 makes test to be skipped when running on k8s 1.4
4448
func SkipIf14() {
4549
if strings.Contains(TestContext.Version, "1.4") {
4650
Skip("This test is disabled on kubernetes of versions 1.4")
@@ -71,6 +75,7 @@ func AddServiceAccountToAdmins(c kubernetes.Interface) {
7175
Expect(err).NotTo(HaveOccurred(), "Failed to create role binding for serviceaccounts")
7276
}
7377

78+
// RemoveServiceAccountFromAdmins removes system:serviceaccounts from cluster-admin ClusterRole
7479
func RemoveServiceAccountFromAdmins(c kubernetes.Interface) {
7580
if IsVersionOlderThan16() {
7681
return
@@ -80,6 +85,7 @@ func RemoveServiceAccountFromAdmins(c kubernetes.Interface) {
8085
Expect(err).NotTo(HaveOccurred(), "Failed to remove serviceaccount from cluster-admin role")
8186
}
8287

88+
// TestContext holds e2e CLI flags
8389
var TestContext = TContext{}
8490

8591
var url string
@@ -90,6 +96,7 @@ func init() {
9096
flag.StringVar(&url, "cluster-url", "http://127.0.0.1:8080", "apiserver address to use with restclient")
9197
}
9298

99+
// SanitizedVersion parses K8s 2-component version string into float64 representation
93100
func SanitizedVersion() float64 {
94101
var dirtyVersion string
95102
if strings.HasPrefix(TestContext.Version, "v") {
@@ -102,20 +109,24 @@ func SanitizedVersion() float64 {
102109
return version
103110
}
104111

112+
// IsVersionOlderThan16 returns true, if k8s version is less than 1.6
105113
func IsVersionOlderThan16() bool {
106114
return SanitizedVersion() < 1.6
107115
}
108116

117+
// Logf prints formatted message to the tests log
109118
func Logf(format string, a ...interface{}) {
110119
fmt.Fprintf(GinkgoWriter, format, a...)
111120
}
112121

122+
// LoadConfig loads k8s client config
113123
func LoadConfig() *rest.Config {
114124
config, err := clientcmd.BuildConfigFromFlags(url, "")
115125
Expect(err).NotTo(HaveOccurred())
116126
return config
117127
}
118128

129+
// KubeClient returns client to standard k8s entities
119130
func KubeClient() (*kubernetes.Clientset, error) {
120131
Logf("Using master %v\n", url)
121132
config := LoadConfig()
@@ -130,11 +141,13 @@ func GetAcClient(namespace string) (client.Interface, error) {
130141
return client, err
131142
}
132143

144+
// DeleteNS deletes k8s namespace
133145
func DeleteNS(clientset *kubernetes.Clientset, namespace *v1.Namespace) {
134146
defer GinkgoRecover()
135147
clientset.Namespaces().Delete(namespace.Name, nil)
136148
}
137149

150+
// WaitForPod waits for k8s pod to get to specified running phase
138151
func WaitForPod(clientset *kubernetes.Clientset, namespace string, name string, phase v1.PodPhase) *v1.Pod {
139152
defer GinkgoRecover()
140153
var podUpdated *v1.Pod
@@ -151,6 +164,7 @@ func WaitForPod(clientset *kubernetes.Clientset, namespace string, name string,
151164
return podUpdated
152165
}
153166

167+
// WaitForPodNotToBeCreated waits for pod to be created
154168
func WaitForPodNotToBeCreated(clientset *kubernetes.Clientset, namespace string, name string) {
155169
defer GinkgoRecover()
156170
Consistently(func() bool {
@@ -160,6 +174,7 @@ func WaitForPodNotToBeCreated(clientset *kubernetes.Clientset, namespace string,
160174
}).Should(BeTrue())
161175
}
162176

177+
// DumpLogs dumps pod logs
163178
func DumpLogs(clientset *kubernetes.Clientset, pods ...*v1.Pod) {
164179
for _, pod := range pods {
165180
dumpLogs(clientset, pod)
@@ -176,11 +191,12 @@ func dumpLogs(clientset *kubernetes.Clientset, pod *v1.Pod) {
176191
Expect(err).NotTo(HaveOccurred())
177192
}
178193

194+
// ForEachYamlDocument executes action for each YAML document (parts of YAML file separated by "---")
179195
func ForEachYamlDocument(data []byte, action func([]byte)) {
180196
matches := yamlDocumentDelimiter.FindAllIndex(data, -1)
181197
lastStart := 0
182198
for _, doc := range matches {
183-
action(data[lastStart: doc[0]])
199+
action(data[lastStart:doc[0]])
184200
lastStart = doc[1]
185201
}
186202
action(data[lastStart:])

0 commit comments

Comments
 (0)