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

Feature/multiple sources #23

Merged
merged 33 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ad58c3b
feature: adding the ability to have multiple sources
zach-source May 13, 2022
dd1b4c3
feature: added source add command
zach-source May 14, 2022
cb92593
chore: remove unused concept
zach-source May 16, 2022
b151909
chore: remove unused concept
zach-source May 16, 2022
1f08105
chore: fixing test
zach-source May 17, 2022
3dc4307
bugfix: fixing panic on table printer
zach-source May 17, 2022
a4af7a1
chore: adding makefile checks for go version
zach-source May 23, 2022
16c840d
chore: adding conversion-gen and controller-gen install
zach-source Jun 7, 2022
970c731
conversion.go changes committed
zach-source Jun 7, 2022
09cade0
code committed for bp bedrock milestone 2 development & UT
akhi1616 Jun 17, 2022
613f16f
code committed for BP Bedrock miletsone3 with 2 open queries mentione…
akhi1616 Jun 24, 2022
5a31bda
Merge pull request #12 from akhi1616/bpbedrockmilestone3
dacleyra Jun 28, 2022
a91bc64
cleanup
dacleyra Jun 28, 2022
70e6eb2
update readme
dacleyra Jun 28, 2022
663e90f
updated datactl sources add dataservice --help
mxpaspa Oct 14, 2022
e6e0b82
initial commit
ab-ibm Dec 22, 2022
7769d63
fixed issue with eventid
ab-ibm Dec 27, 2022
03a40d4
updated readme with info how to configure ilmt datasource
ab-ibm Jan 25, 2023
064c33d
updates after review
ab-ibm Jan 25, 2023
a75fbe3
Merge pull request #21 from redhat-marketplace/feature_ilmt_support
dacleyra Jan 25, 2023
fd2fc05
Merge pull request #13 from redhat-marketplace/fix/multiSourceCleanup
dacleyra Jan 25, 2023
ff11259
Merge branch 'main' into feature/multipleSources
dacleyra Jan 25, 2023
99d87b5
parameterize namespace
dacleyra Mar 23, 2023
a465eb2
use kubeconfig for namespace, remove default clusterrolebinding
dacleyra Mar 24, 2023
9a1b875
merge main
dacleyra Mar 24, 2023
550dda8
mod tidy
dacleyra Mar 24, 2023
4667571
fix ginkgo v2, add config cleanup to ilmt test
dacleyra Mar 24, 2023
3759137
update break down step
dacleyra Mar 24, 2023
c5404fa
update break down step
dacleyra Mar 24, 2023
458bf61
no hardcode InsecureSkipTLSVerify
dacleyra Mar 24, 2023
6966375
no hardcode InsecureSkipTLSVerify
dacleyra Mar 24, 2023
4cf5a4c
use insecure flag from KubectlConfig
dacleyra Mar 28, 2023
9be34f4
use KubectlConfig for insecure
dacleyra Mar 28, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@
*.coverprofile
dist/
version.txt

bin/
35 changes: 34 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
GO=go
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 19
MAXIMUM_SUPPORTED_GO_MINOR_VERSION = 19
GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)

.DEFAULT_GOAL := install

GOBIN := $(shell pwd)/bin
PATH := $(GOBIN):$(PATH)

export PATH
export GOBIN

