Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new workload plugin version and controller-gen logic #76

Merged
merged 15 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,32 @@ linters:
enable:
- asciicheck
- bodyclose
#- cyclop
#- depguard
# - cyclop
# - depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
#- exhaustive
#- exhaustivestruct
# - exhaustive
# - exhaustivestruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
# disable due to false positives
#- gci
# - gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
# - godox
- goerr113
# disable due to false positives in detecting gofmt -s
#- gofmt
# - gofmt
- goheader
- goimports
- gomnd
Expand All @@ -119,7 +119,7 @@ linters:
- paralleltest
- prealloc
- predeclared
#- revive
# - revive
- rowserrcheck
- sqlclosecheck
- staticcheck
Expand All @@ -133,8 +133,8 @@ linters:
- unused
- wastedassign
- whitespace
- wrapcheck
#- wsl
# - wrapcheck
# - wsl

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand All @@ -144,18 +144,25 @@ issues:
- gomnd
- funlen
- scopelint
- testpackage
- path: internal/commands/*\.go
linters:
- gochecknoglobals
- path: internal/plugins/workload/v1/scaffolds
linters:
- goconst
- path: internal/plugins/workload/v2/scaffolds
linters:
- goconst
- path: internal/plugins/config/v1/plugin.go
linters:
- gocritic
- path: internal/plugins/workload/v1/scaffolds/templates/readme.go
linters:
- gomnd
- path: internal/plugins/workload/v2/scaffolds/templates/readme.go
linters:
- gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
Expand Down
2 changes: 1 addition & 1 deletion .licenserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"**/*.go": [
"// Copyright 2023 Nukleros"
"// Copyright 2024 Nukleros"
]
}
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 VMware Tanzu Labs
Copyright (c) 2024 Nukleros
Copyright (c) 2021 VMware, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ INIT_OPTS=init \
--enable-olm=true
CREATE_OPTS=create api \
--workload-config .workloadConfig/workload.yaml \
--controller \
--resource \
--controller \
--enable-olm=true

define create_path
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
operator-builder
Copyright 2024 Nukleros
Copyright 2021 VMware, Inc.

This product is licensed to you under the MIT license (the "License"). You may
Expand All @@ -7,4 +8,3 @@ not use this product except in compliance with the MIT License.
This product may include a number of subcomponents with separate copyright
notices and license terms. Your use of these subcomponents is subject to the
terms and conditions of the subcomponent's license, as noted in the LICENSE file.

12 changes: 10 additions & 2 deletions cmd/operator-builder/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// Copyright 2023 Nukleros
// Copyright 2024 Nukleros
// Copyright 2021 VMware, Inc.
// SPDX-License-Identifier: MIT

package main

import (
"os"

log "github.com/sirupsen/logrus"

"github.com/nukleros/operator-builder/internal/plugins/workload"
"github.com/nukleros/operator-builder/pkg/cli"
)

func main() {
command, err := cli.NewKubebuilderCLI()
command, err := cli.NewKubebuilderCLI(workload.FromEnv())
if err != nil {
log.Fatal(err)
}

if command == nil {
log.Println("skipping command execution...")
os.Exit(0)
}

if err := command.Run(); err != nil {
log.Fatal(err)
}
Expand Down
6 changes: 4 additions & 2 deletions docs/api-updates-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ For example, you have begun development on a brand new operator. You have
generated the source code from a set of YAML manifests with markers. While
testing, you discover that a field is misspelled, or that a default value should
be changed, or that a new field should be added. The following instructions
describe how to overwrite an existing API to update the existing spec.
describe how to overwrite an existing API to update the existing spec. Please
note that in the below example the `--resource=true` is not necessary and is
only provided in the example for verbosity. This option is set by default.

After making the necessary changes to your manifests run the following:

```bash
operator-builder create api \
--workload-config [path/to/workload/config] \
--controller=false \
--resource \
--resource=true \
--force
```

Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ operator-builder create api \

We again provide the same workload config file. Here we also added the
`--controller` and `--resource` arguments. These indicate that we want both a
new controller and new custom resource created.
new controller and new custom resource created. Please
note that in the above example both flags are not necessary and are
only provided in the example for verbosity. These options are set by default.

You now have a new working Kubernetes Operator! Next, we will test it out.

Expand Down
57 changes: 32 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
module github.com/nukleros/operator-builder

go 1.22
go 1.22.0

toolchain go1.22.1
toolchain go1.22.4

require (
github.com/go-playground/validator v9.31.0+incompatible
github.com/nukleros/gener8s v0.1.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/afero v1.9.3
github.com/spf13/cobra v1.6.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
k8s.io/apimachinery v0.30.0
k8s.io/client-go v0.30.0

// NOTE: please ensure the internal.utils.ControllerToolsVersion matches this entry as we
// use this both in code generation as well as the generated project code.
sigs.k8s.io/controller-tools v0.15.0
sigs.k8s.io/kubebuilder/v3 v3.9.1
sigs.k8s.io/kubebuilder/v4 v4.0.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/gobuffalo/flect v1.0.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -42,19 +47,21 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.5.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.21.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.24.2 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
k8s.io/api v0.30.0 // indirect
k8s.io/apiextensions-apiserver v0.30.0 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading
Loading