Skip to content

Commit

Permalink
Change names of theia and commands
Browse files Browse the repository at this point in the history
Signed-off-by: Yongming Ding <dyongming@vmware.com>
  • Loading branch information
Yongming Ding committed Jun 3, 2022
1 parent 36493ed commit 819f75c
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 261 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/upload_release_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,48 @@ jobs:
asset_path: ./assets/flow-visibility.yml
asset_name: flow-visibility.yml
asset_content_type: application/octet-stream
- name: Upload theiactl-darwin-x86_64
- name: Upload theia-darwin-x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/theiactl-darwin-x86_64
asset_name: theiactl-darwin-x86_64
asset_path: ./assets/theia-darwin-x86_64
asset_name: theia-darwin-x86_64
asset_content_type: application/octet-stream
- name: Upload theiactl-linux-arm
- name: Upload theia-linux-arm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/theiactl-linux-arm
asset_name: theiactl-linux-arm
asset_path: ./assets/theia-linux-arm
asset_name: theia-linux-arm
asset_content_type: application/octet-stream
- name: Upload theiactl-linux-arm64
- name: Upload theia-linux-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/theiactl-linux-arm64
asset_name: theiactl-linux-arm64
asset_path: ./assets/theia-linux-arm64
asset_name: theia-linux-arm64
asset_content_type: application/octet-stream
- name: Upload theiactl-linux-x86_64
- name: Upload theia-linux-x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/theiactl-linux-x86_64
asset_name: theiactl-linux-x86_64
asset_path: ./assets/theia-linux-x86_64
asset_name: theia-linux-x86_64
asset_content_type: application/octet-stream
- name: Upload theiactl-windows-x86_64.exe
- name: Upload theia-windows-x86_64.exe
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/theiactl-windows-x86_64.exe
asset_name: theiactl-windows-x86_64.exe
asset_path: ./assets/theia-windows-x86_64.exe
asset_name: theia-windows-x86_64.exe
asset_content_type: application/octet-stream
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BINDIR ?= $(CURDIR)/bin
GO_FILES := $(shell find . -type d -name '.cache' -prune -o -type f -name '*.go' -print)
GOPATH ?= $$($(GO) env GOPATH)
DOCKER_CACHE := $(CURDIR)/.cache
THEIACTL_BINARY_NAME ?= theiactl
THEIA_BINARY_NAME ?= theia
GO_VERSION := $(shell head -n 1 build/images/deps/go-version)

DOCKER_BUILD_ARGS = --build-arg GO_VERSION=$(GO_VERSION)
Expand Down Expand Up @@ -159,17 +159,17 @@ clickhouse-monitor-plugin:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/theia/plugins/clickhouse-monitor

.PHONY: theiactl
theiactl:
.PHONY: theia
theia:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/theia/pkg/theiactl
GOOS=linux $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/theia/pkg/theia

# Add the darwin version binary to help dev&test on Mac for now
.PHONY: theiactl-darwin
theiactl-darwin:
.PHONY: theia-darwin
theia-darwin:
@mkdir -p $(BINDIR)
GOOS=darwin $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/theia/pkg/theiactl
GOOS=darwin $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/theia/pkg/theia

.PHONY: theiactl-release
theiactl-release:
@$(GO) build -o $(BINDIR)/$(THEIACTL_BINARY_NAME) $(GOFLAGS) -ldflags '-s -w $(LDFLAGS)' antrea.io/theia/pkg/theiactl
.PHONY: theia-release
theia-release:
@$(GO) build -o $(BINDIR)/$(THEIA_BINARY_NAME) $(GOFLAGS) -ldflags '-s -w $(LDFLAGS)' antrea.io/theia/pkg/theia
129 changes: 0 additions & 129 deletions docs/network-policy-recommendation.md

This file was deleted.

38 changes: 0 additions & 38 deletions docs/theiactl.md

This file was deleted.

6 changes: 3 additions & 3 deletions hack/release/prepare-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ pushd $THIS_DIR/../.. > /dev/null
mkdir -p "$1"
OUTPUT_DIR=$(cd "$1" && pwd)

