Skip to content

Commit

Permalink
first implementation (#1)
Browse files Browse the repository at this point in the history
* initial development

* setup commands

* add goreleaser config and release pipeline

---------

Co-authored-by: Alessandro Cannarella <[email protected]>
Co-authored-by: Omar El Malak <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2024
1 parent cc3f816 commit 547ff51
Show file tree
Hide file tree
Showing 14 changed files with 872 additions and 3 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
branches:
- main # Esegue build snapshot per ogni push su main
tags:
- 'v*' # Esegue una release ufficiale quando il tag inizia con 'v'

env:
GORELEASER_VERSION: v2.3.2

jobs:
build:
name: Build and Release for Supported Architectures
runs-on: ubuntu-latest

steps:
# Checkout del codice
- name: Checkout Repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
show-progress: false

# Setup di Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.2'

# Installazione di GoReleaser
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
version: ${{ env.GORELEASER_VERSION }}
install-only: true

# Esecuzione di GoReleaser per snapshot build (su main)
- name: Run GoReleaser (Snapshot)
if: github.ref == 'refs/heads/main'
run: goreleaser release --snapshot --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Esecuzione di GoReleaser per rilasci ufficiali (su tag)
- name: Run GoReleaser (Release)
if: startsWith(github.ref, 'refs/tags/v')
run: goreleaser release --clean --skip-validate --skip-publish=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Salva i binari come artefatti in snapshot build
- name: Upload artifact (Snapshot)
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: artifacts
path: bin/
114 changes: 111 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Custom gitignore rules

bin/
coverage.txt

# End of Custom gitignore rules

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,windows,macos,go
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,windows,macos,go

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
Expand All @@ -19,7 +30,104 @@

# Go workspace file
go.work
go.work.sum

# env file
.env
### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,windows,macos,go


mipyconfig.json
environment
config_path.txt
dist/
44 changes: 44 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- main: ./cmd/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm
- arm64
- "386"
goarm:
- "6"
- "7"

archives:
- format: binary
name_template: >-
{{ .Binary }}-
{{- .Os }}-
{{- .Arch }}{{ with .Arm }}v{{ . }}{{ end }}
{{- with .Mips }}-{{ . }}{{ end }}
{{- if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}
checksum:
name_template: checksums.txt
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# mipy
Cli helper to help in IaC provisioning through the Console pipelines

## Setup

The mipy cli makes use of a configmap file as this one:
```json
{
"basePath": "string",
"templates": [
{
"type": "enum",
"id": "string",
"cicdProvider": "string", // for now only "azure" is supported
"cicdProviderBaseUrl": "string",
"azureOrganization": "string",
"azureProject": "string",
"terraformPipelineId": "string"
}
],
"logLevel": "string"
}
```

## Commands

### version

```
mipy version
```

### help

```
mipy help
```

### config

flags are:
- get
- set [PATH]
- --help

```
mipy config set mipy.json
```

### launch

flags are:
- --environment (-e): required
- --cr-list
- --parallel
- --error-code
- --debug
- --dry-run
29 changes: 29 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024-2024 Mipy Project
//
// 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 (
"os"

"github.com/mia-platform/mipy/internal/cmd"
)

func main() {
rootCmd := cmd.NewRootCommand()
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
os.Exit(0)
}
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/mia-platform/mipy

go 1.23.2

require github.com/mia-platform/miactl v0.15.0

require (
github.com/go-logr/logr v1.4.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mia-platform/miactl v0.15.0 h1:tCvFnkqMjit+Y7giZaF3ZVPXKvz1eG3Cen/CsXA4QfI=
github.com/mia-platform/miactl v0.15.0/go.mod h1:QOflNDd0wdfmB6TvTe7XWG8KTDo7R5RVIlQvMqQY9DU=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 547ff51

Please sign in to comment.