MCPcopy Index your code
hub / github.com/coder/coder / deterministicAppIDs

Function deterministicAppIDs

provisioner/terraform/resources_test.go:1868–1885  ·  view source on GitHub ↗

deterministicAppIDs handles setting agent app ids to something deterministic. In plan files, ids are not present. In state files, they are. It is simpler for comparisons if we just set it to something deterministic.

(resources []*proto.Resource)

Source from the content-addressed store, hash-verified

1866// In plan files, ids are not present. In state files, they are.
1867// It is simpler for comparisons if we just set it to something deterministic.
1868func deterministicAppIDs(resources []*proto.Resource) {
1869 for _, resource := range resources {
1870 for _, agent := range resource.Agents {
1871 for _, app := range agent.Apps {
1872 data := sha256.Sum256([]byte(app.Slug + app.DisplayName))
1873 id, _ := uuid.FromBytes(data[:16])
1874 app.Id = id.String()
1875 }
1876 for _, dc := range agent.Devcontainers {
1877 for _, app := range dc.Apps {
1878 data := sha256.Sum256([]byte(app.Slug + app.DisplayName))
1879 id, _ := uuid.FromBytes(data[:16])
1880 app.Id = id.String()
1881 }
1882 }
1883 }
1884 }
1885}

Callers 2

TestConvertStateGoldenFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected