Skip to content

Commit 57310dc

Browse files
author
Eric Stroczynski
authored
Merge pull request #62 from anmol372/helmv1
Move plugin helm/v1 from Operator SDK
2 parents 92e963c + b294533 commit 57310dc

Some content is hidden

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

62 files changed

+6488
-63
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ WORKDIR /
2424
COPY --from=builder /workspace/helm-operator .
2525
USER nonroot:nonroot
2626

27-
ENTRYPOINT ["/helm-operator"]
27+
ENTRYPOINT ["/helm-operator", "run"]

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ endif
1212

1313
# GO_BUILD_ARGS should be set when running 'go build' or 'go install'.
1414
REPO = $(shell go list -m)
15-
VERSION = $(shell git describe --dirty --tags --always)
15+
#TODO (anrastog): set version to repo build/tag after v1 plugin is available in master.
16+
VERSION = master
1617
GIT_COMMIT = $(shell git rev-parse HEAD)
1718
GO_BUILD_ARGS = \
1819
-gcflags "all=-trimpath=$(shell dirname $(shell pwd))" \
@@ -22,7 +23,7 @@ GO_BUILD_ARGS = \
2223
-X '$(REPO)/internal/version.GitCommit=$(GIT_COMMIT)' \
2324
" \
2425

25-
all: manager
26+
#all: manager
2627

2728
# Run tests
2829
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
@@ -45,14 +46,15 @@ vet:
4546

4647
lint: golangci-lint
4748
$(GOLANGCI_LINT) run
48-
49+
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
50+
$(GOLANGCI_LINT) run --fix
4951
# Build the docker image
5052
docker-build:
51-
docker build . -t ${IMG}
53+
docker build . -t quay.io/joelanford/helm-operator:$(VERSION)
5254

5355
# Push the docker image
5456
docker-push:
55-
docker push ${IMG}
57+
docker push quay.io/joelanford/helm-operator:$(VERSION)
5658

5759
# find or download controller-gen
5860
# download controller-gen if necessary

go.mod

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,50 @@ module github.com/joelanford/helm-operator
33
go 1.13
44

55
require (
6+
github.com/Microsoft/hcsshim v0.8.9 // indirect
7+
github.com/bugsnag/bugsnag-go v1.5.3 // indirect
8+
github.com/bugsnag/panicwrap v1.2.0 // indirect
9+
github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect
10+
github.com/docker/go-metrics v0.0.1 // indirect
11+
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
12+
github.com/garyburd/redigo v1.6.0 // indirect
613
github.com/go-logr/logr v0.1.0
14+
github.com/gofrs/uuid v3.3.0+incompatible // indirect
15+
github.com/gorilla/handlers v1.4.2 // indirect
16+
github.com/iancoleman/strcase v0.1.2
17+
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
18+
github.com/kr/text v0.1.0
19+
github.com/mattn/go-colorable v0.1.2 // indirect
720
github.com/onsi/ginkgo v1.12.1
821
github.com/onsi/gomega v1.10.1
22+
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect
923
github.com/operator-framework/operator-lib v0.1.0
24+
github.com/prometheus/client_golang v1.5.1 // indirect
25+
github.com/sirupsen/logrus v1.6.0
26+
github.com/spf13/afero v1.2.2
1027
github.com/spf13/cobra v1.0.0
1128
github.com/spf13/pflag v1.0.5
12-
github.com/stretchr/testify v1.5.1
13-
go.uber.org/zap v1.13.0
29+
github.com/stretchr/testify v1.6.1
30+
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
31+
github.com/yvasiyarov/gorelic v0.0.7 // indirect
32+
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 // indirect
33+
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
34+
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
35+
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
36+
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b
1437
gomodules.xyz/jsonpatch/v2 v2.0.1
15-
helm.sh/helm/v3 v3.2.0
16-
k8s.io/api v0.18.4
17-
k8s.io/apiextensions-apiserver v0.18.4
18-
k8s.io/apimachinery v0.18.4
19-
k8s.io/cli-runtime v0.18.2
20-
k8s.io/client-go v0.18.4
21-
k8s.io/klog v1.0.0
22-
k8s.io/kubectl v0.18.2
38+
google.golang.org/genproto v0.0.0-20200701001935-0939c5918c31 // indirect
39+
google.golang.org/grpc v1.30.0 // indirect
40+
google.golang.org/protobuf v1.25.0 // indirect
41+
helm.sh/helm/v3 v3.3.4
42+
k8s.io/api v0.18.8
43+
k8s.io/apiextensions-apiserver v0.18.8
44+
k8s.io/apimachinery v0.18.8
45+
k8s.io/cli-runtime v0.18.8
46+
k8s.io/client-go v0.18.8
47+
k8s.io/kubectl v0.18.8
2348
rsc.io/letsencrypt v0.0.3 // indirect
24-
sigs.k8s.io/controller-runtime v0.6.1
49+
sigs.k8s.io/controller-runtime v0.6.2
50+
sigs.k8s.io/kubebuilder v1.0.9-0.20201021204649-36124ae2e027
2551
sigs.k8s.io/yaml v1.2.0
2652
)