validate-go-version: ## Validates the installed version of go against Mattermost's minimum requirement.
@if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
exit 0 ;\
elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -gt $(MAXIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi

.PHONY: tag
tag:
git tag $(svu next)
Expand All @@ -18,7 +46,7 @@ test:
ginkgo -r --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --show-node-events

.PHONY: generate
generate:
generate: validate-go-version tools
go generate ./...

.PHONY: install
Expand All @@ -37,3 +65,8 @@ release: goreleaser
.PHONY: goreleaser
goreleaser:
go install github.com/goreleaser/[email protected]

tools:
go mod download
go install "k8s.io/code-generator/cmd/[email protected]"
go install "sigs.k8s.io/controller-tools/cmd/[email protected]"
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
- [Installation](#installation)
- [Usage](#usage)
- [Getting started](#getting-started)
- [Export](#export)
- [Exporting from DataService sources](#exporting-from-dataservice-sources)
- [Exporting from IBM License Metric Tool sources](#exporting-from-ibm-license-metric-tool-sources)

<!-- markdown-toc end -->

Expand Down Expand Up @@ -45,24 +46,30 @@ Datactl tool can be used standalone. Just move oc-datactl to your path and use `

4. Add the role-binding to the default service account on operator-namespace.

Install the role and role binding for the default service account for the `openshift-redhat-marketplace`
namespace. The datactl tool will use these by default.
Install the ClusterRole and create the ClusterRoleBinding for the default service account for the namespace the IBM Metrics Operator's
DataService is installed to `by default: redhat-marketplace`. The datactl tool will use this service account by default.

```sh
oc apply -f resources/service-account-role.yaml // file found in release
oc create clusterrolebinding rhm-files --clusterrole=rhm-files --serviceaccount=redhat-marketplace:default
```

5. Now you're configured. You can start using the export commands.

## Export
## Exporting from DataService sources

Recommended approach is to run the commands in this order:

```sh
// Must be logged in to the cluster
oc datactl export pull

// If you're in a connect
// Add the dataservice as a source, to which you are logged into with your current context
datactl sources add dataservice --use-default-context --allow-self-signed=true --namespace=redhat-marketplace

// Pull the data from dataservice sources
oc datactl export pull --source-type=dataservice

// If you're connected to the internet
oc datactl export push

// If no errors from push.
Expand All @@ -71,14 +78,19 @@ oc datactl export commit

Let's break down what each one is doing.

`datactl sources add dataservice --use-default-context --allow-self-signed=true`

- Adds the default-context cluster's dataservice as a source for pulling
- Writes the source data-service-endpoint to `~/.datactl/config`

`oc datactl export pull`

- Pulls files from data service and stores them in a tar file under your `~/.datactl/data` folder.
- Writes the status of the files found in `~/.datactl/config`

`oc datactl export push`

- Pushes the files pulled to Red Hat Marketplace.
- Files pulled by the previous command are pushed to Red Hat Marketplace.
- If this process errors, do not commit. Retry the export push or open a support ticket.

`oc datactl export commit`
Expand All @@ -88,3 +100,24 @@ Let's break down what each one is doing.
- After some time, the files in dataservice will be cleaned up to save space.

If you want to transfer it somewhere else, you can find the tar file under your `~/.datactl/data/` directory.

## Exporting from IBM License Metric Tool sources

_Prerequisite_: API Token is required to get data from IBM License Metric Tool (ILMT). Login to your ILMT environment, go to _Profile_ and click _Show token_ under API Token section.

First step is to configure ILMT data source. Execute following command

`datactl sources add ilmt`

and provide ILMT hostname, port number and token

To pull data from ILMT, execute command

`datactl export pull --source-type=ilmt`

First time you will be asked to provide start date. Next time last synchronization date is stored in config file and will be updated to pull data from last synchronization date.

To push data to Red Hat Marketplace execute command

`datactl export push`

5 changes: 4 additions & 1 deletion cmd/datactl/app/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

configcmd "github.com/redhat-marketplace/datactl/cmd/datactl/app/config"
"github.com/redhat-marketplace/datactl/cmd/datactl/app/metering"
"github.com/redhat-marketplace/datactl/cmd/datactl/app/sources"
"github.com/redhat-marketplace/datactl/pkg/datactl/config"
"github.com/redhat-marketplace/datactl/pkg/datactl/output"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/rest"
cliflag "k8s.io/component-base/cli/flag"
Expand All @@ -37,6 +37,8 @@ import (
"k8s.io/kubectl/pkg/util/term"

_ "embed"

"github.com/redhat-marketplace/datactl/pkg/printers/output"
)

var (
Expand Down Expand Up @@ -146,6 +148,7 @@ func NewDatactlCommand(in io.Reader, out, err io.Writer) *cobra.Command {
Message: "Metering Commands:",
Commands: []*cobra.Command{
metering.NewCmdExport(rhmConfigFlags, f, ioStreams),
sources.NewCmdSources(rhmConfigFlags, f, ioStreams),
},
},
{
Expand Down
Loading