Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: persist generatedcoder_app id#18487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dannykopping wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromdk/app-id
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioncoderd/agentapi/apps.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ func (a *AppsAPI) BatchUpdateAppHealths(ctx context.Context, req *agentproto.Bat
Health: app.Health,
})
if err != nil {
return nil, xerrors.Errorf("update workspace app health for app %q (%q): %w",err,app.ID, app.Slug)
return nil, xerrors.Errorf("update workspace app health for app %q (%q): %w", app.ID, app.Slug, err)
}
}

Expand Down
13 changes: 12 additions & 1 deletioncoderd/provisionerdserver/provisionerdserver.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2595,8 +2595,19 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
openIn = database.WorkspaceAppOpenInSlimWindow
}

var appID string
if app.Id == "" || app.Id == uuid.Nil.String() {
appID = uuid.NewString()
} else {
appID = app.Id
}
id, err := uuid.Parse(appID)
if err != nil {
return xerrors.Errorf("parse app uuid: %w", err)
}

dbApp, err := db.InsertWorkspaceApp(ctx, database.InsertWorkspaceAppParams{
ID:uuid.New(),
ID:id,
CreatedAt: dbtime.Now(),
AgentID: dbAgent.ID,
Slug: slug,
Expand Down
12 changes: 12 additions & 0 deletionsprovisioner/terraform/resources.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ import (
"strings"

"github.com/awalterschulze/gographviz"
"github.com/google/uuid"
tfjson "github.com/hashicorp/terraform-json"
"github.com/mitchellh/mapstructure"
"golang.org/x/xerrors"
Expand DownExpand Up@@ -93,6 +94,7 @@ type agentDisplayAppsAttributes struct {

// A mapping of attributes on the "coder_app" resource.
type agentAppAttributes struct {
ID string `mapstructure:"id"`
AgentID string `mapstructure:"agent_id"`
// Slug is required in terraform, but to avoid breaking existing users we
// will default to the resource name if it is not specified.
Expand DownExpand Up@@ -522,7 +524,17 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
continue
}

id := attrs.ID
if id == "" {
// This should never happen since the "id" attribute is set on creation:
// https://github.com/coder/terraform-provider-coder/blob/cfa101df4635e405e66094fa7779f9a89d92f400/provider/app.go#L37
logger.Warn(ctx, "coder_app's id was unexpectedly empty", slog.F("name", attrs.Name))

id = uuid.NewString()
}

agent.Apps = append(agent.Apps, &proto.App{
Id: id,
Slug: attrs.Slug,
DisplayName: attrs.DisplayName,
Command: attrs.Command,
Expand Down
6 changes: 6 additions & 0 deletionsprovisioner/terraform/resources_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -967,6 +967,9 @@ func TestConvertResources(t *testing.T) {
if agent.GetInstanceId() != "" {
agent.Auth = &proto.Agent_InstanceId{}
}
for _, app := range agent.Apps {
app.Id = ""
}
}
}

Expand DownExpand Up@@ -1037,6 +1040,9 @@ func TestConvertResources(t *testing.T) {
if agent.GetInstanceId() != "" {
agent.Auth = &proto.Agent_InstanceId{}
}
for _, app := range agent.Apps {
app.Id = ""
}
}
}
// Convert expectedNoMetadata and resources into a
Expand Down
1 change: 1 addition & 0 deletionsprovisionerd/proto/version.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ import "github.com/coder/coder/v2/apiversion"
// - Add new field named `scheduling` to `Prebuild`, with fields for timezone
// and schedule rules to define cron-based scaling of prebuilt workspace
// instances based on time patterns.
// - Added new field named `id` to `App`, which transports the ID generated by the coder_app provider to be persisted.
const (
CurrentMajor = 1
CurrentMinor = 7
Expand Down
13 changes: 11 additions & 2 deletionsprovisionersdk/proto/provisioner.pb.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionsprovisionersdk/proto/provisioner.proto
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,6 +266,7 @@ message App {
bool hidden = 11;
AppOpenIn open_in = 12;
string group = 13;
string id = 14;
}

// Healthcheck represents configuration for checking for app readiness.
Expand Down
4 changes: 4 additions & 0 deletionssite/e2e/provisionerGenerated.ts
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionssite/e2e/tests/app.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,6 +42,7 @@ test("app", async ({ context, page }) => {
token,
apps: [
{
id: randomUUID(),
url: `http://localhost:${addr.port}`,
displayName: appName,
order: 0,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp