diff --git a/Makefile b/Makefile index 49a2713c14..255a9ba9d5 100644 --- a/Makefile +++ b/Makefile @@ -173,12 +173,12 @@ override LDFLAGS += \ .PHONY: build-operator build-operator: ## Build Spark operator. echo "Building spark-operator binary..." - go build -o $(SPARK_OPERATOR) -ldflags '${LDFLAGS}' cmd/main.go + go build -o $(SPARK_OPERATOR) -ldflags '${LDFLAGS}' cmd/operator/main.go .PHONY: build-sparkctl build-sparkctl: ## Build sparkctl binary. echo "Building sparkctl binary..." - CGO_ENABLED=0 go build -o $(SPARKCTL) -buildvcs=false sparkctl/main.go + CGO_ENABLED=0 go build -o $(SPARKCTL) -buildvcs=false cmd/sparkctl/main.go .PHONY: install-sparkctl install-sparkctl: build-sparkctl ## Install sparkctl binary. @@ -191,7 +191,7 @@ clean: ## Clean spark-operator and sparktcl binaries. rm -f $(SPARKCTL) .PHONY: build-api-docs -build-api-docs: gen-crd-api-reference-docs ## Build api documentaion. +build-api-docs: gen-crd-api-reference-docs ## Build api documentation. $(GEN_CRD_API_REFERENCE_DOCS) \ -config hack/api-docs/config.json \ -api-dir github.com/kubeflow/spark-operator/api/v1beta2 \ diff --git a/cmd/main.go b/cmd/main.go deleted file mode 100644 index 38085497b7..0000000000 --- a/cmd/main.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2024 The Kubeflow authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "fmt" - "os" - - "github.com/kubeflow/spark-operator/cmd/operator" -) - -func main() { - if err := operator.NewCommand().Execute(); err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } -} diff --git a/cmd/operator/root.go b/cmd/operator/main.go similarity index 84% rename from cmd/operator/root.go rename to cmd/operator/main.go index 2ddaa900d8..a6d41c002d 100644 --- a/cmd/operator/root.go +++ b/cmd/operator/main.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -14,9 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package operator +package main import ( + "fmt" + "os" + "github.com/spf13/cobra" "github.com/kubeflow/spark-operator/cmd/operator/controller" @@ -37,3 +40,10 @@ func NewCommand() *cobra.Command { command.AddCommand(version.NewCommand()) return command } + +func main() { + if err := NewCommand().Execute(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} diff --git a/sparkctl/README.md b/cmd/sparkctl/README.md similarity index 100% rename from sparkctl/README.md rename to cmd/sparkctl/README.md diff --git a/sparkctl/cmd/client.go b/cmd/sparkctl/app/client.go similarity index 99% rename from sparkctl/cmd/client.go rename to cmd/sparkctl/app/client.go index e22d26afa1..0ab01ad876 100644 --- a/sparkctl/cmd/client.go +++ b/cmd/sparkctl/app/client.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/create.go b/cmd/sparkctl/app/create.go similarity index 99% rename from sparkctl/cmd/create.go rename to cmd/sparkctl/app/create.go index eddad79257..9509b9d7e4 100644 --- a/sparkctl/cmd/create.go +++ b/cmd/sparkctl/app/create.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/create_test.go b/cmd/sparkctl/app/create_test.go similarity index 99% rename from sparkctl/cmd/create_test.go rename to cmd/sparkctl/app/create_test.go index aa3d89615d..28d62fddac 100644 --- a/sparkctl/cmd/create_test.go +++ b/cmd/sparkctl/app/create_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "strings" diff --git a/sparkctl/cmd/delete.go b/cmd/sparkctl/app/delete.go similarity index 99% rename from sparkctl/cmd/delete.go rename to cmd/sparkctl/app/delete.go index f75dc65df5..06021b2716 100644 --- a/sparkctl/cmd/delete.go +++ b/cmd/sparkctl/app/delete.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/event.go b/cmd/sparkctl/app/event.go similarity index 99% rename from sparkctl/cmd/event.go rename to cmd/sparkctl/app/event.go index 63a0a5b880..37ced1ad0a 100644 --- a/sparkctl/cmd/event.go +++ b/cmd/sparkctl/app/event.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/forward.go b/cmd/sparkctl/app/forward.go similarity index 99% rename from sparkctl/cmd/forward.go rename to cmd/sparkctl/app/forward.go index caeb7638f9..43b817daf8 100644 --- a/sparkctl/cmd/forward.go +++ b/cmd/sparkctl/app/forward.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/gcs.go b/cmd/sparkctl/app/gcs.go similarity index 99% rename from sparkctl/cmd/gcs.go rename to cmd/sparkctl/app/gcs.go index fc807f8927..5601497afb 100644 --- a/sparkctl/cmd/gcs.go +++ b/cmd/sparkctl/app/gcs.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "fmt" diff --git a/sparkctl/cmd/list.go b/cmd/sparkctl/app/list.go similarity index 99% rename from sparkctl/cmd/list.go rename to cmd/sparkctl/app/list.go index 5777d14db9..63c2bf3b8a 100644 --- a/sparkctl/cmd/list.go +++ b/cmd/sparkctl/app/list.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/log.go b/cmd/sparkctl/app/log.go similarity index 99% rename from sparkctl/cmd/log.go rename to cmd/sparkctl/app/log.go index c917ccceaf..9ccdf4a8fe 100644 --- a/sparkctl/cmd/log.go +++ b/cmd/sparkctl/app/log.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/root.go b/cmd/sparkctl/app/root.go similarity index 99% rename from sparkctl/cmd/root.go rename to cmd/sparkctl/app/root.go index 6ba1c5cae8..e845b8be89 100644 --- a/sparkctl/cmd/root.go +++ b/cmd/sparkctl/app/root.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "fmt" diff --git a/sparkctl/cmd/s3.go b/cmd/sparkctl/app/s3.go similarity index 99% rename from sparkctl/cmd/s3.go rename to cmd/sparkctl/app/s3.go index 28e9350ae1..4bdbeaa6c9 100644 --- a/sparkctl/cmd/s3.go +++ b/cmd/sparkctl/app/s3.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "context" diff --git a/sparkctl/cmd/status.go b/cmd/sparkctl/app/status.go similarity index 99% rename from sparkctl/cmd/status.go rename to cmd/sparkctl/app/status.go index cd773454a0..59d2a05faa 100644 --- a/sparkctl/cmd/status.go +++ b/cmd/sparkctl/app/status.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "fmt" diff --git a/sparkctl/cmd/testdata/hadoop-conf/binary.dat b/cmd/sparkctl/app/testdata/hadoop-conf/binary.dat similarity index 100% rename from sparkctl/cmd/testdata/hadoop-conf/binary.dat rename to cmd/sparkctl/app/testdata/hadoop-conf/binary.dat diff --git a/sparkctl/cmd/testdata/hadoop-conf/core-site.xml b/cmd/sparkctl/app/testdata/hadoop-conf/core-site.xml similarity index 100% rename from sparkctl/cmd/testdata/hadoop-conf/core-site.xml rename to cmd/sparkctl/app/testdata/hadoop-conf/core-site.xml diff --git a/sparkctl/cmd/testdata/test-app.yaml b/cmd/sparkctl/app/testdata/test-app.yaml similarity index 100% rename from sparkctl/cmd/testdata/test-app.yaml rename to cmd/sparkctl/app/testdata/test-app.yaml diff --git a/sparkctl/cmd/utils.go b/cmd/sparkctl/app/utils.go similarity index 98% rename from sparkctl/cmd/utils.go rename to cmd/sparkctl/app/utils.go index d2b2aa5050..0786c8a5ba 100644 --- a/sparkctl/cmd/utils.go +++ b/cmd/sparkctl/app/utils.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cmd +package app import ( "time" diff --git a/sparkctl/main.go b/cmd/sparkctl/main.go similarity index 90% rename from sparkctl/main.go rename to cmd/sparkctl/main.go index 80c89a81b6..4f0e00e654 100644 --- a/sparkctl/main.go +++ b/cmd/sparkctl/main.go @@ -19,9 +19,9 @@ package main import ( _ "k8s.io/client-go/plugin/pkg/client/auth" - "github.com/kubeflow/spark-operator/sparkctl/cmd" + "github.com/kubeflow/spark-operator/cmd/sparkctl/app" ) func main() { - cmd.Execute() + app.Execute() }