Skip to content

Commit 3a38021

Browse files
Merge pull request #48 from dineshgowda24/prerelease
- Finish all release preps
2 parents eed7523 + c3a5375 commit 3a38021

File tree

9 files changed

+113
-32
lines changed

9 files changed

+113
-32
lines changed

gcloud/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"log"
87
"os/exec"
98
"strings"
109

1110
"github.com/dineshgowda24/alfred-gcp-workflow/workflow/config"
11+
"github.com/dineshgowda24/alfred-gcp-workflow/workflow/log"
1212
)
1313

1414
func runGCloudCmd[T any](cfg *Config, cmd string, extraArgs ...string) (T, error) {
@@ -19,7 +19,7 @@ func runGCloudCmd[T any](cfg *Config, cmd string, extraArgs ...string) (T, error
1919
cmdExec := exec.Command(config.GetGCloudPath(), args...)
2020
cmdExec.Stderr = &stderr
2121

22-
log.Println("gcloud command:", cmdExec.String())
22+
log.Info("gcloud command:", cmdExec.String())
2323
raw, err := cmdExec.Output()
2424
if err != nil {
2525
return out, fmt.Errorf("gcloud command failed: %s", stderr.String())

info.plist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>bundleid</key>
6-
<string>dineshgowda.gcp</string>
6+
<string>com.dineshchikkanna.alfred.gcp</string>
77
<key>category</key>
88
<string>Productivity</string>
99
<key>connections</key>
@@ -132,7 +132,7 @@
132132
<key>argumenttype</key>
133133
<integer>1</integer>
134134
<key>escaping</key>
135-
<integer>7</integer>
135+
<integer>32</integer>
136136
<key>keyword</key>
137137
<string>gcp</string>
138138
<key>queuedelaycustom</key>
@@ -146,7 +146,7 @@
146146
<key>runningsubtext</key>
147147
<string>Please Wait</string>
148148
<key>script</key>
149-
<string>./alfred-gcp-workflow --query={query}</string>
149+
<string>./alfred-gcp-workflow --query="{query}"</string>
150150
<key>scriptargtype</key>
151151
<integer>0</integer>
152152
<key>scriptfile</key>
@@ -213,7 +213,7 @@
213213
214214
An Alfred workflow to quickly open GCP services in your browser or search GCP resources with ease.
215215
216-
More more info visit: https://github.com/dineshgowda24/alfred-gcp-workflow</string>
216+
More info visit: https://github.com/dineshgowda24/alfred-gcp-workflow</string>
217217
<key>uidata</key>
218218
<dict>
219219
<key>1B2C4A00-09E5-472C-84C9-ABC4017DBA62</key>
@@ -257,13 +257,13 @@ More more info visit: https://github.com/dineshgowda24/alfred-gcp-workflow</stri
257257
<key>variables</key>
258258
<dict>
259259
<key>ALFRED_GCP_WORKFLOW_CACHE_TTL_SECONDS</key>
260-
<string>172800</string>
260+
<string>604800</string>
261261
</dict>
262262
<key>variablesdontexport</key>
263263
<array/>
264264
<key>version</key>
265-
<string>v0.1.0-beta</string>
265+
<string>v0.0.1</string>
266266
<key>webaddress</key>
267-
<string>https://dineshgowda.com</string>
267+
<string>https://github.com/dineshgowda24/alfred-gcp-workflow</string>
268268
</dict>
269269
</plist>

orchestrator/home.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func (h *HomeHandler) Handle(ctx *Context) error {
7070
Subtitle: "🔩 Use @ to override gcloud config",
7171
Icon: aw.IconAccount,
7272
Valid: false,
73+
AutoComplete: "@",
74+
Arg: "@",
7375
SortPriority: 4,
7476
})
7577

@@ -79,6 +81,8 @@ func (h *HomeHandler) Handle(ctx *Context) error {
7981
Subtitle: "🗺️ Use `$` to override region",
8082
Icon: aw.IconNetwork,
8183
Valid: false,
84+
AutoComplete: "$",
85+
Arg: "$",
8286
SortPriority: 5,
8387
})
8488
} else {
@@ -87,6 +91,8 @@ func (h *HomeHandler) Handle(ctx *Context) error {
8791
Subtitle: "🗺️ Use `$` to override region",
8892
Icon: aw.IconNetwork,
8993
Valid: false,
94+
AutoComplete: "$",
95+
Arg: "$",
9096
SortPriority: 6,
9197
})
9298
}

