Skip to content
This repository was archived by the owner on Dec 11, 2021. It is now read-only.

Commit 7dddb95

Browse files
Eric Stroczynskiestroz
Eric Stroczynski
authored andcommitted
*: clean up samples (operator-framework#4035)
1 parent c828d43 commit 7dddb95

File tree

10 files changed

+53
-238
lines changed

10 files changed

+53
-238
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,5 @@ tags
114114
.ionide
115115

116116
# End of https://www.toptal.com/developers/gitignore/api/go,vim,emacs,visualstudiocode
117+
118+
*\.DS_Store

example/memcached-operator/memcached_controller.go.tmpl

Lines changed: 0 additions & 182 deletions
This file was deleted.

hack/generate/samples/generate_all.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"github.com/operator-framework/operator-sdk/internal/testutils"
2828
)
2929

30-
const testdata = "/testdata/"
31-
3230
var (
3331
binaryName string
3432
)
@@ -43,7 +41,7 @@ func main() {
4341
os.Exit(1)
4442
}
4543

46-
samplesPath := filepath.Join(currentPath, testdata)
44+
samplesPath := filepath.Join(currentPath, "testdata")
4745
log.Infof("using the path: (%v)", samplesPath)
4846

4947
log.Infof("creating Helm Memcached Sample")

hack/generate/samples/internal/go/memcached_with_webhooks.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package gosamples
1616

1717
import (
1818
"fmt"
19+
"os"
1920
"path/filepath"
2021
"strings"
2122

@@ -93,6 +94,9 @@ func (mh *MemcachedGoWithWebhooks) Run() {
9394
mh.uncommentKustomizationFile()
9495

9596
pkg.RunOlmIntegration(mh.ctx)
97+
98+
// Clean up built binaries, if any.
99+
pkg.CheckError("cleaning up", os.RemoveAll(filepath.Join(mh.ctx.Dir, "bin")))
96100
}
97101

98102
// uncommentKustomizationFile will uncomment the file kustomization.yaml
@@ -225,7 +229,7 @@ func (mh *MemcachedGoWithWebhooks) implementingAPI() {
225229
filepath.Join(mh.ctx.Dir, "api", mh.ctx.Version, fmt.Sprintf("%s_types.go", strings.ToLower(mh.ctx.Kind))),
226230
fmt.Sprintf("type %sSpec struct {\n\t// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster\n\t// Important: Run \"make\" to regenerate code after modifying this file", mh.ctx.Kind),
227231
`
228-
232+
229233
// Size defines the number of Memcached instances
230234
Size int32 `+"`"+`json:"size,omitempty"`+"`"+`
231235
`)
@@ -236,8 +240,8 @@ func (mh *MemcachedGoWithWebhooks) implementingAPI() {
236240
filepath.Join(mh.ctx.Dir, "api", mh.ctx.Version, fmt.Sprintf("%s_types.go", strings.ToLower(mh.ctx.Kind))),
237241
fmt.Sprintf("type %sStatus struct {\n\t// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster\n\t// Important: Run \"make\" to regenerate code after modifying this file", mh.ctx.Kind),
238242
`
239-
240-
// Nodes store the name of the pods which are running Memcached instances
243+
244+
// Nodes store the name of the pods which are running Memcached instances
241245
Nodes []string `+"`"+`json:"nodes,omitempty"`+"`"+`
242246
`)
243247
pkg.CheckError("inserting Node Status", err)

hack/generate/samples/internal/pkg/context.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,3 @@ func NewSampleContext(binary string, path string, env ...string) (s SampleContex
4444

4545
return s, err
4646
}
47-
48-
// NewSampleContextWithTestContext returns a SampleContext containing the kubebuilder TestContext informed
49-
// It is useful to allow the samples code be re-used in the e2e tests.
50-
func NewSampleContextWithTestContext(tc *testutils.TestContext) (s SampleContext, err error) {
51-
s.TestContext = *tc
52-
return s, err
53-
}

testdata/go/memcached-operator/api/v1alpha1/memcached_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
type MemcachedSpec struct {
2828
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2929
// Important: Run "make" to regenerate code after modifying this file
30-
30+
3131
// Size defines the number of Memcached instances
3232
Size int32 `json:"size,omitempty"`
3333

@@ -40,8 +40,8 @@ type MemcachedSpec struct {
4040
type MemcachedStatus struct {
4141
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
4242
// Important: Run "make" to regenerate code after modifying this file
43-
44-
// Nodes store the name of the pods which are running Memcached instances
43+
44+
// Nodes store the name of the pods which are running Memcached instances
4545
Nodes []string `json:"nodes,omitempty"`
4646

4747
}
-42.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)