Skip to content

Commit 6667b33

Browse files
authored
Restructure directory and dependency order (#3)
1 parent 19954e4 commit 6667b33

File tree

8 files changed

+44
-44
lines changed

8 files changed

+44
-44
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Version := $(shell git describe --tags --dirty)
22
GitCommit := $(shell git rev-parse HEAD)
3-
LDFLAGS := "-s -w -X awssh/internal/cli.Version=$(Version) -X awssh/internal/cli.GitCommit=$(GitCommit)"
3+
LDFLAGS := "-s -w -X awssh/cmd.Version=$(Version) -X awssh/cmd.GitCommit=$(GitCommit)"
44
OUTDIR := bin
55

66
.PHONY: test pretty mod tidy
@@ -17,13 +17,13 @@ pretty:
1717
gofmt -s -w **/*.go
1818

1919
build:
20-
CGO_ENABLED=0 go build -ldflags $(LDFLAGS) -o awssh app/cli/main.go
20+
CGO_ENABLED=0 go build -ldflags $(LDFLAGS) -o awssh
2121

2222
.PHONY: dist
2323
dist:
2424
mkdir -p $(OUTDIR)
25-
CGO_ENABLED=0 GOOS=linux go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh app/cli/main.go
26-
CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-darwin app/cli/main.go
27-
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-armhf app/cli/main.go
28-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-arm64 app/cli/main.go
29-
CGO_ENABLED=0 GOOS=windows go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh.exe app/cli/main.go
25+
CGO_ENABLED=0 GOOS=linux go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh
26+
CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-darwin
27+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-armhf
28+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh-arm64
29+
CGO_ENABLED=0 GOOS=windows go build -ldflags $(LDFLAGS) -o $(OUTDIR)/awssh.exe

app/cli/main.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

internal/cli/root.go renamed to cmd/root.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package cli
1+
package cmd
22

33
import (
4-
"awssh/config"
5-
"awssh/internal/aws"
6-
"awssh/internal/logging"
7-
84
"fmt"
95
"regexp"
106
"strings"
117

128
"github.com/manifoldco/promptui"
139
"github.com/spf13/cobra"
10+
11+
"awssh/config"
12+
"awssh/internal/aws"
13+
"awssh/internal/logging"
1414
)
1515

1616
var (

internal/cli/version.go renamed to cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cli
1+
package cmd
22

33
import (
44
"fmt"

internal/aws/aws.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package aws
22

33
import (
4-
"awssh/internal/logging"
5-
64
"fmt"
75
"strings"
86

97
"github.com/aws/aws-sdk-go/aws"
108
aws_session "github.com/aws/aws-sdk-go/aws/session"
119
"github.com/aws/aws-sdk-go/service/ec2"
10+
11+
"awssh/internal/logging"
1212
)
1313

1414
// NewSession creates a new AWS session from region input or region environment variables (ex: AWS_DEFAULT_REGION, AWS_REGION)

internal/aws/instance.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
"os/exec"
77
"strings"
88

9-
"awssh/config"
10-
"awssh/internal/logging"
11-
"awssh/internal/ssh"
12-
139
"github.com/aws/aws-sdk-go/aws"
1410
"github.com/aws/aws-sdk-go/aws/awserr"
1511
aws_session "github.com/aws/aws-sdk-go/aws/session"
1612
"github.com/aws/aws-sdk-go/service/ec2"
1713
"github.com/aws/aws-sdk-go/service/ec2instanceconnect"
14+
15+
"awssh/config"
16+
"awssh/internal/logging"
17+
"awssh/internal/ssh"
1818
)
1919

2020
// EC2Instance represent all the necessary EC2 components

internal/ssh/ssh.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"net"
66
"os"
77

8-
"awssh/config"
9-
"awssh/internal/logging"
10-
118
gossh "golang.org/x/crypto/ssh"
129
"golang.org/x/crypto/ssh/agent"
10+
11+
"awssh/config"
12+
"awssh/internal/logging"
1313
)
1414

1515
// Session represent an SSH data model consist of a SSH PublicKey

main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"awssh/cmd"
7+
"awssh/config"
8+
)
9+
10+
func main() {
11+
12+
config.Load()
13+
14+
rootCmd := cmd.MakeRoot()
15+
versionCmd := cmd.MakeVersion()
16+
17+
rootCmd.AddCommand(versionCmd)
18+
19+
if err := rootCmd.Execute(); err != nil {
20+
os.Exit(1)
21+
}
22+
}

0 commit comments

Comments
 (0)