Skip to content

Commit

Permalink
Merge pull request #367 from slingdata-io/v1.2.17
Browse files Browse the repository at this point in the history
V1.2.17
  • Loading branch information
flarco authored Aug 28, 2024
2 parents 0fdce18 + 740de17 commit c424f5b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cmd/sling/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ COPY --chown=sling:sling sling /usr/local/bin/sling
RUN chmod 755 /usr/local/bin/sling

# Switch to non-root user
RUN mkdir -p /home/sling && chmod 755 /home/sling && chown sling:sling /home/sling
USER sling

# Final ENV updates
ENV DBUS_SESSION_BUS_ADDRESS="/dev/null"
ENV ORACLE_HOME="/usr/lib/oracle/19.3/client64"
ENV LD_LIBRARY_PATH="/usr/lib/oracle/19.3/client64/lib"
ENV PATH="${PATH}:/usr/local/go/bin:/root/go/bin:/opt/mssql-tools/bin:/usr/lib/oracle/19.3/client64/bin"
Expand Down
2 changes: 2 additions & 0 deletions cmd/sling/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ COPY --chown=sling:sling sling /usr/local/bin/sling
RUN chmod 755 /usr/local/bin/sling

# Switch to non-root user
RUN mkdir -p /home/sling && chmod 755 /home/sling && chown sling:sling /home/sling
USER sling

# Final ENV updates
ENV DBUS_SESSION_BUS_ADDRESS="/dev/null"
ENV ORACLE_HOME="/opt/oracle/instantclient_19_19"
ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_19_19"
ENV PATH="${PATH}:/usr/local/go/bin:/root/go/bin:/opt/oracle/instantclient_19_19:/opt/mssql-tools18/bin"
Expand Down
6 changes: 4 additions & 2 deletions core/dbio/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func (c *Connection) AsDatabase(cache ...bool) (dc database.Connection, err erro
return nil, g.Error("not a database type: %s", c.Type)
}

if len(cache) > 0 && cache[0] {
// default cache to true
if len(cache) == 0 || (len(cache) > 0 && cache[0]) {
if c.Database == nil {
c.Database, err = database.NewConnContext(
c.Context().Ctx, c.URL(), g.MapToKVArr(c.DataS())...,
Expand All @@ -286,7 +287,8 @@ func (c *Connection) AsFile(cache ...bool) (fc filesys.FileSysClient, err error)
return nil, g.Error("not a file system type: %s", c.Type)
}

if len(cache) > 0 && cache[0] {
// default cache to true
if len(cache) == 0 || (len(cache) > 0 && cache[0]) {
if c.File == nil {
c.File, err = filesys.NewFileSysClientFromURLContext(
c.Context().Ctx, c.URL(), g.MapToKVArr(c.DataS())...,
Expand Down
4 changes: 0 additions & 4 deletions core/dbio/connection/connection_discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (c *Connection) Test() (ok bool, err error) {
if err != nil {
return ok, g.Error(err, "could not connect to %s", c.Name)
}
defer dbConn.Close()
case c.Type.IsFile():
fileClient, err := c.AsFile()
if err != nil {
Expand All @@ -36,7 +35,6 @@ func (c *Connection) Test() (ok bool, err error) {
if err != nil {
return ok, g.Error(err, "could not connect to %s", c.Name)
}
defer fileClient.Close()

url := c.URL()

Expand Down Expand Up @@ -97,7 +95,6 @@ func (c *Connection) Discover(opt *DiscoverOptions) (ok bool, nodes filesys.File
if err != nil {
return ok, nodes, schemata, g.Error(err, "could not connect to %s", c.Name)
}
defer dbConn.Close()

var table database.Table
if opt.Pattern != "" {
Expand Down Expand Up @@ -142,7 +139,6 @@ func (c *Connection) Discover(opt *DiscoverOptions) (ok bool, nodes filesys.File
if err != nil {
return ok, nodes, schemata, g.Error(err, "could not connect to %s", c.Name)
}
defer fileClient.Close()

url := c.URL()
if opt.Pattern != "" {
Expand Down
2 changes: 2 additions & 0 deletions core/dbio/connection/connection_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func (ec *EnvConns) Discover(name string, opt *DiscoverOptions) (nodes filesys.F
return nodes, schemata, g.Error("Invalid Connection name: %s. Make sure it is created. See https://docs.slingdata.io/sling-cli/environment", name)
}

defer conn.Connection.Close()
_, nodes, schemata, err = conn.Connection.Discover(opt)
return
}
Expand All @@ -286,6 +287,7 @@ func (ec *EnvConns) Test(name string) (ok bool, err error) {
if !ok1 || name == "" {
return ok, g.Error("Invalid Connection name: %s. Make sure it is created. See https://docs.slingdata.io/sling-cli/environment", name)
}
defer conn.Connection.Close()
ok, err = conn.Connection.Test()
return
}
Expand Down
13 changes: 6 additions & 7 deletions core/sling/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (rd *ReplicationConfig) ProcessWildcardsDatabase(c connection.Connection, w
return g.Error("could not get tables for schema: %s", schemaT.Schema)
}

streamsAdded := []string{}
for _, table := range schemata.Tables() {

// add to stream map
Expand All @@ -238,8 +239,9 @@ func (rd *ReplicationConfig) ProcessWildcardsDatabase(c connection.Connection, w

cfg := rd.Streams[wildcardName]
rd.AddStream(table.FullName(), cfg)
g.Debug("wildcard '%s' matched stream => %s", wildcardName, table.FullName())
streamsAdded = append(streamsAdded, table.FullName())
}
g.Debug("wildcard '%s' matched %d streams => %+v", wildcardName, len(streamsAdded), streamsAdded)

// delete * from stream map
rd.DeleteStream(wildcardName)
Expand Down Expand Up @@ -274,7 +276,7 @@ func (rd *ReplicationConfig) ProcessWildcardsFile(c connection.Connection, wildc
return g.Error("could not get files for schema: %s", wildcardName)
}

added := 0
streamsAdded := []string{}
for _, node := range nodes {
streamName, streamConfig, found := rd.GetStream(node.Path())
if found {
Expand All @@ -295,16 +297,13 @@ func (rd *ReplicationConfig) ProcessWildcardsFile(c connection.Connection, wildc

// add path
rd.AddStream(node.Path(), rd.Streams[wildcardName])
added++
g.Debug("wildcard '%s' matched stream => %s", wildcardName, node.Path())
streamsAdded = append(streamsAdded, node.Path())
}
g.Debug("wildcard '%s' matched %d streams => %+v", wildcardName, len(streamsAdded), streamsAdded)

// delete from stream map
rd.DeleteStream(wildcardName)

if added == 0 {
g.Debug("0 streams added for %#v (nodes=%d)", wildcardName, len(nodes))
}
}

return
Expand Down
4 changes: 4 additions & 0 deletions core/store/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func settings() {
}

func GetMachineID() string {
if Db == nil {
machineID, _ := machineid.ProtectedID("sling")
return machineID
}
s := &Setting{Key: "machine-id"}
Db.First(&s)
return s.Value
Expand Down

0 comments on commit c424f5b

Please sign in to comment.