Skip to content

Commit

Permalink
pkg/plugin/v3: Use GroupPackageName (the API Group cleaned to be used as
Browse files Browse the repository at this point in the history
the package name) as the package name when generating
controllers and controller suite test files with
non-empty API groups in MultiGroup projects.
When generating controller with an empty group name in a
MultiGroup project, or when generating a controller in a non
MultiGroup project keep the current behavior, which is
using the `controllers` package name for both the
controllers and controllers suite test files.
  • Loading branch information
miguelsorianod committed Oct 21, 2020
1 parent 1c04fab commit 2bde5a9
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func (f *Controller) SetTemplateDefaults() error {
//nolint:lll
const controllerTemplate = `{{ .Boilerplate }}
{{if and .MultiGroup .Resource.Group }}
package {{ .Resource.GroupPackageName }}
{{else}}
package controllers
{{end}}
import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ func (f *SuiteTest) GetCodeFragments() file.CodeFragmentsMap {

const controllerSuiteTestTemplate = `{{ .Boilerplate }}
{{if and .MultiGroup .Resource.Group }}
package {{ .Resource.GroupPackageName }}
{{else}}
package controllers
{{end}}
import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package crew

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package crew

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package foopolicy

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package foopolicy

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package seacreatures

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package seacreatures

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package seacreatures

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package ship

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package ship

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package ship

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package ship

import (
"path/filepath"
Expand Down

0 comments on commit 2bde5a9

Please sign in to comment.