Skip to content

Commit f6c22b5

Browse files
authored
fix: Generate src/main/java (operator-framework#33)
1 parent 7d4aa48 commit f6c22b5

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

pkg/quarkus/v1alpha/scaffolds/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (s *initScaffolder) Scaffold() error {
6262
)
6363

6464
return scaffold.Execute(
65+
&templates.SrcMainJava{},
6566
&templates.PomXmlFile{
6667
Package: util.ReverseDomain(s.config.GetDomain()),
6768
ProjectName: s.config.GetProjectName(),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2021 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package templates
16+
17+
import (
18+
"path/filepath"
19+
20+
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
21+
)
22+
23+
var _ machinery.Template = &SrcMainJava{}
24+
25+
type SrcMainJava struct {
26+
machinery.TemplateMixin
27+
}
28+
29+
// SetTemplateDefaults implements machinery.Template
30+
func (s *SrcMainJava) SetTemplateDefaults() error {
31+
s.Path = filepath.Join("src", "main", "java", ".placeholder")
32+
s.TemplateBody = srcMainJavaPlaceholder
33+
return nil
34+
}
35+
36+
const srcMainJavaPlaceholder = ``
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2021 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package templates
16+
17+
import (
18+
. "github.com/onsi/ginkgo"
19+
. "github.com/onsi/gomega"
20+
)
21+
22+
var _ = Describe("srcmainjava", func() {
23+
24+
Describe("SetTemplateDefaults", func() {
25+
It("Should not stutter operator", func() {
26+
27+
smj := SrcMainJava{}
28+
29+
err := smj.SetTemplateDefaults()
30+
Expect(err).ToNot(HaveOccurred())
31+
Expect(smj.Path).To(Equal("src/main/java/.placeholder"))
32+
})
33+
})
34+
})

0 commit comments

Comments
 (0)