orchestrator/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
const (
11-
contributingURL = "https://github.com/dineshgowda24/alfred-gcp-workflow/CONTRIBUTING.md"
11+
contributingURL = "https://github.com/dineshgowda24/alfred-gcp-workflow/blob/main/CONTRIBUTING.md"
1212
)
1313

1414
func buildAutocomplete(ctx *Context, service *services.Service) string {

parser/query.go

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

33
import (
4-
"log"
54
"strings"
65

76
"github.com/dineshgowda24/alfred-gcp-workflow/gcloud"
87
"github.com/dineshgowda24/alfred-gcp-workflow/services"
98
"github.com/dineshgowda24/alfred-gcp-workflow/workflow/arg"
9+
"github.com/dineshgowda24/alfred-gcp-workflow/workflow/log"
1010
)
1111

1212
type Result struct {
@@ -99,7 +99,7 @@ func (r *Result) extractConfig(words []string) []string {
9999
func (r *Result) matchConfig(name string) {
100100
configs, err := gcloud.GetAllConfigs()
101101
if err != nil {
102-
log.Println("error fetching configs:", err)
102+
log.Error("error fetching configs:", err)
103103
r.PartialConfigQuery = name
104104
return
105105
}

searchers/searcher.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import (
2020
"github.com/dineshgowda24/alfred-gcp-workflow/services"
2121
)
2222

23+
// Searcher is an interface for searching GCP resources.
2324
type Searcher interface {
2425
Search(wf *aw.Workflow, svc *services.Service, config *gcloud.Config, pq *parser.Result) error
2526
}
2627

28+
// Registry contains the map of all the searchers.
2729
type Registry struct {
2830
lookup map[string]Searcher
2931
}
@@ -46,32 +48,33 @@ func (r *Registry) Exists(parent, child *services.Service) bool {
4648
return ok
4749
}
4850

51+
// GetDefaultRegistry returns a default registry with all the searchers registered.
4952
func GetDefaultRegistry() *Registry {
5053
return &Registry{
5154
lookup: map[string]Searcher{
55+
"artifactregistry/repositories": &artifactregistry.RepositorySearcher{},
56+
"cloudrun/functions": &cloudrun.FunctionSearcher{},
57+
"cloudrun/services": &cloudrun.ServiceSearcher{},
5258
"cloudsql/instances": &sql.InstanceSearcher{},
53-
"memorystore/redis": &memorystore.RedisInstanceSearcher{},
54-
"pubsub/topics": &pubsub.TopicSearcher{},
55-
"pubsub/subscriptions": &pubsub.SubscriptionSearcher{},
56-
"storage/buckets": &storage.BucketSearcher{},
57-
"compute/instances": &compute.InstanceSearcher{},
59+
"cloudtasks/queues": &cloudtask.QueueSearcher{},
5860
"compute/disks": &compute.DiskSearcher{},
5961
"compute/images": &compute.ImageSearcher{},
62+
"compute/instances": &compute.InstanceSearcher{},
6063
"compute/instancetemplates": &compute.InstanceTmplSearcher{},
6164
"compute/machineimages": &compute.MachineImageSearcher{},
6265
"compute/snapshots": &compute.SnapshotSearcher{},
63-
"gke/clusters": &k8s.ClusterSearcher{},
6466
"filestore/instances": &filestore.InstanceSearcher{},
67+
"gke/clusters": &k8s.ClusterSearcher{},
68+
"memorystore/redis": &memorystore.RedisInstanceSearcher{},
69+
"netconnectivity/cloudrouter": &netconnectivity.CloudRouterSearcher{},
70+
"netconnectivity/vpngateway": &netconnectivity.VPNGatewaySearcher{},
71+
"netconnectivity/vpntunnel": &netconnectivity.VPNTunnelSearcher{},
6572
"netservices/dns": &netservices.DNSZoneSearcher{},
73+
"pubsub/subscriptions": &pubsub.SubscriptionSearcher{},
74+
"pubsub/topics": &pubsub.TopicSearcher{},
75+
"storage/buckets": &storage.BucketSearcher{},
6676
"vpc/networks": &vpc.NetworkSearcher{},
6777
"vpc/routes": &vpc.RouteSearcher{},
68-
"netconnectivity/vpntunnel": &netconnectivity.VPNTunnelSearcher{},
69-
"netconnectivity/vpngateway": &netconnectivity.VPNGatewaySearcher{},
70-
"netconnectivity/cloudrouter": &netconnectivity.CloudRouterSearcher{},
71-
"artifactregistry/repositories": &artifactregistry.RepositorySearcher{},
72-
"cloudrun/services": &cloudrun.ServiceSearcher{},
73-
"cloudrun/functions": &cloudrun.FunctionSearcher{},
74-
"cloudtasks/queues": &cloudtask.QueueSearcher{},
7578
},
7679
}
7780
}

services/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package services
33
import (
44
"bytes"
55
"embed"
6-
"log"
76
"path/filepath"
87
"text/template"
98

109
aw "github.com/deanishe/awgo"
1110
"github.com/dineshgowda24/alfred-gcp-workflow/gcloud"
11+
"github.com/dineshgowda24/alfred-gcp-workflow/workflow/log"
1212
"gopkg.in/yaml.v2"
1313
)
1414

@@ -54,13 +54,13 @@ func (s *Service) Icon() *aw.Icon {
5454
func (s *Service) Url(config *gcloud.Config) (string, error) {
5555
t, err := template.New("url").Parse(s.URL)
5656
if err != nil {
57-
log.Printf("error parsing template for service %s: %v\n", s.Name, err)
57+
log.Errorf("error parsing template for service %s: %v", s.Name, err)
5858
return "", err
5959
}
6060

6161
var buf bytes.Buffer
6262
if err := t.Execute(&buf, config); err != nil {
63-
log.Printf("error executing template for service %s: %v\n", s.Name, err)
63+
log.Errorf("error executing template for service %s: %v", s.Name, err)
6464
return "", err
6565
}
6666
return buf.String(), nil

tools/release.sh

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
set -euo pipefail
33

44
RELEASE_DIR="$(pwd)/release/"
5-
PACKAGE_NAME="alfred-gcp-workflow.alfredworkflow"
5+
PKG_DIR="$(pwd)"
6+
PACKAGE_NAME="$PKG_DIR/alfred-gcp-workflow.alfredworkflow"
7+
BUNDLE_ID="com.dineshchikkanna.alfred.gcp"
68

79
bold() { echo -e "\033[1m$1\033[0m"; }
810
green() { echo -e "\033[32m$1\033[0m"; }
@@ -97,6 +99,30 @@ copy_assets() {
9799
cp -R assets services.yml regions.yml icon.png info.plist LICENSE README.md "$RELEASE_DIR"
98100
}
99101

102+
code_sign() {
103+
bold "Code signing the workflow..."
104+
cd "$RELEASE_DIR" || exit 1
105+
106+
if [[ $SHOULD_TAG != "y" && $SHOULD_TAG != "Y" ]]; then
107+
yellow "⚡ Skipping code signing as no tag was created."
108+
return
109+
fi
110+
111+
if [[ -z "${APPLE_DEVELOPER_ID_CERT_ID:-}" ]]; then
112+
red "❌ Missing Apple Developer ID Certificate ID. Please set the APPLE_DEVELOPER_ID_CERT_ID environment variable."
113+
exit 1
114+
fi
115+
116+
codesign -s "$APPLE_DEVELOPER_ID_CERT_ID" -f -v --timestamp --options runtime ./alfred-gcp-workflow
117+
if [[ $? -ne 0 ]]; then
118+
red "❌ Code signing failed. Please ensure you have a valid code signing identity."
119+
exit 1
120+
fi
121+
122+
green "✔️ Code signed successfully."
123+
cd "$PKG_DIR" || exit 1
124+
}
125+
100126
package_workflow() {
101127
bold "Packaging .alfredworkflow file..."
102128
ditto -ck "$RELEASE_DIR" "$PACKAGE_NAME"
@@ -109,6 +135,33 @@ zip_workflow() {
109135
green "✔️ Zipped workflow."
110136
}
111137

138+
notarize_app() {
139+
bold "Notarizing the build..."
140+
141+
if [[ $SHOULD_TAG != "y" && $SHOULD_TAG != "Y" ]]; then
142+
yellow "⚡ Skipping notarization as no tag was created."
143+
return
144+
fi
145+
146+
if [[ -z "${APPLE_ID:-}" || -z "${APPLE_TEAM_ID:-}" || -z "${APPLE_DEVELOPER_APP_PASSWORD:-}" ]]; then
147+
red "❌ Missing Apple ID, Team ID, or Developer App Password. Please set these environment variables."
148+
exit 1
149+
fi
150+
151+
xcrun notarytool submit "${PACKAGE_NAME}.zip" \
152+
--wait \
153+
--apple-id "$APPLE_ID" \
154+
--team-id "$APPLE_TEAM_ID" \
155+
--password "$APPLE_DEVELOPER_APP_PASSWORD"
156+
157+
if [[ $? -ne 0 ]]; then
158+
red "❌ Notarization failed. Please check your credentials and try again."
159+
exit 1
160+
fi
161+
162+
green "✔️ Notarization completed successfully."
163+
}
164+
112165
open_github_release_page() {
113166
bold "Opening GitHub release page for tag ${VERSION}..."
114167
open "https://github.com/dineshgowda24/alfred-gcp-workflow/releases/new?tag=${VERSION}&title=${VERSION}&body=%23%23%20Changes%0A%0AUser-facing%0A-%20TODO"
@@ -134,8 +187,10 @@ main() {
134187
merge_binaries
135188
clean_intermediate_binaries
136189
copy_assets
190+
code_sign
137191
package_workflow
138192
zip_workflow
193+
notarize_app
139194
show_files
140195
open_github_release_page
141196
open_finder

workflow/resource/resource.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ func (b *Builder[T]) store() error {
105105

106106
data, err := b.fetch(b.cfg)
107107
if err != nil {
108-
b.wf.Cache.Store(b.errKey(), []byte(err.Error()))
108+
msg := UXMsg{
109+
Error: err.Error(),
110+
}
111+
b.wf.Cache.StoreJSON(b.errKey(), &msg)
109112
return err
110113
}
111114
return b.wf.Cache.StoreJSON(b.cacheKey(), data)
@@ -169,17 +172,31 @@ func (b *Builder[T]) showCachedErr() bool {
169172

170173
title := msg.Title
171174
icon := aw.IconInfo
175+
subtitle := msg.Subtitle
172176
if msg.Error != "" {
173-
title = msg.Error
177+
title = "🔔 Error fetching resources"
178+
subtitle = "<CMD> + l to view error details"
174179
icon = aw.IconError
175180
}
176181

177182
b.wf.NewItem(title).
178-
Subtitle(msg.Subtitle).
183+
Subtitle(subtitle).
179184
Icon(icon).
180185
Arg("").
181186
Valid(false).
187+
Largetype(msg.Error).
182188
Autocomplete("")
189+
190+
if msg.Error != "" {
191+
errorFilePath := filepath.Join(b.wf.CacheDir(), b.errKey())
192+
b.wf.NewFileItem("📂 View full error file").
193+
Subtitle("<CTRL> to open file options").
194+
Icon(aw.IconInfo).
195+
IsFile(true).
196+
Arg(errorFilePath).
197+
Valid(true)
198+
199+
}
183200
b.wf.SendFeedback()
184201
return true
185202
}

0 commit comments

Comments
 (0)