Skip to content

Commit

Permalink
Merge branch 'kaytu-io:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ADorigi authored Jul 8, 2024
2 parents a2e4861 + b882add commit cb0b52b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ func ExecuteContext(ctx context.Context) {

var items []preferences.PreferenceValueItem
for _, p := range preferences.DefaultPreferences() {
p := p
var v *string
if p.Value != nil {
v = &p.Value.Value
Expand All @@ -405,7 +406,7 @@ func ExecuteContext(ctx context.Context) {
Service: p.Service,
Key: p.Key,
Value: v,
Pinned: p.Pinned,
Pinned: &p.Pinned,
})
}
out, err := yaml.Marshal(preferences.PreferencesYamlFile{Preferences: items})
Expand Down
32 changes: 32 additions & 0 deletions docs/how-to-gcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
This document explains how to optimize gcp compute instances

## 1. Have the following Software Installed

1. Kaytu CLI


## 2. Login to kaytu CLI
`kaytu login`

Install CLI plugin:

kaytu plugin install gcp


## 4. Create a Service Account

Create a service account with the following roles:
1. Cloud Billing
2. Compute Engine

## 5. Create Key and store credentials file

## 6. Export credentials file path

Export credentials file path in the environment variable

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"

## 7. Run optimization Check

> kaytu optimize compute-instance
14 changes: 8 additions & 6 deletions preferences/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
)

type PreferencesYamlFile struct {
Preferences []PreferenceValueItem
Preferences []PreferenceValueItem `yaml:"preferences"`
}

type PreferenceValueItem struct {
Service string
Key string
Value *string
Pinned bool `yaml:"pinned,omitempty"`
Service string `yaml:"service"`
Key string `yaml:"key"`
Value *string `yaml:"value,omitempty"`
Pinned *bool `yaml:"pinned,omitempty"`
}

var (
Expand Down Expand Up @@ -47,7 +47,9 @@ func UpdateValues(pis []PreferenceValueItem) error {
} else {
defaultPref[idx].Value = wrapperspb.String(*pi.Value)
}
defaultPref[idx].Pinned = pi.Pinned
if pi.Pinned != nil {
defaultPref[idx].Pinned = *pi.Pinned
}
found = true
break
}
Expand Down

0 comments on commit cb0b52b

Please sign in to comment.