Skip to content

Commit 2ec911e

Browse files
authored
feat(sidekick): run gcloud.Generate (#2586)
This change adds a boilerplate gcloud.Generate function and integrates it into the sidekick refresh flow. Logic related to the gcloud.yaml file is moved into a new internal/config/gcloud/ package, since it must be part of the config.Config struct to be passed into Generate, and to avoid a dependency cycle, since config.Config is imported by internal/gcloud.
1 parent 6ea6d31 commit 2ec911e

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

internal/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"path"
2727
"strings"
2828

29+
"github.com/googleapis/google-cloud-rust/generator/internal/config/gcloudyaml"
2930
"github.com/googleapis/google-cloud-rust/generator/internal/license"
3031
toml "github.com/pelletier/go-toml/v2"
3132
)
@@ -55,6 +56,10 @@ type Config struct {
5556
Source map[string]string `toml:"source,omitempty"`
5657
Codec map[string]string `toml:"codec,omitempty"`
5758
CommentOverrides []DocumentationOverride `toml:"documentation-overrides,omitempty"`
59+
60+
// Gcloud is used to pass data into gcloud.Generate. It does not use the
61+
// normal .sidekick.toml file, but instead reads a gcloud.yaml file.
62+
Gcloud *gcloudyaml.Config
5863
}
5964

6065
// Configuration parameters that affect Parsers and Codecs, including the
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package gcloud
15+
package gcloudyaml
1616

1717
// Config represents the top-level schema of a gcloud config YAML file.
1818
type Config struct {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package gcloud
15+
package gcloudyaml
1616

1717
import (
1818
"bytes"
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
func TestGcloudConfig(t *testing.T) {
28-
data, err := os.ReadFile("testdata/parallelstore/gcloud.yaml")
28+
data, err := os.ReadFile("testdata/gcloud.yaml")
2929
if err != nil {
3030
t.Fatalf("failed to read temporary YAML file: %v", err)
3131
}
File renamed without changes.

internal/gcloud/command.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414

1515
package gcloud
1616

17+
import "github.com/googleapis/google-cloud-rust/generator/internal/config/gcloudyaml"
18+
1719
type Command struct {
18-
ReleaseTracks []ReleaseTrack `yaml:"release_tracks,omitempty"`
19-
Autogenerated bool `yaml:"auto_generated,omitempty"`
20-
Hidden bool `yaml:"hidden,omitempty"`
21-
HelpText *CommandHelpText `yaml:"help_text,omitempty"`
22-
Arguments *Arguments `yaml:"arguments,omitempty"`
23-
Request *Request `yaml:"request,omitempty"`
24-
Response *Response `yaml:"response,omitempty"`
25-
Async *Async `yaml:"async,omitempty"`
20+
ReleaseTracks []gcloudyaml.ReleaseTrack `yaml:"release_tracks,omitempty"`
21+
Autogenerated bool `yaml:"auto_generated,omitempty"`
22+
Hidden bool `yaml:"hidden,omitempty"`
23+
HelpText *CommandHelpText `yaml:"help_text,omitempty"`
24+
Arguments *Arguments `yaml:"arguments,omitempty"`
25+
Request *Request `yaml:"request,omitempty"`
26+
Response *Response `yaml:"response,omitempty"`
27+
Async *Async `yaml:"async,omitempty"`
2628
}
2729

2830
type Arguments struct {

internal/gcloud/generate.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package gcloud
16+
17+
import (
18+
"github.com/googleapis/google-cloud-rust/generator/internal/api"
19+
"github.com/googleapis/google-cloud-rust/generator/internal/config"
20+
)
21+
22+
func Generate(model *api.API, outdir string, cfg *config.Config) error {
23+
return nil
24+
}

internal/sidekick/refresh.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/googleapis/google-cloud-rust/generator/internal/codec_sample"
2323
"github.com/googleapis/google-cloud-rust/generator/internal/config"
2424
"github.com/googleapis/google-cloud-rust/generator/internal/dart"
25+
"github.com/googleapis/google-cloud-rust/generator/internal/gcloud"
2526
"github.com/googleapis/google-cloud-rust/generator/internal/golang"
2627
"github.com/googleapis/google-cloud-rust/generator/internal/parser"
2728
"github.com/googleapis/google-cloud-rust/generator/internal/rust"
@@ -110,6 +111,8 @@ func refreshDir(rootConfig *config.Config, cmdLine *CommandLine, output string)
110111
return dart.Generate(model, output, config)
111112
case "sample":
112113
return codec_sample.Generate(model, output, config)
114+
case "gcloud":
115+
return gcloud.Generate(model, output, config)
113116
default:
114117
return fmt.Errorf("unknown language: %s", config.General.Language)
115118
}

0 commit comments

Comments
 (0)