THEIACTL_BUILDS=(
THEIA_BUILDS=(
"linux amd64 linux-x86_64"
"linux arm64 linux-arm64"
"linux arm linux-arm"
"windows amd64 windows-x86_64.exe"
"darwin amd64 darwin-x86_64"
)

for build in "${THEIACTL_BUILDS[@]}"; do
for build in "${THEIA_BUILDS[@]}"; do
args=($build)
os="${args[0]}"
arch="${args[1]}"
Expand All @@ -57,7 +57,7 @@ for build in "${THEIACTL_BUILDS[@]}"; do
# cgo is disabled by default when cross-compiling, but enabled by default
# for native builds. We ensure it is always disabled for portability since
# these binaries will be distributed as release assets.
GOOS=$os GOARCH=$arch CGO_ENABLED=0 THEIACTL_BINARY_NAME="theia-$suffix" BINDIR="$OUTPUT_DIR"/ make theiactl-release
GOOS=$os GOARCH=$arch CGO_ENABLED=0 THEIA_BINARY_NAME="theia-$suffix" BINDIR="$OUTPUT_DIR"/ make theia-release
done


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import (
"github.com/spf13/cobra"
)

// policyrecoCmd represents the policyreco command group
var policyrecoCmd = &cobra.Command{
Use: "policyreco",
Short: "Commands of Theia policy recommendation feature",
// policyRecommendationCmd represents the policy recommendation command group
var policyRecommendationCmd = &cobra.Command{
Use: "policy-recommendation",
Aliases: []string{"pr"},
Short: "Commands of Theia policy recommendation feature",
Long: `Command group of Theia policy recommendation feature.
Must specify a subcommand like start, check or result.`,
Must specify a subcommand like run, status or retrieve.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Error: must also specify a subcommand like start, check or result")
fmt.Println("Error: must also specify a subcommand like run, status or retrieve")
},
}

func init() {
rootCmd.AddCommand(policyrecoCmd)
rootCmd.AddCommand(policyRecommendationCmd)
rootCmd.PersistentFlags().StringP(
"kubeconfig",
"k",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ import (
"k8s.io/client-go/kubernetes"
)

// resultCmd represents the result command
var resultCmd = &cobra.Command{
// policyRecommendationRetrieveCmd represents the policy-recommendation retrieve command
var policyRecommendationRetrieveCmd = &cobra.Command{
Use: "result",
Short: "Get the recommendation result of a policy recommendation Spark job",
Long: `Get the recommendation result of a policy recommendation Spark job by ID.
It will return the recommended network policies described in yaml.`,
Args: cobra.RangeArgs(0, 1),
Example: `
Get the recommendation result with job ID e998433e-accb-4888-9fc8-06563f073e86
$ theiactl policyreco result --id e998433e-accb-4888-9fc8-06563f073e86
$ theia policy-recommendation retrieve --id e998433e-accb-4888-9fc8-06563f073e86
Or
$ theiactl policyreco result e998433e-accb-4888-9fc8-06563f073e86
$ theia policy-recommendation retrieve e998433e-accb-4888-9fc8-06563f073e86
Use a customized ClickHouse endpoint when connecting to ClickHouse to getting the result
$ theiactl policyreco result e998433e-accb-4888-9fc8-06563f073e86 --clickhouse-endpoint 10.10.1.1
$ theia policy-recommendation retrieve e998433e-accb-4888-9fc8-06563f073e86 --clickhouse-endpoint 10.10.1.1
Use Cluster IP when connecting to ClickHouse to getting the result
$ theiactl policyreco result e998433e-accb-4888-9fc8-06563f073e86 --use-cluster-ip
$ theia policy-recommendation retrieve e998433e-accb-4888-9fc8-06563f073e86 --use-cluster-ip
Save the recommendation result to file
$ theiactl policyreco result e998433e-accb-4888-9fc8-06563f073e86 --use-cluster-ip --file output.yaml
$ theia policy-recommendation retrieve e998433e-accb-4888-9fc8-06563f073e86 --use-cluster-ip --file output.yaml
`,
RunE: func(cmd *cobra.Command, args []string) error {
// Parse the flags
Expand Down Expand Up @@ -147,7 +147,7 @@ func getPolicyRecommendationResult(clientset kubernetes.Interface, kubeconfig st
return "", fmt.Errorf("error when connecting to ClickHouse, %v", err)
}
if filePath != "" {
if err := ioutil.WriteFile(filePath, []byte(recoResult), 0644); err != nil {
if err := ioutil.WriteFile(filePath, []byte(recoResult), 0600); err != nil {
return "", fmt.Errorf("error when writing recommendation result to file: %v", err)
}
} else {
Expand Down Expand Up @@ -214,25 +214,25 @@ func getResultFromClickHouse(connect *sql.DB, id string) (string, error) {
}

func init() {
policyrecoCmd.AddCommand(resultCmd)
resultCmd.Flags().StringP(
policyRecommendationCmd.AddCommand(policyRecommendationRetrieveCmd)
policyRecommendationRetrieveCmd.Flags().StringP(
"id",
"i",
"",
"ID of the policy recommendation Spark job.",
)
resultCmd.Flags().String(
policyRecommendationRetrieveCmd.Flags().String(
"clickhouse-endpoint",
"",
"The ClickHouse service endpoint.",
)
resultCmd.Flags().Bool(
policyRecommendationRetrieveCmd.Flags().Bool(
"use-cluster-ip",
false,
`Enable this option will use ClusterIP instead of port forwarding when connecting to the ClickHouse service.
(Only works when running in cluster)`,
)
resultCmd.Flags().StringP(
policyRecommendationRetrieveCmd.Flags().StringP(
"file",
"f",
"",
Expand Down
File renamed without changes.
Loading

0 comments on commit 819f75c

Please sign in to comment.