Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"permissions": {
"allow": [
"Bash(go list:*)",
"Bash(curl:*)",
"Bash(find:*)",
"Bash(go mod:*)",
"Bash(go env:*)",
"Bash(make:*)",
"Bash(go build:*)"
],
"deny": [],
"ask": []
}
}
19 changes: 19 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

run:
timeout: 20m
skip-dirs:
- vendor
- tools/vendor
skip-files:
- pkg/provider/ibmcloud/action/powervs/powervs.go
concurrency: 1

linters-settings:
govet:
enable-all: true

issues:
exclude-dirs:
- vendor
- tools/vendor
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ build: $(BUILD_DIR)/mapt

.PHONY: test
test:
GOMAXPROCS=1 CGO_ENABLED=1 go test -p 1 --tags build -v -ldflags="$(VERSION_VARIABLES)" ./pkg/... ./cmd/... -skip github.com/mapt-oss/pulumi-ibmcloud/sdk/go/...

.PHONY: test-race
test-race:
CGO_ENABLED=1 go test -race --tags build -v -ldflags="$(VERSION_VARIABLES)" ./pkg/... ./cmd/...

.PHONY: clean ## Remove all build artifacts
Expand All @@ -89,7 +93,7 @@ fmt:
# Run golangci-lint against code
.PHONY: lint
lint: $(TOOLS_BINDIR)/golangci-lint
"$(TOOLS_BINDIR)"/golangci-lint run -v --timeout 10m
"$(TOOLS_BINDIR)"/golangci-lint run -v --timeout 20m --skip-dirs vendor

# Build the container image
.PHONY: oci-build
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@ Instances can be wrapped on specific topologies like airgap, in this case mapt w

Instances can also define a timeout to avoid leftovers in case destoy operation is missing. Using this approach mapt will be execute as an unateneded execution using servless technologies.

[MacOS](docs/aws/mac.md)-[Windows Server](docs/aws/windows.md)-[Windows Desktop](docs/azure/windows.md)-[RHEL](docs/aws/rhel.md)-[Fedora](docs/azure/fedora.md)-[Ubuntu](docs/azure/ubuntu.md)
[MacOS](docs/aws/mac.md) - [Windows Server](docs/aws/windows.md) - [Windows Desktop](docs/azure/windows.md) - [RHEL](docs/aws/rhel.md) - [Fedora](docs/azure/fedora.md) - [Ubuntu](docs/azure/ubuntu.md)

### Services

Mapt offers some managed services boosted with some of the features from the instances offerings (i.e spot) and also create some ad hoc services on top the instances offerings to improve reutilization of instances when there is no easy way to do it (i.e. Mac-Pool).

[AKS](docs/azure/aks.md)-[EKS](docs/aws/eks.md)-[Mac-Pool](docs/aws/mac-pool.md) - [OpenShift-SNC](docs/aws/openshift-snc.md) - [Kind](docs/aws/openshift-snc.md)
[AKS](docs/azure/aks.md) - [EKS](docs/aws/eks.md) - [Mac-Pool](docs/aws/mac-pool.md) - [OpenShift-SNC](docs/aws/openshift-snc.md) - [Kind](docs/aws/openshift-snc.md)

### Architectures

x86 and arm64 archs can be provisioned through any of the previous targets based on parameters.

In addition we can provision

[s390x](docs/ibmcloud/ibm-z.md) - [ppc64](docs/ibmcloud/ibm-power.mdS)


### Integrations

Currently each target offered by Mapt can be added as:
The integrations allow to provision the machine and link to different CI/CD systems based on their native integrations.

* [Github Self Hosted Runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners)
* [Cirrus Persistent Worker](https://cirrus-ci.org/guide/persistent-workers/)
Expand Down
93 changes: 93 additions & 0 deletions cmd/mapt/cmd/ibmcloud/hosts/ibm-power.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package hosts

import (
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
ibmpower "github.com/redhat-developer/mapt/pkg/provider/ibmcloud/action/ibm-power"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
cmdIBMPower = "ibm-power"
cmdIBMPowerDesc = "manage ibm-power machines (ppc64)"
)

func IBMPowerCmd() *cobra.Command {
c := &cobra.Command{
Use: cmdIBMPower,
Short: cmdIBMPowerDesc,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return nil
},
}

flagSet := pflag.NewFlagSet(cmdIBMPower, pflag.ExitOnError)
params.AddCommonFlags(flagSet)
c.PersistentFlags().AddFlagSet(flagSet)

c.AddCommand(ibmPowerCreate(), ibmPowerDestroy())
return c
}

