Skip to content

Commit

Permalink
add a go client
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <[email protected]>
  • Loading branch information
YangKeao committed Dec 1, 2021
1 parent 2c56542 commit e536509
Show file tree
Hide file tree
Showing 33 changed files with 1,182 additions and 1,418 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ modules.builtin
*.
*.symvers

/target/**/*

!/buildkit/go.mod
!go.mod
/bin
252 changes: 0 additions & 252 deletions Cargo.lock

This file was deleted.

13 changes: 0 additions & 13 deletions Cargo.toml

This file was deleted.

11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
all: driver/chaos_driver.ko target/release/kchaos
all: driver/chaos_driver.ko bin/kchaos

driver/chaos_driver.ko:
$(MAKE) -C ./driver all

target/debug/kchaos:
cargo build --debug

target/release/kchaos:
cargo build --release
bin/kchaos:
go build -o ./bin/kchaos ./cmd

clean:
$(MAKE) -C ./driver clean

.PHONY: all driver/chaos_driver.ko target/release/kchaos target/debug/kchaos
.PHONY: all driver/chaos_driver.ko bin/kchaos
47 changes: 47 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2021 Chaos Mesh 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/spf13/cobra"

"github.com/chaos-mesh/chaos-driver/pkg/cmd/inject"
"github.com/chaos-mesh/chaos-driver/pkg/cmd/recover"
"github.com/chaos-mesh/chaos-driver/pkg/cmd/version"
)

var rootCmd = &cobra.Command{
Short: "kchaos is the client to communicate with chaos driver",
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
},
}

func init() {
rootCmd.AddCommand(inject.Inject)
rootCmd.AddCommand(version.Version)
rootCmd.AddCommand(recover.Recover)
}

func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion driver/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
chaos_driver-y += main.o chaos_device.o injection.o syscall_tracepoint.o fs_injection.o blk_io_injection.o lazy_list.o ioem.o
chaos_driver-y += main.o chaos_device.o injection.o ioem.o
obj-m += chaos_driver.o

KVERSION ?= $(shell uname -r)
Expand Down
2 changes: 0 additions & 2 deletions driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ The argument will never be read, so it could be nil. The return value will be an
struct chaos_injection {
__u32 matcher_type;
void* matcher_arg;
size_t matcher_arg_size;

__u32 injector_type;
void* injector_arg;
size_t injector_arg_size;
}
```

Expand Down
Loading

0 comments on commit e536509

Please sign in to comment.