Skip to content

Commit

Permalink
fixup! feat: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
miton18 committed Jul 3, 2024
1 parent 78022d1 commit e7cb895
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
4 changes: 2 additions & 2 deletions docs/resources/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
page_title: "clevercloud_docker Resource - terraform-provider-clevercloud"
subcategory: ""
description: |-
Manage Docker https:// applications.
Manage Docker https://www.docker.com/ applications.
See Docker product https://www.clever-cloud.com/doc/getting-started/by-language/docker/ specification.
---

# clevercloud_docker (Resource)

Manage [Docker](https://) applications.
Manage [Docker](https://www.docker.com/) applications.

See [Docker product](https://www.clever-cloud.com/doc/getting-started/by-language/docker/) specification.

Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/docker/resource_docker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manage [Docker](https://) applications.
Manage [Docker](https://www.docker.com/) applications.

See [Docker product](https://www.clever-cloud.com/doc/getting-started/by-language/docker/) specification.
26 changes: 13 additions & 13 deletions pkg/resources/docker/resource_docker_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,32 @@ func (r *ResourceDocker) Read(ctx context.Context, req resource.ReadRequest, res
return
}

appPHP, diags := application.ReadApp(ctx, r.cc, r.org, state.ID.ValueString())
app, diags := application.ReadApp(ctx, r.cc, r.org, state.ID.ValueString())
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
if appPHP.AppIsDeleted {
if app.AppIsDeleted {
resp.State.RemoveResource(ctx)
return
}

state.Name = pkg.FromStr(appPHP.App.Name)
state.Description = pkg.FromStr(appPHP.App.Description)
state.MinInstanceCount = pkg.FromI(int64(appPHP.App.Instance.MinInstances))
state.MaxInstanceCount = pkg.FromI(int64(appPHP.App.Instance.MaxInstances))
state.SmallestFlavor = pkg.FromStr(appPHP.App.Instance.MinFlavor.Name)
state.BiggestFlavor = pkg.FromStr(appPHP.App.Instance.MaxFlavor.Name)
state.Region = pkg.FromStr(appPHP.App.Zone)
state.DeployURL = pkg.FromStr(appPHP.App.DeployURL)
state.Name = pkg.FromStr(app.App.Name)
state.Description = pkg.FromStr(app.App.Description)
state.MinInstanceCount = pkg.FromI(int64(app.App.Instance.MinInstances))
state.MaxInstanceCount = pkg.FromI(int64(app.App.Instance.MaxInstances))
state.SmallestFlavor = pkg.FromStr(app.App.Instance.MinFlavor.Name)
state.BiggestFlavor = pkg.FromStr(app.App.Instance.MaxFlavor.Name)
state.Region = pkg.FromStr(app.App.Zone)
state.DeployURL = pkg.FromStr(app.App.DeployURL)

if appPHP.App.SeparateBuild {
state.BuildFlavor = pkg.FromStr(appPHP.App.BuildFlavor.Name)
if app.App.SeparateBuild {
state.BuildFlavor = pkg.FromStr(app.App.BuildFlavor.Name)
} else {
state.BuildFlavor = types.StringNull()
}

vhosts := pkg.Map(appPHP.App.Vhosts, func(vhost tmp.Vhost) string {
vhosts := pkg.Map(app.App.Vhosts, func(vhost tmp.Vhost) string {
return vhost.Fqdn
})
hasDefaultVHost := pkg.HasSome(vhosts, func(vhost string) bool {
Expand Down
15 changes: 3 additions & 12 deletions pkg/resources/docker/resource_docker_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ type Docker struct {
}

//go:embed resource_docker.md
var phpDoc string
var dockerDoc string

func (r ResourceDocker) Schema(ctx context.Context, req resource.SchemaRequest, res *resource.SchemaResponse) {
res.Schema = schema.Schema{
Version: 0,
MarkdownDescription: phpDoc,
MarkdownDescription: dockerDoc,
Attributes: attributes.WithRuntimeCommons(map[string]schema.Attribute{
"dockerfile": schema.StringAttribute{
Optional: true,
Expand Down Expand Up @@ -126,16 +126,7 @@ func (p *Docker) toEnv(ctx context.Context, diags diag.Diagnostics) map[string]s

pkg.IfIsSet(p.AppFolder, func(s string) { env["APP_FOLDER"] = s })

/*
CC_DOCKERFILE . Dockerfile
CC_DOCKER_EXPOSED_HTTP_PORT Set to custom HTTP port if your Docker container runs on custom port. 8080
CC_DOCKER_EXPOSED_TCP_PORT Set to custom TCP port if your Docker container runs on custom port. 4040
CC_DOCKER_FIXED_CIDR_V6 Activate the support of IPv6 with an IPv6 subnet int the docker daemon.
CC_DOCKER_LOGIN_PASSWORD The password of your username.
CC_DOCKER_LOGIN_SERVER The server of your private registry (optional). Docker’s public registry
CC_DOCKER_LOGIN_USERNAME The username to login to a private registry.
CC_MOUNT_DOCKER_SOCKET Set to true to access the host Docker socket from inside your container. false
*/
// Docker specific
pkg.IfIsSet(p.Dockerfile, func(s string) { env["CC_DOCKERFILE"] = s })
pkg.IfIsSetI(p.ContainerPort, func(i int64) { env["CC_DOCKER_EXPOSED_HTTP_PORT"] = fmt.Sprintf("%d", i) })
pkg.IfIsSetI(p.ContainerPortTCP, func(i int64) { env["CC_DOCKER_EXPOSED_TCP_PORT"] = fmt.Sprintf("%d", i) })
Expand Down

0 comments on commit e7cb895

Please sign in to comment.