func ibmPowerCreate() *cobra.Command {
c := &cobra.Command{
Use: params.CreateCmdName,
Short: params.CreateCmdName,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return ibmpower.New(
&maptContext.ContextArgs{
Context: cmd.Context(),
ProjectName: viper.GetString(params.ProjectName),
BackedURL: viper.GetString(params.BackedURL),
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
Debug: viper.IsSet(params.Debug),
DebugLevel: viper.GetUint(params.DebugLevel),
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
GHRunnerArgs: params.GithubRunnerArgs(),
Tags: viper.GetStringMapString(params.Tags),
},
&ibmpower.PWArgs{})
},
}
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
params.AddGHActionsFlags(flagSet)
params.AddCirrusFlags(flagSet)
c.PersistentFlags().AddFlagSet(flagSet)
return c
}

func ibmPowerDestroy() *cobra.Command {
c := &cobra.Command{
Use: params.DestroyCmdName,
Short: params.DestroyCmdName,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return ibmpower.Destroy(&maptContext.ContextArgs{
Context: cmd.Context(),
ProjectName: viper.GetString(params.ProjectName),
BackedURL: viper.GetString(params.BackedURL),
Debug: viper.IsSet(params.Debug),
DebugLevel: viper.GetUint(params.DebugLevel),
Serverless: viper.IsSet(params.Serverless),
ForceDestroy: viper.IsSet(params.ForceDestroy),
})
},
}
flagSet := pflag.NewFlagSet(params.DestroyCmdName, pflag.ExitOnError)
flagSet.Bool(params.Serverless, false, params.ServerlessDesc)
flagSet.Bool(params.ForceDestroy, false, params.ForceDestroyDesc)
c.PersistentFlags().AddFlagSet(flagSet)
return c
}
93 changes: 93 additions & 0 deletions cmd/mapt/cmd/ibmcloud/hosts/ibm-z.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package hosts

import (
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
ibmz "github.com/redhat-developer/mapt/pkg/provider/ibmcloud/action/ibm-z"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
cmdIBMZ = "ibm-z"
cmdIBMZDesc = "manage ibm-power machines (s390x)"
)

func IBMZCmd() *cobra.Command {
c := &cobra.Command{
Use: cmdIBMZ,
Short: cmdIBMZDesc,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return nil
},
}

flagSet := pflag.NewFlagSet(cmdIBMZ, pflag.ExitOnError)
params.AddCommonFlags(flagSet)
c.PersistentFlags().AddFlagSet(flagSet)

c.AddCommand(ibmZCreate(), ibmZDestroy())
return c
}

func ibmZCreate() *cobra.Command {
c := &cobra.Command{
Use: params.CreateCmdName,
Short: params.CreateCmdName,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return ibmz.New(
&maptContext.ContextArgs{
Context: cmd.Context(),
ProjectName: viper.GetString(params.ProjectName),
BackedURL: viper.GetString(params.BackedURL),
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
Debug: viper.IsSet(params.Debug),
DebugLevel: viper.GetUint(params.DebugLevel),
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
GHRunnerArgs: params.GithubRunnerArgs(),
Tags: viper.GetStringMapString(params.Tags),
},
&ibmz.ZArgs{})
},
}
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
params.AddGHActionsFlags(flagSet)
params.AddCirrusFlags(flagSet)
c.PersistentFlags().AddFlagSet(flagSet)
return c
}

func ibmZDestroy() *cobra.Command {
c := &cobra.Command{
Use: params.DestroyCmdName,
Short: params.DestroyCmdName,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return ibmz.Destroy(&maptContext.ContextArgs{
Context: cmd.Context(),
ProjectName: viper.GetString(params.ProjectName),
BackedURL: viper.GetString(params.BackedURL),
Debug: viper.IsSet(params.Debug),
DebugLevel: viper.GetUint(params.DebugLevel),
Serverless: viper.IsSet(params.Serverless),
ForceDestroy: viper.IsSet(params.ForceDestroy),
})
},
}
flagSet := pflag.NewFlagSet(params.DestroyCmdName, pflag.ExitOnError)
flagSet.Bool(params.Serverless, false, params.ServerlessDesc)
flagSet.Bool(params.ForceDestroy, false, params.ForceDestroyDesc)
c.PersistentFlags().AddFlagSet(flagSet)
return c
}
35 changes: 35 additions & 0 deletions cmd/mapt/cmd/ibmcloud/ibmcloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ibmcloud

