-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a733b0
commit 0cc3b78
Showing
8 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package model | ||
|
||
import ( | ||
ssmTypes "github.com/aws/aws-sdk-go-v2/service/ssm/types" | ||
) | ||
|
||
type ( | ||
SSMParameter ssmTypes.ParameterMetadata | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package repo | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/ssm" | ||
"github.com/bporter816/aws-tui/model" | ||
) | ||
|
||
type SSM struct { | ||
ssmClient *ssm.Client | ||
} | ||
|
||
func NewSSM(ssmClient *ssm.Client) *SSM { | ||
return &SSM{ | ||
ssmClient: ssmClient, | ||
} | ||
} | ||
|
||
func (s SSM) ListParameters() ([]model.SSMParameter, error) { | ||
pg := ssm.NewDescribeParametersPaginator( | ||
s.ssmClient, | ||
&ssm.DescribeParametersInput{}, | ||
) | ||
var parameters []model.SSMParameter | ||
for pg.HasMorePages() { | ||
out, err := pg.NextPage(context.TODO()) | ||
if err != nil { | ||
return []model.SSMParameter{}, err | ||
} | ||
for _, v := range out.Parameters { | ||
parameters = append(parameters, model.SSMParameter(v)) | ||
} | ||
} | ||
return parameters, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package main | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/bporter816/aws-tui/repo" | ||
"github.com/bporter816/aws-tui/ui" | ||
"github.com/bporter816/aws-tui/view" | ||
) | ||
|
||
type SSMParameters struct { | ||
*ui.Table | ||
view.SSM | ||
repo *repo.SSM | ||
app *Application | ||
} | ||
|
||
func NewSSMParameters(repo *repo.SSM, app *Application) *SSMParameters { | ||
s := &SSMParameters{ | ||
Table: ui.NewTable([]string{ | ||
"NAME", | ||
"TIER", | ||
"TYPE", | ||
"DATA TYPE", | ||
}, 1, 0), | ||
repo: repo, | ||
app: app, | ||
} | ||
return s | ||
} | ||
|
||
func (s SSMParameters) GetLabels() []string { | ||
return []string{"Parameters"} | ||
} | ||
|
||
func (s SSMParameters) GetKeyActions() []KeyAction { | ||
return []KeyAction{} | ||
} | ||
|
||
func (s SSMParameters) Render() { | ||
model, err := s.repo.ListParameters() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
var data [][]string | ||
for _, v := range model { | ||
var name, tier, parameterType, dataType, version, policies string | ||
if v.Name != nil { | ||
name = *v.Name | ||
} | ||
tier = string(v.Tier) | ||
parameterType = string(v.Type) | ||
if v.DataType != nil { | ||
dataType = *v.DataType | ||
} | ||
version = strconv.FormatInt(v.Version, 10) | ||
policies = strconv.Itoa(len(v.Policies)) | ||
data = append(data, []string{ | ||
name, | ||
tier, | ||
parameterType, | ||
dataType, | ||
version, | ||
policies, | ||
}) | ||
} | ||
s.SetData(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package view | ||
|
||
type SSM struct { | ||
} | ||
|
||
func (s SSM) GetService() string { | ||
return "Systems Manager" | ||
} |