Skip to content

Commit ed59d5d

Browse files
committed
feat(config): add configuration management and default registry URL
chore(ci): update Go version to 1.22 in CI workflows
1 parent 0188a4d commit ed59d5d

4 files changed

Lines changed: 60 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Go
2626
uses: actions/setup-go@v6
2727
with:
28-
go-version: '1.21'
28+
go-version: '1.22'
2929
cache: true
3030

3131
- name: Download dependencies
@@ -56,7 +56,7 @@ jobs:
5656
- name: Set up Go
5757
uses: actions/setup-go@v6
5858
with:
59-
go-version: '1.21'
59+
go-version: '1.22'
6060
cache: true
6161

6262
- name: Run golangci-lint
@@ -79,7 +79,7 @@ jobs:
7979
- name: Set up Go
8080
uses: actions/setup-go@v6
8181
with:
82-
go-version: '1.21'
82+
go-version: '1.22'
8383
cache: true
8484

8585
- name: Build

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Go
3030
uses: actions/setup-go@v6
3131
with:
32-
go-version: '1.21'
32+
go-version: '1.22'
3333
cache: true
3434

3535
- name: Get version

internal/config/config.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package config
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
)
7+
8+
// Config holds the configuration for the SDK manager
9+
type Config struct {
10+
ConfigDir string
11+
CacheDir string
12+
InstallDir string
13+
RegistryURL string
14+
}
15+
16+
// New creates a new configuration with default values
17+
func New() (*Config, error) {
18+
homeDir, err := os.UserHomeDir()
19+
if err != nil {
20+
return nil, err
21+
}
22+
23+
configDir := filepath.Join(homeDir, ".unosdk")
24+
cacheDir := filepath.Join(configDir, "cache")
25+
installDir := filepath.Join(configDir, "sdks")
26+
27+
return &Config{
28+
ConfigDir: configDir,
29+
CacheDir: cacheDir,
30+
InstallDir: installDir,
31+
RegistryURL: DefaultRegistryURL,
32+
}, nil
33+
}
34+
35+
// EnsureDirectories creates necessary directories if they don't exist
36+
func (c *Config) EnsureDirectories() error {
37+
dirs := []string{
38+
c.ConfigDir,
39+
c.CacheDir,
40+
c.InstallDir,
41+
}
42+
43+
for _, dir := range dirs {
44+
if err := os.MkdirAll(dir, 0755); err != nil {
45+
return err
46+
}
47+
}
48+
49+
return nil
50+
}

internal/config/defaults.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package config
2+
3+
const (
4+
// DefaultRegistryURL is the default registry URL for SDK metadata
5+
DefaultRegistryURL = "https://api.github.com/repos/javaquery/unosdk-registry"
6+
)

0 commit comments

Comments
 (0)