import (
"github.com/redhat-developer/mapt/cmd/mapt/cmd/ibmcloud/hosts"
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
cmd = "ibmcloud"
cmdDesc = "ibmcloud operations"
)

func GetCmd() *cobra.Command {
c := &cobra.Command{
Use: cmd,
Short: cmdDesc,
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
return nil
},
}

flagSet := pflag.NewFlagSet(cmd, pflag.ExitOnError)
params.AddCommonFlags(flagSet)
c.PersistentFlags().AddFlagSet(flagSet)
c.AddCommand(
hosts.IBMPowerCmd(),
hosts.IBMZCmd())
return c
}
4 changes: 3 additions & 1 deletion cmd/mapt/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"
"github.com/redhat-developer/mapt/cmd/mapt/cmd/aws"
"github.com/redhat-developer/mapt/cmd/mapt/cmd/azure"
"github.com/redhat-developer/mapt/cmd/mapt/cmd/ibmcloud"
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
"github.com/redhat-developer/mapt/pkg/util/logging"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -61,7 +62,8 @@ func init() {
// Subcommands
rootCmd.AddCommand(
aws.GetCmd(),
azure.GetCmd())
azure.GetCmd(),
ibmcloud.GetCmd())
}

func Execute() {
Expand Down
55 changes: 55 additions & 0 deletions docs/ibmcloud/ibm-power.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Overview

This actions will handle provision Ubuntu ppc64 machines on ibm cloud power vs.


## Create

```bash
mapt ibmcloud ibm-power z create -h
create

Usage:
mapt ibmcloud ibm-power create [flags]

Flags:
--conn-details-output string path to export host connection information (host, username and privateKey)
--ghactions-runner-labels strings List of labels separated by comma to be added to the self-hosted runner
--ghactions-runner-repo string Full URL of the repository where the Github Actions Runner should be registered
--ghactions-runner-token string Token needed for registering the Github Actions Runner token
-h, --help help for create
--it-cirrus-pw-labels stringToString additional labels to use on the persistent worker (--it-cirrus-pw-labels key1=value1,key2=value2) (default [])
--it-cirrus-pw-token string Add mapt target as a cirrus persistent worker. The value will hold a valid token to be used by cirrus cli to join the project.
--tags stringToString tags to add on each resource (--tags name1=value1,name2=value2) (default [])

Global Flags:
--backed-url string backed for stack state. (local) file:///path/subpath (s3) s3://existing-bucket, (azure) azblob://existing-blobcontainer. See more https://www.pulumi.com/docs/iac/concepts/state-and-backends/#using-a-self-managed-backend
--debug Enable debug traces and set verbosity to max. Typically to get information to troubleshooting an issue.
--debug-level uint Set the level of verbosity on debug. You can set from minimum 1 to max 9. (default 3)
--project-name string project name to identify the instance of the stack
```

### Outputs

* It will crete an instance and will give as result several files located at path defined by `--conn-details-output`:

* **host**: host for the Windows machine (lb if spot)
* **username**: username to connect to the machine
* **id_rsa**: private key to connect to machine

* Also, it will create a state folder holding the state for the created resources at azure, the path for this folder is defined within `--backed-url`, the content from that folder it is required with the same project name (`--project-name`) in order to destroy the resources.

### Container

```bash
podman run -d --name ibm-power \
-v ${PWD}:/workspace:z \
-e IBMCLOUD_ACCOUNT=XXX \
-e IBMCLOUD_API_KEY=XXX \
-e IC_REGION=us-south \
-e IC_ZONE=dal12 \ # power vs use this notation
quay.io/redhat-developer/mapt:1.0.0 ibm-power create \
--project-name ibm-power \
--backed-url file:///workspace \
--conn-details-output /workspace
```
Loading