go.sum

Lines changed: 294 additions & 45 deletions
Large diffs are not rendered by default.

internal/cmd/run/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func NewCmd() *cobra.Command {
4343

4444
cmd := &cobra.Command{
4545
Use: "run",
46-
Short: "Run the operator",
46+
Short: "Run the helm operator controller",
4747
Run: func(cmd *cobra.Command, _ []string) {
4848
logf.SetLogger(zapl.New(zapl.UseFlagOptions(opts)))
4949
r.run(cmd)

internal/version/version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package version
1818

1919
var (
20+
//TODO: Hardcode it to version string to support importing and usage in operator-sdk
2021
Version = "unknown"
2122
GitCommit = "unknown"
2223
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package cmdutil
18+
19+
import "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
20+
21+
// RunOptions represent the types used to implement the different commands
22+
type RunOptions interface {
23+
// - Step 1: verify that the command can be run (e.g., go version, project version, arguments, ...)
24+
Validate() error
25+
// - Step 2: create the Scaffolder instance
26+
GetScaffolder() (scaffold.Scaffolder, error)
27+
// - Step 3: call the Scaffold method of the Scaffolder instance. Doesn't need any method
28+
// - Step 4: finish the command execution
29+
PostScaffold() error
30+
}
31+
32+
// Run executes a command
33+
func Run(options RunOptions) error {
34+
// Step 1: validate
35+
if err := options.Validate(); err != nil {
36+
return err
37+
}
38+
39+
// Step 2: get scaffolder
40+
scaffolder, err := options.GetScaffolder()
41+
if err != nil {
42+
return err
43+
}
44+
// Step 3: scaffold
45+
if scaffolder != nil {
46+
if err := scaffolder.Scaffold(); err != nil {
47+
return err
48+
}
49+
}
50+
// Step 4: finish
51+
if err := options.PostScaffold(); err != nil {
52+
return err
53+
}
54+
55+
return nil
56+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package filesystem
18+
19+
import (
20+
"errors"
21+
"fmt"
22+
)
23+
24+
// This file contains the errors returned by the file system wrapper
25+
// They are not exported as they should not be created outside of this package
26+
// Exported functions are provided to check which kind of error was returned
27+
28+
// fileExistsError is returned if it could not be checked if the file exists
29+
type fileExistsError struct {
30+
path string
31+
err error
32+
}
33+
34+
// Error implements error interface
35+
func (e fileExistsError) Error() string {
36+
return fmt.Sprintf("failed to check if %s exists: %v", e.path, e.err)
37+
}
38+
39+
// Unwrap implements Wrapper interface
40+
func (e fileExistsError) Unwrap() error {
41+
return e.err
42+
}
43+
44+
// IsFileExistsError checks if the returned error is because the file could not be checked for existence
45+
func IsFileExistsError(err error) bool {
46+
return errors.As(err, &fileExistsError{})
47+
}
48+
49+
// openFileError is returned if the file could not be opened
50+
type openFileError struct {
51+
path string
52+
err error
53+
}
54+
55+
// Error implements error interface
56+
func (e openFileError) Error() string {
57+
return fmt.Sprintf("failed to open %s: %v", e.path, e.err)
58+
}
59+
60+
// Unwrap implements Wrapper interface
61+
func (e openFileError) Unwrap() error {
62+
return e.err
63+
}
64+
65+
// IsOpenFileError checks if the returned error is because the file could not be opened
66+
func IsOpenFileError(err error) bool {
67+
return errors.As(err, &openFileError{})
68+
}
69+
70+
// createDirectoryError is returned if the directory could not be created
71+
type createDirectoryError struct {
72+
path string
73+
err error
74+
}
75+
76+
// Error implements error interface
77+
func (e createDirectoryError) Error() string {
78+
return fmt.Sprintf("failed to create directory for %s: %v", e.path, e.err)
79+
}
80+
81+
// Unwrap implements Wrapper interface
82+
func (e createDirectoryError) Unwrap() error {
83+
return e.err
84+
}
85+
86+
// IsCreateDirectoryError checks if the returned error is because the directory could not be created
87+
func IsCreateDirectoryError(err error) bool {
88+
return errors.As(err, &createDirectoryError{})
89+
}
90+
91+
// createFileError is returned if the file could not be created
92+
type createFileError struct {
93+
path string
94+
err error
95+
}
96+
97+
// Error implements error interface
98+
func (e createFileError) Error() string {
99+
return fmt.Sprintf("failed to create %s: %v", e.path, e.err)
100+
}
101+
102+
// Unwrap implements Wrapper interface
103+
func (e createFileError) Unwrap() error {
104+
return e.err
105+
}
106+
107+
// IsCreateFileError checks if the returned error is because the file could not be created
108+
func IsCreateFileError(err error) bool {
109+
return errors.As(err, &createFileError{})
110+
}
111+
112+
// readFileError is returned if the file could not be read
113+
type readFileError struct {
114+
path string
115+
err error
116+
}
117+
118+
// Error implements error interface
119+
func (e readFileError) Error() string {
120+
return fmt.Sprintf("failed to read from %s: %v", e.path, e.err)
121+
}
122+
123+
// Unwrap implements Wrapper interface
124+
func (e readFileError) Unwrap() error {
125+
return e.err
126+
}
127+
128+
// IsReadFileError checks if the returned error is because the file could not be read
129+
func IsReadFileError(err error) bool {
130+
return errors.As(err, &readFileError{})
131+
}
132+
133+
// writeFileError is returned if the file could not be written
134+
type writeFileError struct {
135+
path string
136+
err error
137+
}
138+
139+
// Error implements error interface
140+
func (e writeFileError) Error() string {
141+
return fmt.Sprintf("failed to write to %s: %v", e.path, e.err)
142+
}
143+
144+
// Unwrap implements Wrapper interface
145+
func (e writeFileError) Unwrap() error {
146+
return e.err
147+
}
148+
149+
// IsWriteFileError checks if the returned error is because the file could not be written to
150+
func IsWriteFileError(err error) bool {
151+
return errors.As(err, &writeFileError{})
152+
}
153+
154+
// closeFileError is returned if the file could not be created
155+
type closeFileError struct {
156+
path string
157+
err error
158+
}
159+
160+
// Error implements error interface
161+
func (e closeFileError) Error() string {
162+
return fmt.Sprintf("failed to close %s: %v", e.path, e.err)
163+
}
164+
165+
// Unwrap implements Wrapper interface
166+
func (e closeFileError) Unwrap() error {
167+
return e.err
168+
}
169+
170+
// IsCloseFileError checks if the returned error is because the file could not be closed
171+
func IsCloseFileError(err error) bool {
172+
return errors.As(err, &closeFileError{})
173+
}

0 commit comments

Comments
 (0)